Mesa (main): glsl/lower_vector_derefs: Don't emit conditional assignments

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 11 17:59:12 UTC 2022


Module: Mesa
Branch: main
Commit: ed66d7c3851ddfd65ada1d4b8b3764f5d29f0f01
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ed66d7c3851ddfd65ada1d4b8b3764f5d29f0f01

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Jan 14 15:07:53 2022 -0800

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 <mattst88 at gmail.com> [v1]
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>

---

 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);



More information about the mesa-commit mailing list