Defer parenthesis generation until needed.

Previously, we would generate parentheses proactively when generating
binary ops, however, this leads to uglier code and hits warnings in
compilers when used as a conditional.
This commit is contained in:
Hans-Kristian Arntzen 2016-12-05 10:22:54 +01:00
Родитель cc207e32c8
Коммит e67f6f85a4
62 изменённых файлов: 340 добавлений и 310 удалений

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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));

Просмотреть файл

@ -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));

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -10,6 +10,6 @@ void main()
float b = v1;
float _17 = a;
a = v1;
FragColor = ((_17 + b) * b);
FragColor = (_17 + b) * b;
}

Просмотреть файл

@ -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));

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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()

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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()

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -20,6 +20,6 @@ void main()
sShared[gl_LocalInvocationIndex] = idata;
memoryBarrierShared();
barrier();
_43.out_data[ident] = sShared[((4u - gl_LocalInvocationIndex) - 1u)];
_43.out_data[ident] = sShared[(4u - gl_LocalInvocationIndex) - 1u];
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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)));
}

Просмотреть файл

@ -10,6 +10,6 @@ in vec2 vTex;
void main()
{
FragColor = (vColor * texture(uTex, vTex));
FragColor = vColor * texture(uTex, vTex);
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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));
}

Просмотреть файл

@ -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];
}

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -11,7 +11,7 @@ in vec3 aNormal;
void main()
{
gl_Position = (_16.uMVP * aVertex);
gl_Position = _16.uMVP * aVertex;
vNormal = aNormal;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -11,7 +11,7 @@ in vec3 aNormal;
void main()
{
gl_Position = (_16.mvp * aVertex);
gl_Position = _16.mvp * aVertex;
vNormal = aNormal;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -9,6 +9,6 @@ layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = (subpassLoad(uSubpass0) + subpassLoad(uSubpass1));
FragColor = subpassLoad(uSubpass0) + subpassLoad(uSubpass1);
}

Просмотреть файл

@ -15,6 +15,6 @@ layout(location = 0) in vec4 vColor;
void main()
{
FragColor = ((vColor + push.value0) + push.value1);
FragColor = (vColor + push.value0) + push.value1;
}

Просмотреть файл

@ -13,6 +13,6 @@ layout(location = 0) in vec4 vColor;
void main()
{
FragColor = ((vColor + push.value0) + push.value1);
FragColor = (vColor + push.value0) + push.value1;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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]);
}

Просмотреть файл

@ -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]);
}

Просмотреть файл

@ -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));
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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,38 @@ void CompilerGLSL::handle_invalid_expression(uint32_t id)
force_recompile = true;
}
// 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);
@ -1922,7 +1954,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 +1963,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<SPIRExpression>(result_id, join("(", rhs, ")"), result_type, true);
else
return set<SPIRExpression>(result_id, rhs, result_type, true);
return set<SPIRExpression>(result_id, rhs, result_type, true);
}
else
{
@ -1947,7 +1976,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 +1985,7 @@ 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 +2021,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 +2039,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 +2047,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 +2066,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 +2097,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 +2105,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 +2121,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 +2256,11 @@ 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 +2278,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 +2352,7 @@ void CompilerGLSL::emit_sampled_image_op(uint32_t result_type, uint32_t result_i
type_to_glsl(get<SPIRType>(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 +2533,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 +2623,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 +2912,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 +3004,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);
@ -3384,7 +3413,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 +3542,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 +3613,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 +3641,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 +3672,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 +3788,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<SPIRType>(result_type)), "(", merge(args), ")");
}
@ -3770,7 +3799,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 +3810,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 +4149,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 +4260,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 +4356,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 +4526,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 +4536,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 +4596,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.");

Просмотреть файл

@ -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,7 @@ protected:
std::string declare_temporary(uint32_t type, uint32_t id);
void append_global_func_args(const SPIRFunction &func, uint32_t index, std::vector<std::string> &arglist);
std::string to_expression(uint32_t id);
std::string to_enclosed_expression(uint32_t id);
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);

Просмотреть файл

@ -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:
@ -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.