Check if we can use multiple initializers.
Need same type and qualifiers in GLSL and friends.
This commit is contained in:
parent
4f07a32c29
commit
51d45511a6
@ -63,9 +63,8 @@ void test()
|
||||
break;
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
float h;
|
||||
for (; i < 20; i = i + 1, h = h + 10.0)
|
||||
for (int i = 0; i < 20; i = i + 1, h = h + 10.0)
|
||||
{
|
||||
}
|
||||
_11.data = h;
|
||||
|
@ -60,11 +60,9 @@ void main()
|
||||
idat = idat * 2.0;
|
||||
k = k + 1;
|
||||
}
|
||||
uint i_1 = 0u;
|
||||
for (; i_1 < 16u; i_1 = i_1 + uint(1), k = k + 1)
|
||||
for (uint i_1 = 0u; i_1 < 16u; i_1 = i_1 + uint(1), k = k + 1)
|
||||
{
|
||||
uint j = 0u;
|
||||
for (; j < 30u; j = j + uint(1))
|
||||
for (uint j = 0u; j < 30u; j = j + uint(1))
|
||||
{
|
||||
idat = _24.mvp * idat;
|
||||
}
|
||||
|
@ -21,8 +21,7 @@ void main()
|
||||
return;
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
for (; i < 20; i = i + 1)
|
||||
for (int i = 0; i < 20; i = i + 1)
|
||||
{
|
||||
if (i == 10)
|
||||
{
|
||||
|
@ -33,11 +33,9 @@ void main()
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint i = 0u;
|
||||
for (; i < 16u; i = i + uint(1), k = k + 1)
|
||||
for (uint i = 0u; i < 16u; i = i + uint(1), k = k + 1)
|
||||
{
|
||||
uint j = 0u;
|
||||
for (; j < 30u; j = j + uint(1))
|
||||
for (uint j = 0u; j < 30u; j = j + uint(1))
|
||||
{
|
||||
idat = _24.mvp * idat;
|
||||
}
|
||||
|
@ -5354,7 +5354,38 @@ void CompilerGLSL::emit_function(SPIRFunction &func, uint64_t return_flags)
|
||||
if (!func.analyzed_variable_scope)
|
||||
{
|
||||
if (options.cfg_analysis)
|
||||
{
|
||||
analyze_variable_scope(func);
|
||||
|
||||
// Check if we can actually use the loop variables we found in analyze_variable_scope.
|
||||
// To use multiple initializers, we need the same type and qualifiers.
|
||||
for (auto block : func.blocks)
|
||||
{
|
||||
auto &b = get<SPIRBlock>(block);
|
||||
if (b.loop_variables.size() < 2)
|
||||
continue;
|
||||
|
||||
uint64_t flags = get_decoration_mask(b.loop_variables.front());
|
||||
uint32_t type = get<SPIRVariable>(b.loop_variables.front()).basetype;
|
||||
bool invalid_initializers = false;
|
||||
for (auto loop_variable : b.loop_variables)
|
||||
{
|
||||
if (flags != get_decoration_mask(loop_variable) ||
|
||||
type != get<SPIRVariable>(b.loop_variables.front()).basetype)
|
||||
{
|
||||
invalid_initializers = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (invalid_initializers)
|
||||
{
|
||||
for (auto loop_variable : b.loop_variables)
|
||||
get<SPIRVariable>(loop_variable).loop_variable = false;
|
||||
b.loop_variables.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
entry_block.dominated_variables = func.local_variables;
|
||||
func.analyzed_variable_scope = true;
|
||||
|
Loading…
Reference in New Issue
Block a user