示例#1
0
        private void AppendSamplerBindStatistics(FetchFrameInfo frameInfo)
        {
            // #mivance see AppendConstantBindStatistics
            FetchFrameSamplerBindStats template = frameInfo.stats.samplers[0];

            FetchFrameSamplerBindStats[] totalSamplersPerStage = new FetchFrameSamplerBindStats[(int)ShaderStageType.Count];
            for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++)
            {
                totalSamplersPerStage[s]           = new FetchFrameSamplerBindStats();
                totalSamplersPerStage[s].bindslots = new UInt32[template.bindslots.Length];
            }

            {
                FetchFrameSamplerBindStats[] resources = frameInfo.stats.samplers;
                for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++)
                {
                    totalSamplersPerStage[s].calls += resources[s].calls;
                    totalSamplersPerStage[s].sets  += resources[s].sets;
                    totalSamplersPerStage[s].nulls += resources[s].nulls;

                    System.Diagnostics.Debug.Assert(totalSamplersPerStage[s].bindslots.Length == resources[s].bindslots.Length);
                    for (var l = 0; l < resources[s].bindslots.Length; l++)
                    {
                        totalSamplersPerStage[s].bindslots[l] += resources[s].bindslots[l];
                    }
                }
            }

            FetchFrameSamplerBindStats totalSamplersForAllStages = new FetchFrameSamplerBindStats();

            totalSamplersForAllStages.bindslots = new UInt32[totalSamplersPerStage[0].bindslots.Length];

            for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++)
            {
                FetchFrameSamplerBindStats perStage = totalSamplersPerStage[s];
                totalSamplersForAllStages.calls += perStage.calls;
                totalSamplersForAllStages.sets  += perStage.sets;
                totalSamplersForAllStages.nulls += perStage.nulls;
                for (var l = 0; l < perStage.bindslots.Length; l++)
                {
                    totalSamplersForAllStages.bindslots[l] += perStage.bindslots[l];
                }
            }

            statisticsLog.AppendText("\n*** Sampler Bind Statistics ***\n\n");

            for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++)
            {
                statisticsLog.AppendText(String.Format("{0} calls: {1}, non-null sampler sets: {2}, null sampler sets: {3}\n",
                                                       m_Core.CurPipelineState.Abbrev((ShaderStageType)s), totalSamplersPerStage[s].calls,
                                                       totalSamplersPerStage[s].sets, totalSamplersPerStage[s].nulls));
            }

            statisticsLog.AppendText(String.Format("Total calls: {0}, non-null sampler sets: {1}, null sampler sets: {2}\n",
                                                   totalSamplersForAllStages.calls, totalSamplersForAllStages.sets, totalSamplersForAllStages.nulls));

            statisticsLog.AppendText(CreateSimpleIntegerHistogram("Aggregate slot counts per invocation across all stages", totalSamplersForAllStages.bindslots));
        }
示例#2
0
        private void AppendSamplerBindStatistics(FetchFrameInfo[] frameList)
        {
            // #mivance see AppendConstantBindStatistics
            FetchFrameSamplerBindStats template = frameList[0].stats.samplers[0];

            FetchFrameSamplerBindStats[] totalSamplersPerStage = new FetchFrameSamplerBindStats[(int)ShaderStageType.Count];
            for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++)
            {
                totalSamplersPerStage[s]       = new FetchFrameSamplerBindStats();
                totalSamplersPerStage[s].slots = new UInt32[template.slots.Length];
            }

            foreach (var f in frameList)
            {
                FetchFrameSamplerBindStats[] resources = f.stats.samplers;
                for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++)
                {
                    totalSamplersPerStage[s].calls += resources[s].calls;
                    totalSamplersPerStage[s].sets  += resources[s].sets;
                    totalSamplersPerStage[s].nulls += resources[s].nulls;

                    System.Diagnostics.Debug.Assert(totalSamplersPerStage[s].slots.Length == resources[s].slots.Length);
                    for (var l = 0; l < resources[s].slots.Length; l++)
                    {
                        totalSamplersPerStage[s].slots[l] += resources[s].slots[l];
                    }
                }
            }

            FetchFrameSamplerBindStats totalSamplersForAllStages = new FetchFrameSamplerBindStats();

            totalSamplersForAllStages.slots = new UInt32[totalSamplersPerStage[0].slots.Length];

            for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++)
            {
                FetchFrameSamplerBindStats perStage = totalSamplersPerStage[s];
                totalSamplersForAllStages.calls += perStage.calls;
                totalSamplersForAllStages.sets  += perStage.sets;
                totalSamplersForAllStages.nulls += perStage.nulls;
                for (var l = 0; l < perStage.slots.Length; l++)
                {
                    totalSamplersForAllStages.slots[l] += perStage.slots[l];
                }
            }

            statisticsLog.AppendText("\n*** Sampler Bind Statistics ***\n\n");

            for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++)
            {
                statisticsLog.AppendText(String.Format("{0} calls: {1}, non-null sampler sets: {2}, null sampler sets: {3}\n",
                                                       m_Core.CurPipelineState.Abbrev((ShaderStageType)s), totalSamplersPerStage[s].calls,
                                                       totalSamplersPerStage[s].sets, totalSamplersPerStage[s].nulls));
            }

            statisticsLog.AppendText(String.Format("Total calls: {0}, non-null sampler sets: {1}, null sampler sets: {2}\n",
                                                   totalSamplersForAllStages.calls, totalSamplersForAllStages.sets, totalSamplersForAllStages.nulls));

            statisticsLog.AppendText("\nHistogram of aggregate slot counts per invocation across all stages:\n");
            UInt32 maxCount     = 0;
            int    maxWithValue = 0;

            for (var s = 1; s < totalSamplersForAllStages.slots.Length; s++)
            {
                UInt32 value = totalSamplersForAllStages.slots[s];
                if (value > 0)
                {
                    maxWithValue = s;
                }
                maxCount = Math.Max(maxCount, value);
            }

            for (var s = 1; s <= maxWithValue; s++)
            {
                UInt32 count = totalSamplersForAllStages.slots[s];
                int    slice = SliceForString(Stars, count, maxCount);
                statisticsLog.AppendText(String.Format("{0,2}: {1} {2}\n", s, Stars.Substring(0, slice), CountOrEmpty(count)));
            }
        }