Пример #1
0
 void DrawLegendItem(InternalLabeler labeler, Vector2 position, string labelName, string valueName, string labelText, int value, Color color)
 {
     //Format...[] GenX {count}
     _memoryMonitor.TempBoxDrawer.ShowGradientBoxOnce(position, position - new Vector2(10, 10), color, color);
     labeler.ShowLabel(labelName, position + new Vector2(4, -10), labelText, color);
     _stringBuilder.SetText(value);
     labeler.ShowLabelEx(valueName, position + new Vector2(44, -10), _stringBuilder, color);
 }
Пример #2
0
        void DrawUIView(InternalLabeler labeler)
        {
            DrawBorderLines(Color.Gray, _memoryMonitor.LineDrawer);
            GearsetResources.Console.SolidBoxDrawer.ShowGradientBoxOnce(Position, Position + Size, new Color(56, 56, 56, 150), new Color(16, 16, 16, 127));

            if (ScaleNob.IsMouseOver)
            {
                ScaleNob.DrawBorderLines(Color.Gray);
            }

            labeler.ShowLabel(LabelName.Title, Position + new Vector2(0, -12), "Managed Memory - (allocation per tick in KB)");
        }
Пример #3
0
        void PlotTickMemoryGraph(InternalLabeler labeler, float graphWidth)
        {
            _plot.Sampler.Values.Clear();
            _plot.Position = new Vector2(Position.X + LegendWidth, Position.Y);
            _plot.Size     = new Vector2(graphWidth, Size.Y);

            var i  = 0;
            var id = _memoryMonitor.FrameId;

            while (i < MemoryMonitor.MaxFrames)
            {
                id++;
                if (id == MemoryMonitor.MaxFrames)
                {
                    id = 0;
                }

                //Display Kilobytes per tick
                _plot.Sampler.Values.Enqueue(_memoryMonitor.Frames[id].TickMemoryBytes / 1024.0f);
                i++;
            }

            labeler.ShowLabel(LabelName.MinYAxis, Position + new Vector2(2 + LegendWidth, Size.Y - 12), "0", Color.White);

            _stringBuilder.SetText(_maxTotalYScaleMb).Append(" MB");
            labeler.ShowLabelEx(LabelName.MaxYAxis, Position + new Vector2(2 + LegendWidth, 0), _stringBuilder, Color.White);

            float actualmin, actualmax;

            _plot.Sampler.GetLimits(out actualmin, out actualmax);

            var min = _plot.Min = _plot.Min + (actualmin - _plot.Min) * 0.3f;
            var max = _plot.Max = _plot.Max + (actualmax - _plot.Max) * 0.3f;

            GearsetResources.Console.Plotter.PlotGraph(_plot, _memoryMonitor.LineDrawer, labeler, MemoryMonitor.MaxFrames, min, max, _plot.Position, _plot.Size, actualmin, actualmax, Size.X - LegendWidth - 40.0f);
        }
