From ffa014dd4853d231e3b380e12ccc96318e184f64 Mon Sep 17 00:00:00 2001 From: degasus Date: Sat, 20 Dec 2014 12:14:33 +0100 Subject: [PATCH] VideoCommon: merge debug info generators --- Source/Core/VideoBackends/D3D/Render.cpp | 51 ++---------------------- Source/Core/VideoBackends/OGL/Render.cpp | 38 +----------------- Source/Core/VideoCommon/RenderBase.cpp | 44 ++++++++++++++++++++ Source/Core/VideoCommon/RenderBase.h | 1 + 4 files changed, 49 insertions(+), 85 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 9609fbf722..a07b2754da 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -8,13 +8,11 @@ #include #include -#include "Common/Profiler.h" #include "Common/Timer.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/Host.h" -#include "Core/Movie.h" #include "VideoBackends/D3D/BoundingBox.h" #include "VideoBackends/D3D/D3DBase.h" @@ -914,53 +912,10 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co vp = CD3D11_VIEWPORT(0.0f, 0.0f, (float)GetBackbufferWidth(), (float)GetBackbufferHeight()); D3D::context->RSSetViewports(1, &vp); - // Finish up the current frame, print some stats - if (g_ActiveConfig.bShowFPS || SConfig::GetInstance().m_ShowFrameCount) - { - std::string fps = ""; - if (g_ActiveConfig.bShowFPS) - fps = StringFromFormat("FPS: %d", m_fps_counter.m_fps); - - if (g_ActiveConfig.bShowFPS && SConfig::GetInstance().m_ShowFrameCount) - fps += " - "; - if (SConfig::GetInstance().m_ShowFrameCount) - { - fps += StringFromFormat("Frame: %d", Movie::g_currentFrame); - if (Movie::IsPlayingInput()) - fps += StringFromFormat(" / %d", Movie::g_totalFrames); - } - - fps += "\n"; - - D3D::font.DrawTextScaled(0, 0, 20, 0.0f, 0xFF00FFFF, fps); - } - - if (SConfig::GetInstance().m_ShowLag) - { - std::string lag = StringFromFormat("Lag: %" PRIu64 "\n", Movie::g_currentLagCount); - D3D::font.DrawTextScaled(0, 18, 20, 0.0f, 0xFF00FFFF, lag); - } - - if (SConfig::GetInstance().m_ShowInputDisplay) - { - D3D::font.DrawTextScaled(0, 36, 20, 0.0f, 0xFF00FFFF, Movie::GetInputDisplay()); - } Renderer::DrawDebugText(); - - if (g_ActiveConfig.bOverlayStats) - { - D3D::font.DrawTextScaled(0, 36, 20, 0.0f, 0xFF00FFFF, Statistics::ToString()); - } - else if (g_ActiveConfig.bOverlayProjStats) - { - D3D::font.DrawTextScaled(0, 36, 20, 0.0f, 0xFF00FFFF, Statistics::ToStringProj()); - } - - std::string profile_output = Profiler::ToString(); - if (!profile_output.empty()) - { - D3D::font.DrawTextScaled(0, 44, 20, 0.0f, 0xFF00FFFF, profile_output); - } + std::string debug_info = GetDebugText(); + if (debug_info != "") + D3D::font.DrawTextScaled(0, 0, 20, 0.0f, 0xFF00FFFF, debug_info); OSD::DrawMessages(); D3D::EndFrame(); diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index aa5275b3f9..f7eaf5f281 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -12,14 +12,12 @@ #include "Common/Atomic.h" #include "Common/CommonPaths.h" #include "Common/FileUtil.h" -#include "Common/Profiler.h" #include "Common/StringUtil.h" #include "Common/Thread.h" #include "Common/Timer.h" #include "Core/ConfigManager.h" #include "Core/Core.h" -#include "Core/Movie.h" #include "VideoBackends/OGL/BoundingBox.h" #include "VideoBackends/OGL/FramebufferManager.h" @@ -729,35 +727,6 @@ void Renderer::DrawDebugInfo() // Reset viewport for drawing text glViewport(0, 0, GLInterface->GetBackBufferWidth(), GLInterface->GetBackBufferHeight()); - // Draw various messages on the screen, like FPS, statistics, etc. - std::string debug_info; - - if (g_ActiveConfig.bShowFPS || SConfig::GetInstance().m_ShowFrameCount) - { - std::string fps = ""; - if (g_ActiveConfig.bShowFPS) - debug_info += StringFromFormat("FPS: %d", m_fps_counter.m_fps); - - if (g_ActiveConfig.bShowFPS && SConfig::GetInstance().m_ShowFrameCount) - debug_info += " - "; - if (SConfig::GetInstance().m_ShowFrameCount) - { - debug_info += StringFromFormat("Frame: %llu", (unsigned long long) Movie::g_currentFrame); - if (Movie::IsPlayingInput()) - debug_info += StringFromFormat(" / %llu", (unsigned long long) Movie::g_totalFrames); - } - - debug_info += "\n"; - } - - if (SConfig::GetInstance().m_ShowLag) - debug_info += StringFromFormat("Lag: %" PRIu64 "\n", Movie::g_currentLagCount); - - if (SConfig::GetInstance().m_ShowInputDisplay) - debug_info += Movie::GetInputDisplay(); - - debug_info += Profiler::ToString(); - if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL && g_ActiveConfig.bShowEFBCopyRegions) { // Set Line Size @@ -876,12 +845,7 @@ void Renderer::DrawDebugInfo() stats.efb_regions.clear(); } - if (g_ActiveConfig.bOverlayStats) - debug_info += Statistics::ToString(); - - if (g_ActiveConfig.bOverlayProjStats) - debug_info += Statistics::ToStringProj(); - + std::string debug_info = GetDebugText(); if (!debug_info.empty()) { // Render a shadow, and then the text. diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 84c037c753..d287485da6 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -12,16 +12,19 @@ // Next frame, that one is scanned out and the other one gets the copy. = double buffering. // --------------------------------------------------------------------------------------------- +#include #include #include #include "Common/Atomic.h" +#include "Common/Profiler.h" #include "Common/StringUtil.h" #include "Common/Timer.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/Host.h" +#include "Core/Movie.h" #include "Core/FifoPlayer/FifoRecorder.h" #include "VideoCommon/AVIDump.h" @@ -388,6 +391,47 @@ void Renderer::DrawDebugText() g_renderer->RenderText(final_yellow, 20, 20, 0xFFFFFF00); } +std::string Renderer::GetDebugText() +{ + // Draw various messages on the screen, like FPS, statistics, etc. + std::string debug_info; + + if (g_ActiveConfig.bShowFPS || SConfig::GetInstance().m_ShowFrameCount) + { + std::string fps = ""; + if (g_ActiveConfig.bShowFPS) + debug_info += StringFromFormat("FPS: %d", g_renderer->m_fps_counter.m_fps); + + if (g_ActiveConfig.bShowFPS && SConfig::GetInstance().m_ShowFrameCount) + debug_info += " - "; + if (SConfig::GetInstance().m_ShowFrameCount) + { + debug_info += StringFromFormat("Frame: %llu", (unsigned long long) Movie::g_currentFrame); + if (Movie::IsPlayingInput()) + debug_info += StringFromFormat(" / %llu", (unsigned long long) Movie::g_totalFrames); + } + + debug_info += "\n"; + } + + if (SConfig::GetInstance().m_ShowLag) + debug_info += StringFromFormat("Lag: %" PRIu64 "\n", Movie::g_currentLagCount); + + if (SConfig::GetInstance().m_ShowInputDisplay) + debug_info += Movie::GetInputDisplay(); + + debug_info += Profiler::ToString(); + + + if (g_ActiveConfig.bOverlayStats) + debug_info += Statistics::ToString(); + + if (g_ActiveConfig.bOverlayProjStats) + debug_info += Statistics::ToStringProj(); + + return debug_info; +} + void Renderer::UpdateDrawRectangle(int backbuffer_width, int backbuffer_height) { float FloatGLWidth = (float)backbuffer_width; diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index ef68d665a6..bb0c55cb02 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -96,6 +96,7 @@ public: // Random utilities static void SetScreenshot(const std::string& filename); static void DrawDebugText(); + static std::string GetDebugText(); virtual void RenderText(const std::string& text, int left, int top, u32 color) = 0;