Skip to content

Commit cf812ba

Browse files
committed
Materialize more external WGSL profiles
1 parent b84e2f6 commit cf812ba

5 files changed

Lines changed: 8 additions & 7 deletions

File tree

docs/moon_wgsl-issue-tracker.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Last updated: 2026-05-08
1616
| `WGSL-261` | Strict statement terminators | The statement collector treated a closing `}` as a valid terminator for simple statements, so invalid WGSL like `z = 1.0 }` could be accepted by moon_wgsl even though Naga rejects it with `expected ;`. | `DONE` | Statement collection now records whether a statement ended with a top-level semicolon, and strict AST validation marks semicolon-required statements invalid when the semicolon is missing. Template interpolation braces from naga_oil-style `#{...}` are tracked separately from WGSL block braces, so recursive block validation does not descend into source templates. Added parser regressions for assignment, return, and function-call statements without semicolons, and verified the real wgpu `issue_4485.wgsl` invalid source is now rejected before IR lowering. |
1717
| `WGSL-260` | Composer semantic phase architecture | Even after composer rewrites became symbol-binding-first, several phase boundaries still compressed semantic objects into strings: semantic reference facts were `HashSet[String]`, compose bindings carried `from_name/to_name/identity?`, live binding resolution stored `resolved_to_name`, and transform rewrite bindings accepted string reference names. | `DONE` | Added structured semantic reference path sets, changed compose bindings to carry `WgslSemanticReferencePath` plus a non-optional `WgslComposeSymbolTarget`, changed live binding resolution to pass target symbol objects instead of resolved-name strings, and changed transform rewrite plans to accept `WgslReferencePath` rather than string bindings. Added architecture guardrails banning `add_symbol_binding`, optional identity compose bindings, string-only semantic reference sets, and resolved-name phase state. Verification is tracked with this audit pass on 2026-05-08. |
1818
| `WGSL-259` | Composer symbol-binding architecture | `WgslReferenceRewritePlan` carried stable symbol identities but still exposed binding rewrites by downgrading them into `WgslRenamePlan`; the final AST rewrite therefore remained name-first at the execution boundary, and unqualified duplicate import bindings could remain ambiguous until transform declined a rewrite. | `DONE` | Removed the binding-plan-to-rename-plan adapters, removed optional identity from plain rename rules, and made reference/declaration binding rewrites consume `WgslReferenceRewriteBinding` directly when collecting AST identifier nodes. Composer binding sets now reject same-scope/same-reference bindings that point at different identities, including unqualified imports. Added guardrails preventing `reference_rename_plan` / `global_declaration_rename_plan` from returning and documenting that composer rewrites must remain symbol-binding-first. Verification is tracked with this audit pass on 2026-05-08. |
19-
| `WGSL-258` | 100% WGSL/naga-oil quality gate | External real-project WGSL scanning still allowed skipped files to remain implicit, so coverage regressions could hide behind a stable aggregate skipped count. | `IN_PROGRESS` | Replaced the skipped-file path with `testdata/external_wgsl_corpus_expected_failures.tsv`; the external corpus gate now reports `skipped=0` and every non-materialized file is an expected-failure contract keyed by `(repo, rel_path, reason)`. Added real Bevy sprite/UI render source roots plus concrete Bevy tonemapping, deferred, environment-map, SSR, UI, and meshlet profiles; added texture-atomic/cooperative-matrix/64-bit-image-atomic/f64/mesh-shader/ray-hit-vertex-position/per-vertex/binding-array IR/oracle validation plus duplicate import-path candidate selection for Bevy dummy/real modules. Added manifest-owned source materialization for real projects that concatenate, generate, or specialize WGSL before shader module creation, covering wgpu timestamp normalization, wgpu mesh shaders, wgpu ray-query vertex-return shaders, wgpu binding-array and per-vertex shaders, webgpu-samples Cornell shader suffixes/template replacement, webgpu-samples skinned-mesh generated vertex input, and primitive-index/barycentric/multiview validation capabilities. This raises Bevy to 158 source-valid / 149 composed-valid, wgpu to 77 source-valid, Naga to 122 source-valid, webgpu-samples to 68 source-valid, and total external corpus coverage to 475 source-valid files. Remaining work is to burn down the 25 expected failures by fixing the listed compose/IR/profile gaps or proving the external source is intentionally invalid under standalone validation. |
19+
| `WGSL-258` | 100% WGSL/naga-oil quality gate | External real-project WGSL scanning still allowed skipped files to remain implicit, so coverage regressions could hide behind a stable aggregate skipped count. | `IN_PROGRESS` | Replaced the skipped-file path with `testdata/external_wgsl_corpus_expected_failures.tsv`; the external corpus gate now reports `skipped=0` and every non-materialized file is an expected-failure contract keyed by `(repo, rel_path, reason)`. Added real Bevy sprite/UI render source roots plus concrete Bevy tonemapping, deferred, environment-map, SSR, UI, and meshlet profiles; added texture-atomic/cooperative-matrix/64-bit-image-atomic/f64/mesh-shader/ray-hit-vertex-position/per-vertex/binding-array IR/oracle validation plus duplicate import-path candidate selection for Bevy dummy/real modules. Added manifest-owned source materialization for real projects that concatenate, generate, or specialize WGSL before shader module creation, covering wgpu timestamp normalization, wgpu copy-texture/shader-test templates, wgpu mesh shaders, wgpu ray-query vertex-return shaders, wgpu binding-array and per-vertex shaders, Naga ray-query legacy enable injection, webgpu-samples Cornell shader suffixes/template replacement, webgpu-samples skinned-mesh generated vertex input, and primitive-index/barycentric/multiview validation capabilities. This raises Bevy to 158 source-valid / 149 composed-valid, wgpu to 79 source-valid, Naga to 123 source-valid, webgpu-samples to 68 source-valid, and total external corpus coverage to 478 source-valid files. Remaining work is to burn down the 22 expected failures by fixing the listed compose/IR/profile gaps or proving the external source is intentionally invalid under standalone validation. |
2020
| `WGSL-257` | 100% naga-oil compose parity | The current real-project gate proves composed outputs are Naga-valid, but it does not prove byte-for-byte or normalized semantic parity with upstream `naga_oil` on the same fixture, shader defs, and additional imports. | `TODO` | Add manifest-driven compose parity profiles that run Rust `naga_oil` oracle and moon_wgsl against the same entry, bool/value defs, capabilities, and fixture roots. Differences must be classified, with critical Bevy PBR/CorePipeline profiles moving to normalized byte parity. |
2121
| `WGSL-256` | 100% official WGSL syntax coverage | The official CTS gate extracts a useful static valid subset but does not yet exercise all valid/invalid CTS WGSL cases as parser acceptance/rejection contracts. | `IN_PROGRESS` | Added static invalid WGSL extraction and rejection gating: 87 invalid CTS cases are extracted, 64 are rejected by moon IR plus Naga validation, and 23 are explicitly tracked in `testdata/gpuweb_cts_invalid_accepted_by_oracle.txt` because the pinned Naga oracle accepts them. Remaining work is to extract dynamic/template-driven invalid CTS cases rather than only static literals/object cases. |
22-
| `WGSL-255` | IR invariant validation | Naga validation checks emitted WGSL, but the internal IR can still carry invalid handles, stale type assumptions, illegal pointer/value use, or lost layout/provenance until emit or external validation exposes it indirectly. | `IN_PROGRESS` | Added typed IR validation for expression type availability, scalar control-flow conditions, WGSL `select` mask signatures including `vecN<bool>` masks, switch selectors, return values, lvalue store targets, function-call argument counts/types/results, and root-filtered validation before tree-shaken emission. The validator now catches invalid statement/call/store IR before emission while preserving valid Bevy vector-mask `select` patterns, and the external corpus is at 475 source/IR-valid files with 149 composed Bevy cases. Remaining work is to extend the same validator model across resource binding/address-space compatibility, full access/member legality, layout/provenance invariants, and more statement-level side-effect constraints. |
22+
| `WGSL-255` | IR invariant validation | Naga validation checks emitted WGSL, but the internal IR can still carry invalid handles, stale type assumptions, illegal pointer/value use, or lost layout/provenance until emit or external validation exposes it indirectly. | `IN_PROGRESS` | Added typed IR validation for expression type availability, scalar control-flow conditions, WGSL `select` mask signatures including `vecN<bool>` masks, switch selectors, return values, lvalue store targets, function-call argument counts/types/results, and root-filtered validation before tree-shaken emission. The validator now catches invalid statement/call/store IR before emission while preserving valid Bevy vector-mask `select` patterns, and the external corpus is at 478 source/IR-valid files with 149 composed Bevy cases. Remaining work is to extend the same validator model across resource binding/address-space compatibility, full access/member legality, layout/provenance invariants, and more statement-level side-effect constraints. |
2323
| `WGSL-254` | Real shader profile matrix | Bevy, wgpu, and sample shaders are often not standalone source files; many skipped files require concrete shader-def/value-def profiles, additional imports, source fragments, template substitutions, generated snippets, capabilities, or fuller source roots. | `IN_PROGRESS` | Added a manifest-owned external profile matrix with Bevy forward-material bool defs, sprite/UI material roots, prepass visualization defs, SSAO typed value defs, tonemapping binding-index values, deferred/environment/SSR/UI profiles, concrete meshlet culling/raster/material profiles, wgpu timestamp normalization source-prefix profiles, webgpu-samples Cornell suffix/template profiles, and a profile-owned skinned-mesh generated `VertexInput` fragment that mirrors the TypeScript shader-module construction path. The corpus gate now applies those profiles before classification, texture-atomic/texture-int64-atomic/primitive-index/barycentric/multiview/cooperative-matrix/float64/float16-in-float32/mesh-shader/ray-hit-vertex-position/per-vertex/binding-array capability detection covers corresponding real shaders, the oracle normalizes parser-unsupported vendor enable lines only inside the isolated validator, and duplicate Bevy dummy/real module candidates are resolved structurally by active requested symbols. Remaining work is to add profiles or IR support for the remaining feature-context wgpu/Naga files where standalone validation and IR lowering are both available. |
2424
| `WGSL-253` | Differential fuzzing | The suite still relies mostly on curated regressions and harvested corpora, so broad combinations of expressions, statements, literals, types, and builtin signatures can remain untested until a real project trips them. | `TODO` | Add deterministic WGSL generator cases with Naga as source oracle, then route every generated valid shader through moon parse/IR/emit/Naga. Each found bug must be minimized and promoted into the permanent corpus. |
2525
| `WGSL-252` | Differential generated testing / pointer locals and unary consts | Generated differential probing exposed two valid WGSL patterns that moon_wgsl mishandled: pointer-valued local variables were auto-loaded when used as pointer values, so `let p = &x; inc(p);` emitted `inc(*p)`, and untyped unary abstract-int constants such as `const NEG = -1;` could not be inferred when used as switch selectors. | `DONE` | Changed local identifier lowering so local variables whose value type is `ptr` are treated as handle values instead of pointee loads, added unary expression type inference for logical-not and signed/bitwise unary operators, and added white-box plus generated differential regressions for pointer-valued locals and unary const switch selectors. Verification is tracked with this audit pass on 2026-05-08. |

