mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 14:31:08 +01:00
Make the parser code more closely follow the spec's grammar around
`unary_expression`, `postfix_expression`, and `singular_expression`.
Change the handling of postfix expressions (indexing, member/component access,
and swizzling) to apply the indirection at the appropriate time, resulting in
code improvements on all output formats. For example, where we used to generate
the following MSL:
metal::float4 _e13 = bar.matrix[3];
float b = _e13.x;
we now generate, simply:
float b = bar.matrix[3].x;
Propagate WGSL reference types correctly, so that parenthesizing expressions no
longer causes the Load Rule to be applied.
Together with #1332 (already landed), this is a replacement for #1312, and
unblocks #1352.
Fixes #1351.
35 lines
932 B
GLSL
35 lines
932 B
GLSL
#version 310 es
|
|
|
|
precision highp float;
|
|
precision highp int;
|
|
|
|
buffer Bar_block_0Vs {
|
|
mat4x4 matrix;
|
|
int atom;
|
|
uvec2 arr[2];
|
|
int data[];
|
|
} _group_0_binding_0;
|
|
|
|
|
|
void main() {
|
|
uint vi = uint(gl_VertexID);
|
|
float foo1 = 0.0;
|
|
int c[5];
|
|
float baz = foo1;
|
|
foo1 = 1.0;
|
|
mat4x4 matrix = _group_0_binding_0.matrix;
|
|
uvec2 arr[2] = _group_0_binding_0.arr;
|
|
float b = _group_0_binding_0.matrix[3][0];
|
|
int a = _group_0_binding_0.data[(uint(_group_0_binding_0.data.length()) - 2u)];
|
|
_group_0_binding_0.matrix[1][2] = 1.0;
|
|
_group_0_binding_0.matrix = mat4x4(vec4(0.0), vec4(1.0), vec4(2.0), vec4(3.0));
|
|
_group_0_binding_0.arr = uvec2[2](uvec2(0u), uvec2(1u));
|
|
c = int[5](a, int(b), 3, 4, 5);
|
|
c[(vi + 1u)] = 42;
|
|
int value = c[vi];
|
|
gl_Position = (matrix * vec4(ivec4(value)));
|
|
gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w);
|
|
return;
|
|
}
|
|
|