Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WGSL textureSample/Bias/Grad tests (#3981)
Add all the textureSample, textureSampleBias, and textureSampleGrad tests. cube and cube-array tests with derivatives are currently skipped or filtered out as the software rasterizer can't handle this case correctly or at least doesn't match too many GPUs. Rather than increase the tolerances. The big change is the doTextureCalls function now draws a triangle to a 1x1 size texture, per call using isntance drawing. This allows us to control the derivatives on a per call basis. Derviatives are based on a variable called `derivativeBase`. It just the (fragment position - 0.5) so (0,0) for our 1x1 pixel. It is then divided by the size of the texture which means its implicit derivatives will choose mip level 0. This allows us to multiply it to choose any mip level we want to test. This means we can move the textureSample derivative tests into the main textureSample tests. That also means we no longer need to software renderer. The textureSampleBias tests fail in lots of places. The issue appears to be that the WGSL spec requires the bias is clamped to [-16, 15.99] but many GPUs are not doing this. NOTE: Adding textureSampleBias is what made all of this click. The original textureSample tests separated out derivatives but you can not separate them out with textureSampleBais since you can not write an effective tests without mip level for the bias to affect which levels are sampled. Further, you must control the derivatives in order to be able to have the result be something you can test. Implementing textureSampleGrad was also a step to getting this all to work as you can consider textureSample as being built on textureSampleGrad. textureSample(tex, smp, coord) -> textureSampleBias(tex, smp, coord, 0) textureSampleBias(tex, smp, coord, bias) -> textureSampleGrad(tex, smp, dpdx(coord), dpdy(coord)) // plus bias textureSampleGrad(tex, smp, ddx, ddy) -> textureSampleLevel(tex, smp, computeMipLevel(ddx, ddy))
- Loading branch information