summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker/st_glsl_to_tgsi.cpp')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp16
1 files 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 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);
}