From 5a3f19aeaf11575f142d9fdd2a90a96572b0ea7c Mon Sep 17 00:00:00 2001 From: slx7R4GDZM Date: Tue, 14 Oct 2014 22:21:36 -0400 Subject: [PATCH] Fix XFB scaling in D3D --- Source/Core/VideoBackends/D3D/Render.cpp | 16 ++++++++-------- Source/Core/VideoBackends/D3D/Television.cpp | 6 +++--- Source/Core/VideoBackends/D3D/Television.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 645160abda..2c059042c4 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -721,7 +721,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co } u32 xfbCount = 0; - const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbWidth, fbHeight, &xfbCount); + const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbStride, fbHeight, &xfbCount); if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB) { if (g_ActiveConfig.bDumpFrames && !frame_data.empty()) @@ -763,7 +763,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co if (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB) { // TODO: Television should be used to render Virtual XFB mode as well. - s_television.Submit(xfbAddr, fbWidth, fbHeight); + s_television.Submit(xfbAddr, fbStride, fbWidth, fbHeight); s_television.Render(); } else if (g_ActiveConfig.bUseXFB) @@ -795,12 +795,12 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co // use virtual xfb with offset int xfbHeight = xfbSource->srcHeight; int xfbWidth = xfbSource->srcWidth; - int hOffset = ((s32)xfbSource->srcAddr - (s32)xfbAddr) / ((s32)fbWidth * 2); + int hOffset = ((s32)xfbSource->srcAddr - (s32)xfbAddr) / ((s32)fbStride * 2); drawRc.top = 1.0f - (2.0f * (hOffset) / (float)fbHeight); drawRc.bottom = 1.0f - (2.0f * (hOffset + xfbHeight) / (float)fbHeight); - drawRc.left = -(xfbWidth / (float)fbWidth); - drawRc.right = (xfbWidth / (float)fbWidth); + drawRc.left = -(xfbWidth / (float)fbStride); + drawRc.right = (xfbWidth / (float)fbStride); // The following code disables auto stretch. Kept for reference. // scale draw area for a 1 to 1 pixel mapping with the draw target @@ -946,7 +946,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co UpdateActiveConfig(); TextureCache::OnConfigChanged(g_ActiveConfig); - SetWindowSize(fbWidth, fbHeight); + SetWindowSize(fbStride, fbHeight); const bool windowResized = CheckForResize(); const bool fullscreen = g_ActiveConfig.bFullscreen && @@ -968,10 +968,10 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co bool xfbchanged = false; - if (FramebufferManagerBase::LastXfbWidth() != fbWidth || FramebufferManagerBase::LastXfbHeight() != fbHeight) + if (FramebufferManagerBase::LastXfbWidth() != fbStride || FramebufferManagerBase::LastXfbHeight() != fbHeight) { xfbchanged = true; - unsigned int w = (fbWidth < 1 || fbWidth > MAX_XFB_WIDTH) ? MAX_XFB_WIDTH : fbWidth; + unsigned int w = (fbStride < 1 || fbStride > MAX_XFB_WIDTH) ? MAX_XFB_WIDTH : fbStride; unsigned int h = (fbHeight < 1 || fbHeight > MAX_XFB_HEIGHT) ? MAX_XFB_HEIGHT : fbHeight; FramebufferManagerBase::SetLastXfbWidth(w); FramebufferManagerBase::SetLastXfbHeight(h); diff --git a/Source/Core/VideoBackends/D3D/Television.cpp b/Source/Core/VideoBackends/D3D/Television.cpp index f24a3dcb06..94904c8e1f 100644 --- a/Source/Core/VideoBackends/D3D/Television.cpp +++ b/Source/Core/VideoBackends/D3D/Television.cpp @@ -126,7 +126,7 @@ void Television::Shutdown() SAFE_RELEASE(m_samplerState); } -void Television::Submit(u32 xfbAddr, u32 width, u32 height) +void Television::Submit(u32 xfbAddr, u32 stride, u32 width, u32 height) { m_curAddr = xfbAddr; m_curWidth = width; @@ -134,8 +134,8 @@ void Television::Submit(u32 xfbAddr, u32 width, u32 height) // Load data from GameCube RAM to YUYV texture u8* yuyvSrc = Memory::GetPointer(xfbAddr); - D3D11_BOX box = CD3D11_BOX(0, 0, 0, width, height, 1); - D3D::context->UpdateSubresource(m_yuyvTexture, 0, &box, yuyvSrc, 2*width, 2*width*height); + D3D11_BOX box = CD3D11_BOX(0, 0, 0, stride, height, 1); + D3D::context->UpdateSubresource(m_yuyvTexture, 0, &box, yuyvSrc, 2*stride, 2*stride*height); } void Television::Render() diff --git a/Source/Core/VideoBackends/D3D/Television.h b/Source/Core/VideoBackends/D3D/Television.h index 61f0e3f5f6..e25bb0f571 100644 --- a/Source/Core/VideoBackends/D3D/Television.h +++ b/Source/Core/VideoBackends/D3D/Television.h @@ -27,7 +27,7 @@ public: // Submit video data to be drawn. This will change the current state of the // TV. xfbAddr points to YUYV data stored in GameCube/Wii RAM, but the XFB // may be virtualized when rendering so the RAM may not actually be read. - void Submit(u32 xfbAddr, u32 width, u32 height); + void Submit(u32 xfbAddr, u32 stride, u32 width, u32 height); // Render the current state of the TV. void Render();