SPIRV-Cross/reference/opt/shaders/frag/for-loop-init.frag
Hans-Kristian Arntzen 461f1506e7 Do not eagerly invalidate all active variables on a branch.
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.
2019-07-24 11:17:30 +02:00

68 lines
1.4 KiB
JavaScript

#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out mediump int FragColor;
void main()
{
mediump int _145;
for (;;)
{
FragColor = 16;
_145 = 0;
for (; _145 < 25; )
{
FragColor += 10;
_145++;
continue;
}
for (mediump int _146 = 1; _146 < 30; )
{
FragColor += 11;
_146++;
continue;
}
mediump int _147;
_147 = 0;
for (; _147 < 20; )
{
FragColor += 12;
_147++;
continue;
}
mediump int _62 = _147 + 3;
FragColor += _62;
if (_62 == 40)
{
for (mediump int _151 = 0; _151 < 40; )
{
FragColor += 13;
_151++;
continue;
}
break;
}
FragColor += _62;
mediump ivec2 _148;
_148 = ivec2(0);
for (; _148.x < 10; )
{
FragColor += _148.y;
mediump ivec2 _144 = _148;
_144.x = _148.x + 4;
_148 = _144;
continue;
}
for (mediump int _150 = _62; _150 < 40; )
{
FragColor += _150;
_150++;
continue;
}
FragColor += _62;
break;
}
}