SPIRV-Cross/reference/opt/shaders/frag/loop-dominator-and-switch-default.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

58 lines
1.2 KiB
JavaScript

#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out vec4 fragColor;
vec4 _80;
void main()
{
mediump int _18 = int(_80.x);
vec4 _82;
_82 = _80;
vec4 _89;
for (mediump int _81 = 0; _81 < _18; _82 = _89, _81++)
{
vec4 _83;
switch (_18)
{
case 0:
{
vec4 _74 = _82;
_74.y = 0.0;
_83 = _74;
break;
}
case 1:
{
vec4 _76 = _82;
_76.y = 1.0;
_83 = _76;
break;
}
default:
{
vec4 _88;
_88 = _82;
for (mediump int _84 = 0; _84 < _18; )
{
vec4 _72 = _88;
_72.y = _88.y + 0.5;
_88 = _72;
_84++;
continue;
}
_89 = _88;
continue;
}
}
vec4 _79 = _83;
_79.y = _83.y + 0.5;
_89 = _79;
continue;
}
fragColor = _82;
}