diff --git a/bin/resources/shaders/dx11/convert.fx b/bin/resources/shaders/dx11/convert.fx index aa1d0c7bb9..d41d83d924 100644 --- a/bin/resources/shaders/dx11/convert.fx +++ b/bin/resources/shaders/dx11/convert.fx @@ -20,8 +20,10 @@ struct VS_OUTPUT cbuffer cb0 : register(b0) { + float4 BGColor; int EMODA; int EMODC; + int cb0_pad[2]; }; static const float3x3 rgb2yuv = diff --git a/bin/resources/shaders/dx11/merge.fx b/bin/resources/shaders/dx11/merge.fx index 32efe16bc6..aba39b60ea 100644 --- a/bin/resources/shaders/dx11/merge.fx +++ b/bin/resources/shaders/dx11/merge.fx @@ -3,7 +3,7 @@ Texture2D Texture; SamplerState Sampler; -cbuffer cb0 +cbuffer cb0 : register(b0) { float4 BGColor; int EMODA; diff --git a/pcsx2/GS/Renderers/Common/GSDevice.h b/pcsx2/GS/Renderers/Common/GSDevice.h index edead1ac5d..8996419276 100644 --- a/pcsx2/GS/Renderers/Common/GSDevice.h +++ b/pcsx2/GS/Renderers/Common/GSDevice.h @@ -75,11 +75,10 @@ enum ChannelFetch class MergeConstantBuffer { public: + GSVector4 BGColor; u32 EMODA; u32 EMODC; u32 pad[2]; - - MergeConstantBuffer() { memset(this, 0, sizeof(*this)); } }; class InterlaceConstantBuffer diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index fe383ae376..1eba87ef7e 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -704,9 +704,7 @@ void GSDevice11::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, // Upload constant to select YUV algo, but skip constant buffer update if we don't need it if (feedback_write_2 || feedback_write_1 || sTex[0]) { - MergeConstantBuffer cb; - cb.EMODA = EXTBUF.EMODA; - cb.EMODC = EXTBUF.EMODC; + const MergeConstantBuffer cb = {c, EXTBUF.EMODA, EXTBUF.EMODC}; m_ctx->UpdateSubresource(m_merge.cb.get(), 0, nullptr, &cb, 0, 0); } diff --git a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp index 609b0181ad..58781ed60b 100644 --- a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp +++ b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp @@ -609,7 +609,6 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GL_PUSH("DoMerge"); const GSVector4 full_r(0.0f, 0.0f, 1.0f, 1.0f); - const u32 yuv_constants[4] = {EXTBUF.EMODA, EXTBUF.EMODC}; const bool feedback_write_2 = PMODE.EN2 && sTex[2] != nullptr && EXTBUF.FBIN == 1; const bool feedback_write_1 = PMODE.EN1 && sTex[2] != nullptr && EXTBUF.FBIN == 0; const bool feedback_write_2_but_blend_bg = feedback_write_2 && PMODE.SLBG == 1; @@ -624,6 +623,14 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, if (sTex[0]) static_cast(sTex[0])->TransitionToState(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); + // Upload constant to select YUV algo, but skip constant buffer update if we don't need it + if (feedback_write_2 || feedback_write_1 || sTex[0]) + { + SetUtilityRootSignature(); + const MergeConstantBuffer uniforms = {c, EXTBUF.EMODA, EXTBUF.EMODC}; + SetUtilityPushConstants(&uniforms, sizeof(uniforms)); + } + const GSVector2i dsize(dTex->GetSize()); const GSVector4i darea(0, 0, dsize.x, dsize.y); bool dcleared = false; @@ -663,7 +670,6 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, { SetUtilityRootSignature(); SetPipeline(m_convert[static_cast(ShaderConvert::YUV)].get()); - SetUtilityPushConstants(yuv_constants, sizeof(yuv_constants)); DrawStretchRect(full_r, dRect[2], fbsize); } EndRenderPass(); @@ -696,7 +702,6 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, SetUtilityRootSignature(); SetUtilityTexture(sTex[0], m_linear_sampler_cpu); SetPipeline(m_merge[PMODE.MMOD].get()); - SetUtilityPushConstants(&c, sizeof(c)); DrawStretchRect(sRect[0], dRect[0], dTex->GetSize()); } @@ -706,7 +711,6 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, SetUtilityRootSignature(); SetPipeline(m_convert[static_cast(ShaderConvert::YUV)].get()); SetUtilityTexture(dTex, m_linear_sampler_cpu); - SetUtilityPushConstants(yuv_constants, sizeof(yuv_constants)); OMSetRenderTargets(sTex[2], nullptr, fbarea); BeginRenderPass(D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE, D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE); DrawStretchRect(full_r, dRect[2], dsize);