GS/Vulkan: Fix incorrect layout in depth feedback loops

Was setting the incorrect texture slot as dirty.
This commit is contained in:
Stenzek 2023-12-22 04:11:38 +10:00 committed by Connor McLaughlin
parent 6a0bbea9c5
commit 9a4094e997
1 changed files with 28 additions and 15 deletions

View File

@ -3462,27 +3462,40 @@ void GSDeviceVK::OMSetRenderTargets(
{ {
if (vkRt) if (vkRt)
{ {
// NVIDIA drivers appear to return random garbage when sampling the RT via a feedback loop, if the load op for if (feedback_loop & FeedbackLoopFlag_ReadAndWriteRT)
// 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())
{ {
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) ? if (vkRt->GetLayout() != GSTextureVK::Layout::FeedbackLoop)
GSTextureVK::Layout::FeedbackLoop : {
GSTextureVK::Layout::ColorAttachment); // 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) if (vkDs)
{ {
// need to update descriptors to reflect the new layout // need to update descriptors to reflect the new layout
if ((feedback_loop & FeedbackLoopFlag_ReadDS) && vkDs->GetLayout() != GSTextureVK::Layout::FeedbackLoop) if (feedback_loop & FeedbackLoopFlag_ReadDS)
m_dirty_flags |= (DIRTY_FLAG_TFX_TEXTURE_0 << TFX_TEXTURE_RT); {
if (vkDs->GetLayout() != GSTextureVK::Layout::FeedbackLoop)
vkDs->TransitionToLayout((feedback_loop & FeedbackLoopFlag_ReadDS) ? {
GSTextureVK::Layout::FeedbackLoop : m_dirty_flags |= (DIRTY_FLAG_TFX_TEXTURE_0 << TFX_TEXTURE_TEXTURE);
GSTextureVK::Layout::DepthStencilAttachment); vkDs->TransitionToLayout(GSTextureVK::Layout::FeedbackLoop);
}
}
else
{
vkDs->TransitionToLayout(GSTextureVK::Layout::DepthStencilAttachment);
}
} }
} }