mirror of https://github.com/PCSX2/pcsx2.git
GS/Vulkan: Fix merging non-black cleared target
This commit is contained in:
parent
c1ca3888ec
commit
e5a5cf0ef0
|
@ -1102,9 +1102,23 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
|
||||||
EndRenderPass();
|
EndRenderPass();
|
||||||
|
|
||||||
// transition everything before starting the new render pass
|
// transition everything before starting the new render pass
|
||||||
static_cast<GSTexture12*>(dTex)->TransitionToState(D3D12_RESOURCE_STATE_RENDER_TARGET);
|
const bool has_input_0 =
|
||||||
if (sTex[0])
|
(sTex[0] && (sTex[0]->GetState() == GSTexture::State::Dirty ||
|
||||||
|
(sTex[0]->GetState() == GSTexture::State::Cleared || sTex[0]->GetClearColor() != 0)));
|
||||||
|
const bool has_input_1 = (PMODE.SLBG == 0 || feedback_write_2_but_blend_bg) && sTex[1] &&
|
||||||
|
(sTex[1]->GetState() == GSTexture::State::Dirty ||
|
||||||
|
(sTex[1]->GetState() == GSTexture::State::Cleared || sTex[1]->GetClearColor() != 0));
|
||||||
|
if (has_input_0)
|
||||||
|
{
|
||||||
|
static_cast<GSTexture12*>(sTex[0])->CommitClear();
|
||||||
static_cast<GSTexture12*>(sTex[0])->TransitionToState(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
static_cast<GSTexture12*>(sTex[0])->TransitionToState(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||||
|
}
|
||||||
|
if (has_input_1)
|
||||||
|
{
|
||||||
|
static_cast<GSTexture12*>(sTex[1])->CommitClear();
|
||||||
|
static_cast<GSTexture12*>(sTex[1])->TransitionToState(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||||
|
}
|
||||||
|
static_cast<GSTexture12*>(dTex)->TransitionToState(D3D12_RESOURCE_STATE_RENDER_TARGET);
|
||||||
|
|
||||||
// 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])
|
||||||
|
@ -1117,25 +1131,21 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
|
||||||
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;
|
||||||
if (sTex[1] && (PMODE.SLBG == 0 || feedback_write_2_but_blend_bg))
|
if (has_input_1 && (PMODE.SLBG == 0 || feedback_write_2_but_blend_bg))
|
||||||
{
|
{
|
||||||
// 2nd output is enabled and selected. Copy it to destination so we can blend it with 1st output
|
// 2nd output is enabled and selected. Copy it to destination so we can blend it with 1st output
|
||||||
// Note: value outside of dRect must contains the background color (c)
|
// Note: value outside of dRect must contains the background color (c)
|
||||||
if (sTex[1]->GetState() == GSTexture::State::Dirty)
|
OMSetRenderTargets(dTex, nullptr, darea);
|
||||||
{
|
SetUtilityTexture(sTex[1], sampler);
|
||||||
static_cast<GSTexture12*>(sTex[1])->TransitionToState(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
BeginRenderPass(D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR,
|
||||||
OMSetRenderTargets(dTex, nullptr, darea);
|
D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE, D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS,
|
||||||
SetUtilityTexture(sTex[1], sampler);
|
D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS, D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS,
|
||||||
BeginRenderPass(D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR,
|
D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS, c);
|
||||||
D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE, D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS,
|
SetUtilityRootSignature();
|
||||||
D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS, D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS,
|
SetPipeline(m_convert[static_cast<int>(ShaderConvert::COPY)].get());
|
||||||
D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS, c);
|
DrawStretchRect(sRect[1], PMODE.SLBG ? dRect[2] : dRect[1], dsize);
|
||||||
SetUtilityRootSignature();
|
dTex->SetState(GSTexture::State::Dirty);
|
||||||
SetPipeline(m_convert[static_cast<int>(ShaderConvert::COPY)].get());
|
dcleared = true;
|
||||||
DrawStretchRect(sRect[1], PMODE.SLBG ? dRect[2] : dRect[1], dsize);
|
|
||||||
dTex->SetState(GSTexture::State::Dirty);
|
|
||||||
dcleared = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload constant to select YUV algo
|
// Upload constant to select YUV algo
|
||||||
|
@ -1182,7 +1192,7 @@ void GSDevice12::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
|
||||||
D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE, D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE);
|
D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE, D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sTex[0] && sTex[0]->GetState() == GSTexture::State::Dirty)
|
if (has_input_0)
|
||||||
{
|
{
|
||||||
// 1st output is enabled. It must be blended
|
// 1st output is enabled. It must be blended
|
||||||
SetUtilityRootSignature();
|
SetUtilityRootSignature();
|
||||||
|
|
|
@ -1274,9 +1274,23 @@ void GSDeviceVK::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
|
||||||
EndRenderPass();
|
EndRenderPass();
|
||||||
|
|
||||||
// transition everything before starting the new render pass
|
// transition everything before starting the new render pass
|
||||||
static_cast<GSTextureVK*>(dTex)->TransitionToLayout(GSTextureVK::Layout::ColorAttachment);
|
const bool has_input_0 =
|
||||||
if (sTex[0])
|
(sTex[0] && (sTex[0]->GetState() == GSTexture::State::Dirty ||
|
||||||
|
(sTex[0]->GetState() == GSTexture::State::Cleared || sTex[0]->GetClearColor() != 0)));
|
||||||
|
const bool has_input_1 = (PMODE.SLBG == 0 || feedback_write_2_but_blend_bg) && sTex[1] &&
|
||||||
|
(sTex[1]->GetState() == GSTexture::State::Dirty ||
|
||||||
|
(sTex[1]->GetState() == GSTexture::State::Cleared || sTex[1]->GetClearColor() != 0));
|
||||||
|
if (has_input_0)
|
||||||
|
{
|
||||||
|
static_cast<GSTextureVK*>(sTex[0])->CommitClear();
|
||||||
static_cast<GSTextureVK*>(sTex[0])->TransitionToLayout(GSTextureVK::Layout::ShaderReadOnly);
|
static_cast<GSTextureVK*>(sTex[0])->TransitionToLayout(GSTextureVK::Layout::ShaderReadOnly);
|
||||||
|
}
|
||||||
|
if (has_input_1)
|
||||||
|
{
|
||||||
|
static_cast<GSTextureVK*>(sTex[1])->CommitClear();
|
||||||
|
static_cast<GSTextureVK*>(sTex[1])->TransitionToLayout(GSTextureVK::Layout::ShaderReadOnly);
|
||||||
|
}
|
||||||
|
static_cast<GSTextureVK*>(dTex)->TransitionToLayout(GSTextureVK::Layout::ColorAttachment);
|
||||||
|
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue