wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

Support `@must_use` function attribute in WGSL

Open ErichDonGubler opened this issue 6 months ago • 1 comments

We do not currently support the @must_use function attribute, despite being specified in the current v1 spec. draft. This was introduced in early 2023; see gpuweb/gpuweb#3862, gpuweb/gpuweb#3819.

Repro steps

Ideally, a runnable example we can check out.

  1. With this in.wgsl input file:

    @must_use 
    fn helper() -> u32 {
    	return 2;
    }
    
    @compute @workgroup_size(1)
    fn comp_main() {
    	let asdf = helper();
    }
    

    …run this on latest trunk (ATOW, d239361c1f5d5cfb8cee73382b1e8bc8476e3b29):

    $ cargo run -p naga-cli --all-features -- in.wgsl
    

Expected vs observed behavior

Clearly describe what you get, and how it goes across your expectations.

This should compile without error. The asdf binding is unused, but that should, at most, be a warning. Instead, the current output of repro steps is:

Could not parse WGSL:
error: unknown attribute: 'must_use'
  ┌─ in.wgsl:1:2
  │
1 │ @must_use
  │  ^^^^^^^^ unknown attribute

ErichDonGubler avatar Feb 02 '24 14:02 ErichDonGubler

Firefox bug: bug 1878314

ErichDonGubler avatar Feb 02 '24 14:02 ErichDonGubler

This is a higher priority than it might appear, because it prevents some popular WebGPU demos from running.

jimblandy avatar Feb 26 '24 17:02 jimblandy