461f1506e7
This is not necessary, as we must emit an invalidating store before we potentially consume an invalid expression. In fact, we're a bit conservative here in this case for example: int tmp = variable; if (...) { variable = 10; } else { // Consuming tmp here is fine, but it was // invalidated while emitting other branch. // Technically, we need to study if there is an invalidating store // in the CFG between the loading block and this block, and the other // branch will not be a part of that analysis. int tmp2 = tmp * tmp; } Fixing this case means complex CFG traversal *everywhere*, and it feels like overkill. Fixing this exposed a bug with access chains, so fix a bug where expression dependencies were not inherited properly in access chains. Access chains are now considered forwarded if there is at least one dependency which is also forwarded.
96 lines
1.9 KiB
Plaintext
96 lines
1.9 KiB
Plaintext
#version 310 es
|
|
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
layout(binding = 0, std430) readonly buffer Distribution
|
|
{
|
|
vec2 distribution[];
|
|
} _137;
|
|
|
|
layout(binding = 2, std140) uniform UBO
|
|
{
|
|
vec4 uModTime;
|
|
} _166;
|
|
|
|
layout(binding = 1, std430) writeonly buffer HeightmapFFT
|
|
{
|
|
uint heights[];
|
|
} _225;
|
|
|
|
uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel)
|
|
{
|
|
uint _86;
|
|
if (sel.x)
|
|
{
|
|
_86 = b.x;
|
|
}
|
|
else
|
|
{
|
|
_86 = a.x;
|
|
}
|
|
uint _97;
|
|
if (sel.y)
|
|
{
|
|
_97 = b.y;
|
|
}
|
|
else
|
|
{
|
|
_97 = a.y;
|
|
}
|
|
return uvec2(_86, _97);
|
|
}
|
|
|
|
vec2 alias(vec2 i, vec2 N)
|
|
{
|
|
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 r2 = b.yy;
|
|
vec2 R1 = r2 * r3;
|
|
return R0 + vec2(-R1.x, R1.y);
|
|
}
|
|
|
|
uint pack2(vec2 v)
|
|
{
|
|
return packHalf2x16(v);
|
|
}
|
|
|
|
void generate_heightmap()
|
|
{
|
|
uvec2 N = uvec2(64u, 1u) * gl_NumWorkGroups.xy;
|
|
uvec2 i = gl_GlobalInvocationID.xy;
|
|
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 = _137.distribution[(i.y * N.x) + i.x];
|
|
vec2 b = _137.distribution[(wi.y * N.x) + wi.x];
|
|
vec2 param_3 = vec2(i);
|
|
vec2 param_4 = vec2(N);
|
|
vec2 k = _166.uModTime.xy * alias(param_3, param_4);
|
|
float k_len = length(k);
|
|
float w = sqrt(9.81000041961669921875 * k_len) * _166.uModTime.z;
|
|
float cw = cos(w);
|
|
float sw = sin(w);
|
|
vec2 param_5 = a;
|
|
vec2 param_6 = vec2(cw, sw);
|
|
a = cmul(param_5, param_6);
|
|
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;
|
|
vec2 param_9 = res;
|
|
_225.heights[(i.y * N.x) + i.x] = pack2(param_9);
|
|
}
|
|
|
|
void main()
|
|
{
|
|
generate_heightmap();
|
|
}
|
|
|