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

Refactor texture-builins for compat no storage #3991

Merged

Conversation

greggman
Copy link
Contributor

compat is allowed to have no storage buffers but the texture-builin tests were relying on storage buffers both for inputs and outputs.

For inputs, switching to a uniform buffer is fine. There are 50 calls with at most 5 parameters each aligned to 16 bytes so that's 4000 bytes which fits within the minimum uniform block size.

For outputs, switching to writing output to a texture via the fragment shader works but in order not to have to change how derivatives work, instead we render
1 instance at a time and use setViewport to choose which texel to write to. We were using @Builtin(position) in the fragment shader and expecting it to be 0.5, 0.5 but since we're writing to different fragments now we have to subtract the instance index (v.ndx) from position.x to get it back to 0.5, 0.5.

@greggman greggman force-pushed the fix-texture-builtins-for-vertex-on-compat branch from c61a679 to 36b28a7 Compare October 10, 2024 09:14
Copy link
Contributor

@shrekshao shrekshao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

compat is allowed to have no storage buffers
but the texture-builin tests were relying on storage
buffers both for inputs and outputs.

For inputs, switching to a uniform buffer is fine.
There are 50 calls with at most 5 parameters each
aligned to 16 bytes so that's 4000 bytes which fits
within the minimum uniform block size.

For outputs, switching to writing output to a texture
via the fragment shader works but in order not to have
to change how derivatives work, instead we render
1 instance at a time and use setViewport to choose
which texel to write to. We were using @Builtin(position)
in the fragment shader and expecting it to be 0.5, 0.5
but since we're writing to different fragments now we
have to subtract the instance index (v.ndx) from position.x
to get it back to 0.5, 0.5.
@greggman greggman force-pushed the fix-texture-builtins-for-vertex-on-compat branch from 36b28a7 to 1c5a71a Compare October 11, 2024 23:37
@greggman greggman enabled auto-merge (squash) October 11, 2024 23:38
@greggman greggman merged commit 00c3c50 into gpuweb:main Oct 11, 2024
1 check passed
@greggman greggman deleted the fix-texture-builtins-for-vertex-on-compat branch October 12, 2024 00:41
teoxoy pushed a commit to mozilla/gpuweb-cts that referenced this pull request Oct 25, 2024
compat is allowed to have no storage buffers
but the texture-builin tests were relying on storage
buffers both for inputs and outputs.

For inputs, switching to a uniform buffer is fine.
There are 50 calls with at most 5 parameters each
aligned to 16 bytes so that's 4000 bytes which fits
within the minimum uniform block size.

For outputs, switching to writing output to a texture
via the fragment shader works but in order not to have
to change how derivatives work, instead we render
1 instance at a time and use setViewport to choose
which texel to write to. We were using @Builtin(position)
in the fragment shader and expecting it to be 0.5, 0.5
but since we're writing to different fragments now we
have to subtract the instance index (v.ndx) from position.x
to get it back to 0.5, 0.5.
teoxoy pushed a commit to mozilla/gpuweb-cts that referenced this pull request Oct 25, 2024
compat is allowed to have no storage buffers
but the texture-builin tests were relying on storage
buffers both for inputs and outputs.

For inputs, switching to a uniform buffer is fine.
There are 50 calls with at most 5 parameters each
aligned to 16 bytes so that's 4000 bytes which fits
within the minimum uniform block size.

For outputs, switching to writing output to a texture
via the fragment shader works but in order not to have
to change how derivatives work, instead we render
1 instance at a time and use setViewport to choose
which texel to write to. We were using @Builtin(position)
in the fragment shader and expecting it to be 0.5, 0.5
but since we're writing to different fragments now we
have to subtract the instance index (v.ndx) from position.x
to get it back to 0.5, 0.5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants