コード例 #1
0
        public override bool Draw(AnalyzedShaderDataBase data)
        {
            MaliAnalyzedShaderData maliShader = data as MaliAnalyzedShaderData;

            if (maliShader == null)
            {
                Debug.LogError("数据无法转换成 MaliAnalyzedShaderData !");
                return(false);
            }

            EditorGUILayout.LabelField("工作寄存器使用情况 : ", maliShader.WorkRegisterUsed.ToString());
            EditorGUILayout.LabelField("Uniform寄存器使用情况 : ", maliShader.UniformRegistersUsed.ToString());
            EditorGUILayout.LabelField("溢出到栈 : ", maliShader.StackSpilling.ToString());

            drawCycles("总指令周期 : ", maliShader.TotalArithmeticCycles, maliShader.TotalLoad_StoreCycles, maliShader.TotalVaryingCycles, maliShader.TotalTextureCycles, maliShader.TotalBound);
            drawCycles("最短路径指令周期 : ", maliShader.ShortestPathArithmeticCycles, maliShader.ShortestPathLoad_StoreCycles, maliShader.ShortestPathVaryingCycles, maliShader.ShortestPathTextureCycles, maliShader.ShortestPathBound);
            drawCycles("最长路径指令周期 : ", maliShader.LongestPathArithmeticCycles, maliShader.LongestPathLoad_StoreCycles, maliShader.LongestPathVaryingCycles, maliShader.LongestPathTextureCycles, maliShader.LongestPathBound);

            EditorGUILayout.LabelField("存在Uniform计算 : ", maliShader.UniformComputation.ToString());

            return(true);
        }
コード例 #2
0
        protected override EAnalyzeStageStatus execute(int index)
        {
            AnalyzedVariantData varint = m_AnalyzeWrap.Variants[index];

            foreach (var item in varint.CompileResult)
            {
                MaliAnalyzedShaderData shaderData = new MaliAnalyzedShaderData();

                shaderData.SourceCode = varint.ShaderSourceCodes[item.Key];
                shaderData.ShaderType = item.Key;

                varint.Shaders.Add(shaderData);

                for (int i = 0; i < item.Value.Length; i++)
                {
                    string line = item.Value[i];

                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }
                    else if (string.IsNullOrEmpty(m_AnalyzeWrap.AnalyzedData.Hardware) && line.StartsWith("Hardware: "))
                    {
                        int spaceIndex = line.LastIndexOf(' ');
                        m_AnalyzeWrap.AnalyzedData.Hardware = line.Substring(spaceIndex + 1, line.Length - spaceIndex - 1);
                    }
                    else if (string.IsNullOrEmpty(m_AnalyzeWrap.AnalyzedData.Driver) && line.StartsWith("Driver: "))
                    {
                        m_AnalyzeWrap.AnalyzedData.Driver = line.Replace("Driver: ", string.Empty);
                    }
                    else if (line.StartsWith("ERROR: "))
                    {
                        shaderData.ERROR = line;
                        break;
                    }
                    else if (line.StartsWith("Work registers: "))
                    {
                        int.TryParse(line.Replace("Work registers: ", string.Empty), out shaderData.WorkRegisterUsed);
                    }
                    else if (line.StartsWith("Uniform registers: "))
                    {
                        int.TryParse(line.Replace("Uniform registers: ", string.Empty), out shaderData.UniformRegistersUsed);
                    }
                    else if (line.StartsWith("Stack spilling: "))
                    {
                        shaderData.StackSpilling = line != "Stack spilling: False";
                    }
                    else if (line.StartsWith("Total instruction cycles:"))
                    {
                        getInstructionNormFormLine(line, "Total instruction cycles:", out shaderData.TotalArithmeticCycles, out shaderData.TotalLoad_StoreCycles, out shaderData.TotalVaryingCycles, out shaderData.TotalTextureCycles, out shaderData.TotalBound);
                    }
                    else if (line.StartsWith("Shortest path cycles:"))
                    {
                        getInstructionNormFormLine(line, "Shortest path cycles:", out shaderData.ShortestPathArithmeticCycles, out shaderData.ShortestPathLoad_StoreCycles, out shaderData.ShortestPathVaryingCycles, out shaderData.ShortestPathTextureCycles, out shaderData.ShortestPathBound);
                    }
                    else if (line.StartsWith("Longest path cycles:"))
                    {
                        getInstructionNormFormLine(line, "Longest path cycles:", out shaderData.LongestPathArithmeticCycles, out shaderData.LongestPathLoad_StoreCycles, out shaderData.LongestPathVaryingCycles, out shaderData.LongestPathTextureCycles, out shaderData.LongestPathBound);
                    }
                    else if (line.StartsWith("Uniform computation: "))
                    {
                        shaderData.UniformComputation = line != "Uniform computation: False";
                    }
                }
            }

            //TODO 这里处理各种异常

            return(EAnalyzeStageStatus.Success);
        }