From 81d1b7f0c2bebbc9c8835f1bfe6ae1cb3c324105 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Sun, 28 Dec 2014 16:30:48 +0100 Subject: [PATCH 1/4] XFBEncoder: Cosmetics. --- Source/Core/VideoBackends/D3D/XFBEncoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/VideoBackends/D3D/XFBEncoder.cpp b/Source/Core/VideoBackends/D3D/XFBEncoder.cpp index 9e95e1ea74..e0932fe616 100644 --- a/Source/Core/VideoBackends/D3D/XFBEncoder.cpp +++ b/Source/Core/VideoBackends/D3D/XFBEncoder.cpp @@ -92,7 +92,7 @@ static const char XFB_ENCODE_PS[] = "float3 SampleEFB(float2 coord)\n" "{\n" "float2 texCoord = lerp(float2(Params.TexLeft,Params.TexTop), float2(Params.TexRight,Params.TexBottom), coord / float2(Params.Width,Params.Height));\n" - "return EFBTexture.Sample(EFBSampler, float3(texCoord, 0)).rgb;\n" + "return EFBTexture.Sample(EFBSampler, float3(texCoord, 0.0)).rgb;\n" "}\n" "void main(out float4 ocol0 : SV_Target, in float4 Pos : SV_Position, in float2 Coord : ENCODECOORD)\n" From 730a6e5f4b71ed0c022da11a9ce795526f501b06 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Sun, 28 Dec 2014 17:32:04 +0100 Subject: [PATCH 2/4] D3D: Fix Virtual XFB viewport. Looks like I was incorrect about swapping the bottom and top members. --- Source/Core/VideoBackends/D3D/Render.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index cf2a0a77ff..43190164c2 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -744,8 +744,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co int xfbWidth = xfbSource->srcWidth; int hOffset = ((s32)xfbSource->srcAddr - (s32)xfbAddr) / ((s32)fbStride * 2); - drawRc.top = targetRc.bottom - (hOffset + xfbHeight) * targetRc.GetHeight() / fbHeight; - drawRc.bottom = targetRc.bottom - hOffset * targetRc.GetHeight() / fbHeight; + drawRc.top = targetRc.top + hOffset * targetRc.GetHeight() / fbHeight; + drawRc.bottom = targetRc.top + (hOffset + xfbHeight) * targetRc.GetHeight() / fbHeight; drawRc.left = targetRc.left + (targetRc.GetWidth() - xfbWidth * targetRc.GetWidth() / fbStride) / 2; drawRc.right = targetRc.left + (targetRc.GetWidth() + xfbWidth * targetRc.GetWidth() / fbStride) / 2; From 89de7e0526e386ad1d7ce7c76e529a3e027fd393 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Sun, 28 Dec 2014 18:26:25 +0100 Subject: [PATCH 3/4] 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, From e1dc0331133c9ca1b1a62cc68b3110a25e70aa38 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Sun, 28 Dec 2014 18:35:23 +0100 Subject: [PATCH 4/4] Renderer: Cosmetics. --- Source/Core/VideoBackends/D3D/Render.cpp | 22 ++++++++++---------- Source/Core/VideoBackends/OGL/Render.cpp | 26 ++++++++++++------------ Source/Core/VideoCommon/RenderBase.cpp | 10 ++++----- Source/Core/VideoCommon/RenderBase.h | 4 ++-- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index d6bcf34f01..5644eae9fb 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -40,12 +40,12 @@ namespace DX11 { -static u32 s_LastAA = 0; +static u32 s_last_multisample_mode = 0; static Television s_television; static bool s_last_fullscreen_mode = false; -static bool s_LastStereo = 0; +static bool s_last_stereo_mode = 0; static bool s_last_xfb_mode = false; ID3D11Buffer* access_efb_cbuf = nullptr; @@ -228,10 +228,10 @@ Renderer::Renderer(void *&window_handle) UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height); - s_LastAA = g_ActiveConfig.iMultisampleMode; - s_LastEFBScale = g_ActiveConfig.iEFBScale; + s_last_multisample_mode = g_ActiveConfig.iMultisampleMode; + s_last_efb_scale = g_ActiveConfig.iEFBScale; s_last_fullscreen_mode = g_ActiveConfig.bFullscreen; - s_LastStereo = g_ActiveConfig.iStereoMode > 0; + s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0; s_last_xfb_mode = g_ActiveConfig.bUseRealXFB; CalculateTargetSize(s_backbuffer_width, s_backbuffer_height); @@ -898,12 +898,12 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co if (xfbchanged || windowResized || fullscreen_changed || - s_LastEFBScale != g_ActiveConfig.iEFBScale || - s_LastAA != g_ActiveConfig.iMultisampleMode || - s_LastStereo != (g_ActiveConfig.iStereoMode > 0)) + s_last_efb_scale != g_ActiveConfig.iEFBScale || + s_last_multisample_mode != g_ActiveConfig.iMultisampleMode || + s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0)) { s_last_xfb_mode = g_ActiveConfig.bUseRealXFB; - s_LastAA = g_ActiveConfig.iMultisampleMode; + s_last_multisample_mode = g_ActiveConfig.iMultisampleMode; PixelShaderCache::InvalidateMSAAShaders(); if (windowResized || fullscreen_changed) @@ -931,8 +931,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height); - s_LastEFBScale = g_ActiveConfig.iEFBScale; - s_LastStereo = g_ActiveConfig.iStereoMode > 0; + s_last_efb_scale = g_ActiveConfig.iEFBScale; + s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0; CalculateTargetSize(s_backbuffer_width, s_backbuffer_height); D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), nullptr); diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 6ef7d3d8ea..be3b37c580 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -85,8 +85,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 int s_last_multisample_mode = 0; +static bool s_last_stereo_mode = false; static bool s_last_xfb_mode = false; static u32 s_blendMode; @@ -586,11 +586,11 @@ Renderer::Renderer() g_ActiveConfig.backend_info.bSupportsGSInstancing ? "" : "GSInstancing " ); - s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode; - s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode); + s_last_multisample_mode = g_ActiveConfig.iMultisampleMode; + s_MSAASamples = GetNumMSAASamples(s_last_multisample_mode); ApplySSAASettings(); - s_LastStereo = g_ActiveConfig.iStereoMode > 0; + s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0; s_last_xfb_mode = g_ActiveConfig.bUseRealXFB; // Decide framebuffer size @@ -607,7 +607,7 @@ Renderer::Renderer() UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height); - s_LastEFBScale = g_ActiveConfig.iEFBScale; + s_last_efb_scale = g_ActiveConfig.iEFBScale; CalculateTargetSize(s_backbuffer_width, s_backbuffer_height); // Because of the fixed framebuffer size we need to disable the resolution @@ -1641,25 +1641,25 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co bool WindowResized = false; int W = (int)GLInterface->GetBackBufferWidth(); int H = (int)GLInterface->GetBackBufferHeight(); - if (W != s_backbuffer_width || H != s_backbuffer_height || s_LastEFBScale != g_ActiveConfig.iEFBScale) + if (W != s_backbuffer_width || H != s_backbuffer_height || s_last_efb_scale != g_ActiveConfig.iEFBScale) { WindowResized = true; s_backbuffer_width = W; s_backbuffer_height = H; - s_LastEFBScale = g_ActiveConfig.iEFBScale; + s_last_efb_scale = g_ActiveConfig.iEFBScale; } - if (xfbchanged || WindowResized || (s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode) || (s_LastStereo != (g_ActiveConfig.iStereoMode > 0))) + if (xfbchanged || WindowResized || (s_last_multisample_mode != g_ActiveConfig.iMultisampleMode) || (s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))) { - s_LastStereo = g_ActiveConfig.iStereoMode > 0; + s_last_stereo_mode = 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)) + if (CalculateTargetSize(s_backbuffer_width, s_backbuffer_height) || s_last_multisample_mode != g_ActiveConfig.iMultisampleMode || s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0)) { - s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode; - s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode); + s_last_multisample_mode = g_ActiveConfig.iMultisampleMode; + s_MSAASamples = GetNumMSAASamples(s_last_multisample_mode); ApplySSAASettings(); delete g_framebuffer_manager; diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 50778172cf..9ff2ba83f0 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -67,7 +67,7 @@ PostProcessingShaderImplementation* Renderer::m_post_processor; TargetRectangle Renderer::target_rc; -int Renderer::s_LastEFBScale; +int Renderer::s_last_efb_scale; bool Renderer::XFBWrited; @@ -176,14 +176,14 @@ bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int newEFBWidth = newEFBHeight = 0; // TODO: Ugly. Clean up - switch (s_LastEFBScale) + switch (s_last_efb_scale) { case SCALE_AUTO: case SCALE_AUTO_INTEGRAL: newEFBWidth = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH); newEFBHeight = FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT); - if (s_LastEFBScale == SCALE_AUTO_INTEGRAL) + if (s_last_efb_scale == SCALE_AUTO_INTEGRAL) { newEFBWidth = ((newEFBWidth-1) / EFB_WIDTH + 1) * EFB_WIDTH; newEFBHeight = ((newEFBHeight-1) / EFB_HEIGHT + 1) * EFB_HEIGHT; @@ -217,7 +217,7 @@ bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int case SCALE_3X: case SCALE_4X: default: - efb_scale_numeratorX = efb_scale_numeratorY = s_LastEFBScale - 3; + efb_scale_numeratorX = efb_scale_numeratorY = s_last_efb_scale - 3; efb_scale_denominatorX = efb_scale_denominatorY = 1; @@ -231,7 +231,7 @@ bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int break; } - if (s_LastEFBScale > SCALE_AUTO_INTEGRAL) + if (s_last_efb_scale > SCALE_AUTO_INTEGRAL) CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT, &newEFBWidth, &newEFBHeight); if (newEFBWidth != s_target_width || newEFBHeight != s_target_height) diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index ef68d665a6..e039329d74 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -155,8 +155,8 @@ protected: static TargetRectangle target_rc; - // can probably eliminate this static var - static int s_LastEFBScale; + // TODO: Can probably eliminate this static var. + static int s_last_efb_scale; static bool XFBWrited;