From 77f6973f58167d94059d3f324c29ab2ca8de4544 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 10 Mar 2022 08:54:56 +0200 Subject: [PATCH] Take care of SPIR-V load IDs in ternary expressions --- source/glsl/spirv.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/glsl/spirv.cpp b/source/glsl/spirv.cpp index 7b3e104e..c6f15614 100644 --- a/source/glsl/spirv.cpp +++ b/source/glsl/spirv.cpp @@ -1021,18 +1021,22 @@ void SpirVGenerator::visit(TernaryExpression &ternary) 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, condition_id, true_label_id, false_label_id); + std::map saved_load_ids = variable_load_ids; + writer.write_op_label(true_label_id); ternary.true_expr->visit(*this); Id true_result_id = r_expression_result_id; true_label_id = writer.get_current_block(); writer.write_op(content.function_body, OP_BRANCH, merge_block_id); + swap(saved_load_ids, variable_load_ids); writer.write_op_label(false_label_id); ternary.false_expr->visit(*this); Id false_result_id = r_expression_result_id; false_label_id = writer.get_current_block(); writer.write_op_label(merge_block_id); + prune_loads(true_label_id); r_expression_result_id = begin_expression(OP_PHI, get_id(*ternary.type), 4); writer.write(true_result_id); writer.write(true_label_id); -- 2.45.2