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

Add support for WGSL override declarations #3895

Closed
e2-71828 opened this issue Jun 29, 2023 · 1 comment
Closed

Add support for WGSL override declarations #3895

e2-71828 opened this issue Jun 29, 2023 · 1 comment
Labels
area: api Issues related to API surface type: enhancement New feature or request

Comments

@e2-71828
Copy link

e2-71828 commented Jun 29, 2023

Is your feature request related to a problem? Please describe.
I have some constant values that need to have the same value in both Rust and WGSL code. Ideally, these constants should be determinable at runtime, so that the program has the opportunity to read them from a configuration file at startup.

Describe the solution you'd like
The WGSL specification describes override declarations which are designed for this purpose. In WebGPU, these are set by specifying GPUPipelineConstants in the GPUProgrammableStage description. The corresponding wgsl type, however, does not include any facility to specify these constants.

Describe alternatives you've considered
There are a few workarounds possible to get similar results:

  1. The values can be passed from Rust to WGSL in a uniform buffer, but this requires using an additional binding in each render pass and the shader compiler can't use any optimizations that take advantage of the fact that this constant won't actually change between draw calls.
  2. A build script or proc macro can read the constant value out of the shader source and import it into Rust. This adds a lot of complexity, and means that these constants must be known at compile time, and can't be determined during the graphics system initialization.
  3. The shader source can be transformed by some kind of templating engine before being handed to the shader compiler. This also adds significant complexity, and means that you're using a nonstandard dialect of WGSL which makes it harder to integrate other tools, like a build-time shader validation check.
@Wumpf Wumpf modified the milestone: WebGPU Specification V1 Jun 29, 2023
@Wumpf
Copy link
Member

Wumpf commented Jun 29, 2023

Thanks for the detailed report, but this is actually already an existing issue here #1762 and there's quite a bit of work to do on Naga as well to enable this #4484
You're spot in in that wgpu isn't WebGPU conformant there yet.

@Wumpf Wumpf closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2023
@Wumpf Wumpf added resolution: duplicate type: enhancement New feature or request area: api Issues related to API surface labels Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API surface type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants