Ensure loop control flow hints only appear above loops.

This commit is contained in:
Hans-Kristian Arntzen 2021-06-03 12:19:10 +02:00
parent d62b3c2b92
commit 449f68ef3b
2 changed files with 6 additions and 2 deletions

View File

@ -34,9 +34,9 @@ void main()
bool _225;
int _229;
uint _222 = 0u;
SPIRV_CROSS_UNROLL
for (;;)
{
SPIRV_CROSS_UNROLL
if (_222 < _11.shadowCascadesNum)
{
mat4 _223;

View File

@ -14016,7 +14016,10 @@ void CompilerGLSL::branch(BlockID from, uint32_t cond, BlockID true_block, Block
if (!true_block_needs_code && !false_block_needs_code)
return;
emit_block_hints(get<SPIRBlock>(from));
// We might have a loop merge here. Only consider selection flattening constructs.
// Loop hints are handled explicitly elsewhere.
if (from_block.hint == SPIRBlock::HintFlatten || from_block.hint == SPIRBlock::HintDontFlatten)
emit_block_hints(from_block);
if (true_block_needs_code)
{
@ -14522,6 +14525,7 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
// for (;;) { create-temporary; break; } consume-temporary;
// so force-declare temporaries here.
emit_hoisted_temporaries(block.potential_declare_temporary);
emit_block_hints(block);
statement("for (;;)");
begin_scope();