We emit loop header variables even for while and dowhile.

Make the name clearer.
This commit is contained in:
Hans-Kristian Arntzen 2019-03-06 12:30:11 +01:00
parent 8bfb04d29d
commit cff057ca5a

View File

@ -10565,7 +10565,7 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
bool select_branch_to_true_block = false;
bool select_branch_to_false_block = false;
bool skip_direct_branch = false;
bool emitted_for_loop_header = false;
bool emitted_loop_header_variables = false;
bool force_complex_continue_block = false;
emit_hoisted_temporaries(block.declare_temporary);
@ -10592,7 +10592,7 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
else
select_branch_to_true_block = true;
emitted_for_loop_header = true;
emitted_loop_header_variables = true;
force_complex_continue_block = true;
}
}
@ -10608,7 +10608,7 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
else
select_branch_to_true_block = true;
emitted_for_loop_header = true;
emitted_loop_header_variables = true;
}
}
// This is the newer loop behavior in glslang which branches from Loop header directly to
@ -10619,14 +10619,14 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
if (attempt_emit_loop_header(block, SPIRBlock::MergeToDirectForLoop))
{
skip_direct_branch = true;
emitted_for_loop_header = true;
emitted_loop_header_variables = true;
}
}
else if (continue_type == SPIRBlock::DoWhileLoop)
{
flush_undeclared_variables(block);
emit_while_loop_initializers(block);
emitted_for_loop_header = true;
emitted_loop_header_variables = true;
// We have some temporaries where the loop header is the dominator.
// We risk a case where we have code like:
// for (;;) { create-temporary; break; } consume-temporary;
@ -10641,6 +10641,7 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
{
flush_undeclared_variables(block);
emit_while_loop_initializers(block);
emitted_loop_header_variables = true;
// We have a generic loop without any distinguishable pattern like for, while or do while.
get<SPIRBlock>(block.continue_block).complex_continue = true;
@ -10663,7 +10664,7 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
// If we didn't successfully emit a loop header and we had loop variable candidates, we have a problem
// as writes to said loop variables might have been masked out, we need a recompile.
if (!emitted_for_loop_header && !block.loop_variables.empty())
if (!emitted_loop_header_variables && !block.loop_variables.empty())
{
force_recompile = true;
for (auto var : block.loop_variables)