]> git.tdb.fi Git - libs/gl.git/commitdiff
Clear variable load cache before a loop in the SPIR-V generator
authorMikko Rasa <tdb@tdb.fi>
Sat, 24 Apr 2021 18:04:10 +0000 (21:04 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 24 Apr 2021 19:29:02 +0000 (22:29 +0300)
Variables may get assigned in the loop and the next iteration needs to
read those values, not the cached pre-loop values.

This could be done better by only clearing loads for the variables which
are actually assigned in the loop, but I'm not sure how exactly I want
to do that.

source/glsl/spirv.cpp

index 70d5fe789f125ecd04e0e6bb89d58614f6b39b4c..35d46ab7f9333b503897585de8bbebded43b62f7 100644 (file)
@@ -1832,6 +1832,8 @@ void SpirVGenerator::visit(Iteration &iter)
        if(iter.init_statement)
                iter.init_statement->visit(*this);
 
+       variable_load_ids.clear();
+
        Id header_id = next_id++;
        Id continue_id = next_id++;
        Id merge_block_id = next_id++;
@@ -1859,7 +1861,6 @@ void SpirVGenerator::visit(Iteration &iter)
        writer.write_op(content.function_body, OP_BRANCH, header_id);
 
        writer.write_op_label(merge_block_id);
-       prune_loads(header_id);
        reachable = true;
 }