testdata/external_wgsl_corpus_expected_failures.tsv

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ naga tests/in/multiview.wgsl raw_invalid_no_preprocessor Expected invalid or cap
77
naga tests/in/multiview_webgl.wgsl raw_invalid_no_preprocessor Expected invalid or capability-context Naga corpus source under the standalone validator profile.
88
naga tests/in/pointers.wgsl raw_invalid_no_preprocessor Expected invalid or capability-context Naga corpus source under the standalone validator profile.
99
naga tests/in/push-constants.wgsl raw_invalid_no_preprocessor Expected invalid or capability-context Naga corpus source under the standalone validator profile.
10-
naga tests/in/ray-query.wgsl raw_invalid_no_preprocessor Expected invalid or capability-context Naga corpus source under the standalone validator profile.
1110
naga tests/in/shadow.wgsl raw_invalid_no_preprocessor Expected invalid or capability-context Naga corpus source under the standalone validator profile.
1211
naga tests/in/skybox.wgsl raw_invalid_no_preprocessor Expected invalid or capability-context Naga corpus source under the standalone validator profile.
1312
naga tests/out/wgsl/800-out-of-bounds-panic.vert.wgsl raw_invalid_no_preprocessor Expected invalid or capability-context Naga corpus source under the standalone validator profile.
@@ -20,7 +19,5 @@ naga tests/out/wgsl/math-functions.frag.wgsl raw_invalid_no_preprocessor Expecte
2019
naga tests/out/wgsl/multiview.wgsl raw_invalid_no_preprocessor Expected invalid or capability-context Naga corpus source under the standalone validator profile.
2120
naga tests/out/wgsl/pointers.wgsl raw_invalid_no_preprocessor Expected invalid or capability-context Naga corpus source under the standalone validator profile.
2221
naga tests/out/wgsl/samplers.frag.wgsl raw_invalid_no_preprocessor Expected invalid or capability-context Naga corpus source under the standalone validator profile.
23-
wgpu tests/src/copy_texture_to_buffer.wgsl raw_invalid_no_preprocessor Expected invalid or feature-context wgpu corpus source under the standalone validator profile.
2422
wgpu tests/tests/wgpu-gpu/regression/issue_4485.wgsl raw_invalid_no_preprocessor Expected invalid or feature-context wgpu corpus source under the standalone validator profile.
2523
wgpu tests/tests/wgpu-gpu/shader/compilation_messages/error_shader.wgsl raw_invalid_no_preprocessor Expected invalid or feature-context wgpu corpus source under the standalone validator profile.
26-
wgpu tests/tests/wgpu-gpu/shader/shader_test.wgsl raw_invalid_no_preprocessor Expected invalid or feature-context wgpu corpus source under the standalone validator profile.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# id repo ref sparse_paths min_valid min_composed notes
22
bevy https://github.com/bevyengine/bevy.git e903ce1a9c7d7008bab4fa3fbbeea298bae12e1b crates/bevy_render/src,crates/bevy_core_pipeline/src,crates/bevy_pbr/src,crates/bevy_sprite_render/src,crates/bevy_ui_render/src,assets/shaders 158 149 Real Bevy engine WGSL shader libraries and examples, including naga-oil-style preprocessing.
3-
wgpu https://github.com/gfx-rs/wgpu.git 04a7fe85d64187f05a8498266bc29419b2c5ca4b examples,tests,wgpu-core/src/timestamp_normalization 77 0 Real wgpu examples and GPU tests.
4-
naga https://github.com/gfx-rs/naga.git d0f28c0b1a3c772e55e68db1c47eff5131cb6732 tests/in/wgsl,tests/out/wgsl 122 0 Naga's own WGSL input and writer output corpus.
3+
wgpu https://github.com/gfx-rs/wgpu.git 04a7fe85d64187f05a8498266bc29419b2c5ca4b examples,tests,wgpu-core/src/timestamp_normalization 79 0 Real wgpu examples and GPU tests.
4+
naga https://github.com/gfx-rs/naga.git d0f28c0b1a3c772e55e68db1c47eff5131cb6732 tests/in/wgsl,tests/out/wgsl 123 0 Naga's own WGSL input and writer output corpus.
55
webgpu-samples https://github.com/webgpu/webgpu-samples.git f2e5ae73db8cbe2dd6b5a7b8cb80d911cf85b50b sample 68 0 Canonical WebGPU sample shaders.
66
learn-wgpu https://github.com/sotrh/learn-wgpu.git 008df3c90188de56696560d248c56efbafe2dccb code 50 0 Learn-wgpu tutorial and compute shader examples.

