The MSL backend emits a loop's `continuing` block at the top of the
`while` loop, above the body. Values the body computed and `continuing`
referenced were then either re-evaluated in place, reading whatever
state the body had left behind, or, for statement results such as call
results, hit an `unreachable!` panic.
Now, when a loop has a `continuing` block or `break_if`, the
temporaries it needs from the body are declared ahead of the loop, and
the body assigns to them instead of declaring them.
The WebGPU specification requires pipeline creation to validate
properties of shader stages, like workgroup sizes, that may depend on
the values of pipeline-overridable constants. Previously, wgpu-core
validated stages using an `Interface` built from the module before
overrides were applied, with results contrary to spec. Override
processing was then carried out by `wgpu_hal`, after all validation
had supposedly been taken care of.
This commit has `create_shader_module` save the validated Naga module
instead of creating a `wgpu_hal` shader module. At pipeline creation
time, `StageCompiler::compile` now applies the stage's override values
with `process_overrides`, validates the stage using an `Interface`
built from the result, and, if that validation succeeds, returns a
`CompiledStage` holding the `wgpu_hal` `ShaderModule` created from it.
Dropping the `CompiledStage` destroys that module once the pipeline
has been created.
Since the override values have already been applied, we pass
`wgpu_hal` empty sets of constants for these modules.
Since the `naga::back::pipeline_constants` module is now used by
`wgpu_core` rather than `wgpu_hal` backends, it can't be conditionally
available based on Naga's backend features. Include it
unconditionally.
This change removes `Interface::finalize_entry_point_name`, since we
no longer build an `Interface` at shader module creation. Instead, we
choose entry points from the `naga::Module` directly.
Add new tests: `tests/tests/wgpu-validation/api/overrides.rs`
Fixes#9774.
Unlike WGSL, Naga IR permits functions to have conflicting names, and
entry points must only have distinct names if they are for the same
shader stage. Document and test this.