SPIRV-Cross/reference/opt/shaders-msl/frag/for-loop-init.frag
Hans-Kristian Arntzen 18bcc9b790 Do not disable temporary forwarding when we suppress usage tracking.
This subtle bug removed any expression validation for trivially swizzled
variables. Make usage suppression a more explicit concept rather than
just hacking off forwarded_temporaries.

There is some fallout here with loop generation since our expression
invalidation is currently a bit too naive to handle loops properly.
The forwarding bug masked this problem until now.

If part of the loop condition is also used in the body, we end up
reading an invalid expression, which in turn forces a temporary to be
generated in the condition block, not good. We'll need to be smarter
here ...
2019-07-23 19:18:44 +02:00

83 lines
1.6 KiB
JavaScript

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
int FragColor [[color(0)]];
};
fragment main0_out main0()
{
main0_out out = {};
int _145;
for (;;)
{
out.FragColor = 16;
_145 = 0;
for (; _145 < 25; )
{
out.FragColor += 10;
_145++;
continue;
}
for (int _146 = 1; _146 < 30; )
{
out.FragColor += 11;
_146++;
continue;
}
int _147;
_147 = 0;
for (; _147 < 20; )
{
out.FragColor += 12;
_147++;
continue;
}
int _62 = _147 + 3;
out.FragColor += _62;
if (_62 == 40)
{
for (int _151 = 0; _151 < 40; )
{
out.FragColor += 13;
_151++;
continue;
}
break;
}
out.FragColor += _62;
int2 _148;
_148 = int2(0);
int _102;
for (;;)
{
_102 = _148.x;
if (_102 < 10)
{
out.FragColor += _148.y;
int2 _144 = _148;
_144.x = _102 + 4;
_148 = _144;
continue;
}
else
{
break;
}
}
for (int _150 = _62; _150 < 40; )
{
out.FragColor += _150;
_150++;
continue;
}
out.FragColor += _62;
break;
}
return out;
}