Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement negative Z clipping in geometry shader #16162

Merged
merged 3 commits into from
Oct 5, 2022

Conversation

unknownbrackets
Copy link
Collaborator

@unknownbrackets unknownbrackets commented Oct 5, 2022

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]

This is only used when clip distance is unsupported, such as on Mali.
This hack was used because culling previously incorrectly handled Z, which
was fixed in hrydgard#14833.
@unknownbrackets unknownbrackets added this to the v1.14.0 milestone Oct 5, 2022
@hrydgard
Copy link
Owner

hrydgard commented Oct 5, 2022

Very cool! Will test on Mali shortly.

@hrydgard
Copy link
Owner

hrydgard commented Oct 5, 2022

Works perfectly on Mali (S20). Let's get it in and see how it goes.

@hrydgard hrydgard merged commit d6bd08c into hrydgard:master Oct 5, 2022
@unknownbrackets unknownbrackets deleted the geo-shader branch October 5, 2022 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants