diff --git a/reference/shaders/asm/comp/bitcast_iadd.asm.comp b/reference/shaders/asm/comp/bitcast_iadd.asm.comp index 6a3e5af6..2d27240a 100644 --- a/reference/shaders/asm/comp/bitcast_iadd.asm.comp +++ b/reference/shaders/asm/comp/bitcast_iadd.asm.comp @@ -15,13 +15,13 @@ layout(binding = 1, std430) restrict buffer _4 void main() { - _6._0 = (_5._1 + uvec4(_5._0)); - _6._0 = (uvec4(_5._0) + _5._1); - _6._0 = (_5._1 + _5._1); + _6._0 = _5._1 + uvec4(_5._0); + _6._0 = uvec4(_5._0) + _5._1; + _6._0 = _5._1 + _5._1; _6._0 = uvec4(_5._0 + _5._0); _6._1 = ivec4(_5._1 + _5._1); - _6._1 = (_5._0 + _5._0); - _6._1 = (ivec4(_5._1) + _5._0); - _6._1 = (_5._0 + ivec4(_5._1)); + _6._1 = _5._0 + _5._0; + _6._1 = ivec4(_5._1) + _5._0; + _6._1 = _5._0 + ivec4(_5._1); } diff --git a/reference/shaders/asm/comp/bitcast_sar.asm.comp b/reference/shaders/asm/comp/bitcast_sar.asm.comp index 3530ed6f..76993021 100644 --- a/reference/shaders/asm/comp/bitcast_sar.asm.comp +++ b/reference/shaders/asm/comp/bitcast_sar.asm.comp @@ -19,9 +19,9 @@ void main() _6._0 = uvec4(_5._0 >> ivec4(_5._1)); _6._0 = uvec4(ivec4(_5._1) >> ivec4(_5._1)); _6._0 = uvec4(_5._0 >> _5._0); - _6._1 = (ivec4(_5._1) >> ivec4(_5._1)); - _6._1 = (_5._0 >> _5._0); - _6._1 = (ivec4(_5._1) >> _5._0); - _6._1 = (_5._0 >> ivec4(_5._1)); + _6._1 = ivec4(_5._1) >> ivec4(_5._1); + _6._1 = _5._0 >> _5._0; + _6._1 = ivec4(_5._1) >> _5._0; + _6._1 = _5._0 >> ivec4(_5._1); } diff --git a/reference/shaders/asm/comp/bitcast_sdiv.asm.comp b/reference/shaders/asm/comp/bitcast_sdiv.asm.comp index 4fd7769d..afa5e41d 100644 --- a/reference/shaders/asm/comp/bitcast_sdiv.asm.comp +++ b/reference/shaders/asm/comp/bitcast_sdiv.asm.comp @@ -19,9 +19,9 @@ void main() _6._0 = uvec4(_5._0 / ivec4(_5._1)); _6._0 = uvec4(ivec4(_5._1) / ivec4(_5._1)); _6._0 = uvec4(_5._0 / _5._0); - _6._1 = (ivec4(_5._1) / ivec4(_5._1)); - _6._1 = (_5._0 / _5._0); - _6._1 = (ivec4(_5._1) / _5._0); - _6._1 = (_5._0 / ivec4(_5._1)); + _6._1 = ivec4(_5._1) / ivec4(_5._1); + _6._1 = _5._0 / _5._0; + _6._1 = ivec4(_5._1) / _5._0; + _6._1 = _5._0 / ivec4(_5._1); } diff --git a/reference/shaders/asm/comp/bitcast_slr.asm.comp b/reference/shaders/asm/comp/bitcast_slr.asm.comp index c50fc0ba..6de92017 100644 --- a/reference/shaders/asm/comp/bitcast_slr.asm.comp +++ b/reference/shaders/asm/comp/bitcast_slr.asm.comp @@ -15,10 +15,10 @@ layout(binding = 1, std430) buffer _4 void main() { - _6._0 = (_5._1 >> uvec4(_5._0)); - _6._0 = (uvec4(_5._0) >> _5._1); - _6._0 = (_5._1 >> _5._1); - _6._0 = (uvec4(_5._0) >> uvec4(_5._0)); + _6._0 = _5._1 >> uvec4(_5._0); + _6._0 = uvec4(_5._0) >> _5._1; + _6._0 = _5._1 >> _5._1; + _6._0 = uvec4(_5._0) >> uvec4(_5._0); _6._1 = ivec4(_5._1 >> _5._1); _6._1 = ivec4(uvec4(_5._0) >> uvec4(_5._0)); _6._1 = ivec4(_5._1 >> uvec4(_5._0)); diff --git a/reference/shaders/asm/comp/bitcast_udiv.asm.comp b/reference/shaders/asm/comp/bitcast_udiv.asm.comp index 1d384de4..aa9d68fe 100644 --- a/reference/shaders/asm/comp/bitcast_udiv.asm.comp +++ b/reference/shaders/asm/comp/bitcast_udiv.asm.comp @@ -15,10 +15,10 @@ layout(binding = 1, std430) buffer _4 void main() { - _6._0 = (_5._1 / uvec4(_5._0)); - _6._0 = (uvec4(_5._0) / _5._1); - _6._0 = (_5._1 / _5._1); - _6._0 = (uvec4(_5._0) / uvec4(_5._0)); + _6._0 = _5._1 / uvec4(_5._0); + _6._0 = uvec4(_5._0) / _5._1; + _6._0 = _5._1 / _5._1; + _6._0 = uvec4(_5._0) / uvec4(_5._0); _6._1 = ivec4(_5._1 / _5._1); _6._1 = ivec4(uvec4(_5._0) / uvec4(_5._0)); _6._1 = ivec4(_5._1 / uvec4(_5._0)); diff --git a/reference/shaders/asm/comp/multiple-entry.asm.comp b/reference/shaders/asm/comp/multiple-entry.asm.comp index b30a164f..65a528cd 100644 --- a/reference/shaders/asm/comp/multiple-entry.asm.comp +++ b/reference/shaders/asm/comp/multiple-entry.asm.comp @@ -15,13 +15,13 @@ layout(binding = 1, std430) restrict buffer _7 void main() { - _9._0 = (_8._1 + uvec4(_8._0)); - _9._0 = (uvec4(_8._0) + _8._1); - _9._0 = (_8._1 + _8._1); + _9._0 = _8._1 + uvec4(_8._0); + _9._0 = uvec4(_8._0) + _8._1; + _9._0 = _8._1 + _8._1; _9._0 = uvec4(_8._0 + _8._0); _9._1 = ivec4(_8._1 + _8._1); - _9._1 = (_8._0 + _8._0); - _9._1 = (ivec4(_8._1) + _8._0); - _9._1 = (_8._0 + ivec4(_8._1)); + _9._1 = _8._0 + _8._0; + _9._1 = ivec4(_8._1) + _8._0; + _9._1 = _8._0 + ivec4(_8._1); } diff --git a/reference/shaders/asm/frag/invalidation.asm.frag b/reference/shaders/asm/frag/invalidation.asm.frag index b702bf6b..1cdc9761 100644 --- a/reference/shaders/asm/frag/invalidation.asm.frag +++ b/reference/shaders/asm/frag/invalidation.asm.frag @@ -10,6 +10,6 @@ void main() float b = v1; float _17 = a; a = v1; - FragColor = ((_17 + b) * b); + FragColor = (_17 + b) * b; } diff --git a/reference/shaders/comp/bake_gradient.comp b/reference/shaders/comp/bake_gradient.comp index 201d4221..41facc8c 100644 --- a/reference/shaders/comp/bake_gradient.comp +++ b/reference/shaders/comp/bake_gradient.comp @@ -14,23 +14,23 @@ layout(binding = 3, rgba16f) uniform mediump writeonly image2D iGradJacobian; mediump float jacobian(mediump vec2 dDdx, mediump vec2 dDdy) { - return (((1.0 + dDdx.x) * (1.0 + dDdy.y)) - (dDdx.y * dDdy.x)); + return ((1.0 + dDdx.x) * (1.0 + dDdy.y)) - (dDdx.y * dDdy.x); } void main() { - vec4 uv = ((vec2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5)); + vec4 uv = (vec2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5); float h = textureLod(uHeight, uv.xy, 0.0).x; float x0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(-1, 0)).x; float x1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(1, 0)).x; float y0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, -1)).x; float y1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, 1)).x; - vec2 grad = ((_46.uScale.xy * 0.5) * vec2((x1 - x0), (y1 - y0))); - vec2 displacement = (textureLod(uDisplacement, uv.zw, 0.0).xy * 1.2000000476837158203125); - vec2 dDdx = ((textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(1, 0)).xy - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(-1, 0)).xy) * 0.60000002384185791015625); - vec2 dDdy = ((textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, 1)).xy - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, -1)).xy) * 0.60000002384185791015625); - vec2 param = (dDdx * _46.uScale.z); - vec2 param_1 = (dDdy * _46.uScale.z); + vec2 grad = (_46.uScale.xy * 0.5) * vec2(x1 - x0, y1 - y0); + vec2 displacement = textureLod(uDisplacement, uv.zw, 0.0).xy * 1.2000000476837158203125; + vec2 dDdx = (textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(1, 0)).xy - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(-1, 0)).xy) * 0.60000002384185791015625; + vec2 dDdy = (textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, 1)).xy - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, -1)).xy) * 0.60000002384185791015625; + vec2 param = dDdx * _46.uScale.z; + vec2 param_1 = dDdy * _46.uScale.z; float j = jacobian(param, param_1); displacement = vec2(0.0); imageStore(iHeightDisplacement, ivec2(gl_GlobalInvocationID.xy), vec4(h, displacement, 0.0)); diff --git a/reference/shaders/comp/basic.comp b/reference/shaders/comp/basic.comp index f7233127..ca2503bd 100644 --- a/reference/shaders/comp/basic.comp +++ b/reference/shaders/comp/basic.comp @@ -20,7 +20,7 @@ void main() { uint ident = gl_GlobalInvocationID.x; vec4 idata = _23.in_data[ident]; - if ((dot(idata, vec4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875)) + if (dot(idata, vec4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875) { uint _52 = atomicAdd(_48.counter, 1u); _45.out_data[_52] = idata; diff --git a/reference/shaders/comp/cfg.comp b/reference/shaders/comp/cfg.comp index 46b87920..63d95ab1 100644 --- a/reference/shaders/comp/cfg.comp +++ b/reference/shaders/comp/cfg.comp @@ -9,7 +9,7 @@ layout(binding = 0, std430) buffer SSBO void test() { float m; - if ((_11.data != 0.0)) + if (_11.data != 0.0) { float tmp = 10.0; _11.data = tmp; @@ -19,12 +19,12 @@ void test() float tmp_1 = 15.0; _11.data = tmp_1; } - if ((_11.data != 0.0)) + if (_11.data != 0.0) { float e; - if ((_11.data != 5.0)) + if (_11.data != 5.0) { - if ((_11.data != 6.0)) + if (_11.data != 6.0) { e = 10.0; } @@ -65,13 +65,13 @@ void test() } int i = 0; float h; - for (; (i < 20); i = (i + 1), h = (h + 10.0)) + for (; i < 20; i = i + 1, h = h + 10.0) { } _11.data = h; do { - } while ((m != 20.0)); + } while (m != 20.0); _11.data = m; } diff --git a/reference/shaders/comp/composite-construct.comp b/reference/shaders/comp/composite-construct.comp index 828be805..91bb5348 100644 --- a/reference/shaders/comp/composite-construct.comp +++ b/reference/shaders/comp/composite-construct.comp @@ -19,7 +19,7 @@ layout(binding = 1, std430) buffer SSBO1 vec4 summe(vec4 values[3][2]) { - return (((values[0][0] + values[2][1]) + values[0][1]) + values[1][0]); + return ((values[0][0] + values[2][1]) + values[0][1]) + values[1][0]; } void main() diff --git a/reference/shaders/comp/culling.comp b/reference/shaders/comp/culling.comp index 0e1c87cd..cd284b96 100644 --- a/reference/shaders/comp/culling.comp +++ b/reference/shaders/comp/culling.comp @@ -20,7 +20,7 @@ void main() { uint ident = gl_GlobalInvocationID.x; float idata = _22.in_data[ident]; - if ((idata > 12.0)) + if (idata > 12.0) { uint _45 = atomicAdd(_41.count, 1u); _38.out_data[_45] = idata; diff --git a/reference/shaders/comp/defer-parens.comp b/reference/shaders/comp/defer-parens.comp new file mode 100644 index 00000000..cf985293 --- /dev/null +++ b/reference/shaders/comp/defer-parens.comp @@ -0,0 +1,21 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + vec4 data; + int index; +} _13; + +void main() +{ + vec4 d = _13.data; + _13.data = vec4(d.x, d.yz + vec2(10.0), d.w); + _13.data = (d + d) + d; + _13.data = (d.yz + vec2(10.0)).xxyy; + float t = (d.yz + vec2(10.0)).y; + _13.data = vec4(t); + t = (d.zw + vec2(10.0))[_13.index]; + _13.data = vec4(t); +} + diff --git a/reference/shaders/comp/dowhile.comp b/reference/shaders/comp/dowhile.comp index e62fb61b..01449340 100644 --- a/reference/shaders/comp/dowhile.comp +++ b/reference/shaders/comp/dowhile.comp @@ -21,9 +21,9 @@ void main() vec4 idat = _28.in_data[ident]; do { - idat = (_28.mvp * idat); - i = (i + 1); - } while ((i < 16)); + idat = _28.mvp * idat; + i = i + 1; + } while (i < 16); _52.out_data[ident] = idat; } diff --git a/reference/shaders/comp/generate_height.comp b/reference/shaders/comp/generate_height.comp index a12e0042..a2128dd8 100644 --- a/reference/shaders/comp/generate_height.comp +++ b/reference/shaders/comp/generate_height.comp @@ -42,17 +42,17 @@ uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel) vec2 alias(vec2 i, vec2 N) { - return mix(i, (i - N), greaterThan(i, (N * 0.5))); + return mix(i, i - N, greaterThan(i, N * 0.5)); } vec2 cmul(vec2 a, vec2 b) { vec2 r3 = a.yx; vec2 r1 = b.xx; - vec2 R0 = (a * r1); + vec2 R0 = a * r1; vec2 r2 = b.yy; - vec2 R1 = (r2 * r3); - return (R0 + vec2((-R1.x), R1.y)); + vec2 R1 = r2 * r3; + return R0 + vec2(-R1.x, R1.y); } uint pack2(vec2 v) @@ -62,19 +62,19 @@ uint pack2(vec2 v) void generate_heightmap() { - uvec2 N = (uvec2(64u, 1u) * gl_NumWorkGroups.xy); + uvec2 N = uvec2(64u, 1u) * gl_NumWorkGroups.xy; uvec2 i = gl_GlobalInvocationID.xy; - uvec2 param = (N - i); + uvec2 param = N - i; uvec2 param_1 = uvec2(0u); bvec2 param_2 = equal(i, uvec2(0u)); uvec2 wi = workaround_mix(param, param_1, param_2); - vec2 a = _190.distribution[((i.y * N.x) + i.x)]; - vec2 b = _190.distribution[((wi.y * N.x) + wi.x)]; + vec2 a = _190.distribution[(i.y * N.x) + i.x]; + vec2 b = _190.distribution[(wi.y * N.x) + wi.x]; vec2 param_3 = vec2(i); vec2 param_4 = vec2(N); - vec2 k = (_218.uModTime.xy * alias(param_3, param_4)); + vec2 k = _218.uModTime.xy * alias(param_3, param_4); float k_len = length(k); - float w = (sqrt((9.81000041961669921875 * k_len)) * _218.uModTime.z); + float w = sqrt(9.81000041961669921875 * k_len) * _218.uModTime.z; float cw = cos(w); float sw = sin(w); vec2 param_5 = a; @@ -83,10 +83,10 @@ void generate_heightmap() vec2 param_7 = b; vec2 param_8 = vec2(cw, sw); b = cmul(param_7, param_8); - b = vec2(b.x, (-b.y)); - vec2 res = (a + b); + b = vec2(b.x, -b.y); + vec2 res = a + b; vec2 param_9 = res; - _276.heights[((i.y * N.x) + i.x)] = pack2(param_9); + _276.heights[(i.y * N.x) + i.x] = pack2(param_9); } void main() diff --git a/reference/shaders/comp/image.comp b/reference/shaders/comp/image.comp index 19e15c99..74799050 100644 --- a/reference/shaders/comp/image.comp +++ b/reference/shaders/comp/image.comp @@ -6,7 +6,7 @@ layout(binding = 1, rgba8) uniform mediump writeonly image2D uImageOut; void main() { - vec4 v = imageLoad(uImageIn, (ivec2(gl_GlobalInvocationID.xy) + imageSize(uImageIn))); + vec4 v = imageLoad(uImageIn, ivec2(gl_GlobalInvocationID.xy) + imageSize(uImageIn)); imageStore(uImageOut, ivec2(gl_GlobalInvocationID.xy), v); } diff --git a/reference/shaders/comp/inout-struct.invalid.comp b/reference/shaders/comp/inout-struct.invalid.comp index 767d0599..d636dd64 100644 --- a/reference/shaders/comp/inout-struct.invalid.comp +++ b/reference/shaders/comp/inout-struct.invalid.comp @@ -27,23 +27,23 @@ layout(binding = 2, std430) buffer SSBO3 void baz(out Foo foo) { uint ident = gl_GlobalInvocationID.x; - foo.a = indata.data[((4u * ident) + 0u)]; - foo.b = indata.data[((4u * ident) + 1u)]; - foo.c = indata.data[((4u * ident) + 2u)]; - foo.d = indata.data[((4u * ident) + 3u)]; + foo.a = indata.data[(4u * ident) + 0u]; + foo.b = indata.data[(4u * ident) + 1u]; + foo.c = indata.data[(4u * ident) + 2u]; + foo.d = indata.data[(4u * ident) + 3u]; } void meow(inout Foo foo) { - foo.a = (foo.a + vec4(10.0)); - foo.b = (foo.b + vec4(20.0)); - foo.c = (foo.c + vec4(30.0)); - foo.d = (foo.d + vec4(40.0)); + foo.a = foo.a + vec4(10.0); + foo.b = foo.b + vec4(20.0); + foo.c = foo.c + vec4(30.0); + foo.d = foo.d + vec4(40.0); } vec4 bar(Foo foo) { - return (((foo.a + foo.b) + foo.c) + foo.d); + return ((foo.a + foo.b) + foo.c) + foo.d; } void main() @@ -60,6 +60,6 @@ void main() param_3.b = foobar.foos[gl_GlobalInvocationID.x].b; param_3.c = foobar.foos[gl_GlobalInvocationID.x].c; param_3.d = foobar.foos[gl_GlobalInvocationID.x].d; - outdata.data[gl_GlobalInvocationID.x] = (bar(param_2) + bar(param_3)); + outdata.data[gl_GlobalInvocationID.x] = bar(param_2) + bar(param_3); } diff --git a/reference/shaders/comp/loop.comp b/reference/shaders/comp/loop.comp index 4fe1db62..a9848dda 100644 --- a/reference/shaders/comp/loop.comp +++ b/reference/shaders/comp/loop.comp @@ -18,13 +18,13 @@ void main() vec4 idat = _24.in_data[ident]; int k = 0; uint i = 0u; - if ((idat.y == 20.0)) + if (idat.y == 20.0) { do { - k = (k * 2); - i = (i + uint(1)); - } while ((i < ident)); + k = k * 2; + i = i + uint(1); + } while (i < ident); } switch (k) { @@ -32,8 +32,8 @@ void main() { for (;;) { - i = (i + uint(1)); - if ((i > 10u)) + i = i + uint(1); + if (i > 10u) { break; } @@ -45,8 +45,8 @@ void main() { for (;;) { - i = (i + 2u); - if ((i > 20u)) + i = i + 2u; + if (i > 20u) { break; } @@ -55,51 +55,51 @@ void main() break; } } - while ((k < 10)) + while (k < 10) { - idat = (idat * 2.0); - k = (k + 1); + idat = idat * 2.0; + k = k + 1; } uint i_1 = 0u; - for (; (i_1 < 16u); i_1 = (i_1 + uint(1)), k = (k + 1)) + for (; i_1 < 16u; i_1 = i_1 + uint(1), k = k + 1) { uint j = 0u; - for (; (j < 30u); j = (j + uint(1))) + for (; j < 30u; j = j + uint(1)) { - idat = (_24.mvp * idat); + idat = _24.mvp * idat; } } k = 0; for (;;) { - k = (k + 1); - if ((k > 10)) + k = k + 1; + if (k > 10) { - k = (k + 2); + k = k + 2; } else { - k = (k + 3); + k = k + 3; continue; } - k = (k + 10); + k = k + 10; continue; } k = 0; do { - k = (k + 1); - } while ((k > 10)); + k = k + 1; + } while (k > 10); int l = 0; for (;;) { - if ((l == 5)) + if (l == 5) { - l = (l + 1); + l = l + 1; continue; } - idat = (idat + vec4(1.0)); - l = (l + 1); + idat = idat + vec4(1.0); + l = l + 1; continue; } _177.out_data[ident] = idat; diff --git a/reference/shaders/comp/mod.comp b/reference/shaders/comp/mod.comp index eee2bd97..dfb9cf4c 100644 --- a/reference/shaders/comp/mod.comp +++ b/reference/shaders/comp/mod.comp @@ -16,9 +16,9 @@ void main() uint ident = gl_GlobalInvocationID.x; vec4 v = mod(_23.in_data[ident], _33.out_data[ident]); _33.out_data[ident] = v; - uvec4 vu = (floatBitsToUint(_23.in_data[ident]) % floatBitsToUint(_33.out_data[ident])); + uvec4 vu = floatBitsToUint(_23.in_data[ident]) % floatBitsToUint(_33.out_data[ident]); _33.out_data[ident] = uintBitsToFloat(vu); - ivec4 vi = (floatBitsToInt(_23.in_data[ident]) % floatBitsToInt(_33.out_data[ident])); + ivec4 vi = floatBitsToInt(_23.in_data[ident]) % floatBitsToInt(_33.out_data[ident]); _33.out_data[ident] = intBitsToFloat(vi); } diff --git a/reference/shaders/comp/return.comp b/reference/shaders/comp/return.comp index 3ca656f8..ebbaac2d 100644 --- a/reference/shaders/comp/return.comp +++ b/reference/shaders/comp/return.comp @@ -9,22 +9,22 @@ layout(binding = 1, std430) buffer SSBO2 void main() { uint ident = gl_GlobalInvocationID.x; - if ((ident == 2u)) + if (ident == 2u) { _27.out_data[ident] = vec4(20.0); } else { - if ((ident == 4u)) + if (ident == 4u) { _27.out_data[ident] = vec4(10.0); return; } } int i = 0; - for (; (i < 20); i = (i + 1)) + for (; i < 20; i = i + 1) { - if ((i == 10)) + if (i == 10) { break; } diff --git a/reference/shaders/comp/shared.comp b/reference/shaders/comp/shared.comp index 8349872e..e2ff6045 100644 --- a/reference/shaders/comp/shared.comp +++ b/reference/shaders/comp/shared.comp @@ -9,7 +9,7 @@ layout(binding = 0, std430) buffer SSBO layout(binding = 1, std430) buffer SSBO2 { float out_data[]; -} _43; +} _44; shared float sShared[4]; @@ -20,6 +20,6 @@ void main() sShared[gl_LocalInvocationIndex] = idata; memoryBarrierShared(); barrier(); - _43.out_data[ident] = sShared[((4u - gl_LocalInvocationIndex) - 1u)]; + _44.out_data[ident] = sShared[(4u - gl_LocalInvocationIndex) - 1u]; } diff --git a/reference/shaders/comp/struct-layout.comp b/reference/shaders/comp/struct-layout.comp index 0aae525f..1cbf5dfb 100644 --- a/reference/shaders/comp/struct-layout.comp +++ b/reference/shaders/comp/struct-layout.comp @@ -19,6 +19,6 @@ layout(binding = 0, std430) buffer SSBO void main() { uint ident = gl_GlobalInvocationID.x; - _23.out_data[ident].m = (_30.in_data[ident].m * _30.in_data[ident].m); + _23.out_data[ident].m = _30.in_data[ident].m * _30.in_data[ident].m; } diff --git a/reference/shaders/comp/torture-loop.comp b/reference/shaders/comp/torture-loop.comp index 74335788..abcbb7c5 100644 --- a/reference/shaders/comp/torture-loop.comp +++ b/reference/shaders/comp/torture-loop.comp @@ -22,10 +22,10 @@ void main() int _39 = k; int _40 = _39 + 1; k = _40; - if ((_40 < 10)) + if (_40 < 10) { - idat = (idat * 2.0); - k = (k + 1); + idat = idat * 2.0; + k = k + 1; continue; } else @@ -34,18 +34,18 @@ void main() } } uint i = 0u; - for (; (i < 16u); i = (i + uint(1)), k = (k + 1)) + for (; i < 16u; i = i + uint(1), k = k + 1) { uint j = 0u; - for (; (j < 30u); j = (j + uint(1))) + for (; j < 30u; j = j + uint(1)) { - idat = (_24.mvp * idat); + idat = _24.mvp * idat; } } do { - k = (k + 1); - } while ((k > 10)); + k = k + 1; + } while (k > 10); _89.out_data[ident] = idat; } diff --git a/reference/shaders/comp/type-alias.comp b/reference/shaders/comp/type-alias.comp index 73632b77..51f3792e 100644 --- a/reference/shaders/comp/type-alias.comp +++ b/reference/shaders/comp/type-alias.comp @@ -44,6 +44,6 @@ void main() s1.a = _55.s1s[gl_GlobalInvocationID.x].a; S0 param = s0; S1 param_1 = s1; - _66.outputs[gl_GlobalInvocationID.x] = (overload(param) + overload(param_1)); + _66.outputs[gl_GlobalInvocationID.x] = overload(param) + overload(param_1); } diff --git a/reference/shaders/comp/udiv.comp b/reference/shaders/comp/udiv.comp index 1a75f728..0c1f926a 100644 --- a/reference/shaders/comp/udiv.comp +++ b/reference/shaders/comp/udiv.comp @@ -13,6 +13,6 @@ layout(binding = 0, std430) buffer SSBO void main() { - _10.outputs[gl_GlobalInvocationID.x] = (_23.inputs[gl_GlobalInvocationID.x] / 29u); + _10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u; } diff --git a/reference/shaders/desktop-only/comp/fp64.desktop.comp b/reference/shaders/desktop-only/comp/fp64.desktop.comp index a5cbe76e..b63fcdf7 100644 --- a/reference/shaders/desktop-only/comp/fp64.desktop.comp +++ b/reference/shaders/desktop-only/comp/fp64.desktop.comp @@ -37,8 +37,8 @@ layout(binding = 3, std140) buffer SSBO3 void main() { - ssbo_0.a = (ssbo_0.a + dvec4(10.0lf, 20.0lf, 30.0lf, 40.0lf)); - ssbo_0.a = (ssbo_0.a + dvec4(20.0lf)); + ssbo_0.a = ssbo_0.a + dvec4(10.0lf, 20.0lf, 30.0lf, 40.0lf); + ssbo_0.a = ssbo_0.a + dvec4(20.0lf); dvec4 a = ssbo_0.a; dmat4 amat = ssbo_0.b; ssbo_0.a = abs(a); @@ -68,7 +68,7 @@ void main() a = faceforward(a, a, a); a = reflect(a, a); a = refract(a, a, a.x); - dmat4 l = dmat4((amat[0] * amat[0]), (amat[1] * amat[1]), (amat[2] * amat[2]), (amat[3] * amat[3])); + dmat4 l = dmat4(amat[0] * amat[0], amat[1] * amat[1], amat[2] * amat[2], amat[3] * amat[3]); l = outerProduct(a, a); l = transpose(l); double m = determinant(l); @@ -77,8 +77,8 @@ void main() k = lessThanEqual(a, a); k = greaterThan(a, a); k = greaterThanEqual(a, a); - ssbo_1.b.x = (ssbo_1.b.x + 1.0lf); - ssbo_2.b[0].x = (ssbo_2.b[0].x + 1.0lf); - ssbo_3.b[0].x = (ssbo_3.b[0].x + 1.0lf); + ssbo_1.b.x = ssbo_1.b.x + 1.0lf; + ssbo_2.b[0].x = ssbo_2.b[0].x + 1.0lf; + ssbo_3.b[0].x = ssbo_3.b[0].x + 1.0lf; } diff --git a/reference/shaders/desktop-only/comp/int64.desktop.comp b/reference/shaders/desktop-only/comp/int64.desktop.comp index 5fda5aa4..b979cd2d 100644 --- a/reference/shaders/desktop-only/comp/int64.desktop.comp +++ b/reference/shaders/desktop-only/comp/int64.desktop.comp @@ -36,17 +36,17 @@ layout(binding = 3, std140) buffer SSBO3 void main() { - ssbo_0.a = (ssbo_0.a + i64vec4(10l, 20l, 30l, 40l)); - ssbo_1.b = (ssbo_1.b + u64vec4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul)); - ssbo_0.a = (ssbo_0.a + i64vec4(20l)); - ssbo_0.a = abs((ssbo_0.a + i64vec4(ssbo_1.b))); - ssbo_0.a = (ssbo_0.a + i64vec4(1l)); - ssbo_1.b = (ssbo_1.b + u64vec4(i64vec4(1l))); - ssbo_0.a = (ssbo_0.a - i64vec4(1l)); - ssbo_1.b = (ssbo_1.b - u64vec4(i64vec4(1l))); + ssbo_0.a = ssbo_0.a + i64vec4(10l, 20l, 30l, 40l); + ssbo_1.b = ssbo_1.b + u64vec4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul); + ssbo_0.a = ssbo_0.a + i64vec4(20l); + ssbo_0.a = abs(ssbo_0.a + i64vec4(ssbo_1.b)); + ssbo_0.a = ssbo_0.a + i64vec4(1l); + ssbo_1.b = ssbo_1.b + u64vec4(i64vec4(1l)); + ssbo_0.a = ssbo_0.a - i64vec4(1l); + ssbo_1.b = ssbo_1.b - u64vec4(i64vec4(1l)); ssbo_1.b = doubleBitsToUint64(int64BitsToDouble(ssbo_0.a)); ssbo_0.a = doubleBitsToInt64(uint64BitsToDouble(ssbo_1.b)); - ssbo_2.a[0] = (ssbo_2.a[0] + 1l); - ssbo_3.a[0] = (ssbo_3.a[0] + 2l); + ssbo_2.a[0] = ssbo_2.a[0] + 1l; + ssbo_3.a[0] = ssbo_3.a[0] + 2l; } diff --git a/reference/shaders/desktop-only/frag/in-block-qualifiers.frag b/reference/shaders/desktop-only/frag/in-block-qualifiers.frag index abb6a45a..281053c8 100644 --- a/reference/shaders/desktop-only/frag/in-block-qualifiers.frag +++ b/reference/shaders/desktop-only/frag/in-block-qualifiers.frag @@ -16,6 +16,6 @@ layout(location = 7) in sample float i; void main() { - FragColor = (((((((vec4(vin.f) + vin.g) + vec4(float(vin.h))) + vec4(vin.i)) + vec4(f)) + g) + vec4(float(h))) + vec4(i)); + FragColor = ((((((vec4(vin.f) + vin.g) + vec4(float(vin.h))) + vec4(vin.i)) + vec4(f)) + g) + vec4(float(h))) + vec4(i); } diff --git a/reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag b/reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag index 251603c9..4c30ed15 100644 --- a/reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag +++ b/reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag @@ -9,6 +9,6 @@ layout(location = 0) out vec4 FragColor; void main() { - FragColor = vec4(float((((textureSamples(uSampler) + textureSamples(uSamplerArray)) + imageSamples(uImage)) + imageSamples(uImageArray)))); + FragColor = vec4(float(((textureSamples(uSampler) + textureSamples(uSamplerArray)) + imageSamples(uImage)) + imageSamples(uImageArray))); } diff --git a/reference/shaders/frag/basic.frag b/reference/shaders/frag/basic.frag index c7c49727..f83b2815 100644 --- a/reference/shaders/frag/basic.frag +++ b/reference/shaders/frag/basic.frag @@ -10,6 +10,6 @@ in vec2 vTex; void main() { - FragColor = (vColor * texture(uTex, vTex)); + FragColor = vColor * texture(uTex, vTex); } diff --git a/reference/shaders/frag/composite-extract-forced-temporary.frag b/reference/shaders/frag/composite-extract-forced-temporary.frag index 78b28a99..e4384f55 100644 --- a/reference/shaders/frag/composite-extract-forced-temporary.frag +++ b/reference/shaders/frag/composite-extract-forced-temporary.frag @@ -10,6 +10,6 @@ layout(location = 0) out vec4 FragColor; void main() { float f = texture(Texture, vTexCoord).x; - FragColor = vec4((f * f)); + FragColor = vec4(f * f); } diff --git a/reference/shaders/frag/constant-array.frag b/reference/shaders/frag/constant-array.frag index 86eac2d0..ef9b7947 100644 --- a/reference/shaders/frag/constant-array.frag +++ b/reference/shaders/frag/constant-array.frag @@ -13,7 +13,7 @@ layout(location = 0) in mediump flat int index; vec4 resolve(Foobar f) { - return vec4((f.a + f.b)); + return vec4(f.a + f.b); } void main() @@ -23,6 +23,6 @@ void main() Foobar param = Foobar(10.0, 20.0); Foobar indexable_2[2] = Foobar[](Foobar(10.0, 40.0), Foobar(90.0, 70.0)); Foobar param_1 = indexable_2[index]; - FragColor = (((indexable[index] + indexable_1[index][(index + 1)]) + resolve(param)) + resolve(param_1)); + FragColor = ((indexable[index] + (indexable_1[index][index + 1])) + resolve(param)) + resolve(param_1); } diff --git a/reference/shaders/frag/ground.frag b/reference/shaders/frag/ground.frag index 7b0dda27..d9b655ea 100644 --- a/reference/shaders/frag/ground.frag +++ b/reference/shaders/frag/ground.frag @@ -29,16 +29,16 @@ float saturate(float x) void Resolve(vec3 Albedo, vec3 Normal, float Roughness, float Metallic) { LightingOut = vec4(0.0); - NormalOut = vec4(((Normal * 0.5) + vec3(0.5)), 0.0); + NormalOut = vec4((Normal * 0.5) + vec3(0.5), 0.0); SpecularOut = vec4(Roughness, Metallic, 0.0, 0.0); AlbedoOut = vec4(Albedo, 1.0); } void main() { - vec3 Normal = ((texture(TexNormalmap, TexCoord).xyz * 2.0) - vec3(1.0)); + vec3 Normal = (texture(TexNormalmap, TexCoord).xyz * 2.0) - vec3(1.0); Normal = normalize(Normal); - highp float param = (length(EyeVec) / 1000.0); + highp float param = length(EyeVec) / 1000.0; vec2 scatter_uv; scatter_uv.x = saturate(param); vec3 nEye = normalize(EyeVec); @@ -47,12 +47,12 @@ void main() vec3 grass = vec3(0.100000001490116119384765625, 0.300000011920928955078125, 0.100000001490116119384765625); vec3 dirt = vec3(0.100000001490116119384765625); vec3 snow = vec3(0.800000011920928955078125); - float grass_snow = smoothstep(0.0, 0.1500000059604644775390625, ((_56.g_CamPos.y + EyeVec.y) / 200.0)); + float grass_snow = smoothstep(0.0, 0.1500000059604644775390625, (_56.g_CamPos.y + EyeVec.y) / 200.0); vec3 base = mix(grass, snow, vec3(grass_snow)); float edge = smoothstep(0.699999988079071044921875, 0.75, Normal.y); Color = mix(dirt, base, vec3(edge)); - Color = (Color * Color); - float Roughness = (1.0 - (edge * grass_snow)); + Color = Color * Color; + float Roughness = 1.0 - (edge * grass_snow); highp vec3 param_1 = Color; highp vec3 param_2 = Normal; highp float param_3 = Roughness; diff --git a/reference/shaders/frag/pls.frag b/reference/shaders/frag/pls.frag index 77576b28..e0c8f270 100644 --- a/reference/shaders/frag/pls.frag +++ b/reference/shaders/frag/pls.frag @@ -13,9 +13,9 @@ in vec4 PLSIn3; void main() { - PLSOut0 = (PLSIn0 * 2.0); - PLSOut1 = (PLSIn1 * 6.0); - PLSOut2 = (PLSIn2 * 7.0); - PLSOut3 = (PLSIn3 * 4.0); + PLSOut0 = PLSIn0 * 2.0; + PLSOut1 = PLSIn1 * 6.0; + PLSOut2 = PLSIn2 * 7.0; + PLSOut3 = PLSIn3 * 4.0; } diff --git a/reference/shaders/frag/sampler-ms.frag b/reference/shaders/frag/sampler-ms.frag index 45fea2d6..dbab3fb8 100644 --- a/reference/shaders/frag/sampler-ms.frag +++ b/reference/shaders/frag/sampler-ms.frag @@ -9,6 +9,6 @@ layout(location = 0) out vec4 FragColor; void main() { ivec2 coord = ivec2(gl_FragCoord.xy); - FragColor = (((texelFetch(uSampler, coord, 0) + texelFetch(uSampler, coord, 1)) + texelFetch(uSampler, coord, 2)) + texelFetch(uSampler, coord, 3)); + FragColor = ((texelFetch(uSampler, coord, 0) + texelFetch(uSampler, coord, 1)) + texelFetch(uSampler, coord, 2)) + texelFetch(uSampler, coord, 3); } diff --git a/reference/shaders/frag/sampler.frag b/reference/shaders/frag/sampler.frag index af07f179..406cec6d 100644 --- a/reference/shaders/frag/sampler.frag +++ b/reference/shaders/frag/sampler.frag @@ -16,6 +16,6 @@ vec4 sample_texture(mediump sampler2D tex, vec2 uv) void main() { highp vec2 param = vTex; - FragColor = (vColor * sample_texture(uTex, param)); + FragColor = vColor * sample_texture(uTex, param); } diff --git a/reference/shaders/frag/swizzle.frag b/reference/shaders/frag/swizzle.frag index eb269a2e..e619be2f 100644 --- a/reference/shaders/frag/swizzle.frag +++ b/reference/shaders/frag/swizzle.frag @@ -12,9 +12,9 @@ void main() { FragColor = vec4(texture(samp, vUV).xyz, 1.0); FragColor = vec4(texture(samp, vUV).xz, 1.0, 4.0); - FragColor = vec4(texture(samp, vUV).xx, texture(samp, (vUV + vec2(0.100000001490116119384765625))).yy); + FragColor = vec4(texture(samp, vUV).xx, texture(samp, vUV + vec2(0.100000001490116119384765625)).yy); FragColor = vec4(vNormal, 1.0); - FragColor = vec4((vNormal + vec3(1.7999999523162841796875)), 1.0); - FragColor = vec4(vUV, (vUV + vec2(1.7999999523162841796875))); + FragColor = vec4(vNormal + vec3(1.7999999523162841796875), 1.0); + FragColor = vec4(vUV, vUV + vec2(1.7999999523162841796875)); } diff --git a/reference/shaders/frag/ubo_layout.frag b/reference/shaders/frag/ubo_layout.frag index 1ea3150f..bc0b01c0 100644 --- a/reference/shaders/frag/ubo_layout.frag +++ b/reference/shaders/frag/ubo_layout.frag @@ -21,6 +21,6 @@ layout(location = 0) out vec4 FragColor; void main() { - FragColor = (ubo1.foo.foo[0] + ubo0.foo.foo[0]); + FragColor = ubo1.foo.foo[0] + ubo0.foo.foo[0]; } diff --git a/reference/shaders/geom/basic.geom b/reference/shaders/geom/basic.geom index 11b95d5c..f2eea50a 100644 --- a/reference/shaders/geom/basic.geom +++ b/reference/shaders/geom/basic.geom @@ -13,13 +13,13 @@ in VertexData void main() { gl_Position = gl_in[0].gl_Position; - vNormal = (vin[0].normal + vec3(float(gl_InvocationID))); + vNormal = vin[0].normal + vec3(float(gl_InvocationID)); EmitVertex(); gl_Position = gl_in[1].gl_Position; - vNormal = (vin[1].normal + vec3((4.0 * float(gl_InvocationID)))); + vNormal = vin[1].normal + vec3(4.0 * float(gl_InvocationID)); EmitVertex(); gl_Position = gl_in[2].gl_Position; - vNormal = (vin[2].normal + vec3((2.0 * float(gl_InvocationID)))); + vNormal = vin[2].normal + vec3(2.0 * float(gl_InvocationID)); EmitVertex(); EndPrimitive(); } diff --git a/reference/shaders/tesc/water_tess.tesc b/reference/shaders/tesc/water_tess.tesc index 47e3043c..422a467e 100644 --- a/reference/shaders/tesc/water_tess.tesc +++ b/reference/shaders/tesc/water_tess.tesc @@ -18,66 +18,66 @@ in vec2 vPatchPosBase[32]; bool frustum_cull(vec2 p0) { - vec2 min_xz = ((p0 - vec2(10.0)) * _41.uScale.xy); - vec2 max_xz = (((p0 + _41.uPatchSize) + vec2(10.0)) * _41.uScale.xy); + vec2 min_xz = (p0 - vec2(10.0)) * _41.uScale.xy; + vec2 max_xz = ((p0 + _41.uPatchSize) + vec2(10.0)) * _41.uScale.xy; vec3 bb_min = vec3(min_xz.x, -10.0, min_xz.y); vec3 bb_max = vec3(max_xz.x, 10.0, max_xz.y); - vec3 center = ((bb_min + bb_max) * 0.5); - float radius = (0.5 * length((bb_max - bb_min))); + vec3 center = (bb_min + bb_max) * 0.5; + float radius = 0.5 * length(bb_max - bb_min); vec3 f0 = vec3(dot(_41.uFrustum[0], vec4(center, 1.0)), dot(_41.uFrustum[1], vec4(center, 1.0)), dot(_41.uFrustum[2], vec4(center, 1.0))); vec3 f1 = vec3(dot(_41.uFrustum[3], vec4(center, 1.0)), dot(_41.uFrustum[4], vec4(center, 1.0)), dot(_41.uFrustum[5], vec4(center, 1.0))); vec3 _199 = f0; - bool _205 = any(lessThanEqual(_199, vec3((-radius)))); + bool _205 = any(lessThanEqual(_199, vec3(-radius))); bool _215; - if ((!_205)) + if (!_205) { - _215 = any(lessThanEqual(f1, vec3((-radius)))); + _215 = any(lessThanEqual(f1, vec3(-radius))); } else { _215 = _205; } - return (!_215); + return !_215; } float lod_factor(vec2 pos_) { - vec2 pos = (pos_ * _41.uScale.xy); - vec3 dist_to_cam = (_41.uCamPos - vec3(pos.x, 0.0, pos.y)); - float level = log2(((length(dist_to_cam) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod)); + vec2 pos = pos_ * _41.uScale.xy; + vec3 dist_to_cam = _41.uCamPos - vec3(pos.x, 0.0, pos.y); + float level = log2((length(dist_to_cam) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod); return clamp(level, 0.0, _41.uMaxTessLevel.x); } vec4 tess_level(vec4 lod) { - return (exp2((-lod)) * _41.uMaxTessLevel.y); + return exp2(-lod) * _41.uMaxTessLevel.y; } float tess_level(float lod) { - return (_41.uMaxTessLevel.y * exp2((-lod))); + return _41.uMaxTessLevel.y * exp2(-lod); } void compute_tess_levels(vec2 p0) { vOutPatchPosBase = p0; - vec2 param = (p0 + (vec2(-0.5) * _41.uPatchSize)); + vec2 param = p0 + (vec2(-0.5) * _41.uPatchSize); float l00 = lod_factor(param); - vec2 param_1 = (p0 + (vec2(0.5, -0.5) * _41.uPatchSize)); + vec2 param_1 = p0 + (vec2(0.5, -0.5) * _41.uPatchSize); float l10 = lod_factor(param_1); - vec2 param_2 = (p0 + (vec2(1.5, -0.5) * _41.uPatchSize)); + vec2 param_2 = p0 + (vec2(1.5, -0.5) * _41.uPatchSize); float l20 = lod_factor(param_2); - vec2 param_3 = (p0 + (vec2(-0.5, 0.5) * _41.uPatchSize)); + vec2 param_3 = p0 + (vec2(-0.5, 0.5) * _41.uPatchSize); float l01 = lod_factor(param_3); - vec2 param_4 = (p0 + (vec2(0.5) * _41.uPatchSize)); + vec2 param_4 = p0 + (vec2(0.5) * _41.uPatchSize); float l11 = lod_factor(param_4); - vec2 param_5 = (p0 + (vec2(1.5, 0.5) * _41.uPatchSize)); + vec2 param_5 = p0 + (vec2(1.5, 0.5) * _41.uPatchSize); float l21 = lod_factor(param_5); - vec2 param_6 = (p0 + (vec2(-0.5, 1.5) * _41.uPatchSize)); + vec2 param_6 = p0 + (vec2(-0.5, 1.5) * _41.uPatchSize); float l02 = lod_factor(param_6); - vec2 param_7 = (p0 + (vec2(0.5, 1.5) * _41.uPatchSize)); + vec2 param_7 = p0 + (vec2(0.5, 1.5) * _41.uPatchSize); float l12 = lod_factor(param_7); - vec2 param_8 = (p0 + (vec2(1.5) * _41.uPatchSize)); + vec2 param_8 = p0 + (vec2(1.5) * _41.uPatchSize); float l22 = lod_factor(param_8); vec4 lods = vec4(dot(vec4(l01, l11, l02, l12), vec4(0.25)), dot(vec4(l00, l10, l01, l11), vec4(0.25)), dot(vec4(l10, l20, l11, l21), vec4(0.25)), dot(vec4(l11, l21, l12, l22), vec4(0.25))); vPatchLods = lods; @@ -99,7 +99,7 @@ void main() { vec2 p0 = vPatchPosBase[0]; vec2 param = p0; - if ((!frustum_cull(param))) + if (!frustum_cull(param)) { gl_TessLevelOuter[0] = -1.0; gl_TessLevelOuter[1] = -1.0; diff --git a/reference/shaders/tese/water_tess.tese b/reference/shaders/tese/water_tess.tese index 002a26e0..029f5c9e 100644 --- a/reference/shaders/tese/water_tess.tese +++ b/reference/shaders/tese/water_tess.tese @@ -21,7 +21,7 @@ out vec3 vWorld; vec2 lerp_vertex(vec2 tess_coord) { - return (vOutPatchPosBase + (tess_coord * _31.uPatchSize)); + return vOutPatchPosBase + (tess_coord * _31.uPatchSize); } mediump vec2 lod_factor(vec2 tess_coord) @@ -29,13 +29,13 @@ mediump vec2 lod_factor(vec2 tess_coord) mediump vec2 x = mix(vPatchLods.yx, vPatchLods.zw, vec2(tess_coord.x)); mediump float level = mix(x.x, x.y, tess_coord.y); mediump float floor_level = floor(level); - mediump float fract_level = (level - floor_level); + mediump float fract_level = level - floor_level; return vec2(floor_level, fract_level); } mediump vec3 sample_height_displacement(vec2 uv, vec2 off, mediump vec2 lod) { - return mix(textureLod(uHeightmapDisplacement, (uv + (off * 0.5)), lod.x).xyz, textureLod(uHeightmapDisplacement, (uv + (off * 1.0)), (lod.x + 1.0)).xyz, vec3(lod.y)); + return mix(textureLod(uHeightmapDisplacement, uv + (off * 0.5), lod.x).xyz, textureLod(uHeightmapDisplacement, uv + (off * 1.0), lod.x + 1.0).xyz, vec3(lod.y)); } void main() @@ -45,17 +45,17 @@ void main() vec2 pos = lerp_vertex(param); vec2 param_1 = tess_coord; mediump vec2 lod = lod_factor(param_1); - vec2 tex = (pos * _31.uInvHeightmapSize); - pos = (pos * _31.uScale.xy); + vec2 tex = pos * _31.uInvHeightmapSize; + pos = pos * _31.uScale.xy; mediump float delta_mod = exp2(lod.x); - vec2 off = (_31.uInvHeightmapSize * delta_mod); - vGradNormalTex = vec4((tex + (_31.uInvHeightmapSize * 0.5)), (tex * _31.uScale.zw)); + vec2 off = _31.uInvHeightmapSize * delta_mod; + vGradNormalTex = vec4(tex + (_31.uInvHeightmapSize * 0.5), tex * _31.uScale.zw); vec2 param_2 = tex; vec2 param_3 = off; vec2 param_4 = lod; vec3 height_displacement = sample_height_displacement(param_2, param_3, param_4); - pos = (pos + height_displacement.yz); + pos = pos + height_displacement.yz; vWorld = vec3(pos.x, height_displacement.x, pos.y); - gl_Position = (_31.uMVP * vec4(vWorld, 1.0)); + gl_Position = _31.uMVP * vec4(vWorld, 1.0); } diff --git a/reference/shaders/vert/basic.vert b/reference/shaders/vert/basic.vert index fc81060c..429b36d5 100644 --- a/reference/shaders/vert/basic.vert +++ b/reference/shaders/vert/basic.vert @@ -11,7 +11,7 @@ in vec3 aNormal; void main() { - gl_Position = (_16.uMVP * aVertex); + gl_Position = _16.uMVP * aVertex; vNormal = aNormal; } diff --git a/reference/shaders/vert/ground.vert b/reference/shaders/vert/ground.vert index 0799f665..41de1063 100644 --- a/reference/shaders/vert/ground.vert +++ b/reference/shaders/vert/ground.vert @@ -54,12 +54,12 @@ vec2 warp_position() float vlod = dot(LODWeights, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); vlod = mix(vlod, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w, all(equal(LODWeights, vec4(0.0)))); float floor_lod = floor(vlod); - float fract_lod = (vlod - floor_lod); + float fract_lod = vlod - floor_lod; uint ufloor_lod = uint(floor_lod); uvec2 uPosition = uvec2(Position); - uvec2 mask = ((uvec2(1u) << uvec2(ufloor_lod, (ufloor_lod + 1u))) - uvec2(1u)); + uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - uvec2(1u); uint _332; - if ((uPosition.x < 32u)) + if (uPosition.x < 32u) { _332 = mask.x; } @@ -69,7 +69,7 @@ vec2 warp_position() } uint _342 = _332; uint _343; - if ((uPosition.y < 32u)) + if (uPosition.y < 32u) { _343 = mask.y; } @@ -78,33 +78,33 @@ vec2 warp_position() _343 = 0u; } uvec2 rounding = uvec2(_342, _343); - vec4 lower_upper_snapped = vec4(((uPosition + rounding).xyxy & (~mask).xxyy)); + vec4 lower_upper_snapped = vec4((uPosition + rounding).xyxy & ~mask.xxyy); return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, vec2(fract_lod)); } vec2 lod_factor(vec2 uv) { - float level = (textureLod(TexLOD, uv, 0.0).x * 7.96875); + float level = textureLod(TexLOD, uv, 0.0).x * 7.96875; float floor_level = floor(level); - float fract_level = (level - floor_level); + float fract_level = level - floor_level; return vec2(floor_level, fract_level); } void main() { - vec2 PatchPos = (_284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _381.InvGroundSize_PatchScale.zw); + vec2 PatchPos = _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _381.InvGroundSize_PatchScale.zw; vec2 WarpedPos = warp_position(); - vec2 VertexPos = (PatchPos + WarpedPos); - vec2 NormalizedPos = (VertexPos * _381.InvGroundSize_PatchScale.xy); + vec2 VertexPos = PatchPos + WarpedPos; + vec2 NormalizedPos = VertexPos * _381.InvGroundSize_PatchScale.xy; vec2 param = NormalizedPos; vec2 lod = lod_factor(param); - vec2 Offset = (_381.InvGroundSize_PatchScale.xy * exp2(lod.x)); - float Elevation = mix(textureLod(TexHeightmap, (NormalizedPos + (Offset * 0.5)), lod.x).x, textureLod(TexHeightmap, (NormalizedPos + (Offset * 1.0)), (lod.x + 1.0)).x, lod.y); + vec2 Offset = _381.InvGroundSize_PatchScale.xy * exp2(lod.x); + float Elevation = mix(textureLod(TexHeightmap, NormalizedPos + (Offset * 0.5), lod.x).x, textureLod(TexHeightmap, NormalizedPos + (Offset * 1.0), lod.x + 1.0).x, lod.y); vec3 WorldPos = vec3(NormalizedPos.x, Elevation, NormalizedPos.y); - WorldPos = (WorldPos * _381.GroundScale.xyz); - WorldPos = (WorldPos + _381.GroundPosition.xyz); - EyeVec = (WorldPos - _58.g_CamPos.xyz); - TexCoord = (NormalizedPos + (_381.InvGroundSize_PatchScale.xy * 0.5)); - gl_Position = ((((_58.g_ViewProj_Row0 * WorldPos.x) + (_58.g_ViewProj_Row1 * WorldPos.y)) + (_58.g_ViewProj_Row2 * WorldPos.z)) + _58.g_ViewProj_Row3); + WorldPos = WorldPos * _381.GroundScale.xyz; + WorldPos = WorldPos + _381.GroundPosition.xyz; + EyeVec = WorldPos - _58.g_CamPos.xyz; + TexCoord = NormalizedPos + (_381.InvGroundSize_PatchScale.xy * 0.5); + gl_Position = (((_58.g_ViewProj_Row0 * WorldPos.x) + (_58.g_ViewProj_Row1 * WorldPos.y)) + (_58.g_ViewProj_Row2 * WorldPos.z)) + _58.g_ViewProj_Row3; } diff --git a/reference/shaders/vert/ocean.vert b/reference/shaders/vert/ocean.vert index e53bd806..76d07675 100644 --- a/reference/shaders/vert/ocean.vert +++ b/reference/shaders/vert/ocean.vert @@ -55,12 +55,12 @@ vec2 warp_position() float vlod = dot(LODWeights, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); vlod = mix(vlod, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w, all(equal(LODWeights, vec4(0.0)))); float floor_lod = floor(vlod); - float fract_lod = (vlod - floor_lod); + float fract_lod = vlod - floor_lod; uint ufloor_lod = uint(floor_lod); uvec4 uPosition = uvec4(Position); - uvec2 mask = ((uvec2(1u) << uvec2(ufloor_lod, (ufloor_lod + 1u))) - uvec2(1u)); + uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - uvec2(1u); uint _333; - if ((uPosition.x < 32u)) + if (uPosition.x < 32u) { _333 = mask.x; } @@ -71,7 +71,7 @@ vec2 warp_position() uvec4 rounding; rounding.x = _333; uint _345; - if ((uPosition.y < 32u)) + if (uPosition.y < 32u) { _345 = mask.x; } @@ -81,7 +81,7 @@ vec2 warp_position() } rounding.y = _345; uint _356; - if ((uPosition.x < 32u)) + if (uPosition.x < 32u) { _356 = mask.y; } @@ -91,7 +91,7 @@ vec2 warp_position() } rounding.z = _356; uint _368; - if ((uPosition.y < 32u)) + if (uPosition.y < 32u) { _368 = mask.y; } @@ -100,34 +100,34 @@ vec2 warp_position() _368 = 0u; } rounding.w = _368; - vec4 lower_upper_snapped = vec4(((uPosition.xyxy + rounding) & (~mask).xxyy)); + vec4 lower_upper_snapped = vec4((uPosition.xyxy + rounding) & ~mask.xxyy); return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, vec2(fract_lod)); } vec2 lod_factor(vec2 uv) { - float level = (textureLod(TexLOD, uv, 0.0).x * 7.96875); + float level = textureLod(TexLOD, uv, 0.0).x * 7.96875; float floor_level = floor(level); - float fract_level = (level - floor_level); + float fract_level = level - floor_level; return vec2(floor_level, fract_level); } void main() { - vec2 PatchPos = (_284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _405.InvOceanSize_PatchScale.zw); + vec2 PatchPos = _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _405.InvOceanSize_PatchScale.zw; vec2 WarpedPos = warp_position(); - vec2 VertexPos = (PatchPos + WarpedPos); - vec2 NormalizedPos = (VertexPos * _405.InvOceanSize_PatchScale.xy); - vec2 NormalizedTex = (NormalizedPos * _405.NormalTexCoordScale.zw); + vec2 VertexPos = PatchPos + WarpedPos; + vec2 NormalizedPos = VertexPos * _405.InvOceanSize_PatchScale.xy; + vec2 NormalizedTex = NormalizedPos * _405.NormalTexCoordScale.zw; vec2 param = NormalizedPos; vec2 lod = lod_factor(param); - vec2 Offset = ((_405.InvOceanSize_PatchScale.xy * exp2(lod.x)) * _405.NormalTexCoordScale.zw); - vec3 Displacement = mix(textureLod(TexDisplacement, (NormalizedTex + (Offset * 0.5)), lod.x).yxz, textureLod(TexDisplacement, (NormalizedTex + (Offset * 1.0)), (lod.x + 1.0)).yxz, vec3(lod.y)); - vec3 WorldPos = (vec3(NormalizedPos.x, 0.0, NormalizedPos.y) + Displacement); - WorldPos = (WorldPos * _405.OceanScale.xyz); - WorldPos = (WorldPos + _405.OceanPosition.xyz); - EyeVec = (WorldPos - _58.g_CamPos.xyz); - TexCoord = (vec4(NormalizedTex, (NormalizedTex * _405.NormalTexCoordScale.xy)) + ((_405.InvOceanSize_PatchScale.xyxy * 0.5) * _405.NormalTexCoordScale.zwzw)); - gl_Position = ((((_58.g_ViewProj_Row0 * WorldPos.x) + (_58.g_ViewProj_Row1 * WorldPos.y)) + (_58.g_ViewProj_Row2 * WorldPos.z)) + _58.g_ViewProj_Row3); + vec2 Offset = (_405.InvOceanSize_PatchScale.xy * exp2(lod.x)) * _405.NormalTexCoordScale.zw; + vec3 Displacement = mix(textureLod(TexDisplacement, NormalizedTex + (Offset * 0.5), lod.x).yxz, textureLod(TexDisplacement, NormalizedTex + (Offset * 1.0), lod.x + 1.0).yxz, vec3(lod.y)); + vec3 WorldPos = vec3(NormalizedPos.x, 0.0, NormalizedPos.y) + Displacement; + WorldPos = WorldPos * _405.OceanScale.xyz; + WorldPos = WorldPos + _405.OceanPosition.xyz; + EyeVec = WorldPos - _58.g_CamPos.xyz; + TexCoord = vec4(NormalizedTex, NormalizedTex * _405.NormalTexCoordScale.xy) + ((_405.InvOceanSize_PatchScale.xyxy * 0.5) * _405.NormalTexCoordScale.zwzw); + gl_Position = (((_58.g_ViewProj_Row0 * WorldPos.x) + (_58.g_ViewProj_Row1 * WorldPos.y)) + (_58.g_ViewProj_Row2 * WorldPos.z)) + _58.g_ViewProj_Row3; } diff --git a/reference/shaders/vert/texture_buffer.vert b/reference/shaders/vert/texture_buffer.vert index b5fa0dc1..0a198e75 100644 --- a/reference/shaders/vert/texture_buffer.vert +++ b/reference/shaders/vert/texture_buffer.vert @@ -6,6 +6,6 @@ layout(binding = 5, rgba32f) uniform highp readonly imageBuffer uSampo; void main() { - gl_Position = (texelFetch(uSamp, 10) + imageLoad(uSampo, 100)); + gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100); } diff --git a/reference/shaders/vert/ubo.vert b/reference/shaders/vert/ubo.vert index 6e38dde1..335c1fe1 100644 --- a/reference/shaders/vert/ubo.vert +++ b/reference/shaders/vert/ubo.vert @@ -11,7 +11,7 @@ in vec3 aNormal; void main() { - gl_Position = (_16.mvp * aVertex); + gl_Position = _16.mvp * aVertex; vNormal = aNormal; } diff --git a/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag b/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag index 729aa899..5b9c0dda 100644 --- a/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag +++ b/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag @@ -19,21 +19,21 @@ vec4 sample_duals() { vec4 a = sample_dual(SPIRV_Cross_CombineduTexture0uSampler0); vec4 b = sample_dual(SPIRV_Cross_CombineduTexture1uSampler1); - return (a + b); + return a + b; } vec4 sample_global_tex(mediump sampler2D SPIRV_Cross_CombineduTexture0samp, mediump sampler2D SPIRV_Cross_CombineduTexture1samp) { vec4 a = texture(SPIRV_Cross_CombineduTexture0samp, vTex); vec4 b = sample_dual(SPIRV_Cross_CombineduTexture1samp); - return (a + b); + return a + b; } vec4 sample_global_sampler(mediump sampler2D SPIRV_Cross_CombinedtexuSampler0, mediump sampler2D SPIRV_Cross_CombinedtexuSampler1) { vec4 a = texture(SPIRV_Cross_CombinedtexuSampler0, vTex); vec4 b = sample_dual(SPIRV_Cross_CombinedtexuSampler1); - return (a + b); + return a + b; } void main() @@ -43,6 +43,6 @@ void main() vec4 c2 = sample_global_tex(SPIRV_Cross_CombineduTexture0uSampler1, SPIRV_Cross_CombineduTexture1uSampler1); vec4 c3 = sample_global_sampler(SPIRV_Cross_CombineduTexture0uSampler0, SPIRV_Cross_CombineduTexture0uSampler1); vec4 c4 = sample_global_sampler(SPIRV_Cross_CombineduTexture1uSampler0, SPIRV_Cross_CombineduTexture1uSampler1); - FragColor = ((((c0 + c1) + c2) + c3) + c4); + FragColor = (((c0 + c1) + c2) + c3) + c4; } diff --git a/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk b/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk index 125a2a73..ae8df4c9 100644 --- a/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk +++ b/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk @@ -19,21 +19,21 @@ vec4 sample_duals() { vec4 a = sample_dual(uSampler0, uTexture0); vec4 b = sample_dual(uSampler1, uTexture1); - return (a + b); + return a + b; } vec4 sample_global_tex(mediump sampler samp) { vec4 a = texture(sampler2D(uTexture0, samp), vTex); vec4 b = sample_dual(samp, uTexture1); - return (a + b); + return a + b; } vec4 sample_global_sampler(mediump texture2D tex) { vec4 a = texture(sampler2D(tex, uSampler0), vTex); vec4 b = sample_dual(uSampler1, tex); - return (a + b); + return a + b; } void main() @@ -43,6 +43,6 @@ void main() vec4 c2 = sample_global_tex(uSampler1); vec4 c3 = sample_global_sampler(uTexture0); vec4 c4 = sample_global_sampler(uTexture1); - FragColor = ((((c0 + c1) + c2) + c3) + c4); + FragColor = (((c0 + c1) + c2) + c3) + c4; } diff --git a/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag b/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag index 7d745633..cb6745be 100644 --- a/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag +++ b/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag @@ -9,6 +9,6 @@ layout(location = 0) out vec4 FragColor; void main() { - FragColor = (texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 1) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 2)); + FragColor = texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 1) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 2); } diff --git a/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk b/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk index 99a814c3..488c8939 100644 --- a/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk +++ b/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk @@ -9,6 +9,6 @@ layout(location = 0) out vec4 FragColor; void main() { - FragColor = (subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2)); + FragColor = subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2); } diff --git a/reference/shaders/vulkan/frag/input-attachment.vk.frag b/reference/shaders/vulkan/frag/input-attachment.vk.frag index 9d7b675b..8d216b2c 100644 --- a/reference/shaders/vulkan/frag/input-attachment.vk.frag +++ b/reference/shaders/vulkan/frag/input-attachment.vk.frag @@ -9,6 +9,6 @@ layout(location = 0) out vec4 FragColor; void main() { - FragColor = (texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 0) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 0)); + FragColor = texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 0) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 0); } diff --git a/reference/shaders/vulkan/frag/input-attachment.vk.frag.vk b/reference/shaders/vulkan/frag/input-attachment.vk.frag.vk index 1a2de44f..c8b5d9a7 100644 --- a/reference/shaders/vulkan/frag/input-attachment.vk.frag.vk +++ b/reference/shaders/vulkan/frag/input-attachment.vk.frag.vk @@ -9,6 +9,6 @@ layout(location = 0) out vec4 FragColor; void main() { - FragColor = (subpassLoad(uSubpass0) + subpassLoad(uSubpass1)); + FragColor = subpassLoad(uSubpass0) + subpassLoad(uSubpass1); } diff --git a/reference/shaders/vulkan/frag/push-constant.vk.frag b/reference/shaders/vulkan/frag/push-constant.vk.frag index eee4ccdb..c04a7ca4 100644 --- a/reference/shaders/vulkan/frag/push-constant.vk.frag +++ b/reference/shaders/vulkan/frag/push-constant.vk.frag @@ -15,6 +15,6 @@ layout(location = 0) in vec4 vColor; void main() { - FragColor = ((vColor + push.value0) + push.value1); + FragColor = (vColor + push.value0) + push.value1; } diff --git a/reference/shaders/vulkan/frag/push-constant.vk.frag.vk b/reference/shaders/vulkan/frag/push-constant.vk.frag.vk index 748a0286..6cec90f1 100644 --- a/reference/shaders/vulkan/frag/push-constant.vk.frag.vk +++ b/reference/shaders/vulkan/frag/push-constant.vk.frag.vk @@ -13,6 +13,6 @@ layout(location = 0) in vec4 vColor; void main() { - FragColor = ((vColor + push.value0) + push.value1); + FragColor = (vColor + push.value0) + push.value1; } diff --git a/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag b/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag index 3271439a..78477cfb 100644 --- a/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag +++ b/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag @@ -23,15 +23,15 @@ vec4 sample_func_dual(vec2 uv, mediump sampler2D SPIRV_Cross_Combinedtexsamp) void main() { - vec2 off = (vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 0))); - vec2 off2 = (vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 1))); - highp vec2 param = ((vTex + off) + off2); + vec2 off = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 0)); + vec2 off2 = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 1)); + highp vec2 param = (vTex + off) + off2; vec4 c0 = sample_func(param, SPIRV_Cross_CombineduTextureuSampler); - highp vec2 param_1 = ((vTex + off) + off2); + highp vec2 param_1 = (vTex + off) + off2; vec4 c1 = sample_func_dual(param_1, SPIRV_Cross_CombineduTextureuSampler); vec4 c2 = texture(SPIRV_Cross_CombineduTextureArrayuSampler, vTex3); vec4 c3 = texture(SPIRV_Cross_CombineduTextureCubeuSampler, vTex3); vec4 c4 = texture(SPIRV_Cross_CombineduTexture3DuSampler, vTex3); - FragColor = ((((c0 + c1) + c2) + c3) + c4); + FragColor = (((c0 + c1) + c2) + c3) + c4; } diff --git a/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk b/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk index e3120008..cfa2f396 100644 --- a/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk +++ b/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk @@ -24,15 +24,15 @@ vec4 sample_func_dual(mediump sampler samp, mediump texture2D tex, vec2 uv) void main() { - vec2 off = (vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 0))); - vec2 off2 = (vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 1))); - highp vec2 param = ((vTex + off) + off2); + vec2 off = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 0)); + vec2 off2 = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 1)); + highp vec2 param = (vTex + off) + off2; vec4 c0 = sample_func(uSampler, param); - highp vec2 param_1 = ((vTex + off) + off2); + highp vec2 param_1 = (vTex + off) + off2; vec4 c1 = sample_func_dual(uSampler, uTexture, param_1); vec4 c2 = texture(sampler2DArray(uTextureArray, uSampler), vTex3); vec4 c3 = texture(samplerCube(uTextureCube, uSampler), vTex3); vec4 c4 = texture(sampler3D(uTexture3D, uSampler), vTex3); - FragColor = ((((c0 + c1) + c2) + c3) + c4); + FragColor = (((c0 + c1) + c2) + c3) + c4; } diff --git a/reference/shaders/vulkan/frag/spec-constant.vk.frag b/reference/shaders/vulkan/frag/spec-constant.vk.frag index 0785cfd5..6fa15eeb 100644 --- a/reference/shaders/vulkan/frag/spec-constant.vk.frag +++ b/reference/shaders/vulkan/frag/spec-constant.vk.frag @@ -44,7 +44,7 @@ void main() bool c28 = (5u <= 6u); bool c29 = (3 >= 4); bool c30 = (5u >= 6u); - mediump int c31 = (c8 + c3); + mediump int c31 = c8 + c3; mediump int c32 = int(5u + 0u); bool c33 = (3 != int(0u)); bool c34 = (5u != 0u); @@ -54,6 +54,6 @@ void main() float vec0[4][(3 + 3)]; float vec1[(3 + 2)][(4 + 5)]; Foo foo; - FragColor = (((vec4((t0 + t1)) + vec4(vec0[0][0])) + vec4(vec1[0][0])) + vec4(foo.elems[3])); + FragColor = ((vec4(t0 + t1) + vec4(vec0[0][0])) + vec4(vec1[0][0])) + vec4(foo.elems[3]); } diff --git a/reference/shaders/vulkan/frag/spec-constant.vk.frag.vk b/reference/shaders/vulkan/frag/spec-constant.vk.frag.vk index f8e241be..14747d10 100644 --- a/reference/shaders/vulkan/frag/spec-constant.vk.frag.vk +++ b/reference/shaders/vulkan/frag/spec-constant.vk.frag.vk @@ -53,7 +53,7 @@ void main() bool c28 = (_34 <= _35); bool c29 = (_16 >= _25); bool c30 = (_34 >= _35); - mediump int c31 = (c8 + c3); + mediump int c31 = c8 + c3; mediump int c32 = int(_34 + 0u); bool c33 = (_16 != int(0u)); bool c34 = (_34 != 0u); @@ -63,6 +63,6 @@ void main() float vec0[_25][(_16 + 3)]; float vec1[(_16 + 2)][(_25 + 5)]; Foo foo; - FragColor = (((vec4((t0 + t1)) + vec4(vec0[0][0])) + vec4(vec1[0][0])) + vec4(foo.elems[_16])); + FragColor = ((vec4(t0 + t1) + vec4(vec0[0][0])) + vec4(vec1[0][0])) + vec4(foo.elems[_16]); } diff --git a/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert b/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert index 8de2b111..60ba1882 100644 --- a/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert +++ b/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert @@ -4,6 +4,6 @@ uniform int SPIRV_Cross_BaseInstance; void main() { - gl_Position = (vec4(1.0, 2.0, 3.0, 4.0) * float((gl_VertexID + (gl_InstanceID + SPIRV_Cross_BaseInstance)))); + gl_Position = vec4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexID + (gl_InstanceID + SPIRV_Cross_BaseInstance)); } diff --git a/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk b/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk index 9ee3cc09..8c4930d7 100644 --- a/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk +++ b/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk @@ -2,6 +2,6 @@ void main() { - gl_Position = (vec4(1.0, 2.0, 3.0, 4.0) * float((gl_VertexIndex + gl_InstanceIndex))); + gl_Position = vec4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexIndex + gl_InstanceIndex); } diff --git a/shaders/comp/defer-parens.comp b/shaders/comp/defer-parens.comp new file mode 100644 index 00000000..4e8ea6b3 --- /dev/null +++ b/shaders/comp/defer-parens.comp @@ -0,0 +1,30 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + vec4 data; + int index; +}; + +void main() +{ + // Tests defer-parens behavior where a binary expression is OpCompositeExtracted chained together + // with an OpCompositeConstruct optimization. + vec4 d = data; + data = vec4(d.x, d.yz + 10.0, d.w); + + // Verify binary ops. + data = d + d + d; + + // Verify swizzles. + data = (d.yz + 10.0).xxyy; + + // OpCompositeExtract + float t = (d.yz + 10.0).y; + data = vec4(t); + + // OpVectorExtractDynamic + t = (d.zw + 10.0)[index]; + data = vec4(t); +} diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 42e6dda4..cb22fc72 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -1220,7 +1220,7 @@ string CompilerGLSL::remap_swizzle(uint32_t result_type, uint32_t input_componen return join(type_to_glsl(out_type), "(", to_expression(expr), ")"); else { - auto e = to_expression(expr) + "."; + auto e = to_enclosed_expression(expr) + "."; // Just clamp the swizzle index if we have more outputs than inputs. for (uint32_t c = 0; c < out_type.vecsize; c++) e += index_to_swizzle(min(c, input_components - 1)); @@ -1454,6 +1454,64 @@ void CompilerGLSL::handle_invalid_expression(uint32_t id) force_recompile = true; } +// Sometimes we proactively enclosed an expression where it turns out we might have not needed it after all. +void CompilerGLSL::strip_enclosed_expression(string &expr) +{ + if (expr.size() < 2 || expr.front() != '(' || expr.back() != ')') + return; + + // Have to make sure that our first and last parens actually enclose everything inside it. + uint32_t paren_count = 0; + for (auto &c : expr) + { + if (c == '(') + paren_count++; + else if (c == ')') + { + paren_count--; + + // If we hit 0 and this is not the final char, our first and final parens actually don't + // enclose the expression, and we cannot strip, e.g.: (a + b) * (c + d). + if (paren_count == 0 && &c != &expr.back()) + return; + } + } + expr.pop_back(); + expr.erase(begin(expr)); +} + +// Just like to_expression except that we enclose the expression inside parentheses if needed. +string CompilerGLSL::to_enclosed_expression(uint32_t id) +{ + auto expr = to_expression(id); + bool need_parens = false; + uint32_t paren_count = 0; + for (auto c : expr) + { + if (c == '(') + paren_count++; + else if (c == ')') + { + assert(paren_count); + paren_count--; + } + else if (c == ' ' && paren_count == 0) + { + need_parens = true; + break; + } + } + assert(paren_count == 0); + + // If this expression contains any spaces which are not enclosed by parentheses, + // we need to enclose it so we can treat the whole string as an expression. + // This happens when two expressions have been part of a binary op earlier. + if (need_parens) + return join('(', expr, ')'); + else + return expr; +} + string CompilerGLSL::to_expression(uint32_t id) { auto itr = invalid_expressions.find(id); @@ -1487,7 +1545,7 @@ string CompilerGLSL::to_expression(uint32_t id) { auto &e = get(id); if (e.base_expression) - return to_expression(e.base_expression) + e.expression; + return to_enclosed_expression(e.base_expression) + e.expression; else return e.expression; } @@ -1922,7 +1980,7 @@ bool CompilerGLSL::expression_is_forwarded(uint32_t id) } SPIRExpression &CompilerGLSL::emit_op(uint32_t result_type, uint32_t result_id, const string &rhs, bool forwarding, - bool extra_parens, bool suppress_usage_tracking) + bool suppress_usage_tracking) { if (forwarding && (forced_temporaries.find(result_id) == end(forced_temporaries))) { @@ -1931,10 +1989,7 @@ SPIRExpression &CompilerGLSL::emit_op(uint32_t result_type, uint32_t result_id, if (!suppress_usage_tracking) forwarded_temporaries.insert(result_id); - if (extra_parens) - return set(result_id, join("(", rhs, ")"), result_type, true); - else - return set(result_id, rhs, result_type, true); + return set(result_id, rhs, result_type, true); } else { @@ -1947,7 +2002,7 @@ SPIRExpression &CompilerGLSL::emit_op(uint32_t result_type, uint32_t result_id, void CompilerGLSL::emit_unary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op) { bool forward = should_forward(op0); - emit_op(result_type, result_id, join(op, to_expression(op0)), forward, true); + emit_op(result_type, result_id, join(op, to_enclosed_expression(op0)), forward); if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) inherit_expression_dependencies(result_id, op0); @@ -1956,7 +2011,8 @@ void CompilerGLSL::emit_unary_op(uint32_t result_type, uint32_t result_id, uint3 void CompilerGLSL::emit_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op) { bool forward = should_forward(op0) && should_forward(op1); - emit_op(result_type, result_id, join(to_expression(op0), " ", op, " ", to_expression(op1)), forward, true); + emit_op(result_type, result_id, join(to_enclosed_expression(op0), " ", op, " ", to_enclosed_expression(op1)), + forward); if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) { @@ -1992,8 +2048,8 @@ SPIRType CompilerGLSL::binary_op_bitcast_helper(string &cast_op0, string &cast_o else { // If we don't cast, our actual input type is that of the first (or second) argument. - cast_op0 = to_expression(op0); - cast_op1 = to_expression(op1); + cast_op0 = to_enclosed_expression(op0); + cast_op1 = to_enclosed_expression(op1); input_type = type0.basetype; } @@ -2010,7 +2066,6 @@ void CompilerGLSL::emit_binary_op_cast(uint32_t result_type, uint32_t result_id, // We might have casted away from the result type, so bitcast again. // For example, arithmetic right shift with uint inputs. // Special case boolean outputs since relational opcodes output booleans instead of int/uint. - bool extra_parens = true; string expr; if (out_type.basetype != input_type && out_type.basetype != SPIRType::Boolean) { @@ -2019,18 +2074,17 @@ void CompilerGLSL::emit_binary_op_cast(uint32_t result_type, uint32_t result_id, expr += '('; expr += join(cast_op0, " ", op, " ", cast_op1); expr += ')'; - extra_parens = false; } else expr += join(cast_op0, " ", op, " ", cast_op1); - emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1), extra_parens); + emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1)); } void CompilerGLSL::emit_unary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op) { bool forward = should_forward(op0); - emit_op(result_type, result_id, join(op, "(", to_expression(op0), ")"), forward, false); + emit_op(result_type, result_id, join(op, "(", to_expression(op0), ")"), forward); if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) inherit_expression_dependencies(result_id, op0); } @@ -2039,7 +2093,7 @@ void CompilerGLSL::emit_binary_func_op(uint32_t result_type, uint32_t result_id, const char *op) { bool forward = should_forward(op0) && should_forward(op1); - emit_op(result_type, result_id, join(op, "(", to_expression(op0), ", ", to_expression(op1), ")"), forward, false); + emit_op(result_type, result_id, join(op, "(", to_expression(op0), ", ", to_expression(op1), ")"), forward); if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) { @@ -2070,7 +2124,7 @@ void CompilerGLSL::emit_binary_func_op_cast(uint32_t result_type, uint32_t resul expr += join(op, "(", cast_op0, ", ", cast_op1, ")"); } - emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1), false); + emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1)); } void CompilerGLSL::emit_trinary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, @@ -2078,7 +2132,7 @@ void CompilerGLSL::emit_trinary_func_op(uint32_t result_type, uint32_t result_id { bool forward = should_forward(op0) && should_forward(op1) && should_forward(op2); emit_op(result_type, result_id, - join(op, "(", to_expression(op0), ", ", to_expression(op1), ", ", to_expression(op2), ")"), forward, false); + join(op, "(", to_expression(op0), ", ", to_expression(op1), ", ", to_expression(op2), ")"), forward); if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) { @@ -2094,7 +2148,7 @@ void CompilerGLSL::emit_quaternary_func_op(uint32_t result_type, uint32_t result bool forward = should_forward(op0) && should_forward(op1) && should_forward(op2) && should_forward(op3); emit_op(result_type, result_id, join(op, "(", to_expression(op0), ", ", to_expression(op1), ", ", to_expression(op2), ", ", to_expression(op3), ")"), - forward, false); + forward); if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) { @@ -2229,11 +2283,12 @@ void CompilerGLSL::emit_mix_op(uint32_t result_type, uint32_t id, uint32_t left, // Just implement it as ternary expressions. string expr; if (lerptype.vecsize == 1) - expr = join(to_expression(lerp), " ? ", to_expression(right), " : ", to_expression(left)); + expr = join(to_enclosed_expression(lerp), " ? ", to_enclosed_expression(right), " : ", + to_enclosed_expression(left)); else { auto swiz = [this](uint32_t expression, uint32_t i) { - return join(to_expression(expression), ".", index_to_swizzle(i)); + return join(to_enclosed_expression(expression), ".", index_to_swizzle(i)); }; expr = type_to_glsl_constructor(restype); @@ -2251,7 +2306,7 @@ void CompilerGLSL::emit_mix_op(uint32_t result_type, uint32_t id, uint32_t left, expr += ")"; } - emit_op(result_type, id, expr, should_forward(left) && should_forward(right) && should_forward(lerp), false); + emit_op(result_type, id, expr, should_forward(left) && should_forward(right) && should_forward(lerp)); } else emit_trinary_func_op(result_type, id, left, right, lerp, "mix"); @@ -2325,7 +2380,7 @@ void CompilerGLSL::emit_sampled_image_op(uint32_t result_type, uint32_t result_i type_to_glsl(get(result_type)).c_str()); } else - emit_op(result_type, result_id, to_combined_image_sampler(image_id, samp_id), true, false); + emit_op(result_type, result_id, to_combined_image_sampler(image_id, samp_id), true); } void CompilerGLSL::emit_texture_op(const Instruction &i) @@ -2506,7 +2561,9 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) bool forward = should_forward(coord); // The IR can give us more components than we need, so chop them off as needed. - auto coord_expr = to_expression(coord) + swizzle(coord_components, expression_type(coord).vecsize); + auto swizzle_expr = swizzle(coord_components, expression_type(coord).vecsize); + // Only enclose the UV expression if needed. + auto coord_expr = (*swizzle_expr == '\0') ? to_expression(coord) : (to_enclosed_expression(coord) + swizzle_expr); // TODO: implement rest ... A bit intensive. @@ -2594,7 +2651,7 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) expr += ")"; - emit_op(result_type, id, expr, forward, false); + emit_op(result_type, id, expr, forward); } void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, uint32_t) @@ -2883,7 +2940,7 @@ string CompilerGLSL::bitcast_glsl(const SPIRType &result_type, uint32_t argument { auto op = bitcast_glsl_op(result_type, expression_type(argument)); if (op.empty()) - return to_expression(argument); + return to_enclosed_expression(argument); else return join(op, "(", to_expression(argument), ")"); } @@ -2975,7 +3032,7 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 { string expr; if (!chain_only) - expr = to_expression(base); + expr = to_enclosed_expression(base); const auto *type = &expression_type(base); @@ -3276,6 +3333,7 @@ string CompilerGLSL::build_composite_combiner(const uint32_t *elems, uint32_t le uint32_t base = 0; bool swizzle_optimization = false; string op; + string subop; for (uint32_t i = 0; i < length; i++) { @@ -3287,7 +3345,7 @@ string CompilerGLSL::build_composite_combiner(const uint32_t *elems, uint32_t le { // Only supposed to be used for vector swizzle -> scalar. assert(!e->expression.empty() && e->expression.front() == '.'); - op += e->expression.substr(1, string::npos); + subop += e->expression.substr(1, string::npos); swizzle_optimization = true; } else @@ -3301,7 +3359,7 @@ string CompilerGLSL::build_composite_combiner(const uint32_t *elems, uint32_t le if (swizzle_optimization) { if (backend.swizzle_is_function) - op += "()"; + subop += "()"; // Don't attempt to remove unity swizzling if we managed to remove duplicate swizzles. // The base "foo" might be vec4, while foo.xyz is vec3 (OpVectorShuffle) and looks like a vec3 due to the .xyz tacked on. @@ -3313,14 +3371,20 @@ string CompilerGLSL::build_composite_combiner(const uint32_t *elems, uint32_t le // Case 2: // foo.xyz: Duplicate swizzle won't kick in. // If foo is vec3, we can remove xyz, giving just foo. - if (!remove_duplicate_swizzle(op)) - remove_unity_swizzle(base, op); + if (!remove_duplicate_swizzle(subop)) + remove_unity_swizzle(base, subop); + + // Strips away redundant parens if we created them during component extraction. + strip_enclosed_expression(subop); swizzle_optimization = false; + op += subop; } + else + op += subop; if (i) op += ", "; - op += to_expression(elems[i]); + subop = to_expression(elems[i]); } base = e ? e->base_expression : 0; @@ -3329,12 +3393,15 @@ string CompilerGLSL::build_composite_combiner(const uint32_t *elems, uint32_t le if (swizzle_optimization) { if (backend.swizzle_is_function) - op += "()"; + subop += "()"; - if (!remove_duplicate_swizzle(op)) - remove_unity_swizzle(base, op); + if (!remove_duplicate_swizzle(subop)) + remove_unity_swizzle(base, subop); + // Strips away redundant parens if we created them during component extraction. + strip_enclosed_expression(subop); } + op += subop; return op; } @@ -3384,7 +3451,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) bool forward = should_forward(ptr) && forced_temporaries.find(id) == end(forced_temporaries); // Suppress usage tracking since using same expression multiple times does not imply any extra work. - emit_op(result_type, id, to_expression(ptr), forward, false, true); + emit_op(result_type, id, to_expression(ptr), forward, true); register_read(id, ptr, forward); break; } @@ -3513,7 +3580,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) bool forward = args_will_forward(id, arg, length, pure) && !callee_has_out_variables && pure && (forced_temporaries.find(id) == end(forced_temporaries)); - emit_op(result_type, id, funexpr, forward, false); + emit_op(result_type, id, funexpr, forward); // Function calls are implicit loads from all variables in question. // Set dependencies for them. @@ -3584,7 +3651,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) constructor_op += ")"; } - emit_op(result_type, id, constructor_op, forward, false); + emit_op(result_type, id, constructor_op, forward); break; } @@ -3612,7 +3679,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) uint32_t id = ops[1]; auto expr = access_chain(ops[2], &ops[3], 1, false); - emit_op(result_type, id, expr, should_forward(ops[2]), false); + emit_op(result_type, id, expr, should_forward(ops[2])); break; } @@ -3643,13 +3710,13 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // Including the base will prevent this and would trigger multiple reads // from expression causing it to be forced to an actual temporary in GLSL. auto expr = access_chain(ops[2], &ops[3], length, true, true); - auto &e = emit_op(result_type, id, expr, true, false, !expression_is_forwarded(ops[2])); + auto &e = emit_op(result_type, id, expr, true, !expression_is_forwarded(ops[2])); e.base_expression = ops[2]; } else { auto expr = access_chain(ops[2], &ops[3], length, true); - emit_op(result_type, id, expr, should_forward(ops[2]), false, !expression_is_forwarded(ops[2])); + emit_op(result_type, id, expr, should_forward(ops[2]), !expression_is_forwarded(ops[2])); } break; } @@ -3759,9 +3826,9 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) for (uint32_t i = 0; i < length; i++) { if (elems[i] >= type0.vecsize) - args.push_back(join(to_expression(vec1), ".", index_to_swizzle(elems[i] - type0.vecsize))); + args.push_back(join(to_enclosed_expression(vec1), ".", index_to_swizzle(elems[i] - type0.vecsize))); else - args.push_back(join(to_expression(vec0), ".", index_to_swizzle(elems[i]))); + args.push_back(join(to_enclosed_expression(vec0), ".", index_to_swizzle(elems[i]))); } expr += join(type_to_glsl_constructor(get(result_type)), "(", merge(args), ")"); } @@ -3770,7 +3837,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) trivial_forward = !expression_is_forwarded(vec0); // We only source from first vector, so can use swizzle. - expr += to_expression(vec0); + expr += to_enclosed_expression(vec0); expr += "."; for (uint32_t i = 0; i < length; i++) expr += index_to_swizzle(elems[i]); @@ -3781,7 +3848,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // A shuffle is trivial in that it doesn't actually *do* anything. // We inherit the forwardedness from our arguments to avoid flushing out to temporaries when it's not really needed. - emit_op(result_type, id, expr, should_forward(vec0) && should_forward(vec1), false, trivial_forward); + emit_op(result_type, id, expr, should_forward(vec0) && should_forward(vec1), trivial_forward); break; } @@ -4120,7 +4187,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) throw CompilerError("Illegal argument to OpQuantizeToF16."); } - emit_op(result_type, id, op, should_forward(arg), false); + emit_op(result_type, id, op, should_forward(arg)); break; } @@ -4231,8 +4298,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) { const char *op = check_atomic_image(ops[2]) ? "imageAtomicAdd" : "atomicAdd"; forced_temporaries.insert(ops[1]); - auto expr = join(op, "(", to_expression(ops[2]), ", -", to_expression(ops[5]), ")"); - emit_op(ops[0], ops[1], expr, should_forward(ops[2]) && should_forward(ops[5]), false); + auto expr = join(op, "(", to_expression(ops[2]), ", -", to_enclosed_expression(ops[5]), ")"); + emit_op(ops[0], ops[1], expr, should_forward(ops[2]) && should_forward(ops[5])); flush_all_atomic_capable_variables(); register_read(ops[1], ops[2], should_forward(ops[2])); break; @@ -4327,7 +4394,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) { uint32_t result_type = ops[0]; uint32_t id = ops[1]; - auto &e = emit_op(result_type, id, to_expression(ops[2]), true, false); + auto &e = emit_op(result_type, id, to_expression(ops[2]), true); // When using the image, we need to know which variable it is actually loaded from. auto *var = maybe_get_backing_variable(ops[2]); @@ -4497,7 +4564,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) if (var && var->forwardable) { - auto &e = emit_op(result_type, id, imgexpr, true, false); + auto &e = emit_op(result_type, id, imgexpr, true); // We only need to track dependencies if we're reading from image load/store. if (!pure) @@ -4507,7 +4574,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) } } else - emit_op(result_type, id, imgexpr, false, false); + emit_op(result_type, id, imgexpr, false); break; } @@ -4567,7 +4634,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) if (type.basetype == SPIRType::Image) { // The size of an image is always constant. - emit_op(result_type, id, join("imageSize(", to_expression(ops[2]), ")"), true, false); + emit_op(result_type, id, join("imageSize(", to_expression(ops[2]), ")"), true); } else throw CompilerError("Invalid type for OpImageQuerySize."); diff --git a/spirv_glsl.hpp b/spirv_glsl.hpp index 27bc05b7..61e1adfd 100644 --- a/spirv_glsl.hpp +++ b/spirv_glsl.hpp @@ -288,7 +288,7 @@ protected: void emit_unary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op); bool expression_is_forwarded(uint32_t id); SPIRExpression &emit_op(uint32_t result_type, uint32_t result_id, const std::string &rhs, bool forward_rhs, - bool extra_parens, bool suppress_usage_tracking = false); + bool suppress_usage_tracking = false); std::string access_chain(uint32_t base, const uint32_t *indices, uint32_t count, bool index_is_literal, bool chain_only = false); @@ -297,6 +297,8 @@ protected: std::string declare_temporary(uint32_t type, uint32_t id); void append_global_func_args(const SPIRFunction &func, uint32_t index, std::vector &arglist); std::string to_expression(uint32_t id); + std::string to_enclosed_expression(uint32_t id); + void strip_enclosed_expression(std::string &expr); std::string to_member_name(const SPIRType &type, uint32_t index); std::string type_to_glsl_constructor(const SPIRType &type); std::string argument_decl(const SPIRFunction::Parameter &arg); diff --git a/spirv_msl.cpp b/spirv_msl.cpp index 1d5a74b7..501511ab 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -660,9 +660,9 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) case Dim1D: if (img_type.arrayed) emit_op(result_type, id, join("uint2(", img_exp, ".get_width(), ", img_exp, ".get_array_size())"), - false, false); + false); else - emit_op(result_type, id, join(img_exp, ".get_width()"), true, false); + emit_op(result_type, id, join(img_exp, ".get_width()"), true); break; case Dim2D: @@ -670,16 +670,16 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) if (img_type.arrayed) emit_op(result_type, id, join("uint3(", img_exp, ".get_width(), ", img_exp, ".get_height(), ", img_exp, ".get_array_size())"), - false, false); + false); else emit_op(result_type, id, join("uint2(", img_exp, ".get_width(), ", img_exp, ".get_height())"), - false, false); + false); break; case Dim3D: emit_op(result_type, id, join("uint3(", img_exp, ".get_width(), ", img_exp, ".get_height(), ", img_exp, ".get_depth())"), - false, false); + false); break; default: @@ -923,7 +923,7 @@ void CompilerMSL::emit_texture_op(const Instruction &i) // Add texture coordinates bool forward = should_forward(coord); - auto coord_expr = to_expression(coord); + auto coord_expr = to_enclosed_expression(coord); string tex_coords = coord_expr; string array_coord; @@ -1114,7 +1114,7 @@ void CompilerMSL::emit_texture_op(const Instruction &i) expr += ")"; - emit_op(result_type, id, expr, forward, false); + emit_op(result_type, id, expr, forward); } // Establish sampled image as expression object and assign the sampler to it.