[rlsw] Review depth formats and fix depth writing #5317
Merged
+30
−28
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.
I reviewed the depth formats and removed the 8-bit one. It could have been marginally useful for orthographic projection, but without heavier adjustments it would never really be practical.
I also added a 32-bit floating-point depth format, which avoids conversions, though after testing it turned out to be slightly slower than 16-bit with conversion. So 16-bit remains the default.
I also added saturation when writing depth values, since in some cases, when the camera was very close to a clipped triangle, the depth value could exceed the limit and cause an overflow.
This might require reviewing some details in the clipping, I find it strange at first glance...
This issue seems to mention the related UB problem: #5309
I compiled in debug mode with UBSan and ran several examples, didn't notice any issues on my side with this update.
The 24-bit format has also been quickly reviewed and tested, everything seems perfect!