-
Notifications
You must be signed in to change notification settings - Fork 82
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
WGSL builtin textureSample compressed formats #3760
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I'm wondering is if I should combine the compressed and uncompressed tests. They're very similar and it wouldn't take too much work to add some small amount of
if compressed {x} else {y}
to consolidate them.
No strong opinion, but this does sound a bit simpler
src/webgpu/shader/execution/expression/call/builtin/textureSample.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/shader/execution/expression/call/builtin/textureSample.spec.ts
Show resolved
Hide resolved
src/webgpu/shader/execution/expression/call/builtin/textureSample.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts
Outdated
Show resolved
Hide resolved
src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts
Outdated
Show resolved
Hide resolved
src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts
Outdated
Show resolved
Hide resolved
src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts
Outdated
Show resolved
Hide resolved
I'm not sure these are needed or not but given we were testing so many other formats it seems like we should be testing compressed formats? It does this by filling a compressed texture with random data. For compressed textures of type unorm or snorm this is fine. For float types this would fail since they random values might be large, Infinity, or NaN. We aren't converting from values to a compressed format. We're filling a buffer with binary random data and assuming the values that come out are in range. After that, read that texture back to the GPU using a compute shader. This way we get WebGPU to decode the compressed texture to an uncompressed format. Some places I got lost. I first put in the derivatives test and it passed. Then I put in non-derivatives test and it failed on srgb formats. This makes some sense I think because I was using only `rgba32float` as the format for pulling the data out of the texture. That meant, when doing the software interpolation it was probably doing it wrong. I switched to using one of `rgba8unorm`, `rgba8snorm` or `rgba8unorm-srgb` as the format the texture is read back to `TexelView` as. I think ideally if I could have an `rgba32float-srgb` that would have been best but that format doesn't exist and I think hacking it into `TexelView` would have made `TexelView`'s list of formats not a subset of WebGPU's Also, I'm pretty worried about the number of tests. Just these 4 tests take 42 seconds to run on my M1 Mac and there's still 22 tests to go for this single built in alone and then all the rest of the texture builtins.
6cacb03
to
bf3d149
Compare
note: only android is failing and it's failing on astc unorm formats with
AFAICT this a bug on Android. The same tests pass on all other devices. If I understand correctly there are no invalid values for astc unorm formats. Further, the code is supposed to be predictable. The values put into the textures for testing should be the same across platforms. So it seems like this is either a GPU bug on those devices, a Dawn bug, or a JS bug (somehow it's producing NaN when it shouldn't) I'm committing this for now. Revert if you have to. I'll also file a chrome bug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT this a bug on Android. The same tests pass on all other devices. If I understand correctly there are no invalid values for astc unorm formats. Further, the code is supposed to be predictable. The values put into the textures for testing should be the same across platforms. So it seems like this is either a GPU bug on those devices, a Dawn bug, or a JS bug (somehow it's producing NaN when it shouldn't)
Could be a filtering issue (see comment) or it could be that some bit patterns in ASTC don't actually have defined outputs. Trying to look up the GL spec I was reminded that there are both LDR and HDR versions of ASTC. We only support LDR, but it seems from the GL extension spec that uploading HDR data into an LDR texture has defined results, see C.2.5 LDR and HDR Modes
.
But there are also mentions of "invalid" inputs like "Results from invalid void extents are undefined."
* We need the software rendering to do the same interpolation as the hardware | ||
* rendered so for -srgb formats we set the TexelView to an -srgb format as | ||
* TexelView handles this case. Note: It might be nice to add rgba32float-srgb | ||
* or something similar to TexelView. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this comment made me remember, IIRC it's undefined whether filtering happens before or after gamma conversion. I think that could cause some issues with the tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read that in the spec too. At the moment all the srgb tests are passing on all devices.
You're right, there are invalid inputs to astc. I can add a PR to filter those out. We'll have to either make an astc aware filler or leave them untested. |
I'm not sure these are needed or not but given we were testing so many other formats it seems like we should be testing compressed formats?
It does this by filling a compressed texture with random data. For compressed textures of type unorm or snorm this is fine. For float types this would fail since they random values might be large, Infinity, or NaN. We aren't converting from values to a compressed format. We're filling a buffer with binary random data and assuming the values that come out are in range.
After that, read that texture back to the GPU using a compute shader. This way we get WebGPU to decode the compressed texture to an uncompressed format.
Some places I got lost. I first put in the derivatives test and it passed. Then I put in non-derivatives test and it failed on srgb formats. This makes some sense I think because I was using only
rgba32float
as the format for pulling the data out of the texture.That meant, when doing the software interpolation it was probably doing it wrong. I switched to using one of
rgba8unorm
,rgba8snorm
orrgba8unorm-srgb
as the format the texture is read back toTexelView
as. I think ideally if I could have anrgba32float-srgb
that would have been best but that format doesn't exist and I think hacking it intoTexelView
would have madeTexelView
's list of formats not a subset of WebGPU'sOne thing I'm wondering is if I should combine the compressed and uncompressed tests. They're very similar and it wouldn't take too much work to add some small amount of
if compressed {x} else {y}
to consolidate them.Requirements for PR author:
.unimplemented()
./** documented */
and new helper files are found inhelper_index.txt
.Requirements for reviewer sign-off:
When landing this PR, be sure to make any necessary issue status updates.