From: Mikko Rasa Date: Sat, 24 Apr 2021 18:04:10 +0000 (+0300) Subject: Clear variable load cache before a loop in the SPIR-V generator X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=513dd710045f66c4e79e1db56cdad87e9ad143a0 Clear variable load cache before a loop in the SPIR-V generator 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. --- diff --git a/source/glsl/spirv.cpp b/source/glsl/spirv.cpp index 70d5fe78..35d46ab7 100644 --- a/source/glsl/spirv.cpp +++ b/source/glsl/spirv.cpp @@ -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; }