private void OnGUI() { shader = EditorGUILayout.ObjectField(shader, typeof(Shader), true) as Shader; if (GUILayout.Button("Compile And Analyze")) { var compiled = CompileShaderUtil.GetCompileShaderText(shader); var parser = new CompiledShaderParser(compiled); ShaderDbUtil.Create(shader, parser); } if (GUILayout.Button("DebugKeyword")) { var keywords = MaliocPluginUtility.GetShaderCurrentKeyword(shader); res = "Keyword:"; foreach (var keyword in keywords) { res += keyword + "\n"; } } if (!string.IsNullOrEmpty(res)) { EditorGUILayout.TextArea(res); } }
private void SetResult(AnalyzedShaderInfo data) { this.resultArea.Clear(); if (data != null) { var keywords = MaliocPluginUtility.GetMaterialCurrentKeyword(mat); programKeyInfo.Clear(); data.GetShaderMatchPrograms(programKeyInfo, keywords); foreach (var key in programKeyInfo) { var info = data.GetProgramInfo(key); var ve = ShaderInfolElement.Create(key, info, data.GetPassInfos()); this.resultArea.Add(ve); } if (programKeyInfo.Count == 0) { this.resultArea.Add(new Label("Not Found.. Keyword:")); foreach (var keyword in keywords) { this.resultArea.Add(new Label(keyword)); } } } }
public void GetShaderMatchPrograms(List <ShaderKeywordInfo> result, List <string> keywords) { result.Clear(); foreach (var kvs in performanceInfoByKeyword) { var keyInfo = kvs.Key; var isMatch = MaliocPluginUtility.IsMatchKeyword(keyInfo.globalKeyword, keyInfo.localKeyword, keywords); if (isMatch) { result.Add(kvs.Key); } } }
public static AnalyzedShaderInfo Create(Shader shader, CompiledShaderParser compiledShaderParser) { AnalyzedShaderInfo info = new AnalyzedShaderInfo(); info.shaderName = shader.name; var programs = compiledShaderParser.GetShaderPrograms(); var passInfos = compiledShaderParser.GetPassInfos(); string dir = Path.Combine(COMPILED_FILE_PATH, shader.name); // create compile files EditorUtility.DisplayProgressBar("Analyzing", "Analyze ShaderProgram", 0.0f); try { CreateCompiledFiles(dir, compiledShaderParser); for (int i = 0; i < programs.Count; ++i) { EditorUtility.DisplayProgressBar("Analyzing", "Analyze ShaderProgram", i / (float)programs.Count); var vertJson = MaliocPluginUtility.CallMaliShaderOfflineCompiler(dir + "/" + i + ".vert", true); var fragJson = MaliocPluginUtility.CallMaliShaderOfflineCompiler(dir + "/" + i + ".frag", true); var vertResult = MaliOcReport.CreateFromJson(vertJson); var fragResult = MaliOcReport.CreateFromJson(fragJson); var shaderProgramInfo = ShaderProgramInfo.Create(vertResult, fragResult); var key = new ShaderKeywordInfo(); key.globalKeyword = programs[i].globalKeyword; key.localKeyword = programs[i].localKeyword; key.passIndex = programs[i].passInfoIdx; info.AddProgramInfo(key, shaderProgramInfo); } }catch (System.ComponentModel.Win32Exception e) { EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog("malioc not found", "please install ARM Mobile studio. or make to malioc path correct.", "OK"); return(null); } EditorUtility.ClearProgressBar(); for (int i = 0; i < passInfos.Count; ++i) { info.AddPassInfo(passInfos[i].name, passInfos[i].tags); } InitDirectory(DB_FILE_PATH); info.SaveToFile(Path.Combine(DB_FILE_PATH, shader.name.Replace('/', '_') + ".json")); return(info); }
private void AppendResult(AnalyzedShaderInfo info, FrameDebuggerEventData data) { if (info == null) { return; } var keywords = MaliocPluginUtility.KeywordStrToList(data.shaderKeywords); info.GetShaderMatchPrograms(programKeyInfo, keywords); foreach (var key in programKeyInfo) { var shaderProgramInfo = info.GetProgramInfo(key); if (key.passIndex == data.shaderPassIndex) { InitShaderElementInfo(shaderProgramInfo); this.resultPosition = this.currentPosition; this.Repaint(); break; } } }