GS/DX11: Fix MMOD=1 merge background color

This commit is contained in:
Connor McLaughlin 2022-04-18 13:08:51 +10:00 committed by refractionpcsx2
parent 5c3ae656a0
commit b0f20c9973
5 changed files with 13 additions and 10 deletions

View File

@ -20,8 +20,10 @@ struct VS_OUTPUT
cbuffer cb0 : register(b0) cbuffer cb0 : register(b0)
{ {
float4 BGColor;
int EMODA; int EMODA;
int EMODC; int EMODC;
int cb0_pad[2];
}; };
static const float3x3 rgb2yuv = static const float3x3 rgb2yuv =

View File

@ -3,7 +3,7 @@
Texture2D Texture; Texture2D Texture;
SamplerState Sampler; SamplerState Sampler;
cbuffer cb0 cbuffer cb0 : register(b0)
{ {
float4 BGColor; float4 BGColor;
int EMODA; int EMODA;

View File

@ -75,11 +75,10 @@ enum ChannelFetch
class MergeConstantBuffer class MergeConstantBuffer
{ {
public: public:
GSVector4 BGColor;
u32 EMODA; u32 EMODA;
u32 EMODC; u32 EMODC;
u32 pad[2]; u32 pad[2];
MergeConstantBuffer() { memset(this, 0, sizeof(*this)); }
}; };
class InterlaceConstantBuffer class InterlaceConstantBuffer

View File

@ -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 // 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]) if (feedback_write_2 || feedback_write_1 || sTex[0])
{ {
MergeConstantBuffer cb; const MergeConstantBuffer cb = {c, EXTBUF.EMODA, EXTBUF.EMODC};
cb.EMODA = EXTBUF.EMODA;
cb.EMODC = EXTBUF.EMODC;
m_ctx->UpdateSubresource(m_merge.cb.get(), 0, nullptr, &cb, 0, 0); m_ctx->UpdateSubresource(m_merge.cb.get(), 0, nullptr, &cb, 0, 0);
} }

View File

@ -609,7 +609,6 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
GL_PUSH("DoMerge"); GL_PUSH("DoMerge");
const GSVector4 full_r(0.0f, 0.0f, 1.0f, 1.0f); 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_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_1 = PMODE.EN1 && sTex[2] != nullptr && EXTBUF.FBIN == 0;
const bool feedback_write_2_but_blend_bg = feedback_write_2 && PMODE.SLBG == 1; 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]) if (sTex[0])
static_cast<GSTexture12*>(sTex[0])->TransitionToState(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); static_cast<GSTexture12*>(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 GSVector2i dsize(dTex->GetSize());
const GSVector4i darea(0, 0, dsize.x, dsize.y); const GSVector4i darea(0, 0, dsize.x, dsize.y);
bool dcleared = false; bool dcleared = false;
@ -663,7 +670,6 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
{ {
SetUtilityRootSignature(); SetUtilityRootSignature();
SetPipeline(m_convert[static_cast<int>(ShaderConvert::YUV)].get()); SetPipeline(m_convert[static_cast<int>(ShaderConvert::YUV)].get());
SetUtilityPushConstants(yuv_constants, sizeof(yuv_constants));
DrawStretchRect(full_r, dRect[2], fbsize); DrawStretchRect(full_r, dRect[2], fbsize);
} }
EndRenderPass(); EndRenderPass();
@ -696,7 +702,6 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
SetUtilityRootSignature(); SetUtilityRootSignature();
SetUtilityTexture(sTex[0], m_linear_sampler_cpu); SetUtilityTexture(sTex[0], m_linear_sampler_cpu);
SetPipeline(m_merge[PMODE.MMOD].get()); SetPipeline(m_merge[PMODE.MMOD].get());
SetUtilityPushConstants(&c, sizeof(c));
DrawStretchRect(sRect[0], dRect[0], dTex->GetSize()); DrawStretchRect(sRect[0], dRect[0], dTex->GetSize());
} }
@ -706,7 +711,6 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
SetUtilityRootSignature(); SetUtilityRootSignature();
SetPipeline(m_convert[static_cast<int>(ShaderConvert::YUV)].get()); SetPipeline(m_convert[static_cast<int>(ShaderConvert::YUV)].get());
SetUtilityTexture(dTex, m_linear_sampler_cpu); SetUtilityTexture(dTex, m_linear_sampler_cpu);
SetUtilityPushConstants(yuv_constants, sizeof(yuv_constants));
OMSetRenderTargets(sTex[2], nullptr, fbarea); OMSetRenderTargets(sTex[2], nullptr, fbarea);
BeginRenderPass(D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE, D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE); BeginRenderPass(D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE, D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE);
DrawStretchRect(full_r, dRect[2], dsize); DrawStretchRect(full_r, dRect[2], dsize);