From ed66d7c3851ddfd65ada1d4b8b3764f5d29f0f01 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 Jan 2022 15:07:53 -0800 Subject: [PATCH] glsl/lower_vector_derefs: Don't emit conditional assignments Use if-statements instead. Any hardware that supports this sort of tessellation has flow control, so it will probably emit the conditional assignment using an if-statement anyway. This is definitely what st_glsl_to_nir does. v2: Fix copy-and-paste bug in the ir_type_swizzle handling. This bug caused segfaults in tests/spec/arb_tessellation_shader/execution/variable-indexing/tcs-patch-vec4-swiz-index-wr.shader_test. Reviewed-by: Matt Turner [v1] Part-of: --- src/compiler/glsl/lower_vector_derefs.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/compiler/glsl/lower_vector_derefs.cpp b/src/compiler/glsl/lower_vector_derefs.cpp index e246efae2b1..fb081aba3e6 100644 --- a/src/compiler/glsl/lower_vector_derefs.cpp +++ b/src/compiler/glsl/lower_vector_derefs.cpp @@ -112,18 +112,17 @@ vector_deref_visitor::visit_enter(ir_assignment *ir) if (new_lhs->ir_type != ir_type_swizzle) { assert(lhs_clone->as_dereference()); - ir_assignment *cond_assign = - new(mem_ctx) ir_assignment(lhs_clone->as_dereference(), - src_temp_deref, - equal(arr_index, cmp_index), - WRITEMASK_X << i); - factory.emit(cond_assign); + + factory.emit(if_tree(equal(arr_index, cmp_index), + assign(lhs_clone->as_dereference(), + src_temp_deref, + WRITEMASK_X << i))); } else { ir_assignment *cond_assign = new(mem_ctx) ir_assignment(swizzle(lhs_clone, i, 1), - src_temp_deref, - equal(arr_index, cmp_index)); - factory.emit(cond_assign); + src_temp_deref); + + factory.emit(if_tree(equal(arr_index, cmp_index), cond_assign)); } } ir->insert_after(factory.instructions);