summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmma Anholt <emma@anholt.net>2022-03-23 21:12:47 -0700
committerDylan Baker <dylan.c.baker@intel.com>2022-04-21 21:03:04 -0700
commit1dcb9e3037e183b7a49d4a38bf4dbad84dc4e3e7 (patch)
tree6b664796e65b835864524d0a9a219223753d2997
parent9f8b840f302557873ce5a64193c60b726d6900a2 (diff)
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@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15540> (cherry picked from commit 00e9c4f3c92752438b47dd926fdf3795773d16bc)
-rw-r--r--.pick_status.json2
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp16
2 files changed, 13 insertions, 5 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 4b968dcd8fc..d9c029fa6c2 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1172,7 +1172,7 @@
"description": "st/glsl-to-tgsi: Fix handling of csel(bool, vec, vec).",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"because_sha": null
},
{
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index ab794bf65b0..b0bb38c14b5 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);
}