testdata/external_wgsl_corpus_profiles.tsv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ bevy crates/bevy_pbr/src/ssr/raymarch.wgsl DEPTH_PREPASS - - - - - - Bevy SSR ra
3737
bevy crates/bevy_pbr/src/ssr/ssr.wgsl DEPTH_PREPASS,DEFERRED_PREPASS,SCREEN_SPACE_REFLECTIONS - - - - - - Bevy screen-space reflection profile with depth, deferred, and SSR settings bindings enabled.
3838
bevy crates/bevy_ui_render/src/box_shadow.wgsl - SHADOW_SAMPLES=4 - - - - - Bevy UI box-shadow profile with Rust-provided sampling count.
3939
wgpu wgpu-core/src/timestamp_normalization/timestamp_normalization.wgsl - - - immediates wgpu-core/src/timestamp_normalization/common.wgsl - - wgpu timestamp normalization entry point exactly as Rust builds it by prefixing common.wgsl.
40+
wgpu tests/src/copy_texture_to_buffer.wgsl - - - - - - {{type}}=u32 wgpu copy-texture helper shader materialized with the Rust test's stencil aspect specialization.
41+
wgpu tests/tests/wgpu-gpu/shader/shader_test.wgsl - - - - - - {{header}}=,{{input_members}}=member: u32,{{input_bindings}}=@group(0) @binding(0),{{storage_type}}=uniform,{{input_type}}=CustomStruct,{{output_type}}=array<u32>,{{body}}=output[0u] = input.member; wgpu shader test template materialized with a concrete uniform-input scalar case generated by the Rust harness.
4042
wgpu tests/tests/wgpu-gpu/timestamp_normalization/shift_right_u96.wgsl - - - - wgpu-core/src/timestamp_normalization/common.wgsl - - wgpu timestamp normalization test shader exactly as Rust builds it by prefixing common.wgsl.
4143
wgpu tests/tests/wgpu-gpu/timestamp_normalization/u64_mul_u32.wgsl - - - - wgpu-core/src/timestamp_normalization/common.wgsl - - wgpu timestamp normalization test shader exactly as Rust builds it by prefixing common.wgsl.
44+
naga tests/in/ray-query.wgsl - - - ray-query profile://naga/ray_query_enable.wgsl - - Naga ray-query legacy input materialized with the enable line required by the current WGSL parser.
4245
webgpu-samples sample/cornell/radiosity.wgsl - - - - - sample/cornell/common.wgsl - Cornell sample compute shader exactly as TypeScript builds it by appending common.wgsl.
4346
webgpu-samples sample/cornell/rasterizer.wgsl - - - - - sample/cornell/common.wgsl - Cornell sample rasterizer shader exactly as TypeScript builds it by appending common.wgsl.
4447
webgpu-samples sample/cornell/raytracer.wgsl - - - - - sample/cornell/common.wgsl - Cornell sample raytracer shader exactly as TypeScript builds it by appending common.wgsl.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enable wgpu_ray_query;

0 commit comments

Comments
 (0)