public static AnalyzedShaderInfo LoadShaderData(Shader shader) { string path = Path.Combine(DB_FILE_PATH, shader.name.Replace('/', '_') + ".json"); return(AnalyzedShaderInfo.LoadFromFile(path)); }
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 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); }