Skip to content

Add declaration tests for WGSL immediate variables#4659

Closed
shaoboyan091 wants to merge 2 commits into
gpuweb:mainfrom
shaoboyan091:pr/immediate-declaration-validation
Closed

Add declaration tests for WGSL immediate variables#4659
shaoboyan091 wants to merge 2 commits into
gpuweb:mainfrom
shaoboyan091:pr/immediate-declaration-validation

Conversation

@shaoboyan091

Copy link
Copy Markdown
Contributor

This PR adds the first WGSL immediate address space validation
coverage.

It includes the shared CTS plumbing required by the tests:

  • adds immediate_address_space to the known WGSL language features
  • models immediate in the shared address space metadata
  • emits required WGSL feature headers from declaration helpers
  • skips immediate validation tests when immediate data support is not exposed

It then adds declaration validation coverage for var<immediate>:

  • accepted scalar, vector, matrix, and struct store types
  • rejected store types, including arrays and f16 cases
  • module-scope-only declarations
  • rejection of binding attributes
  • rejection of explicit access modes
  • one statically used immediate variable per entry point
  • basic ptr<immediate> declaration behavior

Follow-up PRs will add type, expression, function, and uniformity
coverage one suite at a time after this lands.

Testing:

  • npm.cmd run typecheck
  • npm.cmd run lint

This patch adds the shared CTS plumbing needed by the follow-up
WGSL `immediate` address space validation tests.

It adds `immediate_address_space` to the known WGSL language feature
list, models `immediate` in the address space metadata, and treats it
as a module-scope, unbound, read-only address space with
host-shareable store types.

The validation helpers emit the required WGSL `requires` directive and
skip immediate tests when immediate data is not exposed by the browser.
The skip checks `setImmediates`/`maxImmediateSize` because current
Chrome Canary exposes the API before advertising the WGSL feature.

This also removes two now-unnecessary address-space type assertions
that became redundant once the shared metadata was typed by
`AddressSpace`.
This patch adds a focused declaration suite for `var<immediate>`.

The new tests cover accepted scalar, vector, matrix, and struct store
types, rejected store types, module-scope-only declarations, rejection
of binding attributes, rejection of explicit access modes, and the
one-immediate-variable-per-entry-point rule.

It also threads `immediate` through the existing declaration tests so
the generic address space coverage checks the same declaration access
rules as storage, uniform, private, workgroup, and function variables.
The context-dependent resolution table now recognizes
`immediate_address_space` as a language feature name.
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Results for build job (at 91f8171):

-webgpu:shader,validation,decl,context_dependent_resolution:language_names:* - 4 cases, 12 subcases (~3/case)
+webgpu:shader,validation,decl,context_dependent_resolution:language_names:* - 5 cases, 15 subcases (~3/case)
+webgpu:shader,validation,decl,immediate:store_type,valid:* - 8 cases, 8 subcases (~1/case)
+webgpu:shader,validation,decl,immediate:store_type,invalid:* - 13 cases, 13 subcases (~1/case)
+webgpu:shader,validation,decl,immediate:scope:* - 2 cases, 2 subcases (~1/case)
+webgpu:shader,validation,decl,immediate:binding_attributes:* - 4 cases, 4 subcases (~1/case)
+webgpu:shader,validation,decl,immediate:access_mode:* - 4 cases, 4 subcases (~1/case)
+webgpu:shader,validation,decl,immediate:entry_point_interface:* - 5 cases, 5 subcases (~1/case)
+webgpu:shader,validation,decl,immediate:pointers:* - 8 cases, 8 subcases (~1/case)
-webgpu:shader,validation,decl,var:module_scope_types:* - 406 cases, 406 subcases (~1/case)
+webgpu:shader,validation,decl,var:module_scope_types:* - 464 cases, 464 subcases (~1/case)
-webgpu:shader,validation,decl,var:binding_point_on_non_resources:* - 8 cases, 8 subcases (~1/case)
+webgpu:shader,validation,decl,var:binding_point_on_non_resources:* - 12 cases, 12 subcases (~1/case)
-webgpu:shader,validation,decl,var:address_space_access_mode:* - 40 cases, 40 subcases (~1/case)
-webgpu:shader,validation,decl,var:explicit_access_mode:* - 18 cases, 18 subcases (~1/case)
-webgpu:shader,validation,decl,var:implicit_access_mode:* - 6 cases, 6 subcases (~1/case)
-webgpu:shader,validation,decl,var:read_access:* - 13 cases, 13 subcases (~1/case)
-webgpu:shader,validation,decl,var:write_access:* - 13 cases, 13 subcases (~1/case)
 [snip - full report in action logs]
-TOTAL: 281361 cases, 2323132 subcases
+TOTAL: 281500 cases, 2323273 subcases

@shaoboyan091

Copy link
Copy Markdown
Contributor Author

Closing this combined PR. We are going back to the separated PR flow: #4658 will carry only the shared support, and the declaration CTS cases will be sent in a follow-up PR after that lands.

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.

1 participant