Пример #4
0
        internal void Draw(InternalLabeler labeler, ProfilerManager.FrameLog frameLog)
        {
            if (GearsetResources.CurrentRenderPass != RenderPass.BasicEffectPass)
            {
                return;
            }

            if (frameLog == null || Visible == false || Config.PerformanceGraphConfig.VisibleLevelsFlags == 0)
            {
                labeler.HideLabel("__performanceGraph");
                return;
            }

            DrawBorderLines(Color.Gray, Profiler.LineDrawer);
            GearsetResources.Console.SolidBoxDrawer.ShowGradientBoxOnce(Position, Position + Size, new Color(56, 56, 56, 150), new Color(16, 16, 16, 127));

            if (ScaleNob.IsMouseOver)
            {
                ScaleNob.DrawBorderLines(Color.Gray);
            }

            labeler.ShowLabel("__performanceGraph", Position + new Vector2(0, -12), "Performance Graph");

            FrameCounter++;
            if (FrameCounter > SkipFrames)
            {
                FrameCounter = 0;

                //If the frame buffer has capacity will just create a new one; otherwise we'll pop the oldest off and use that.
                Frame frame;
                if (_frames.Count == MaxFrames)
                {
                    frame = _frames.Dequeue();
                    frame.TimingInfos.Clear();
                }
                else
                {
                    frame = new Frame();
                }

                _frames.Enqueue(frame);

                //Populate the frame metrics
                for (var barId = 0; barId < frameLog.Levels.Length; barId++)
                {
                    var bar = frameLog.Levels[barId];
                    for (var j = 0; j < bar.MarkCount; ++j)
                    {
                        frame.TimingInfos.Add(new TimingInfo(
                                                  barId,
                                                  bar.Markers[j].BeginTime,
                                                  bar.Markers[j].EndTime,
                                                  bar.Markers[j].Color));
                    }
                }
            }

            const float frameSpan = 1.0f / 60.0f * 1000f;

            var msToPs = Height / frameSpan;

            //Only render the actual number of frames we are capturing - we may have space for e.g. 120 (2 seconds) but the user is only viewing 60 (1 second)
            var barWidth   = Width / DisplayedFrameCount;
            var graphFloor = Position.Y + Size.Y;
            var position   = new Vector2(Position.X, graphFloor);

            var s = new Vector2(barWidth, msToPs);

            //Set a pointer to the first frame to renders
            var frameId = MaxFrames - DisplayedFrameCount;

            foreach (var frame in _frames)
            {
                //Bail when we have drawn enough
                if (frameId >= MaxFrames)
                {
                    break;
                }

                frameId++;

                foreach (var timeInfo in frame.TimingInfos)
                {
                    if (IsVisibleLevelsFlagSet(timeInfo.Level) == false)
                    {
                        continue;
                    }

                    var durationMilliseconds = timeInfo.EndMilliseconds - timeInfo.StartMilliseconds;
                    if (durationMilliseconds <= 0)
                    {
                        continue;
                    }

                    s.Y        = -durationMilliseconds * msToPs;
                    position.Y = graphFloor - (timeInfo.StartMilliseconds * msToPs);

                    Profiler.TempBoxDrawer.ShowGradientBoxOnce(position, position + s, timeInfo.Color, timeInfo.Color);
                }

                position.X += barWidth;
            }
        }
Пример #5
0
        internal void Draw(InternalLabeler labeler, Profiler.FrameLog frameLog)
        {
            if (Visible == false || Config.ProfilerSummaryConfig.VisibleLevelsFlags == 0) {
                labeler.HideLabel("__profilerSummary");
                return;
            }

            var font = GearsetResources.Font;

            // Generate log string.
            _logString.Length = 0;
            _logStringTimings.Length = 0;
            foreach (var markerInfo in Profiler.Markers) {
                for (var i = 0; i < Profiler.MaxLevels; ++i) {
                    if (!markerInfo.Logs[i].Initialized)
                        continue;

                    if (Levels[i].Enabled == false)
                        continue;

                    if (_logString.Length > 0) {
                        _logString.Append("\n");
                        _logStringTimings.Append("\n");
                    }

                    _logString.Append(" Level ");
                    _logString.AppendNumber(i);

                    _logString.Append(" ");

                    //Indent!
                    for (var x = 0; x < i; x++)
                        _logString.Append("--");

                    _logString.Append(markerInfo.Name);

                    //_logStringTimings.Append(" Avg.:");
                    _logStringTimings.AppendNumber(markerInfo.Logs[i].SnapAvg);
                    _logStringTimings.Append(" ms ");
                }
            }

            var namesSize = font.MeasureString(_logString);
            var timingsSize = font.MeasureString(_logStringTimings);
            Size = namesSize + new Vector2(timingsSize.X, 0) + new Vector2(Padding * 5, Padding * 2);

            if (GearsetResources.CurrentRenderPass == RenderPass.BasicEffectPass) {
                DrawBorderLines(Color.Gray);
                GearsetResources.Console.SolidBoxDrawer.ShowGradientBoxOnce(Position, Position + Size, new Color(56, 56, 56, 150), new Color(16, 16, 16, 127));

                //Fixed size based on summary contrents
                //if (ScaleNob.IsMouseOver)
                //    ScaleNob.DrawBorderLines(Color.Gray);

                labeler.ShowLabel("__profilerSummary", Position + new Vector2(0, -12), "Profiler Summary");

                // Draw log color boxes.
                var position = Position;
                position += new Vector2(Padding);

                foreach (var markerInfo in Profiler.Markers) {
                    for (var i = 0; i < Profiler.MaxLevels; ++i) {
                        if (Levels[i].Enabled == false)
                            continue;

                        if (markerInfo.Logs[i].Initialized == false)
                            continue;

                        Profiler.TempBoxDrawer.ShowGradientBoxOnce(position, position + new Vector2(10), markerInfo.Logs[i].Color, markerInfo.Logs[i].Color);

                        position.Y += font.LineSpacing;
                    }
                }
            }

            if (GearsetResources.CurrentRenderPass == RenderPass.SpriteBatchPass) {
                // Draw log string.
                var position = Position;
                position += new Vector2(Padding * 3, Padding);
                GearsetResources.SpriteBatch.DrawString(font, _logString, position, new Color(180, 180, 180));

                position = Position;
                position += new Vector2(namesSize.X + (Padding * 5), Padding);
                GearsetResources.SpriteBatch.DrawString(font, _logStringTimings, position, new Color(220, 220, 220));
            }
        }
