From 17231418ef79e9e2d5fcc21bbf704848fa2f22ab Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Sun, 2 Feb 2014 01:00:19 +1300 Subject: [PATCH 1/3] videosoftware: Added hack to bypass xfb just so fifoplayer works. Fifoplayer depends on the old behaviour of videosoftware (and the other hardware backends in non virtual/real xfb modes) where the framebuffer gets rendered directly to the screen. Really fifoplayer should call BeginFrame/EndFrame when it finished rendering a frame, but adding this hack back in is simpler. --- Source/Core/VideoBackends/Software/EfbCopy.cpp | 4 ++++ Source/Core/VideoBackends/Software/SWmain.cpp | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/Core/VideoBackends/Software/EfbCopy.cpp b/Source/Core/VideoBackends/Software/EfbCopy.cpp index b800ba8ee2..0b3181fab7 100644 --- a/Source/Core/VideoBackends/Software/EfbCopy.cpp +++ b/Source/Core/VideoBackends/Software/EfbCopy.cpp @@ -45,6 +45,10 @@ namespace EfbCopy EfbInterface::BypassXFB(colorTexture, fbWidth, fbHeight, sourceRc, Gamma); SWRenderer::swapColorTexture(); // Tell SWRenderer we are now finished with it. + + // And since fifo player is broken and never calls BeginFrame/EndFrame + // We will do this swap now. + SWRenderer::Swap(fbWidth, fbHeight); } } } diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index b4a4cb2a2a..e91fb1bae5 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -231,11 +231,13 @@ void VideoSoftware::Video_EndField() // messy when the Hardware Rasterizer is enabled. // And Neobrain loves his Hardware Rasterizer - // If we are runing dual core, Signal the GPU thread about the new colour texture. - if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread) - Common::AtomicStoreRelease(s_swapRequested, true); - else - SWRenderer::Swap(s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight); + if (!g_SWVideoConfig.bBypassXFB) { // BypassXFB has already done a swap, so skip this. + // If we are runing dual core, Signal the GPU thread about the new colour texture. + 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) From c6c6d200146f3e9f663b05a928ee2ab04665e78d Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sat, 1 Mar 2014 18:52:19 +0100 Subject: [PATCH 2/3] videosoftware: Provide a more elaborate comment on the FifoPlayer support hack. --- .../Core/VideoBackends/Software/EfbCopy.cpp | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Source/Core/VideoBackends/Software/EfbCopy.cpp b/Source/Core/VideoBackends/Software/EfbCopy.cpp index 0b3181fab7..a8bd0bf16e 100644 --- a/Source/Core/VideoBackends/Software/EfbCopy.cpp +++ b/Source/Core/VideoBackends/Software/EfbCopy.cpp @@ -27,27 +27,35 @@ namespace EfbCopy { 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) { 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); - if(!g_SWVideoConfig.bBypassXFB) { + if(!g_SWVideoConfig.bBypassXFB) + { EfbInterface::yuv422_packed* xfb_in_ram = (EfbInterface::yuv422_packed *) Memory::GetPointer(xfbAddr); EfbInterface::CopyToXFB(xfb_in_ram, fbWidth, fbHeight, sourceRc, Gamma); - - } else { - u8 *colorTexture = SWRenderer::getColorTexture(); // Ask SWRenderer for the next color texture + } + else + { + // Ask SWRenderer for the next color texture + u8 *colorTexture = SWRenderer::getColorTexture(); 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(); - // And since fifo player is broken and never calls BeginFrame/EndFrame - // We will do this swap now. + // 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); } } From 1bdf232feddff5ac05a47c99aa1dc02c1406ffc6 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Mon, 3 Mar 2014 19:03:15 +0100 Subject: [PATCH 3/3] videosoftware: More coding style fixes. --- Source/Core/VideoBackends/Software/SWmain.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index e91fb1bae5..93aff80323 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -213,26 +213,31 @@ void VideoSoftware::Video_EndField() // 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. - if (g_bSkipCurrentFrame || s_beginFieldArgs.xfbAddr == 0 ) { + if (g_bSkipCurrentFrame || s_beginFieldArgs.xfbAddr == 0) + { swstats.frameCount++; swstats.ResetFrame(); Core::Callback_VideoCopiedToXFB(false); return; } - if (!g_SWVideoConfig.bHwRasterizer) { - if(!g_SWVideoConfig.bBypassXFB) { + if (!g_SWVideoConfig.bHwRasterizer) + { + if(!g_SWVideoConfig.bBypassXFB) + { EfbInterface::yuv422_packed *xfb = (EfbInterface::yuv422_packed *) Memory::GetPointer(s_beginFieldArgs.xfbAddr); 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 - // messy when the Hardware Rasterizer is enabled. - // And Neobrain loves his Hardware Rasterizer + // Ideally we would just move all the OpenGL context stuff to the CPU thread, + // but this gets messy when the hardware rasterizer is enabled. + // And neobrain loves his hardware rasterizer. - if (!g_SWVideoConfig.bBypassXFB) { // BypassXFB has already done a swap, so skip this. - // 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 (!g_SWVideoConfig.bBypassXFB) + { + // If we are in dual core mode, notify the GPU thread about the new color texture. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread) Common::AtomicStoreRelease(s_swapRequested, true); else