GLSL: Fix nested legacy switch workarounds.

This commit is contained in:
Hans-Kristian Arntzen 2020-06-30 12:02:24 +02:00
parent b1082c10af
commit 70f17142de
7 changed files with 122 additions and 6 deletions

View File

@ -10,7 +10,7 @@ void main()
highp vec4 _65;
highp vec4 _66;
highp vec4 _68;
for (int SPIRV_Cross_Dummy = 0; SPIRV_Cross_Dummy < 1; SPIRV_Cross_Dummy++)
for (int SPIRV_Cross_Dummy25 = 0; SPIRV_Cross_Dummy25 < 1; SPIRV_Cross_Dummy25++)
{
if (_13 == 2)
{
@ -59,7 +59,7 @@ void main()
}
}
highp vec4 _70;
for (int SPIRV_Cross_Dummy = 0; SPIRV_Cross_Dummy < 1; SPIRV_Cross_Dummy++)
for (int SPIRV_Cross_Dummy146 = 0; SPIRV_Cross_Dummy146 < 1; SPIRV_Cross_Dummy146++)
{
if ((_13 == 10) || (_13 == 20))
{

View File

@ -0,0 +1,43 @@
#version 100
struct UBO
{
int func_arg;
int inner_func_arg;
};
uniform UBO _34;
void main()
{
vec4 _102;
for (int SPIRV_Cross_Dummy30 = 0; SPIRV_Cross_Dummy30 < 1; SPIRV_Cross_Dummy30++)
{
if (_34.func_arg != 0)
{
vec4 _101;
for (int SPIRV_Cross_Dummy45 = 0; SPIRV_Cross_Dummy45 < 1; SPIRV_Cross_Dummy45++)
{
if (_34.inner_func_arg != 0)
{
_101 = vec4(1.0);
break;
}
else
{
_101 = vec4(0.0);
break;
}
}
_102 = _101;
break;
}
else
{
_102 = vec4(0.0);
break;
}
}
gl_Position = _102;
}

View File

@ -7,7 +7,7 @@ vec2 _19;
void main()
{
highp vec2 _30;
for (int SPIRV_Cross_Dummy = 0; SPIRV_Cross_Dummy < 1; SPIRV_Cross_Dummy++)
for (int SPIRV_Cross_Dummy15 = 0; SPIRV_Cross_Dummy15 < 1; SPIRV_Cross_Dummy15++)
{
if (gl_FragCoord.x != gl_FragCoord.x)
{

View File

@ -8,7 +8,7 @@ void main()
{
int vIndex = int(vIndexF);
highp vec4 v = vec4(0.0);
for (int SPIRV_Cross_Dummy = 0; SPIRV_Cross_Dummy < 1; SPIRV_Cross_Dummy++)
for (int SPIRV_Cross_Dummy21 = 0; SPIRV_Cross_Dummy21 < 1; SPIRV_Cross_Dummy21++)
{
if (vIndex == 2)
{
@ -65,7 +65,7 @@ void main()
}
}
highp vec4 w = vec4(20.0);
for (int SPIRV_Cross_Dummy = 0; SPIRV_Cross_Dummy < 1; SPIRV_Cross_Dummy++)
for (int SPIRV_Cross_Dummy165 = 0; SPIRV_Cross_Dummy165 < 1; SPIRV_Cross_Dummy165++)
{
if ((vIndex == 10) || (vIndex == 20))
{

View File

@ -0,0 +1,41 @@
#version 100
struct UBO
{
int func_arg;
int inner_func_arg;
};
uniform UBO _34;
vec4 test_inner_func(bool b)
{
if (b)
{
return vec4(1.0);
}
else
{
return vec4(0.0);
}
}
vec4 test_func(bool b)
{
if (b)
{
bool param = _34.inner_func_arg != 0;
return test_inner_func(param);
}
else
{
return vec4(0.0);
}
}
void main()
{
bool param = _34.func_arg != 0;
gl_Position = test_func(param);
}

View File

@ -0,0 +1,28 @@
#version 450
layout(set = 0, binding = 0) uniform UBO
{
int func_arg;
int inner_func_arg;
};
vec4 test_inner_func(bool b)
{
if (b)
return vec4(1.0);
else
return vec4(0.0);
}
vec4 test_func(bool b)
{
if (b)
return test_inner_func(inner_func_arg != 0);
else
return vec4(0.0);
}
void main()
{
gl_Position = test_func(func_arg != 0);
}

View File

@ -13386,7 +13386,11 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
{
// ESSL 1.0 is not guaranteed to support do/while.
if (is_legacy_es())
statement("for (int SPIRV_Cross_Dummy = 0; SPIRV_Cross_Dummy < 1; SPIRV_Cross_Dummy++)");
{
uint32_t counter = statement_count;
statement("for (int SPIRV_Cross_Dummy", counter,
" = 0; SPIRV_Cross_Dummy", counter, " < 1; SPIRV_Cross_Dummy", counter, "++)");
}
else
statement("do");
}