Пример #6
0
        internal void Draw(InternalLabeler labeler, Profiler.FrameLog frameLog)
        {
            if (GearsetResources.CurrentRenderPass != RenderPass.BasicEffectPass)
                return;

            if (Visible == false || Config.PerformanceGraphConfig.VisibleLevelsFlags == 0) {
                labeler.HideLabel("__performanceGraph");
                return;
            }

            DrawBorderLines(Color.Gray);
            GearsetResources.Console.SolidBoxDrawer.ShowGradientBoxOnce(Position, Position + Size, new Color(56, 56, 56, 150), new Color(16, 16, 16, 127));

            if (ScaleNob.IsMouseOver)
                ScaleNob.DrawBorderLines(Color.Gray);

            labeler.ShowLabel("__performanceGraph", Position + new Vector2(0, -12), "Performance Graph");

            _frameCounter++;
            if (_frameCounter > SkipFrames) {
                _frameCounter = 0;

                //If the frame buffer has capacity will just create a new one; otherwise we'll pop the oldest off and use that.
                Frame frame;
                if (_frames.Count == MaxFrames) {
                    frame = _frames.Dequeue();
                    frame.TimingInfos.Clear();
                }
                else
                    frame = new Frame();

                _frames.Enqueue(frame);

                //Populate the frame metrics
                for (var barId = 0; barId < frameLog.Levels.Length; barId++) {
                    var bar = frameLog.Levels[barId];
                    for (var j = 0; j < bar.MarkCount; ++j) {
                        frame.TimingInfos.Add(new TimingInfo(
                            barId,
                            bar.Markers[j].BeginTime,
                            bar.Markers[j].EndTime,
                            bar.Markers[j].Color));
                    }
                }
            }

            const float frameSpan = 1.0f / 60.0f * 1000f;

            var msToPs = Height / frameSpan;

            //Only render the actual number of frames we are capturing - we may have space for e.g. 120 (2 seconds) but the user is only viewing 60 (1 second)
            var barWidth = Width / DisplayedFrameCount;
            var graphFloor = Position.Y + Size.Y;
            var position = new Vector2(Position.X, graphFloor);

            var s = new Vector2(barWidth, msToPs);

            //Set a pointer to the first frame to renders
            var frameId = MaxFrames - DisplayedFrameCount;
            foreach (var frame in _frames) {
                //Bail when we have drawn enough
                if (frameId >= MaxFrames)
                    break;

                frameId++;

                foreach (var timeInfo in frame.TimingInfos) {
                    if (Levels[timeInfo.Level].Enabled == false)
                        continue;

                    var durationMilliseconds = timeInfo.EndMilliseconds - timeInfo.StartMilliseconds;
                    if (durationMilliseconds <= 0)
                        continue;

                    s.Y = -durationMilliseconds * msToPs;
                    position.Y = graphFloor - (timeInfo.StartMilliseconds * msToPs);

                    Profiler.TempBoxDrawer.ShowGradientBoxOnce(position, position + s, timeInfo.Color, timeInfo.Color);
                }

                position.X += barWidth;
            }
        }
