From ef0ebd65178e34434f113aa16f12f46c52a26a87 Mon Sep 17 00:00:00 2001 From: Kojin Date: Sat, 15 Dec 2018 21:09:12 -0500 Subject: [PATCH] gsdx-d3d11: Copy render target when it matches texture in slot 4 Needed for channel shuffle, this copies the render target when it's the same as the resource texture bound on slot 4. --- plugins/GSdx/Renderers/DX11/GSDevice11.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/plugins/GSdx/Renderers/DX11/GSDevice11.cpp b/plugins/GSdx/Renderers/DX11/GSDevice11.cpp index 643cb4409a..e3f22295d3 100644 --- a/plugins/GSdx/Renderers/DX11/GSDevice11.cpp +++ b/plugins/GSdx/Renderers/DX11/GSDevice11.cpp @@ -479,7 +479,26 @@ void GSDevice11::DrawPrimitive() void GSDevice11::DrawIndexedPrimitive() { - m_ctx->DrawIndexed(m_index.count, m_index.start, m_vertex.start); + // DX can't read from the FB + // So let's copy it and set that as the shader + // resource for slot 4 to avoid issues. + if (m_state.ps_sr_texture[4] && m_state.ps_sr_texture[4]->Equal(m_state.rt_texture)) + { + //fprintf(stdout, "FB read detected on slot 4: copying fb...\n"); + + GSTexture* cp = CopyRenderTarget(m_state.rt_texture); + + PSSetShaderResource(4, cp); + PSUpdateShaderState(); + + m_ctx->DrawIndexed(m_index.count, m_index.start, m_vertex.start); + + Recycle(cp); + } + else + { + m_ctx->DrawIndexed(m_index.count, m_index.start, m_vertex.start); + } } void GSDevice11::DrawIndexedPrimitive(int offset, int count)