├── Documentation~ ├── Screenshot.png └── EnableShaderCompileModule.png ├── LICENSE.meta ├── README.ja.md.meta ├── README.md.meta ├── link.xml.meta ├── package.json.meta ├── link.xml ├── Editor.meta ├── Runtime.meta ├── Editor ├── UXML.meta ├── ProfilerModuleForShaderCompile.Editor.asmdef.meta ├── Config.cs.meta ├── ShaderCompileInfo.cs.meta ├── ShaderCompileRowUI.cs.meta ├── ProfilerShaderCompileWatcher.cs.meta ├── ShaderCompileProfilerModule.cs.meta ├── ShaderPassLightModeConverter.cs.meta ├── ShaderCompileModuleDetailsViewController.cs.meta ├── UXML │ ├── compileInfo.uxml.meta │ ├── ShaderCompileModuleUI.uxml.meta │ ├── compileInfo.uxml │ └── ShaderCompileModuleUI.uxml ├── ProfilerModuleForShaderCompile.Editor.asmdef ├── Config.cs ├── ShaderCompileInfo.cs ├── ShaderCompileRowUI.cs ├── ShaderPassLightModeConverter.cs ├── ShaderCompileProfilerModule.cs ├── ShaderCompileModuleDetailsViewController.cs └── ProfilerShaderCompileWatcher.cs ├── Runtime ├── ProfilerModuleForShaderCompile.Runtime.asmdef.meta ├── ShaderCompileWatcher.cs.meta ├── ProfilerModuleForShaderCompile.Runtime.asmdef ├── ShaderCompileWatcher.cs.1~ └── ShaderCompileWatcher.cs ├── package.json ├── LICENSE ├── README.ja.md └── README.md /Documentation~/Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wotakuro/ProfilerModuleForShaderCompile/HEAD/Documentation~/Screenshot.png -------------------------------------------------------------------------------- /Documentation~/EnableShaderCompileModule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wotakuro/ProfilerModuleForShaderCompile/HEAD/Documentation~/EnableShaderCompileModule.png -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a864de91931caf42be0b4d4df90d446 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.ja.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c83908b11326e2b468b3b56c0f3865f4 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f974ac5947ce87547995933bbac025ba 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /link.xml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19374cef502daee43ab9a48e00fd4023 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01f8832bfe5182240952cd6de1ac4e70 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /link.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1aaa6c8bfa900d54ea723a93f4e90967 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 839259f2523325e49b6aac7622c4099a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/UXML.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c67bd4650fb05b843ae743c4924305aa 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/ProfilerModuleForShaderCompile.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f9df5166f6760a4b8ffb05769b50d79 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/ProfilerModuleForShaderCompile.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e6dbc123be9a554ca44d0b053f8aeeb 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/Config.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0647162b5e056ac41a0d8a2d72075284 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderCompileInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 30363c0a5c244724ba4add300f7e6394 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderCompileRowUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8283c0f2ad1e67a4fb70434995fa8c3a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/ShaderCompileWatcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 949430597150f2b45a1e911118f9d76c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ProfilerShaderCompileWatcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a942a8e850b10044492bbe3ebb1ee0b9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderCompileProfilerModule.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7d049f7544190e48b6dea5e707cd383 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderPassLightModeConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e0c93417980b6a458a9ee180b554551 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.utj.profilermodule.shadercompile", 3 | "displayName": "ProfilerModuleForShaderCompile", 4 | "version": "1.0.2", 5 | "unity": "2021.2", 6 | "description": "This package provide profiler module for detect shader compile.", 7 | "keywords": [ 8 | "profiler", 9 | "profiling" 10 | ] 11 | } -------------------------------------------------------------------------------- /Editor/ShaderCompileModuleDetailsViewController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37370a6be48c18948a72cccdc1d61fb3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/UXML/compileInfo.uxml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 143cf25c3d449ed40805af4b68097552 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} 11 | -------------------------------------------------------------------------------- /Editor/UXML/ShaderCompileModuleUI.uxml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 344045192c4c9814f9791bc56411b52a 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} 11 | -------------------------------------------------------------------------------- /Runtime/ProfilerModuleForShaderCompile.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ProfilerModuleForShaderCompile.Runtime", 3 | "rootNamespace": "", 4 | "references": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": true, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": false, 11 | "defineConstraints": [], 12 | "versionDefines": [], 13 | "noEngineReferences": false 14 | } -------------------------------------------------------------------------------- /Editor/ProfilerModuleForShaderCompile.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ProfilerModuleForShaderCompile.Editor", 3 | "rootNamespace": "", 4 | "references": [], 5 | "includePlatforms": [ 6 | "Editor" 7 | ], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": false, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Yusuke Kurokawa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.ja.md: -------------------------------------------------------------------------------- 1 | # ProfilerModuleForShaderCompile 2 | 3 | 4 | [English](README.md)
5 | 6 | ## このツールについて 7 | このツールは ShaderCompileをProfilerで一覧できるようにしているProfilerの拡張Moduleです。
8 | また一覧表示するだけでなく、そのShaderCompile情報から自動的にShaderVariantCollectionアセットを作成するツールです。
9 |
10 | こちらは、実機上で発生する ShaderCompileを見たいと言ったときに使えるツールです。
11 |
12 | 姉妹ツール「[UnityShaderVariantLoggerForEditor](https://github.com/wotakuro/UnityShaderVariantLoggerForEditor) 」もあります。
13 | こちらはEditorプレイだけで、アプリ内でどのようなShaderCompileが走るのかを把握したいときに利用します。
14 | 15 | ## 利用方法 16 | ### インストールについて 17 | Packagesフォルダ以下にコチラの中身を入れてください 18 | 19 | ### 有効化方法について 20 | ![ScreenshotToUnityProfiler](Documentation~/EnableShaderCompileModule.png "How to enable")
21 | ProfilerのModuleに「ShaderCompile」があるので、コチラを有効にして利用します。 22 | 23 | ### 使い方 24 | 25 | ![ScreenshotToUnityProfiler](Documentation~/Screenshot.png "screenshote")
26 | 27 | #### 1.Target ShaderVariant Collection 28 | こちらにShaderVariantCollectionアセットを指定すると、Profilerの情報を元に勝手にShaderVariantを足していきます。
29 | Enabledのチェックを外すと自動書き込み機能をオフにすることが出来ます。 30 | 31 | #### 2.Advanced 32 | ここではLogファイルの書き出しに関する設定が出来ます。
33 | Logは自動的に Library/profilermodule.shadercompile/logs フォルダへ書き出されます。 34 | 35 | #### 3.Counter Data 36 | そのフレームで行われたShaderCompileの回数を出します。
37 | ただShaderCompileのカウンターが1フレーム遅れてカウントされてしまいます。
38 | そのため、1フレーム先の情報をActualとして出しています。
39 | 参考情報までに実際のカウンターデータも出しています。 40 | 41 | #### 4.ShaderCompileInformation 42 | 43 | Profilerから見つけたShaderCompileを全て一覧にして出しています。
44 | ShowOnlyCurrentFrameのチェックを入れると現在のフレームの情報のみ出します。
45 |
46 | また"Export to csv"をする事で Profiler中にある全てのフレームのShaderCompile情報をCSVファイルに書き出すことが可能になっています。 47 | 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ProfilerModuleForShaderCompile 2 | 3 | [日本語はコチラ](README.ja.md)
4 | 5 | ## About 6 | This tool is an extension module of the Profiler that allows ShaderCompile to be listed in the Profiler.
7 | This tool not only lists ShaderCompiles, but also automatically creates ShaderVariantCollection assets from the ShaderCompile information.
8 |
9 | This is a tool that can be used when you want to see the ShaderCompile that occurs on the actual device. 10 |
11 | A sister tool, [UnityShaderVariantLoggerForEditor](https://github.com/wotakuro/UnityShaderVariantLoggerForEditor) is also available.
12 | This one is used when you want to keep track of what ShaderCompile is running in the application just for Editor play. 13 |
14 | 15 | ## How to use 16 | 17 | 18 | ### About installation 19 | Please put this under the "Packages" folder. 20 | 21 | ### How to enabled 22 | ![ScreenshotToUnityProfiler](Documentation~/EnableShaderCompileModule.png "How to enable")
23 | Enable the "Shader Compile" in the ProfilerModules. 24 | 25 | ### Screenshot and explaination 26 | 27 | ![ScreenshotToUnityProfiler](Documentation~/Screenshot.png "screenshote")
28 | 29 | #### 1.Target ShaderVariant Collection 30 | If you specify a ShaderVariantCollection asset here, the ShaderVariant will be added on its own based on the Profiler's information.
31 | Unchecking the "Enabled" checkbox will turn off the auto creation feature. 32 | 33 | 34 | #### 2.Advanced 35 | You can disable log file creation here.
36 | Logs are automatically written to the Library/profilermodule.shadercompile/logs folder 37 | 38 | #### 3.Counter Data 39 | The number of ShaderCompiles performed in that frame is displayed
40 | However, the ShaderCompile counter is counted 1 frame delayed.
41 | Therefore, the information one frame ahead is output as an Actual.< br/ > 42 | Current frame data is also shown for reference.
43 | #### 4.ShaderCompileInformation 44 | 45 | All ShaderCompiles found from the Profiler are listed and brought out.
46 | If ShowOnlyCurrentFrame is checked, only information on the current frame will be shown.
47 |
48 | Also, "Export to csv" allows you to export the ShaderCompile information for all frames in the Profiler to a CSV file. 49 | -------------------------------------------------------------------------------- /Editor/UXML/compileInfo.uxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Editor/Config.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | using System.IO; 6 | 7 | namespace UTJ.Profiler.ShaderCompileModule 8 | { 9 | [System.Serializable] 10 | internal class Config 11 | { 12 | private const string ConfigFile = "Library/profilermodule.shadercompile/config.json"; 13 | 14 | [SerializeField] 15 | private string m_targetPath; 16 | [SerializeField] 17 | private bool m_autoEnabled; 18 | [SerializeField] 19 | private bool m_logEnabled; 20 | [SerializeField] 21 | private bool m_filterFrame; 22 | 23 | public ShaderVariantCollection target 24 | { 25 | set 26 | { 27 | var path = AssetDatabase.GetAssetPath(value); 28 | 29 | this.m_targetPath = path; 30 | Save(); 31 | } 32 | get 33 | { 34 | return AssetDatabase.LoadAssetAtPath(this.m_targetPath); 35 | } 36 | } 37 | 38 | public bool autoEnabled 39 | { 40 | get 41 | { 42 | return m_autoEnabled; 43 | } 44 | set 45 | { 46 | m_autoEnabled = value; 47 | this.Save(); 48 | } 49 | } 50 | public bool logEnabled 51 | { 52 | get 53 | { 54 | return m_logEnabled; 55 | } 56 | set 57 | { 58 | m_logEnabled = value; 59 | this.Save(); 60 | } 61 | } 62 | public bool filterFrame 63 | { 64 | get 65 | { 66 | return m_filterFrame; 67 | } 68 | set 69 | { 70 | m_filterFrame = value; 71 | this.Save(); 72 | } 73 | } 74 | 75 | 76 | public static Config GetConfig() 77 | { 78 | if (!File.Exists(ConfigFile)) 79 | { 80 | return GetDefault(); 81 | } 82 | try 83 | { 84 | var str = File.ReadAllText(ConfigFile); 85 | return JsonUtility.FromJson(str); 86 | }catch(System.Exception e) 87 | { 88 | Debug.LogError(e); 89 | } 90 | return GetDefault(); 91 | } 92 | private static Config GetDefault() 93 | { 94 | return new Config() 95 | { 96 | m_targetPath = "", 97 | m_autoEnabled = true, 98 | m_logEnabled = true, 99 | m_filterFrame = true, 100 | }; 101 | } 102 | 103 | public void Save() 104 | { 105 | string dir = System.IO.Path.GetDirectoryName(ConfigFile); 106 | if (!System.IO.Directory.Exists(dir)) 107 | { 108 | System.IO.Directory.CreateDirectory(dir); 109 | } 110 | 111 | var str = JsonUtility.ToJson(this); 112 | File.WriteAllText(ConfigFile, str); 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /Editor/ShaderCompileInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | 6 | namespace UTJ.Profiler.ShaderCompileModule 7 | { 8 | internal class ShaderCompileInfo 9 | { 10 | private static Dictionary s_ShaderCache = new Dictionary(); 11 | 12 | public int frameIdx; 13 | public string shaderName; 14 | public string pass; 15 | public string stage; 16 | public string keyword; 17 | public float timeMs; 18 | public RuntimePlatform platform; 19 | 20 | public ShaderVariantCollection.ShaderVariant GetShaderariant() 21 | { 22 | var variant = new ShaderVariantCollection.ShaderVariant(); 23 | var shader = GetShader(); ; 24 | variant.shader = shader; 25 | variant.keywords = GetKeywordArray(keyword); 26 | string lightMode = ShaderPassLightModeConverter.GetLightModeByPasssName(shader, pass); 27 | variant.passType = GetPassType(lightMode); 28 | 29 | //Debug.Log("PassConvert " + pass + " -> " + lightMode); 30 | return variant; 31 | } 32 | 33 | private Shader GetShader() 34 | { 35 | Shader shader; 36 | if ( s_ShaderCache.TryGetValue(shaderName,out shader)){ 37 | return shader; 38 | } 39 | shader = Shader.Find(shaderName); 40 | s_ShaderCache.Add(shaderName, shader); 41 | return shader; 42 | } 43 | 44 | private string[] GetKeywordArray(string keywords) 45 | { 46 | 47 | string[] keywordArray; 48 | if (string.IsNullOrEmpty(keywords) || keywords == "") 49 | { 50 | keywordArray = new string[] { "" }; 51 | } 52 | else 53 | { 54 | keywordArray = keywords.Split(' '); 55 | } 56 | return keywordArray; 57 | } 58 | private static PassType GetPassType(string str) 59 | { 60 | if(str == null) 61 | { 62 | return PassType.Normal; 63 | } 64 | str = str.ToUpper(); 65 | switch (str) 66 | { 67 | case "": 68 | case "ALWAYS": 69 | return PassType.Normal; 70 | case "VERTEX": 71 | return PassType.Vertex; 72 | case "VERTEXLM": 73 | return PassType.VertexLM; 74 | case "VERTEXLMRGBM": 75 | return PassType.ForwardBase; 76 | case "FORWARDADD": 77 | return PassType.ForwardAdd; 78 | case "PREPASSBASE": 79 | return PassType.LightPrePassBase; 80 | case "PREPASSFINAL": 81 | return PassType.LightPrePassFinal; 82 | case "SHADOWCASTER": 83 | return PassType.ShadowCaster; 84 | case "DEFERRED": 85 | return PassType.Deferred; 86 | case "META": 87 | return PassType.Meta; 88 | case "MOTIONVECTORS": 89 | return PassType.MotionVectors; 90 | case "SRPDEFAULTUNLIT": 91 | return PassType.ScriptableRenderPipelineDefaultUnlit; 92 | } 93 | // PassType.ScriptableRenderPipelineDefaultUnlit 94 | return PassType.ScriptableRenderPipeline; 95 | } 96 | 97 | 98 | } 99 | } -------------------------------------------------------------------------------- /Editor/UXML/ShaderCompileModuleUI.uxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Editor/ShaderCompileRowUI.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | using UnityEngine.UIElements; 6 | 7 | namespace UTJ.Profiler.ShaderCompileModule 8 | { 9 | internal class ShaderCompileRowUI 10 | { 11 | 12 | private class VisualElementData 13 | { 14 | public VisualElement element; 15 | public Label frameIdx; 16 | public Label shader; 17 | public Label time; 18 | public Label pass; 19 | public Label stage; 20 | public Label keyword; 21 | } 22 | 23 | const string k_UxmlRowResourceName = "Packages/com.utj.profilermodule.shadercompile/Editor/UXML/compileInfo.uxml"; 24 | VisualTreeAsset template; 25 | 26 | private VisualElementData defaultData; 27 | private Stack elementsPool = new Stack(); 28 | private List elementsActive = new List(); 29 | 30 | public ShaderCompileRowUI() 31 | { 32 | 33 | } 34 | 35 | public void ReleaseAllNodes() 36 | { 37 | foreach(var active in elementsActive) 38 | { 39 | this.elementsPool.Push(active); 40 | } 41 | elementsActive.Clear(); 42 | } 43 | 44 | public VisualElement CreateNode(ShaderCompileInfo info) 45 | { 46 | var node = GetOrCreateNode(); 47 | elementsActive.Add(node); 48 | 49 | node.frameIdx.text = info.frameIdx.ToString(); 50 | node.shader.text = info.shaderName; 51 | node.time.text = info.timeMs.ToString("0.00")+"ms"; 52 | node.pass.text = info.pass; 53 | node.stage.text = info.stage; 54 | node.keyword.text = info.keyword; 55 | 56 | return node.element; 57 | } 58 | private void InitTemplate() 59 | { 60 | if (template == null) 61 | { 62 | template = AssetDatabase.LoadAssetAtPath(k_UxmlRowResourceName); 63 | this.defaultData = CreateData(template.Instantiate()); 64 | this.SetUpWidth(this.defaultData); 65 | this.defaultData.element.style.height = 20; 66 | this.defaultData.element.style.flexShrink = 0.0f; 67 | } 68 | 69 | } 70 | public VisualElement GetDefaultElement() 71 | { 72 | this.InitTemplate(); 73 | return this.defaultData.element; 74 | } 75 | 76 | private VisualElementData GetOrCreateNode() 77 | { 78 | if(elementsPool.Count > 0) 79 | { 80 | return elementsPool.Pop(); 81 | } 82 | InitTemplate(); 83 | 84 | var elem = template.Instantiate(); 85 | VisualElementData data = CreateData(elem); 86 | SetUpWidth(data); 87 | return data; 88 | } 89 | 90 | private VisualElementData CreateData(VisualElement elem) 91 | { 92 | VisualElementData data = new VisualElementData() 93 | { 94 | element = elem, 95 | frameIdx = elem.Q