-
Notifications
You must be signed in to change notification settings - Fork 345
Open
Labels
wgslWebGPU Shading Language IssuesWebGPU Shading Language Issues
Milestone
Description
I propose that square brackets in the context of an expression (not following an identifier) should construct an array<T, N>, with inferred T and N.
array<T,N>(e1,...,eN) is the same as [e1,...,eN], where T is the type of all elements, and N is the number of elements in the array.
It is a compile error if all the element are not of the same type.
It is a compile error if the array is empty.
For example:
var arr3_f32 : array<f32, 3> = array<f32, 3>(1.0, 2.0, 3.0);
var arr3_i32 : array<i32, 3> = array<i32, 3>(1, 2, 3);
var arr2_bool : array<bool, 2> = array<bool, 2>(true, false);
var arr2_vec3_f32 : array<vec3<f32>, 2> = array<vec3<f32>, 2>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(4.0, 5.0, 6.0));would be semantically identical to:
var arr3_f32 : array<f32, 3> = [1.0, 2.0, 3.0];
var arr3_i32 : array<i32, 3> = [1, 2, 3];
var arr2_bool : array<bool, 2> = [true, false];
var arr2_vec3_f32 : array<vec3<f32>, 2> = [vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(4.0, 5.0, 6.0)];The texture builtins proposal in #1176 includes a named parameter for explicit gradients, which of the type array<vec2<T>, 2>.
Actually passing one of these is extremely verbose:
var gradients : array<vec2<f32>, 2> = array<vec2<f32>, 2>(calcDDX(), calcDDY());
color = textureSample(tex2D, s, coords, grad: gradients);With this proposal, this would become:
color = textureSample(tex2D, s, coords, grad: [calcDDX(), calcDDY()]);jozanza, ria8651, gents83 and EriKWDev
Metadata
Metadata
Assignees
Labels
wgslWebGPU Shading Language IssuesWebGPU Shading Language Issues