From: Mikko Rasa Date: Mon, 8 Nov 2021 13:23:23 +0000 (+0200) Subject: Restore variable load IDs for the else branch of a conditional X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4dea96e285c123aab7d2c849ea3deaf512c3689c;p=libs%2Fgl.git Restore variable load IDs for the else branch of a conditional --- diff --git a/source/glsl/spirv.cpp b/source/glsl/spirv.cpp index e12d0bfc..609cdb19 100644 --- a/source/glsl/spirv.cpp +++ b/source/glsl/spirv.cpp @@ -1856,6 +1856,8 @@ void SpirVGenerator::visit(Conditional &cond) writer.write_op(content.function_body, OP_SELECTION_MERGE, merge_block_id, 0); // Selection control (none) writer.write_op(content.function_body, OP_BRANCH_CONDITIONAL, r_expression_result_id, true_label_id, false_label_id); + std::map saved_load_ids = variable_load_ids; + writer.write_op_label(true_label_id); cond.body.visit(*this); if(writer.get_current_block()) @@ -1866,6 +1868,7 @@ void SpirVGenerator::visit(Conditional &cond) reachable = true; if(!cond.else_body.body.empty()) { + swap(saved_load_ids, variable_load_ids); writer.write_op_label(false_label_id); cond.else_body.visit(*this); reachable |= reachable_if_true;