public override void BeginLineBatch() { m_lineBatch.Begin(); }
protected override void Draw(MyProfiler drawProfiler, int lastFrameIndex, int frameToDraw) { Debug.Assert(frameToDraw >= 0 && frameToDraw < MyProfiler.MAX_FRAMES, "Invalid selected frame"); // Init linebatch if (m_lineBatch == null) { SharpDX.Direct3D9.Device device = MyRender.GraphicsDevice; m_lineBatch = new MyLineBatch(Matrix.Identity, Matrix.CreateOrthographicOffCenter(0, device.Viewport.Width, device.Viewport.Height, 0, 0, -1), 50000); m_fpsBlock.Start(false); } // Handle FPS timer m_fpsBlock.End(false); float elapsedTime = (float)m_fpsBlock.Elapsed.Seconds; float invElapsedTime = elapsedTime > 0 ? 1 / elapsedTime : 0; m_fpsPctg = 0.9f * m_fpsPctg + 0.1f * invElapsedTime; if (MemoryProfiling) { // Handle memory usage for frame float processDeltaMB = m_fpsBlock.ProcessDeltaMB; m_fpsBlock.ProcessMemory[lastFrameIndex] = processDeltaMB; } float managedDeltaMB = m_fpsBlock.ManagedDeltaMB; m_fpsBlock.ManagedMemory[lastFrameIndex] = managedDeltaMB; m_fpsBlock.CustomValues[lastFrameIndex] = m_fpsBlock.CustomValue; m_fpsBlock.Reset(); m_fpsBlock.Start(false); if (m_enabled) { // Draw events as text float eventLineSize = 20; float largeTextLineSize = 28; float textOffsetY = MyRender.GraphicsDevice.Viewport.Height / 2 - 8 * largeTextLineSize; // Draw thread name and level limit m_text.Clear(); m_text.ConcatFormat("\"{2}\" ({0}/{1})", m_selectedProfiler.GlobalProfilerIndex + 1, m_threadProfilers.Count, m_selectedProfiler.OwnerThread.Name).AppendLine(); m_text.Append("Level limit: ").AppendInt32(m_levelLimit).AppendLine(); MyRender.DrawText(new Vector2(20, textOffsetY), m_text, Color.LightGray, 1); textOffsetY += largeTextLineSize * 2 + 10; // Draw frame number and local area m_text.Clear(); m_text.Append("Frame: ").AppendInt32(frameToDraw).AppendLine(); m_text.Append("Local area: ").AppendInt32(m_frameLocalArea); MyRender.DrawText(new Vector2(20, textOffsetY), m_text, Color.Yellow, 1); textOffsetY += largeTextLineSize * 2 + 10; // Draw fps and total calls m_text.Clear(); m_text.Append(m_fpsBlock.Name).Append(" "); if (!m_useCustomFrame) // Show FPS only when not using custom frame { m_text.AppendDecimal(m_fpsPctg, 3); } m_text.AppendLine(); m_text.Append("Total calls: ").AppendInt32(IsValidIndex(frameToDraw, lastFrameIndex) ? m_selectedProfiler.TotalCalls[frameToDraw] : -1); MyRender.DrawText(new Vector2(20, textOffsetY), m_text, Color.Red, 1); textOffsetY += largeTextLineSize; textOffsetY = MyRender.GraphicsDevice.Viewport.Height / 2; var children = m_selectedProfiler.SelectedRootChildren; for (int i = 0; i < children.Count; i++) { MyProfiler.MyProfilerBlock profilerBlock = children[i]; DrawEvent(textOffsetY, profilerBlock, i, frameToDraw, lastFrameIndex); textOffsetY += eventLineSize; } // Draw graphs m_lineBatch.Begin(); DrawPerfEvents(lastFrameIndex); VRageRender.Graphics.BlendState.Opaque.Apply(); m_lineBatch.End(); } // Update horizontal offset if (!Paused && !m_useCustomFrame) { m_selectedFrame = lastFrameIndex; } }