From 89de7e0526e386ad1d7ce7c76e529a3e027fd393 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Sun, 28 Dec 2014 18:26:25 +0100 Subject: [PATCH] Renderer: Invalidate the FramebufferManager if the XFB mode is changed. Fixes incorrect texture sizes after switching XFB modes. --- Source/Core/VideoBackends/D3D/Render.cpp | 5 ++++- Source/Core/VideoBackends/OGL/Render.cpp | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 43190164c2..d6bcf34f01 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -46,6 +46,7 @@ static Television s_television; static bool s_last_fullscreen_mode = false; static bool s_LastStereo = 0; +static bool s_last_xfb_mode = false; ID3D11Buffer* access_efb_cbuf = nullptr; ID3D11BlendState* clearblendstates[4] = {nullptr}; @@ -231,6 +232,7 @@ Renderer::Renderer(void *&window_handle) s_LastEFBScale = g_ActiveConfig.iEFBScale; s_last_fullscreen_mode = g_ActiveConfig.bFullscreen; s_LastStereo = g_ActiveConfig.iStereoMode > 0; + s_last_xfb_mode = g_ActiveConfig.bUseRealXFB; CalculateTargetSize(s_backbuffer_width, s_backbuffer_height); SetupDeviceObjects(); @@ -878,7 +880,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co } } - bool xfbchanged = false; + bool xfbchanged = s_last_xfb_mode != g_ActiveConfig.bUseRealXFB; if (FramebufferManagerBase::LastXfbWidth() != fbStride || FramebufferManagerBase::LastXfbHeight() != fbHeight) { @@ -900,6 +902,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co s_LastAA != g_ActiveConfig.iMultisampleMode || s_LastStereo != (g_ActiveConfig.iStereoMode > 0)) { + s_last_xfb_mode = g_ActiveConfig.bUseRealXFB; s_LastAA = g_ActiveConfig.iMultisampleMode; PixelShaderCache::InvalidateMSAAShaders(); diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 2def435a11..6ef7d3d8ea 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -86,8 +86,8 @@ static RasterFont* s_pfont = nullptr; // 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA. static int s_MSAASamples = 1; static int s_LastMultisampleMode = 0; - static bool s_LastStereo = false; +static bool s_last_xfb_mode = false; static u32 s_blendMode; @@ -589,7 +589,9 @@ Renderer::Renderer() s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode; s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode); ApplySSAASettings(); + s_LastStereo = g_ActiveConfig.iStereoMode > 0; + s_last_xfb_mode = g_ActiveConfig.bUseRealXFB; // Decide framebuffer size s_backbuffer_width = (int)GLInterface->GetBackBufferWidth(); @@ -1625,7 +1627,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co GLInterface->Update(); // just updates the render window position and the backbuffer size - bool xfbchanged = false; + bool xfbchanged = s_last_xfb_mode != g_ActiveConfig.bUseRealXFB; if (FramebufferManagerBase::LastXfbWidth() != fbStride || FramebufferManagerBase::LastXfbHeight() != fbHeight) { @@ -1649,6 +1651,9 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co if (xfbchanged || WindowResized || (s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode) || (s_LastStereo != (g_ActiveConfig.iStereoMode > 0))) { + s_LastStereo = g_ActiveConfig.iStereoMode > 0; + s_last_xfb_mode = g_ActiveConfig.bUseRealXFB; + UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height); if (CalculateTargetSize(s_backbuffer_width, s_backbuffer_height) || s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode || s_LastStereo != (g_ActiveConfig.iStereoMode > 0)) @@ -1656,7 +1661,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode; s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode); ApplySSAASettings(); - s_LastStereo = g_ActiveConfig.iStereoMode > 0; delete g_framebuffer_manager; g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height,