merge some common parts of Swap() into VideoCommon

This commit is contained in:
degasus 2014-02-05 11:48:45 +01:00
parent 3551259c7a
commit d5f1f0d4a9
7 changed files with 28 additions and 31 deletions

View File

@ -7,7 +7,6 @@
#include "Timer.h" #include "Timer.h"
#include "Debugger.h"
#include "EmuWindow.h" #include "EmuWindow.h"
#include "Fifo.h" #include "Fifo.h"
#include "OnScreenDisplay.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. // 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) 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(); OSD::DrawMessages();
D3D::EndFrame(); D3D::EndFrame();
frameCount++;
GFX_DEBUGGER_PAUSE_AT(NEXT_FRAME, true);
TextureCache::Cleanup(); TextureCache::Cleanup();
@ -974,11 +970,6 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& r
if (XFBWrited) if (XFBWrited)
s_fps = UpdateFPSCounter(); 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 // Flip/present backbuffer to frontbuffer here
D3D::Present(); D3D::Present();
@ -1019,9 +1010,6 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& r
D3D::BeginFrame(); D3D::BeginFrame();
D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(), FramebufferManager::GetEFBDepthTexture()->GetDSV()); D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(), FramebufferManager::GetEFBDepthTexture()->GetDSV());
SetViewport(); SetViewport();
Core::Callback_VideoCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB));
XFBWrited = false;
} }
// ALWAYS call RestoreAPIState for each ResetAPIState call you're doing // ALWAYS call RestoreAPIState for each ResetAPIState call you're doing

View File

@ -39,7 +39,7 @@ public:
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc); 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); void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z);

View File

@ -44,7 +44,6 @@
#include "StringUtil.h" #include "StringUtil.h"
#include "FramebufferManager.h" #include "FramebufferManager.h"
#include "Fifo.h" #include "Fifo.h"
#include "Debugger.h"
#include "Core.h" #include "Core.h"
#include "Movie.h" #include "Movie.h"
#include "BPFunctions.h" #include "BPFunctions.h"
@ -1277,7 +1276,7 @@ void DumpFrame(const std::vector<u8>& data, int w, int h)
} }
// This function has the final picture. We adjust the aspect ratio here. // 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; static int w = 0, h = 0;
if (g_bSkipCurrentFrame || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) || !fbWidth || !fbHeight) 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. // Clean out old stuff from caches. It's not worth it to clean out the shader caches.
TextureCache::Cleanup(); 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. // Render to the framebuffer.
FramebufferManager::SetFramebuffer(0); FramebufferManager::SetFramebuffer(0);
@ -1619,8 +1609,6 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& r
// Renderer::SetZBufferRender(); // Renderer::SetZBufferRender();
// SaveTexture("tex.png", GL_TEXTURE_2D, s_FakeZTarget, // SaveTexture("tex.png", GL_TEXTURE_2D, s_FakeZTarget,
// GetTargetWidth(), GetTargetHeight()); // GetTargetWidth(), GetTargetHeight());
Core::Callback_VideoCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB));
XFBWrited = false;
// Invalidate EFB cache // Invalidate EFB cache
ClearEFBCache(); ClearEFBCache();

View File

@ -71,7 +71,7 @@ public:
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) override; 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; void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override;

View File

@ -72,7 +72,7 @@ void VideoFifo_CheckSwapRequest()
if (Common::AtomicLoadAcquire(s_swapRequested)) if (Common::AtomicLoadAcquire(s_swapRequested))
{ {
EFBRectangle rc; 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); Common::AtomicStoreRelease(s_swapRequested, false);
} }
} }

View File

@ -30,6 +30,9 @@
#include "XFMemory.h" #include "XFMemory.h"
#include "FifoPlayer/FifoRecorder.h" #include "FifoPlayer/FifoRecorder.h"
#include "AVIDump.h" #include "AVIDump.h"
#include "Debugger.h"
#include "Statistics.h"
#include "Core.h"
#include <cmath> #include <cmath>
#include <string> #include <string>
@ -117,7 +120,7 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
} }
else else
{ {
g_renderer->Swap(xfbAddr, fbWidth, fbHeight,sourceRc,Gamma); Swap(xfbAddr, fbWidth, fbHeight,sourceRc,Gamma);
Common::AtomicStoreRelease(s_swapRequested, false); Common::AtomicStoreRelease(s_swapRequested, false);
} }
} }
@ -514,3 +517,20 @@ void SetViewport()
if (xfregs.viewport.wd != 0 && xfregs.viewport.ht != 0) if (xfregs.viewport.wd != 0 && xfregs.viewport.ht != 0)
g_renderer->SetViewport(); 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;
}

View File

@ -106,7 +106,8 @@ public:
virtual void RestoreAPIState() = 0; virtual void RestoreAPIState() = 0;
// Finish up the current frame, print some stats // 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; virtual bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc) = 0;