[Mesa-dev] [PATCH 42/50] glsl: Add a lowering pass for 64-bit float max()
Dave Airlie
airlied at gmail.com
Tue Mar 13 04:25:07 UTC 2018
From: Elie Tournier <tournier.elie at gmail.com>
[airlied: update to handle max(dvec, double) case]
Signed-off-by: Elie Tournier <elie.tournier at collabora.com>
---
src/compiler/glsl/lower_instructions.cpp | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp
index 8c3d623..144bc41 100644
--- a/src/compiler/glsl/lower_instructions.cpp
+++ b/src/compiler/glsl/lower_instructions.cpp
@@ -177,6 +177,7 @@ private:
void imul_high_to_mul(ir_expression *ir);
void sqrt_to_abs_sqrt(ir_expression *ir);
void dmin_to_less(ir_expression *ir);
+ void dmax_to_less(ir_expression *ir);
ir_expression *_carry(operand a, operand b);
};
@@ -1693,6 +1694,26 @@ lower_instructions_visitor::dmin_to_less(ir_expression *ir)
this->progress = true;
}
+void
+lower_instructions_visitor::dmax_to_less(ir_expression *ir)
+{
+ const unsigned vec_elem = ir->type->vector_elements;
+ ir_rvalue *x_clone = ir->operands[0]->clone(ir, NULL);
+ ir_rvalue *y_clone = ir->operands[1]->clone(ir, NULL);
+ ir->operation = ir_triop_csel;
+ ir->init_num_operands();
+ if (ir->operands[1]->type->vector_elements == 1 && vec_elem > 1) {
+ ir->operands[0] = less(ir->operands[0], swizzle(ir->operands[1], SWIZZLE_XXXX, vec_elem));
+ ir->operands[1] = swizzle(y_clone, SWIZZLE_XXXX, vec_elem);
+ } else {
+ ir->operands[0] = less(ir->operands[0], ir->operands[1]);
+ ir->operands[1] = y_clone;
+ }
+ ir->operands[2] = x_clone;
+
+ this->progress = true;
+}
+
ir_visitor_status
lower_instructions_visitor::visit_leave(ir_expression *ir)
{
@@ -1842,6 +1863,12 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
dmin_to_less(ir);
break;
+ case ir_binop_max:
+ if (lowering(DMIN_DMAX_TO_LESS) &&
+ ir->type->is_double())
+ dmax_to_less(ir);
+ break;
+
default:
return visit_continue;
}
--
2.9.5
More information about the mesa-dev
mailing list