SPIRV-Cross/reference/opt/shaders/frag/avoid-expression-lowering-to-loop.frag
Hans-Kristian Arntzen 3afbfdb090 Implement context-sensitive expression read tracking.
When inside a loop, treat any read of outer expressions to happen
multiple times, forcing a temporary of said outer expressions.
This avoids the problem where we can end up relying on loop-invariant code motion to happen in the
compiler when converting optimized shaders.
2020-06-29 12:20:35 +02:00

30 lines
562 B
GLSL

#version 310 es
precision mediump float;
precision highp int;
layout(binding = 1, std140) uniform Count
{
float count;
} _44;
layout(binding = 0) uniform mediump sampler2D tex;
layout(location = 0) in highp vec4 vertex;
layout(location = 0) out vec4 fragColor;
void main()
{
highp float _24 = 1.0 / float(textureSize(tex, 0).x);
highp float _34 = dFdx(vertex.x);
float _62;
_62 = 0.0;
for (float _61 = 0.0; _61 < _44.count; )
{
_62 += (_24 * _34);
_61 += 1.0;
continue;
}
fragColor = vec4(_62);
}