gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
12.81k stars 939 forks source link

WGSL: Support the `pointer_composite_access` language extension #6192

Open rcoreilly opened 3 months ago

rcoreilly commented 3 months ago

Description

The WGSL spec has a requires directive to request language extensions, such as pointer_composite_access https://www.w3.org/TR/WGSL/#language-extensions-sec

When I put that at the top of my .wgsl shader, it barfs:

[wgpu] [Error] Device::create_shader_module error: 
Shader 'squares' parsing error: expected global item ('struct', 'const', 'var', 'alias', ';', 'fn') or the end of the file, found 'requires'
  ┌─ wgsl:2:1
  │
2 │ requires pointer_composite_access;
  │ ^^^^^^^^ expected global item ('struct', 'const', 'var', 'alias', ';', 'fn') or the end of the file

I would particularly be interested in when that specific language extension pointer_composite_access will be included as well -- huge improvement in usability. Also unrestricted_pointer_parameters seems rather important if I understand it properly, which I'm not sure I do..

Repro steps add that line to the top of any .wgsl code.

Expected vs observed behavior

didn't work.

Platform

Mac OS, latest trunk HEAD 26398ea using naga cli, and v0.19.4.1 of wgpu-native.

ErichDonGubler commented 1 month ago

@rcoreilly: Basic support for parsing requires is now posted in #6437. As the scope of parsing is in https://github.com/gfx-rs/wgpu/issues/6350, I'll narrow the scope of this issue (and edit the OP) to just the pointer_composite_access extension.