Merge pull request #451 from KhronosGroup/fix-437
Fix case where hoisted temporaries were used before being declared.
This commit is contained in:
commit
3d0c61fac1
@ -0,0 +1,37 @@
|
|||||||
|
#version 310 es
|
||||||
|
precision mediump float;
|
||||||
|
precision highp int;
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 FragColor;
|
||||||
|
layout(location = 0) flat in mediump int vA;
|
||||||
|
layout(location = 1) flat in mediump int vB;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
FragColor = vec4(0.0);
|
||||||
|
mediump int _49;
|
||||||
|
int _60;
|
||||||
|
for (int _57 = 0, _58 = 0; _58 < vA; _57 = _60, _58 += _49)
|
||||||
|
{
|
||||||
|
if ((vA + _58) == 20)
|
||||||
|
{
|
||||||
|
_60 = 50;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int _59;
|
||||||
|
if ((vB + _58) == 40)
|
||||||
|
{
|
||||||
|
_59 = 60;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_59 = _57;
|
||||||
|
}
|
||||||
|
_60 = _59;
|
||||||
|
}
|
||||||
|
_49 = _60 + 10;
|
||||||
|
FragColor += vec4(1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
#version 310 es
|
||||||
|
precision mediump float;
|
||||||
|
precision highp int;
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 FragColor;
|
||||||
|
layout(location = 0) flat in mediump int vA;
|
||||||
|
layout(location = 1) flat in mediump int vB;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
FragColor = vec4(0.0);
|
||||||
|
mediump int k = 0;
|
||||||
|
mediump int j;
|
||||||
|
for (mediump int i = 0; i < vA; i += j)
|
||||||
|
{
|
||||||
|
if ((vA + i) == 20)
|
||||||
|
{
|
||||||
|
k = 50;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((vB + i) == 40)
|
||||||
|
{
|
||||||
|
k = 60;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
j = k + 10;
|
||||||
|
FragColor += vec4(1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
|||||||
|
#version 310 es
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 FragColor;
|
||||||
|
layout(location = 0) flat in int vA;
|
||||||
|
layout(location = 1) flat in int vB;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
FragColor = vec4(0.0);
|
||||||
|
|
||||||
|
int k = 0;
|
||||||
|
int j;
|
||||||
|
for (int i = 0; i < vA; i += j)
|
||||||
|
{
|
||||||
|
if ((vA + i) == 20)
|
||||||
|
k = 50;
|
||||||
|
else if ((vB + i) == 40)
|
||||||
|
k = 60;
|
||||||
|
|
||||||
|
j = k + 10;
|
||||||
|
FragColor += 1.0;
|
||||||
|
}
|
||||||
|
}
|
@ -8336,6 +8336,9 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
|
|||||||
auto flags = meta[tmp.second].decoration.decoration_flags;
|
auto flags = meta[tmp.second].decoration.decoration_flags;
|
||||||
auto &type = get<SPIRType>(tmp.first);
|
auto &type = get<SPIRType>(tmp.first);
|
||||||
statement(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(tmp.second)), ";");
|
statement(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(tmp.second)), ";");
|
||||||
|
|
||||||
|
// The temporary might be read from before it's assigned, set up the expression now.
|
||||||
|
set<SPIRExpression>(tmp.second, to_name(tmp.second), tmp.first, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPIRBlock::ContinueBlockType continue_type = SPIRBlock::ContinueNone;
|
SPIRBlock::ContinueBlockType continue_type = SPIRBlock::ContinueNone;
|
||||||
|
Loading…
Reference in New Issue
Block a user