]> git.tdb.fi Git - libs/gl.git/commitdiff
Restore variable load IDs for the else branch of a conditional
authorMikko Rasa <tdb@tdb.fi>
Mon, 8 Nov 2021 13:23:23 +0000 (15:23 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 8 Nov 2021 13:23:23 +0000 (15:23 +0200)
source/glsl/spirv.cpp

index e12d0bfc6285c0fa65858f71fdb1d0cb0ad74025..609cdb1968ac896627045cf8de82c61dd9284d15 100644 (file)
@@ -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<const VariableDeclaration *, Id> 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;