public static ShaderProgramPerfInfo Create(MaliOcReport report, int variantIdx) { if (variantIdx < 0) { return(null); } if (report == null) { return(null); } if (report.shaders == null || report.shaders.Length <= 0) { return(null); } var shader = report.shaders[0]; var variants = shader.variants; if (variants == null || variants.Length <= variantIdx) { return(null); } if (shader == null) { return(null); } var info = new ShaderProgramPerfInfo(); info.SetVariantProperties(variants[variantIdx].properties); info.SetPerformanceInfo(variants[variantIdx].performance); info.SetShaderProperties(shader.properties); return(info); }
public static ShaderProgramInfo Create(MaliOcReport vertReport, MaliOcReport fragReport) { ShaderProgramInfo info = new ShaderProgramInfo(); info.positionVertPerf = ShaderProgramPerfInfo.Create(vertReport, "Position"); info.varyingVertPerf = ShaderProgramPerfInfo.Create(vertReport, "Varying"); info.fragPerf = ShaderProgramPerfInfo.Create(fragReport, 0); return(info); }
public static ShaderProgramPerfInfo Create(MaliOcReport report, string variantName) { if (report == null || report.shaders == null || report.shaders.Length <= 0 || report.shaders[0] == null) { return(null); } int variantIdx = ShaderVariantsReport.GetIndexByName(report.shaders[0].variants, variantName); return(ShaderProgramPerfInfo.Create(report, variantIdx)); }
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); }