You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
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.
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.
The text was updated successfully, but these errors were encountered:
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.
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 specifyingGPUPipelineConstant
s in theGPUProgrammableStage
description. The correspondingwgsl
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:
The text was updated successfully, but these errors were encountered: