Skip to content

Add shared support for WGSL immediate validation#4658

Open
shaoboyan091 wants to merge 1 commit into
gpuweb:mainfrom
shaoboyan091:pr/immediate-validation-support
Open

Add shared support for WGSL immediate validation#4658
shaoboyan091 wants to merge 1 commit into
gpuweb:mainfrom
shaoboyan091:pr/immediate-validation-support

Conversation

@shaoboyan091
Copy link
Copy Markdown
Contributor

This is the base PR for follow-up WGSL immediate address space
validation coverage.

It adds the shared CTS support needed by later test-suite PRs:

  • 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
  • removes redundant address-space type assertions made unnecessary by the
    stricter metadata typing

Follow-up PRs will add the declaration, type, expression, function, and
uniformity test coverage one commit at a time after this base PR 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`.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

Results for build job (at 7a27097):

-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)
+webgpu:shader,validation,decl,var:explicit_access_mode:* - 21 cases, 21 subcases (~1/case)
+webgpu:shader,validation,decl,var:implicit_access_mode:* - 7 cases, 7 subcases (~1/case)
+webgpu:shader,validation,decl,var:read_access:* - 15 cases, 15 subcases (~1/case)
+webgpu:shader,validation,decl,var:write_access:* - 15 cases, 15 subcases (~1/case)
-webgpu:shader,validation,parse,requires:wgsl_matches_api:* - 11 cases, 11 subcases (~1/case)
+webgpu:shader,validation,parse,requires:wgsl_matches_api:* - 12 cases, 12 subcases (~1/case)
-webgpu:shader,validation,types,pointer:let_ptr_explicit_type_matches_var:* - 26 cases, 26 subcases (~1/case)
-webgpu:shader,validation,types,pointer:let_ptr_reads:* - 26 cases, 26 subcases (~1/case)
-webgpu:shader,validation,types,pointer:let_ptr_writes:* - 26 cases, 26 subcases (~1/case)
+webgpu:shader,validation,types,pointer:let_ptr_explicit_type_matches_var:* - 30 cases, 30 subcases (~1/case)
+webgpu:shader,validation,types,pointer:let_ptr_reads:* - 30 cases, 30 subcases (~1/case)
+webgpu:shader,validation,types,pointer:let_ptr_writes:* - 30 cases, 30 subcases (~1/case)
-webgpu:shader,validation,types,pointer:ptr_address_space_never_uses_access_mode:* - 15 cases, 15 subcases (~1/case)
+webgpu:shader,validation,types,pointer:ptr_address_space_never_uses_access_mode:* - 18 cases, 18 subcases (~1/case)
-TOTAL: 281361 cases, 2323132 subcases
+TOTAL: 281385 cases, 2323156 subcases

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds shared infrastructure to the CTS WGSL shader validation layer for the new immediate address space, so follow-up PRs can add focused test coverage incrementally.

Changes:

  • Adds immediate_address_space to the known WGSL language features and associates it with the new immediate address space metadata.
  • Extends address-space/type helpers to emit requires <feature>; headers when needed and updates host-shareable/type generation rules for immediate.
  • Tightens address-space typing (removing redundant casts) and introduces helpers intended to skip tests when immediate data support is unavailable.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/webgpu/shader/validation/types/pointer.spec.ts Removes redundant AddressSpace casts; now iterates address spaces via typed metadata.
src/webgpu/shader/validation/decl/var.spec.ts Removes redundant AddressSpace casts; now iterates address spaces via typed metadata.
src/webgpu/shader/validation/decl/util.ts Adds WGSL requires header emission and new skip helpers for address-space support.
src/webgpu/shader/types.ts Adds immediate address space + metadata, and updates type generation/host-shareable rules accordingly.
src/webgpu/capability_info.ts Registers immediate_address_space as a known WGSL language feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const kNonHandleAddressSpaces = keysOf(kAddressSpaceInfo).filter(
as => as !== 'handle'
) as AddressSpace[];
const kNonHandleAddressSpaces = keysOf(kAddressSpaceInfo).filter(as => as !== 'handle');
const kNonHandleAddressSpaces = keysOf(kAddressSpaceInfo).filter(
as => as !== 'handle'
) as AddressSpace[];
const kNonHandleAddressSpaces = keysOf(kAddressSpaceInfo).filter(as => as !== 'handle');
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.

2 participants