Merge pull request #118 from neobrain/videosoftware-bypass-xfb-hack

Software renderer: Restore FifoPlayer support by emulating hardware backend behavior.
This commit is contained in:
Pierre Bourdon 2014-03-03 19:05:35 +01:00
commit 6fa39c28fe
2 changed files with 36 additions and 17 deletions

View File

@ -27,24 +27,36 @@ namespace EfbCopy
{ {
void CopyToXfb(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc, float Gamma) void CopyToXfb(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc, float Gamma)
{ {
GLInterface->Update(); // just updates the render window position and the backbuffer size GLInterface->Update(); // update the render window position and the backbuffer size
if (!g_SWVideoConfig.bHwRasterizer) if (!g_SWVideoConfig.bHwRasterizer)
{ {
INFO_LOG(VIDEO, "xfbaddr: %x, fbwidth: %i, fbheight: %i, source: (%i, %i, %i, %i), Gamma %f", INFO_LOG(VIDEO, "xfbaddr: %x, fbwidth: %i, fbheight: %i, source: (%i, %i, %i, %i), Gamma %f",
xfbAddr, fbWidth, fbHeight, sourceRc.top, sourceRc.left, sourceRc.bottom, sourceRc.right, Gamma); xfbAddr, fbWidth, fbHeight, sourceRc.top, sourceRc.left, sourceRc.bottom, sourceRc.right, Gamma);
if(!g_SWVideoConfig.bBypassXFB) { if(!g_SWVideoConfig.bBypassXFB)
{
EfbInterface::yuv422_packed* xfb_in_ram = (EfbInterface::yuv422_packed *) Memory::GetPointer(xfbAddr); EfbInterface::yuv422_packed* xfb_in_ram = (EfbInterface::yuv422_packed *) Memory::GetPointer(xfbAddr);
EfbInterface::CopyToXFB(xfb_in_ram, fbWidth, fbHeight, sourceRc, Gamma); EfbInterface::CopyToXFB(xfb_in_ram, fbWidth, fbHeight, sourceRc, Gamma);
}
} else { else
u8 *colorTexture = SWRenderer::getColorTexture(); // Ask SWRenderer for the next color texture {
// Ask SWRenderer for the next color texture
u8 *colorTexture = SWRenderer::getColorTexture();
EfbInterface::BypassXFB(colorTexture, fbWidth, fbHeight, sourceRc, Gamma); EfbInterface::BypassXFB(colorTexture, fbWidth, fbHeight, sourceRc, Gamma);
SWRenderer::swapColorTexture(); // Tell SWRenderer we are now finished with it. // Tell SWRenderer we are now finished with it.
SWRenderer::swapColorTexture();
// FifoPlayer is broken and never calls BeginFrame/EndFrame.
// Hence, we manually force a swap now. This emulates the behavior
// of hardware backends with XFB emulation disabled.
// TODO: Fix FifoPlayer by making proper use of VideoInterface!
// This requires careful synchronization since GPU commands
// are processed on a different thread than VI commands.
SWRenderer::Swap(fbWidth, fbHeight);
} }
} }
} }

View File

@ -213,29 +213,36 @@ void VideoSoftware::Video_EndField()
// BeginField and EndFeild, We could possibly get away with copying out the whole thing // BeginField and EndFeild, We could possibly get away with copying out the whole thing
// at BeginField for less lag, but for the safest emulation we run it here. // at BeginField for less lag, but for the safest emulation we run it here.
if (g_bSkipCurrentFrame || s_beginFieldArgs.xfbAddr == 0 ) { if (g_bSkipCurrentFrame || s_beginFieldArgs.xfbAddr == 0)
{
swstats.frameCount++; swstats.frameCount++;
swstats.ResetFrame(); swstats.ResetFrame();
Core::Callback_VideoCopiedToXFB(false); Core::Callback_VideoCopiedToXFB(false);
return; return;
} }
if (!g_SWVideoConfig.bHwRasterizer) { if (!g_SWVideoConfig.bHwRasterizer)
if(!g_SWVideoConfig.bBypassXFB) { {
if(!g_SWVideoConfig.bBypassXFB)
{
EfbInterface::yuv422_packed *xfb = (EfbInterface::yuv422_packed *) Memory::GetPointer(s_beginFieldArgs.xfbAddr); EfbInterface::yuv422_packed *xfb = (EfbInterface::yuv422_packed *) Memory::GetPointer(s_beginFieldArgs.xfbAddr);
SWRenderer::UpdateColorTexture(xfb, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight); SWRenderer::UpdateColorTexture(xfb, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight);
} }
} }
// Idealy we would just move all the opengl contex stuff to the CPU thread, but this gets // Ideally we would just move all the OpenGL context stuff to the CPU thread,
// messy when the Hardware Rasterizer is enabled. // but this gets messy when the hardware rasterizer is enabled.
// And Neobrain loves his Hardware Rasterizer // And neobrain loves his hardware rasterizer.
// If we are runing dual core, Signal the GPU thread about the new colour texture. // If BypassXFB has already done a swap (cf. EfbCopy::CopyToXfb), skip this.
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread) if (!g_SWVideoConfig.bBypassXFB)
Common::AtomicStoreRelease(s_swapRequested, true); {
else // If we are in dual core mode, notify the GPU thread about the new color texture.
SWRenderer::Swap(s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight); if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread)
Common::AtomicStoreRelease(s_swapRequested, true);
else
SWRenderer::Swap(s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight);
}
} }
u32 VideoSoftware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData) u32 VideoSoftware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)