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

[naga] Implement binding_array function arguments #6523

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

davnotdev
Copy link

@davnotdev davnotdev commented Nov 12, 2024

Connections
Fixes both cases described in #4857.
Also related to #6283.

Description
There are two cases addressed here:

  1. Allowing binding arrays to appear as function arguments by implementing various missing branches that this case triggers.
  2. Fix issue where OpFunctionCall uses the value of an opaque type loaded via OpAccessChain + OpLoad is used as the argument when only the pointer to that opaque type is valid. This is implemented by keeping track of the pointer id of a loaded variable when OpAccessChain is called.

I'm not two happy with the 2nd fix because it uses an extra map for a relatively obscure edge case. Hopefully, there is a function that does the equivalent.

Testing
To test these changes, I ran the following shaders through naga multiple times (SPV => spirv-val => WGSL => SPV => spirv-val => WGSL => SPV => spirv-val).

The cases described in the WGPU issue above:
https://shader-playground.timjones.io/8a6382938dcc19b6d86bb569a93f1872
https://shader-playground.timjones.io/e37907fe8b30779a53201ef5ba4e1809

The issue I am running into:
https://shader-playground.timjones.io/656df9d61201d86379fe5c6f6b04d43a
(For this shader, the assumption is that SPV_EXT_descriptor_indexing is removed after every translation.)

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@davnotdev davnotdev requested a review from a team as a code owner November 12, 2024 05:30
@cwfitzgerald cwfitzgerald assigned teoxoy and jimblandy and unassigned teoxoy Dec 11, 2024
@jimblandy jimblandy assigned jimblandy and unassigned jimblandy Dec 18, 2024
Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

These changes need to be covered by snapshot tests; see naga/tests/snapshot.rs, in particular:

  • convert_wgsl, which converts WGSL inputs to all possible output formats. Please hand-check the .spvasm to ensure you're getting what you expect.
  • convert_spv_all, which converts SPV inputs into WGSL. You should provide an .spvasm file to accompany each .spv input that is exactly what spirv-dis outputs when run on that .spv file.

We don't do every combination of input and output formats, because that's just too much noise, just WGSL->everything and everything->WGSL.

Please flag for re-review when these issues are addressed.

@@ -264,6 +264,7 @@ impl crate::TypeInner {
crate::TypeInner::Image { .. }
| crate::TypeInner::Sampler { .. }
| crate::TypeInner::AccelerationStructure { .. } => true,
crate::TypeInner::BindingArray { .. } => true,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is right. The documentation for TypeInner::BindingArray says:

The array's element type base may be [Image], [Sampler], or any type that would be permitted for a global in the [Uniform] or [Storage] address spaces.

So just because TypeInner is a BindingArray doesn't mean it's a handle.

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.

3 participants