Пример #7
0
        internal void Draw(InternalLabeler labeler, ProfilerManager.FrameLog frameLog)
        {
            if (frameLog == null || Visible == false || Config.ProfilerSummaryConfig.VisibleLevelsFlags == 0)
            {
                labeler.HideLabel("__profilerSummary");
                return;
            }

            var font = GearsetResources.Font;

            // Generate log string.
            _logString.Length        = 0;
            _logStringTimings.Length = 0;

            foreach (var markerInfo in Profiler.Markers)
            {
                for (var i = 0; i < ProfilerManager.MaxLevels; ++i)
                {
                    if (!markerInfo.Logs[i].Initialized)
                    {
                        continue;
                    }

                    if (IsVisibleLevelsFlagSet(i) == false)
                    {
                        continue;
                    }

                    if (_logString.Length > 0)
                    {
                        _logString.Append("\n");
                        _logStringTimings.Append("\n");
                    }

                    _logString.Append(" Level ");
                    _logString.AppendNumber(i);

                    _logString.Append(" ");

                    //Indent!
                    for (var x = 0; x < i; x++)
                    {
                        _logString.Append("--");
                    }

                    _logString.Append(markerInfo.Name);

                    //_logStringTimings.Append(" Avg.:");
                    _logStringTimings.AppendNumber(markerInfo.Logs[i].SnapAvg);
                    _logStringTimings.Append(" ms ");
                }
            }

            var namesSize   = font.MeasureString(_logString);
            var timingsSize = font.MeasureString(_logStringTimings);

            Size = namesSize + new Vector2(timingsSize.X, 0) + new Vector2(Padding * 5, Padding * 2);

            if (GearsetResources.CurrentRenderPass == RenderPass.BasicEffectPass)
            {
                DrawBorderLines(Color.Gray, Profiler.LineDrawer);
                GearsetResources.Console.SolidBoxDrawer.ShowGradientBoxOnce(Position, Position + Size, new Color(56, 56, 56, 150), new Color(16, 16, 16, 127));

                //Fixed size based on summary contrents
                //if (ScaleNob.IsMouseOver)
                //    ScaleNob.DrawBorderLines(Color.Gray);

                labeler.ShowLabel("__profilerSummary", Position + new Vector2(0, -12), "Profiler Summary");

                // Draw log color boxes.
                var position = Position;
                position += new Vector2(Padding);

                foreach (var markerInfo in Profiler.Markers)
                {
                    for (var i = 0; i < ProfilerManager.MaxLevels; ++i)
                    {
                        if (IsVisibleLevelsFlagSet(i) == false)
                        {
                            continue;
                        }

                        if (markerInfo.Logs[i].Initialized == false)
                        {
                            continue;
                        }

                        Profiler.TempBoxDrawer.ShowGradientBoxOnce(position, position + new Vector2(10), markerInfo.Logs[i].Color, markerInfo.Logs[i].Color);

                        position.Y += font.LineSpacing;
                    }
                }
            }

            if (GearsetResources.CurrentRenderPass == RenderPass.SpriteBatchPass)
            {
                // Draw log string.
                var position = Position;
                position += new Vector2(Padding * 3, Padding);
                GearsetResources.SpriteBatch.DrawString(font, _logString, position, new Color(180, 180, 180));

                position  = Position;
                position += new Vector2(namesSize.X + (Padding * 5), Padding);
                GearsetResources.SpriteBatch.DrawString(font, _logStringTimings, position, new Color(220, 220, 220));
            }
        }
Пример #8
0
        public override void Draw(GameTime gameTime)
        {
            // Just to make sure we're only doing this one per frame.
            if (GearsetResources.CurrentRenderPass != RenderPass.BasicEffectPass)
            {
                return;
            }

            foreach (var plot in _plots)
            {
                if (!plot.Visible)
                {
                    continue;
                }
                var   count = plot.Sampler.Values.Capacity;
                float max, min, actualmin, actualmax;
                var   position = plot.Position;
                var   size     = plot.Size;
                GetLimits(plot, out actualmin, out actualmax);


                min = plot.Min = plot.Min + (actualmin - plot.Min) * 0.3f;
                max = plot.Max = plot.Max + (actualmax - plot.Max) * 0.3f;

                // Draw the background
                GearsetResources.Console.SolidBoxDrawer.ShowGradientBoxOnce(position, position + size, new Color(56, 56, 56, 150), new Color(16, 16, 16, 127));

                // Draw the border
                plot.DrawBorderLines(Color.Gray, _lines);
                //if (plot.TitleBar.IsMouseOver)
                //    plot.TitleBar.DrawBorderLines(Color.White, lines);
                if (plot.ScaleNob.IsMouseOver)
                {
                    plot.ScaleNob.DrawBorderLines(Color.White, _lines);
                }
                _labels.ShowLabel(plot.TitleLabelName, position + new Vector2(0, -12), plot.Sampler.Name);

                if (min != max)
                {
                    // Draw zero
                    if (min < 0 && max > 0)
                    {
                        var normalValue = (0 - min) / (max - min);
                        var yoffset     = new Vector2 {
                            X = 0, Y = size.Y * (1 - normalValue)
                        };
                        _lines.ShowLineOnce(position + yoffset, position + new Vector2(size.X, 0) + yoffset, new Color(230, 0, 0, 220));
                    }

                    var previousPoint = Vector2.Zero;
                    var pixelOffset   = Vector2.UnitY;
                    var i             = 0;
                    foreach (var value in plot.Sampler.Values)
                    {
                        var normalValue = (value - min) / (max - min);
                        var point       = new Vector2 {
                            X = position.X + i / ((float)count - 1) * size.X,
                            Y = position.Y + (size.Y - 1f) * MathHelper.Clamp((1 - normalValue), 0, 1)
                        };

                        if (i != 0)
                        {
                            _lines.ShowLineOnce(previousPoint, point, new Color(138, 198, 49));
                            _lines.ShowLineOnce(previousPoint + pixelOffset, point + pixelOffset, new Color(138, 198, 49));
                        }

                        i++;
                        previousPoint = point;
                    }

                    // Show the min/max labels.
                    _labels.ShowLabel(plot.MinLabelName, position + new Vector2(2, size.Y - 12), actualmin.ToString(), Color.White);
                    _labels.ShowLabel(plot.MaxLabelName, position + new Vector2(2, 0), actualmax.ToString(), Color.White);
                }
                else if (plot.Sampler.Values.Count > 0)
                {
                    _lines.ShowLineOnce(new Vector2(position.X, position.Y + size.Y * .5f), new Vector2(position.X + size.X, position.Y + size.Y * .5f), new Color(138, 198, 49));
                    _lines.ShowLineOnce(new Vector2(position.X, position.Y + size.Y * .5f + 1), new Vector2(position.X + size.X, position.Y + size.Y * .5f + 1), new Color(138, 198, 49));
                    _labels.ShowLabel(plot.MinLabelName, position + new Vector2(2, size.Y * .5f - 12), actualmin.ToString(), Color.White);
                }
                else
                {
                    plot.DrawCrossLines(Color.Gray);
                }
            }
        }