Fix XFB scaling in D3D

This commit is contained in:
slx7R4GDZM 2014-10-14 22:21:36 -04:00 committed by Lioncash
parent 8f61c6f239
commit 5a3f19aeaf
3 changed files with 12 additions and 12 deletions

View File

@ -721,7 +721,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
} }
u32 xfbCount = 0; 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 ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
{ {
if (g_ActiveConfig.bDumpFrames && !frame_data.empty()) 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) if (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB)
{ {
// TODO: Television should be used to render Virtual XFB mode as well. // 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(); s_television.Render();
} }
else if (g_ActiveConfig.bUseXFB) 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 // use virtual xfb with offset
int xfbHeight = xfbSource->srcHeight; int xfbHeight = xfbSource->srcHeight;
int xfbWidth = xfbSource->srcWidth; 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.top = 1.0f - (2.0f * (hOffset) / (float)fbHeight);
drawRc.bottom = 1.0f - (2.0f * (hOffset + xfbHeight) / (float)fbHeight); drawRc.bottom = 1.0f - (2.0f * (hOffset + xfbHeight) / (float)fbHeight);
drawRc.left = -(xfbWidth / (float)fbWidth); drawRc.left = -(xfbWidth / (float)fbStride);
drawRc.right = (xfbWidth / (float)fbWidth); drawRc.right = (xfbWidth / (float)fbStride);
// The following code disables auto stretch. Kept for reference. // The following code disables auto stretch. Kept for reference.
// scale draw area for a 1 to 1 pixel mapping with the draw target // 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(); UpdateActiveConfig();
TextureCache::OnConfigChanged(g_ActiveConfig); TextureCache::OnConfigChanged(g_ActiveConfig);
SetWindowSize(fbWidth, fbHeight); SetWindowSize(fbStride, fbHeight);
const bool windowResized = CheckForResize(); const bool windowResized = CheckForResize();
const bool fullscreen = g_ActiveConfig.bFullscreen && 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; bool xfbchanged = false;
if (FramebufferManagerBase::LastXfbWidth() != fbWidth || FramebufferManagerBase::LastXfbHeight() != fbHeight) if (FramebufferManagerBase::LastXfbWidth() != fbStride || FramebufferManagerBase::LastXfbHeight() != fbHeight)
{ {
xfbchanged = true; 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; unsigned int h = (fbHeight < 1 || fbHeight > MAX_XFB_HEIGHT) ? MAX_XFB_HEIGHT : fbHeight;
FramebufferManagerBase::SetLastXfbWidth(w); FramebufferManagerBase::SetLastXfbWidth(w);
FramebufferManagerBase::SetLastXfbHeight(h); FramebufferManagerBase::SetLastXfbHeight(h);

View File

@ -126,7 +126,7 @@ void Television::Shutdown()
SAFE_RELEASE(m_samplerState); 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_curAddr = xfbAddr;
m_curWidth = width; m_curWidth = width;
@ -134,8 +134,8 @@ void Television::Submit(u32 xfbAddr, u32 width, u32 height)
// Load data from GameCube RAM to YUYV texture // Load data from GameCube RAM to YUYV texture
u8* yuyvSrc = Memory::GetPointer(xfbAddr); u8* yuyvSrc = Memory::GetPointer(xfbAddr);
D3D11_BOX box = CD3D11_BOX(0, 0, 0, width, height, 1); D3D11_BOX box = CD3D11_BOX(0, 0, 0, stride, height, 1);
D3D::context->UpdateSubresource(m_yuyvTexture, 0, &box, yuyvSrc, 2*width, 2*width*height); D3D::context->UpdateSubresource(m_yuyvTexture, 0, &box, yuyvSrc, 2*stride, 2*stride*height);
} }
void Television::Render() void Television::Render()

View File

@ -27,7 +27,7 @@ public:
// Submit video data to be drawn. This will change the current state of the // 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 // 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. // 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. // Render the current state of the TV.
void Render(); void Render();