Skip to content

feat(graphics): expose WGSL pointer_composite_access as a device cap#8786

Merged
mvaligursky merged 1 commit into
mainfrom
mv-wgsl-pointer-composite-access
May 27, 2026
Merged

feat(graphics): expose WGSL pointer_composite_access as a device cap#8786
mvaligursky merged 1 commit into
mainfrom
mv-wgsl-pointer-composite-access

Conversation

@mvaligursky
Copy link
Copy Markdown
Contributor

Adds detection and automatic wiring for the WGSL pointer_composite_access language feature, which provides syntactic sugar for dereferencing pointers to composite typesp.field and p[i] instead of (*p).field and (*p)[i].

Follows the same pattern as unrestricted_pointer_parameters (#8785) and linear_indexing.

Changes:

  • GraphicsDevice.supportsPointerCompositeAccess flag, probed from navigator.gpu.wgslLanguageFeatures in WebgpuGraphicsDevice#initDeviceCaps.
  • CAPS_POINTER_COMPOSITE_ACCESS shader define for conditional compilation (#ifdef).
  • requires pointer_composite_access; directive automatically injected into WGSL shaders on supporting devices via ShaderDefinitionUtils.getWGSLEnables.

Notes:

  • Infrastructure-only — no shader callers yet. The cap is available for future WGSL helpers that benefit from the more readable pointer-access syntax.
  • Firefox/naga doesn't currently expose this feature; the cap will be false there and no requires directive is emitted, so existing portable shaders continue to compile.

Adds detection and automatic wiring for the WGSL `pointer_composite_access`
language feature, which provides syntactic sugar for dereferencing pointers
to composite types — `p.field` and `p[i]` instead of `(*p).field` and
`(*p)[i]`. Follows the same pattern as `unrestricted_pointer_parameters`
and `linear_indexing`:

- `supportsPointerCompositeAccess` device flag, probed from
  navigator.gpu.wgslLanguageFeatures.
- `CAPS_POINTER_COMPOSITE_ACCESS` shader define for conditional compilation.
- `requires pointer_composite_access;` directive automatically injected into
  WGSL shaders on supporting devices.

See https://developer.chrome.com/blog/new-in-webgpu-123#syntax_sugar_for_dereferencing_composites_in_wgsl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: graphics Graphics related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant