diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index 8ec5acf8d3..80dcfd1df3 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -2635,6 +2635,8 @@ void GSDevice11::RenderHW(GSHWDrawConfig& config) } } + // Destination Alpha Setup + const bool multidraw_fb_copy = m_features.multidraw_fb_copy && (config.require_one_barrier || config.require_full_barrier); GSTexture* primid_texture = nullptr; if (config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::PrimIDTracking) { @@ -2649,7 +2651,7 @@ void GSDevice11::RenderHW(GSHWDrawConfig& config) primid_texture, GSVector4(config.drawarea), m_date.primid_init_ps[static_cast(config.datm)].get(), nullptr, false); } else if (config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::Stencil || - config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::StencilOne) + (config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::StencilOne && !multidraw_fb_copy)) SetupDATE(colclip_rt ? colclip_rt : config.rt, config.ds, config.datm, config.drawarea); if (config.vs.expand != GSHWDrawConfig::VSExpand::None) @@ -2764,6 +2766,11 @@ void GSDevice11::RenderHW(GSHWDrawConfig& config) OMSetRenderTargets(draw_rt, draw_ds, &config.scissor, read_only_dsv); SetupOM(config.depth, OMBlendSelector(config.colormask, config.blend), config.blend.constant); + + // Clear stencil as close as possible to the RT bind, to avoid framebuffer swaps. + if (config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::StencilOne && multidraw_fb_copy) + m_ctx->ClearDepthStencilView(*static_cast(draw_ds), D3D11_CLEAR_STENCIL, 0.0f, 1); + SendHWDraw(config, draw_rt_clone, draw_rt, config.require_one_barrier, config.require_full_barrier, false); if (config.blend_multi_pass.enable) diff --git a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp index 4e3584d84a..1c27ce0765 100644 --- a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp +++ b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp @@ -3831,8 +3831,12 @@ GSTexture12* GSDevice12::SetupPrimitiveTrackingDATE(GSHWDrawConfig& config, Pipe void GSDevice12::RenderHW(GSHWDrawConfig& config) { // Destination Alpha Setup - const bool stencil_DATE = (config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::Stencil || - config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::StencilOne); + const bool stencil_DATE_One = config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::StencilOne; + const bool stencil_DATE = (config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::Stencil || stencil_DATE_One); + + // TODO: Backport from vk. + if (stencil_DATE_One) + config.ps.date = 0; GSTexture12* colclip_rt = static_cast(g_gs_device->GetColorClipTexture()); GSTexture12* draw_rt = static_cast(config.rt); diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 4ba5641a47..17c846f71c 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -7939,7 +7939,8 @@ __ri void GSRendererHW::DrawPrims(GSTextureCache::Target* rt, GSTextureCache::Ta } else if (DATE_one) { - if (features.texture_barrier) + const bool multidraw_fb_copy = features.multidraw_fb_copy && (m_conf.require_one_barrier || m_conf.require_full_barrier); + if (features.texture_barrier || multidraw_fb_copy) { m_conf.require_one_barrier = true; m_conf.ps.date = 5 + m_cached_ctx.TEST.DATM;