Implement negative Z clipping in geometry shader #16162
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.
This handles the case of negative Z clipping (implemented in #14833 if shaderClipDistance is supported) for devices which support geometry shaders but not user clip distances when using Vulkan. Only really tested on desktop.
#14146 is a good case of this and that frame dump works with this change (when forcing clip support disabled.)
However, for a device without geometry shaders or shaderClipDistance, #14146 is still an issue (even with software transform.)
This also removes the DisableRangeCulling flag, since it was only added to a few games to work around a bug that has been fixed for a year now (culling Z based on incorrect range.)
Also, I didn't really write this clipping logic in a way that's great for adding another clipping distance for depth clamp, but I suppose it could be done by generating an array of "indices" and a matching array of interpolation factors.I don't love clipping maths, so I may leave that as an exercise for another... Well, I changed it to be possibly easier to add later, but might need more to define the two sides and their respective factors...-[Unknown]