gpuweb / cts

WebGPU Conformance Test Suite
https://gpuweb.github.io/cts/
BSD 3-Clause "New" or "Revised" License
126 stars 77 forks source link

wgsl: types, type-generators are not keywords #2307

Open dneto0 opened 1 year ago

dneto0 commented 1 year ago

See https://github.com/gpuweb/gpuweb/pull/3859 (It hasn't landed yet).

Can shadow predeclared types and type-generators

const i32 = 12;  // shadow predeclared i32
alias u32 = f32; // shadow predeclared u32
const wah = vec2<u32>(1.5);   // this is valid, because u32 is f32 now
var<private> vec4: u32;  // shadow vec4, a type-generator

Template parameters are now expressions, and can be parenthesized.

alias arr = array<(f32),2>;
@group(0) @binding(0) texture_storage_2d<(rgba8unorm),(write)>
@group(0) @binding(1) var<(storage),(read_write)>: u32;

Enumerants used in attributes are expressions, and can be parenthesized.

@fragment
fn main( @interpolate((flat)) a: i32,  @builtin((position)) p : vec4<f32>, @interpolate((perspective),(centroid)) c: vec3f ) -> vec4f { return vec4f(); }
dneto0 commented 1 year ago

https://github.com/gpuweb/gpuweb/pull/3859 has landed now.

dneto0 commented 1 year ago

With https://github.com/gpuweb/gpuweb/pull/3878 the template list discovery algorithm has been fixed to handle subexpressions involving '<' and '=', e.g.

// Comparisons with = in it, i.e. != <= >= == alias a = array<f32,select(2,1,a<=b)>; // the = was confounding the algorithm before.

Allow left shifts: const c = array<f32,1<<2>

The start of a template list can't look like <=

const a = 12;
const b = 13;
const c = 15;
const d = 16;

const e = vec2(a <= b, c >d); // this parses just fine, as if vec2((a<=b),(c>d))