From 0ae3cbf4d6e59e541b3f49ab3a3ce23a6601026f Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 1 Mar 2024 16:44:40 +1000 Subject: [PATCH] GS/Vulkan: Use attachment clear for ONE stencil 66% faster in Persona 3 in DATE-heavy scenes. --- pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index 9490e6533e..a1d2c2f24b 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -5683,9 +5683,9 @@ void GSDeviceVK::RenderHW(GSHWDrawConfig& config) } // render pass restart optimizations - if (hdr_rt || DATE_rp == DATE_RENDER_PASS_STENCIL_ONE) + if (hdr_rt) { - // DATE/HDR require clearing/blitting respectively. + // HDR requires blitting. EndRenderPass(); } else if (InRenderPass() && (m_current_render_target == draw_rt || m_current_depth_target == draw_ds)) @@ -5755,6 +5755,14 @@ void GSDeviceVK::RenderHW(GSHWDrawConfig& config) BeginRenderPass(rp, render_area); } } + else if (DATE_rp == DATE_RENDER_PASS_STENCIL_ONE) + { + const VkClearAttachment ca = {VK_IMAGE_ASPECT_STENCIL_BIT, 0u, {.depthStencil = {0.0f, 1u}}}; + const VkClearRect rc = {{{config.drawarea.left, config.drawarea.top}, + {static_cast(config.drawarea.width()), static_cast(config.drawarea.height())}}, + 0u, 1u}; + vkCmdClearAttachments(m_current_command_buffer, 1, &ca, 1, &rc); + } // rt -> hdr blit if enabled if (hdr_rt && config.rt->GetState() == GSTexture::State::Dirty)