Mesa (main): st/glsl-to-tgsi: Fix handling of csel(bool, vec, vec).

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Apr 9 00:18:06 UTC 2022


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

Author: Emma Anholt <emma at anholt.net>
Date:   Wed Mar 23 21:12:47 2022 -0700

st/glsl-to-tgsi: Fix handling of csel(bool, vec, vec).

We were throwing an assertion failure across shader-db on nv92.  I'm
guessing this is a regression from !14573.

Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15540>

---

 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 553698ae3be..59b342824b8 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1642,12 +1642,20 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
       vector_elements = MAX2(vector_elements,
                              ir->operands[1]->type->vector_elements);
    }
+   /* Swizzle the single scalar argument of an otherwise vector 3-operand instr
+    * (lrp for mix(), csel, etc.).
+    */
    if (ir->operands[2] &&
        ir->operands[2]->type->vector_elements != vector_elements) {
-      /* This can happen with ir_triop_lrp, i.e. glsl mix */
-      assert(ir->operands[2]->type->vector_elements == 1);
-      uint16_t swizzle_x = GET_SWZ(op[2].swizzle, 0);
-      op[2].swizzle = MAKE_SWIZZLE4(swizzle_x, swizzle_x,
+      int i;
+      if (ir->operands[0]->type->vector_elements == 1) {
+         i = 0;
+      } else {
+         assert(ir->operands[2]->type->vector_elements == 1);
+         i = 2;
+      }
+      uint16_t swizzle_x = GET_SWZ(op[i].swizzle, 0);
+      op[i].swizzle = MAKE_SWIZZLE4(swizzle_x, swizzle_x,
                                     swizzle_x, swizzle_x);
    }
 



More information about the mesa-commit mailing list