Vulkan: Clip clamped depth in geometry shader #16165
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.
Well, I know I said I hate clipping maths (and I do), but I decided to give it a shot anyway. It seems to work on NVIDIA, and with no noticeable slowdown there compared to not using the geometry shader and using clip distance/etc. Not sure how this'll perform on mobile, since the shader does get a bit more complicated.
Test frame dump:
#11216_UCUS98703_pursuit_force_clamp.zip
Which should look like this:

Note that this is an especially nice test frame dump, because it requires curves and non-curves to be clipped against minz/maxz for proper rendering.
This corrects deformed geometry on Mali devices which don't support user-space clipping but do support depth clamp. I'm not really aware of any other devices this will help, even Apple supports shader clip distance.
With this change, people with Mali GPUs (which are fairly common) ought to avoid most already-solved depth related issues. Apple users still need to turn off hardware transform.
-[Unknown]