GS/Vulkan: Work around NVIDIA attachment clear bug #10904
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
Using vkCmdClearAttachments() within a render pass on NVIDIA seems to cause dependency issues between draws that are testing depth which precede it. The result is flickering where Z tests should be failing.
Breaking/restarting the render pass isn't enough to work around the bug, it needs an explicit pipeline barrier. As far as I can tell, this is a driver bug, because attachment clears should occur in rasterization order, quoting the spec:
The 96 index draw has Z testing on, but writes are off, and relies on the buffer having legitimate data. If this was solely an issue with the attachment clear, restarting the render pass would have fixed it... so something more complex is going on here, which I don't think we have visibility into at the application level.
And it's not the first bug we've hit with NVIDIA and attachment clears. Shame, because having the additional render pass sucks.
Rationale behind Changes
Fixes flickering in Lego Batman: The Videogame.
Before:
After:
Suggested Testing Steps
Check Lego Batman dump on NVIDIA, and other vendors, to see if they trigger the bug. The workaround code path is only enabled for NVIDIA.
LEGO_Batman_-_The_Videogame_SLUS-21785_20230712021138.gs.xz.zip