diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp index 747f6e6c52..50966436f8 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp @@ -509,8 +509,11 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect // XXX: Without the VI, how would we know what kind of field this is? So // just use progressive. - Renderer::Swap(xfbAddr, FIELD_PROGRESSIVE, fbWidth, fbHeight); - Common::AtomicStoreRelease(s_swapRequested, FALSE); + if (!g_ActiveConfig.bUseXFB) + { + Renderer::Swap(xfbAddr, FIELD_PROGRESSIVE, fbWidth, fbHeight); + Common::AtomicStoreRelease(s_swapRequested, FALSE); + } } bool Renderer::SetScissorRect() @@ -654,7 +657,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) switch(type) { case PEEK_Z: - val = ((float*)map.pData)[6]; + val = ((float*)map.pData)[0]; z = ((u32)(val * 0xffffff)); break; @@ -803,7 +806,7 @@ void Renderer::SetBlendMode(bool forceUpdate) void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) { - if (g_bSkipCurrentFrame || !XFBWrited || !fbWidth || !fbHeight) + if (g_bSkipCurrentFrame || (!XFBWrited && !g_ActiveConfig.bUseRealXFB) || !fbWidth || !fbHeight) { g_VideoInitialize.pCopiedToXFB(false); return; diff --git a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp index 5ee8daf978..22ac753b5c 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp @@ -530,7 +530,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo &sourcerect, Renderer::GetFullTargetWidth(), Renderer::GetFullTargetHeight(), - PixelShaderCache::GetColorMatrixProgram(), VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout()); + (bFromZBuffer) ? PixelShaderCache::GetDepthMatrixProgram() : PixelShaderCache::GetColorMatrixProgram(), VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout()); D3D::context->OMSetRenderTargets(1, &FBManager.GetEFBColorTexture()->GetRTV(), FBManager.GetEFBDepthTexture()->GetDSV()); Renderer::RestoreAPIState(); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp index c045aeb2a0..49a46a520b 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp @@ -318,9 +318,10 @@ void VideoFifo_CheckSwapRequest() { if (Common::AtomicLoadAcquire(s_swapRequested)) { - if (ForceSwap) + if (ForceSwap || g_ActiveConfig.bUseXFB) + { Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.field, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight); - + } Common::AtomicStoreRelease(s_swapRequested, FALSE); } } @@ -333,12 +334,39 @@ inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper) // Run from the graphics thread void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight) { + if (Common::AtomicLoadAcquire(s_swapRequested) && g_ActiveConfig.bUseXFB) + { + u32 aLower = xfbAddr; + u32 aUpper = xfbAddr + 2 * fbWidth * fbHeight; + u32 bLower = s_beginFieldArgs.xfbAddr; + u32 bUpper = s_beginFieldArgs.xfbAddr + 2 * s_beginFieldArgs.fbWidth * s_beginFieldArgs.fbHeight; + + if (addrRangesOverlap(aLower, aUpper, bLower, bUpper)) + VideoFifo_CheckSwapRequest(); + } ForceSwap = false; } // Run from the CPU thread (from VideoInterface.cpp) void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) { + if (s_PluginInitialized && g_ActiveConfig.bUseXFB) + { + s_beginFieldArgs.xfbAddr = xfbAddr; + s_beginFieldArgs.field = field; + s_beginFieldArgs.fbWidth = fbWidth; + s_beginFieldArgs.fbHeight = fbHeight; + + Common::AtomicStoreRelease(s_swapRequested, TRUE); + if (g_VideoInitialize.bOnThread) + { + while (Common::AtomicLoadAcquire(s_swapRequested) && !s_FifoShuttingDown) + //Common::SleepCurrentThread(1); + Common::YieldCPU(); + } + else + VideoFifo_CheckSwapRequest(); + } } void Video_EndField()