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;
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);

View File

@ -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()

View File

@ -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();