Beispiel #1
0
        private static PerformanceMonitor getMonitor(StatisticsCounterType type)
        {
            switch (type)
            {
            case StatisticsCounterType.Invalidations:
            case StatisticsCounterType.Refreshes:
            case StatisticsCounterType.DrawNodeCtor:
            case StatisticsCounterType.DrawNodeAppl:
            case StatisticsCounterType.ScheduleInvk:
                return(target.UpdateMonitor);

            case StatisticsCounterType.VBufOverflow:
            case StatisticsCounterType.TextureBinds:
            case StatisticsCounterType.DrawCalls:
            case StatisticsCounterType.VerticesDraw:
            case StatisticsCounterType.VerticesUpl:
            case StatisticsCounterType.KiloPixels:
                return(target.DrawMonitor);

            default:
                Debug.Assert(false, "Requested counter which is not assigned to any performance monitor.");
                break;
            }

            return(null);
        }
Beispiel #2
0
        private Color4 getColour(StatisticsCounterType type)
        {
            switch (type)
            {
            default:
                return(Color4.Yellow);

            case StatisticsCounterType.Invalidations:
            case StatisticsCounterType.TextureBinds:
            case StatisticsCounterType.TasksRun:
            case StatisticsCounterType.MouseEvents:
                return(Color4.BlueViolet);

            case StatisticsCounterType.DrawCalls:
            case StatisticsCounterType.Refreshes:
            case StatisticsCounterType.Tracks:
            case StatisticsCounterType.KeyEvents:
                return(Color4.YellowGreen);

            case StatisticsCounterType.DrawNodeCtor:
            case StatisticsCounterType.VerticesDraw:
            case StatisticsCounterType.Samples:
                return(Color4.HotPink);

            case StatisticsCounterType.DrawNodeAppl:
            case StatisticsCounterType.VerticesUpl:
            case StatisticsCounterType.SChannels:
                return(Color4.Red);

            case StatisticsCounterType.ScheduleInvk:
            case StatisticsCounterType.KiloPixels:
            case StatisticsCounterType.Components:
                return(Color4.Cyan);
            }
        }
Beispiel #3
0
        private Color4 getColour(StatisticsCounterType type)
        {
            switch (type)
            {
            default:
            case StatisticsCounterType.VBufOverflow:
                return(Color4.Yellow);

            case StatisticsCounterType.Invalidations:
            case StatisticsCounterType.TextureBinds:
                return(Color4.BlueViolet);

            case StatisticsCounterType.DrawCalls:
            case StatisticsCounterType.Refreshes:
                return(Color4.YellowGreen);

            case StatisticsCounterType.DrawNodeCtor:
            case StatisticsCounterType.VerticesDraw:
                return(Color4.HotPink);

            case StatisticsCounterType.DrawNodeAppl:
            case StatisticsCounterType.VerticesUpl:
                return(Color4.Red);

            case StatisticsCounterType.ScheduleInvk:
            case StatisticsCounterType.KiloPixels:
                return(Color4.Cyan);
            }
        }
Beispiel #4
0
        internal static void Increment(StatisticsCounterType type, long amount = 1)
        {
            if (target == null)
            {
                return;
            }

            getMonitor(type)?.GetCounter(type)?.Add(amount);
        }
Beispiel #5
0
        internal static void Add(StatisticsCounterType type, long amount)
        {
            if (amount < 0)
            {
                throw new ArgumentException($"Statistics counter {type} was attempted to be decremented via {nameof(Add)} call.", nameof(amount));
            }

            COUNTERS[(int)type] += amount;
        }
Beispiel #6
0
        /// <summary>
        /// Registers statistics counters to the PerformanceMonitors of the _first_ host
        /// to call this function.
        /// </summary>
        /// <param name="target">The host that wants to register for statistics counters.</param>
        internal static void RegisterCounters(BasicGameHost target)
        {
            if (FrameStatistics.target != null)
            {
                return;
            }

            FrameStatistics.target = target;

            for (StatisticsCounterType i = 0; i < StatisticsCounterType.AmountTypes; ++i)
            {
                getMonitor(i).RegisterCounter(i);
            }
        }
        /// <summary>
        /// Registers statistics counters to the performance overlay first passed into this function
        /// </summary>
        /// <param name="target">The overlay that wants to register for statistics counters.</param>
        internal static void RegisterCounters(PerformanceOverlay target)
        {
            if (FrameStatistics.target != null)
            {
                return;
            }

            for (StatisticsCounterType i = 0; i < StatisticsCounterType.AmountTypes; ++i)
            {
                getMonitor(i, target).RegisterCounter(i);
            }

            FrameStatistics.target = target;
        }
        private static PerformanceMonitor getMonitor(StatisticsCounterType type, PerformanceOverlay target)
        {
            switch (type)
            {
            case StatisticsCounterType.Invalidations:
            case StatisticsCounterType.Refreshes:
            case StatisticsCounterType.DrawNodeCtor:
            case StatisticsCounterType.DrawNodeAppl:
            case StatisticsCounterType.ScheduleInvk:
                return(target.Threads[2].Monitor);

            case StatisticsCounterType.VBufBinds:
            case StatisticsCounterType.VBufOverflow:
            case StatisticsCounterType.TextureBinds:
            case StatisticsCounterType.DrawCalls:
            case StatisticsCounterType.VerticesDraw:
            case StatisticsCounterType.VerticesUpl:
            case StatisticsCounterType.KiloPixels:
                return(target.Threads[3].Monitor);

            case StatisticsCounterType.MouseEvents:
            case StatisticsCounterType.KeyEvents:
                return(target.Threads[1].Monitor);

            case StatisticsCounterType.TasksRun:
            case StatisticsCounterType.Tracks:
            case StatisticsCounterType.Samples:
            case StatisticsCounterType.SChannels:
            case StatisticsCounterType.Components:
                return(target.Threads[0].Monitor);

            default:
                Trace.Assert(false, "Requested counter which is not assigned to any performance monitor.");
                break;
            }

            return(null);
        }
Beispiel #9
0
 public AtomicCounter GetCounter(StatisticsCounterType counterType) => Counters[(int)counterType];
Beispiel #10
0
 public void RegisterCounter(StatisticsCounterType type)
 {
     Counters[(int)type] = new AtomicCounter();
 }
Beispiel #11
0
 internal static void Add(StatisticsCounterType type, long amount) => COUNTERS[(int)type] += amount;
Beispiel #12
0
 internal static void Increment(StatisticsCounterType type) => ++ COUNTERS[(int)type];