diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index 198461f925..ebc193adae 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -3462,27 +3462,40 @@ void GSDeviceVK::OMSetRenderTargets( { if (vkRt) { - // NVIDIA drivers appear to return random garbage when sampling the RT via a feedback loop, if the load op for - // the render pass is CLEAR. Using vkCmdClearAttachments() doesn't work, so we have to clear the image instead. - if (feedback_loop & FeedbackLoopFlag_ReadAndWriteRT && vkRt->GetState() == GSTexture::State::Cleared && - IsDeviceNVIDIA()) + if (feedback_loop & FeedbackLoopFlag_ReadAndWriteRT) { - vkRt->CommitClear(); - } + // NVIDIA drivers appear to return random garbage when sampling the RT via a feedback loop, if the load op for + // the render pass is CLEAR. Using vkCmdClearAttachments() doesn't work, so we have to clear the image instead. + if (vkRt->GetState() == GSTexture::State::Cleared && IsDeviceNVIDIA()) + vkRt->CommitClear(); - vkRt->TransitionToLayout((feedback_loop & FeedbackLoopFlag_ReadAndWriteRT) ? - GSTextureVK::Layout::FeedbackLoop : - GSTextureVK::Layout::ColorAttachment); + if (vkRt->GetLayout() != GSTextureVK::Layout::FeedbackLoop) + { + // need to update descriptors to reflect the new layout + m_dirty_flags |= (DIRTY_FLAG_TFX_TEXTURE_0 << TFX_TEXTURE_RT); + vkRt->TransitionToLayout(GSTextureVK::Layout::FeedbackLoop); + } + } + else + { + vkRt->TransitionToLayout(GSTextureVK::Layout::ColorAttachment); + } } if (vkDs) { // need to update descriptors to reflect the new layout - if ((feedback_loop & FeedbackLoopFlag_ReadDS) && vkDs->GetLayout() != GSTextureVK::Layout::FeedbackLoop) - m_dirty_flags |= (DIRTY_FLAG_TFX_TEXTURE_0 << TFX_TEXTURE_RT); - - vkDs->TransitionToLayout((feedback_loop & FeedbackLoopFlag_ReadDS) ? - GSTextureVK::Layout::FeedbackLoop : - GSTextureVK::Layout::DepthStencilAttachment); + if (feedback_loop & FeedbackLoopFlag_ReadDS) + { + if (vkDs->GetLayout() != GSTextureVK::Layout::FeedbackLoop) + { + m_dirty_flags |= (DIRTY_FLAG_TFX_TEXTURE_0 << TFX_TEXTURE_TEXTURE); + vkDs->TransitionToLayout(GSTextureVK::Layout::FeedbackLoop); + } + } + else + { + vkDs->TransitionToLayout(GSTextureVK::Layout::DepthStencilAttachment); + } } }