From d5f1f0d4a9482359a99a2c737ec077d3e6ef9291 Mon Sep 17 00:00:00 2001 From: degasus Date: Wed, 5 Feb 2014 11:48:45 +0100 Subject: [PATCH] merge some common parts of Swap() into VideoCommon --- Source/Core/VideoBackends/D3D/Render.cpp | 14 +------------- Source/Core/VideoBackends/D3D/Render.h | 2 +- Source/Core/VideoBackends/OGL/Render.cpp | 14 +------------- Source/Core/VideoBackends/OGL/Render.h | 2 +- Source/Core/VideoCommon/MainBase.cpp | 2 +- Source/Core/VideoCommon/RenderBase.cpp | 22 +++++++++++++++++++++- Source/Core/VideoCommon/RenderBase.h | 3 ++- 7 files changed, 28 insertions(+), 31 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 6b452b84c8..cb803c270b 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -7,7 +7,6 @@ #include "Timer.h" -#include "Debugger.h" #include "EmuWindow.h" #include "Fifo.h" #include "OnScreenDisplay.h" @@ -725,7 +724,7 @@ void formatBufferDump(const u8* in, u8* out, int w, int h, int p) } // This function has the final picture. We adjust the aspect ratio here. -void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& rc,float Gamma) +void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& rc,float Gamma) { if (g_bSkipCurrentFrame || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) || !fbWidth || !fbHeight) { @@ -945,9 +944,6 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& r OSD::DrawMessages(); D3D::EndFrame(); - frameCount++; - - GFX_DEBUGGER_PAUSE_AT(NEXT_FRAME, true); TextureCache::Cleanup(); @@ -974,11 +970,6 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& r if (XFBWrited) s_fps = UpdateFPSCounter(); - // Begin new frame - // Set default viewport and scissor, for the clear to work correctly - // New frame - stats.ResetFrame(); - // Flip/present backbuffer to frontbuffer here D3D::Present(); @@ -1019,9 +1010,6 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& r D3D::BeginFrame(); D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(), FramebufferManager::GetEFBDepthTexture()->GetDSV()); SetViewport(); - - Core::Callback_VideoCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB)); - XFBWrited = false; } // ALWAYS call RestoreAPIState for each ResetAPIState call you're doing diff --git a/Source/Core/VideoBackends/D3D/Render.h b/Source/Core/VideoBackends/D3D/Render.h index 17ac782beb..5c5a922cf1 100644 --- a/Source/Core/VideoBackends/D3D/Render.h +++ b/Source/Core/VideoBackends/D3D/Render.h @@ -39,7 +39,7 @@ public: TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc); - void Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma); + void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma); void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z); diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 7e31ace68d..844b7f3e98 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -44,7 +44,6 @@ #include "StringUtil.h" #include "FramebufferManager.h" #include "Fifo.h" -#include "Debugger.h" #include "Core.h" #include "Movie.h" #include "BPFunctions.h" @@ -1277,7 +1276,7 @@ void DumpFrame(const std::vector& data, int w, int h) } // This function has the final picture. We adjust the aspect ratio here. -void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& rc,float Gamma) +void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& rc,float Gamma) { static int w = 0, h = 0; if (g_bSkipCurrentFrame || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) || !fbWidth || !fbHeight) @@ -1593,15 +1592,6 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& r // Clean out old stuff from caches. It's not worth it to clean out the shader caches. TextureCache::Cleanup(); - frameCount++; - - GFX_DEBUGGER_PAUSE_AT(NEXT_FRAME, true); - - // Begin new frame - // Set default viewport and scissor, for the clear to work correctly - // New frame - stats.ResetFrame(); - // Render to the framebuffer. FramebufferManager::SetFramebuffer(0); @@ -1619,8 +1609,6 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& r // Renderer::SetZBufferRender(); // SaveTexture("tex.png", GL_TEXTURE_2D, s_FakeZTarget, // GetTargetWidth(), GetTargetHeight()); - Core::Callback_VideoCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB)); - XFBWrited = false; // Invalidate EFB cache ClearEFBCache(); diff --git a/Source/Core/VideoBackends/OGL/Render.h b/Source/Core/VideoBackends/OGL/Render.h index 2af37e0d93..fb15462921 100644 --- a/Source/Core/VideoBackends/OGL/Render.h +++ b/Source/Core/VideoBackends/OGL/Render.h @@ -71,7 +71,7 @@ public: TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) override; - void Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma) override; + void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma) override; void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override; diff --git a/Source/Core/VideoCommon/MainBase.cpp b/Source/Core/VideoCommon/MainBase.cpp index 7d81e4a10a..128570780b 100644 --- a/Source/Core/VideoCommon/MainBase.cpp +++ b/Source/Core/VideoCommon/MainBase.cpp @@ -72,7 +72,7 @@ void VideoFifo_CheckSwapRequest() if (Common::AtomicLoadAcquire(s_swapRequested)) { EFBRectangle rc; - g_renderer->Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight,rc); + Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight,rc); Common::AtomicStoreRelease(s_swapRequested, false); } } diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 836a0ec03d..31d5d091c7 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -30,6 +30,9 @@ #include "XFMemory.h" #include "FifoPlayer/FifoRecorder.h" #include "AVIDump.h" +#include "Debugger.h" +#include "Statistics.h" +#include "Core.h" #include #include @@ -117,7 +120,7 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect } else { - g_renderer->Swap(xfbAddr, fbWidth, fbHeight,sourceRc,Gamma); + Swap(xfbAddr, fbWidth, fbHeight,sourceRc,Gamma); Common::AtomicStoreRelease(s_swapRequested, false); } } @@ -514,3 +517,20 @@ void SetViewport() if (xfregs.viewport.wd != 0 && xfregs.viewport.ht != 0) g_renderer->SetViewport(); } + +void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc, float Gamma) +{ + // TODO: merge more generic parts into VideoCommon + g_renderer->SwapImpl(xfbAddr, fbWidth, fbHeight, rc, Gamma); + + frameCount++; + GFX_DEBUGGER_PAUSE_AT(NEXT_FRAME, true); + + // Begin new frame + // Set default viewport and scissor, for the clear to work correctly + // New frame + stats.ResetFrame(); + + Core::Callback_VideoCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB)); + XFBWrited = false; +} diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index df176c1346..6744767d14 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -106,7 +106,8 @@ public: virtual void RestoreAPIState() = 0; // Finish up the current frame, print some stats - virtual void Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma = 1.0f) = 0; + static void Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma = 1.0f); + virtual void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma = 1.0f) = 0; virtual bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc) = 0;