From 1dcb9e3037e183b7a49d4a38bf4dbad84dc4e3e7 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 23 Mar 2022 21:12:47 -0700 Subject: st/glsl-to-tgsi: Fix handling of csel(bool, vec, vec). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Part-of: (cherry picked from commit 00e9c4f3c92752438b47dd926fdf3795773d16bc) --- .pick_status.json | 2 +- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 16 ++++++++++++---- 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); } -- cgit v1.2.3