Make identifySamplePoints handle compare #3996
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.
identifySamplePoints works by doing a binary search filling a texture with black (0,0,0,0) and white (1,1,1,1) texels and then sampling it. Any non-zero results means those white pixels were sampled.
This doesn't work for comparisons like textureSampleCompare, textureSampleCompareLevel, and textureGatherCompare because the result of those are 0 or 1 so for example, of the comparison is 'always' then all texels will show up as sampled.
So, instead, if the builtin being tested is a comparison we convert the call to the corresponding non-comparsion builtin.
This lets us find the sample points as best we can (it assumes those functions sample the same texels).
Once we have the sample point we then want to look up the actual values of the texels and print them out. To do this requires reading the texture back from the GPU. We made the texture ourselves so we could maybe theoretically pass the data we sent to the GPU down to identifySamplePoints but it seems good to get the values from the GPU itself so at least they made a round trip through the GPU
When, if it's a comparison, we print out the result of each comparison with that texel. Hopefully this will help us identify why these tests don't pass on some devices.