Closed dj2 closed 6 months ago
bool(true)
bool(false)
let a = true; bool(a);
i32(-2147483648)
i32(2147483647)
i32(0)
let a = 123; i32(a);
u32(0)
u32(4294967295)
let a = 123u; u32(a);
f32(-0.0)
f32(0.0)
f32(<float min>)
f32(<float max>)
let a = 1.0; f32(a);
f16(0.0)
f16(-0.0)
f16(<f16 min>)
f16(<f16 max>)
let a = 1.0h; f16(a);
vec{2,3,4}(1{i, u, f, h, AbstractInt, AbstractFloat})
vec{2,3,4}<{i32, u32, f32, f16}>(1)
const a = 1{i, u, f, h, AbstractInt, AbstractFloat}; vec{2, 3, 4}(a++)
const a = 1; vec{2, 3, 4}<{i32, u32, f32, f16}>(a++)
array<T, 5>(1, 2, 3, 4, 5)
T
array<T, 5>(1)
array<T, 5>(1, 2, 3, 4, 5, 6)
[ ] bool() is false
bool()
[ ] i32() is 0
i32()
[ ] u32() is 0
u32()
[ ] f32() is 0.0
f32()
[ ] f16() is 0.0
f16()
[ ] vec{2, 3, 4}<T>() is 0 value for T
vec{2, 3, 4}<T>()
[ ] mat{2,3,4}x{2,3,4}<{f16, f32}>() is 0.0 for all cells
mat{2,3,4}x{2,3,4}<{f16, f32}>()
[ ] array<T, 5>() is 0 value for T
array<T, 5>()
[ ] struct A{}; A() is 0 value for each field of A
struct A{}; A()
A
[ ] array<T>() -- fails, no zero value for runtime array
array<T>()
[ ] Other non-constructable types fail as zero value initializers
https://www.w3.org/TR/WGSL/#construction-from-components
This seems covered by the https://github.com/gpuweb/cts/blob/main/src/webgpu/shader/execution/expression/constructor/zero_value.spec.ts and https://github.com/gpuweb/cts/blob/main/src/webgpu/shader/execution/expression/constructor/non_zero.spec.ts tests.
Identity constructors
bool(true)
bool(false)
let a = true; bool(a);
i32(-2147483648)
i32(2147483647)
i32(0)
let a = 123; i32(a);
u32(0)
u32(4294967295)
let a = 123u; u32(a);
f32(-0.0)
f32(0.0)
f32(<float min>)
f32(<float max>)
let a = 1.0; f32(a);
f16(0.0)
f16(-0.0)
f16(<f16 min>)
f16(<f16 max>)
let a = 1.0h; f16(a);
Vector constructors
vec{2,3,4}(1{i, u, f, h, AbstractInt, AbstractFloat})
vec{2,3,4}<{i32, u32, f32, f16}>(1)
const a = 1{i, u, f, h, AbstractInt, AbstractFloat}; vec{2, 3, 4}(a++)
-- each value should be 2const a = 1; vec{2, 3, 4}<{i32, u32, f32, f16}>(a++)
-- each value should be 2Matrix constructors
Array constructors
array<T, 5>(1, 2, 3, 4, 5)
for each value ofT
array<T, 5>(1)
failsarray<T, 5>(1, 2, 3, 4, 5, 6)
failsStruct constructors
Zero values
[ ]
bool()
is false[ ]
i32()
is 0[ ]
u32()
is 0[ ]
f32()
is 0.0[ ]
f16()
is 0.0[ ]
vec{2, 3, 4}<T>()
is 0 value forT
[ ]
mat{2,3,4}x{2,3,4}<{f16, f32}>()
is 0.0 for all cells[ ]
array<T, 5>()
is 0 value forT
[ ]
struct A{}; A()
is 0 value for each field ofA
[ ]
array<T>()
-- fails, no zero value for runtime array[ ] Other non-constructable types fail as zero value initializers
https://www.w3.org/TR/WGSL/#construction-from-components