From: Elie Tournier <tournier.e...@gmail.com> Signed-off-by: Elie Tournier <elie.tourn...@collabora.com> --- src/compiler/glsl/lower_instructions.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp index 3064eef..94b262d 100644 --- a/src/compiler/glsl/lower_instructions.cpp +++ b/src/compiler/glsl/lower_instructions.cpp @@ -181,6 +181,7 @@ private: void dmax_to_less(ir_expression *ir); void dfloor_to_dtrunc(ir_expression *ir); void dceil_to_dtrunc(ir_expression *ir); + void dfrac_to_dtrunc(ir_expression *ir); ir_expression *_carry(operand a, operand b); }; @@ -1761,6 +1762,24 @@ lower_instructions_visitor::dceil_to_dtrunc(ir_expression *ir) this->progress = true; } +void +lower_instructions_visitor::dfrac_to_dtrunc(ir_expression *ir) +{ + ir_expression *const floor_expr = + new(ir) ir_expression(ir_unop_floor, + ir->operands[0]->type, ir->operands[0]); + dfloor_to_dtrunc(floor_expr); + ir_expression *const neg_expr = + new(ir) ir_expression(ir_unop_neg, + ir->operands[0]->type, floor_expr); + + ir->operation = ir_binop_add; + ir->init_num_operands(); + ir->operands[1] = neg_expr; + + this->progress = true; +} + ir_visitor_status lower_instructions_visitor::visit_leave(ir_expression *ir) { @@ -1926,6 +1945,12 @@ lower_instructions_visitor::visit_leave(ir_expression *ir) dmax_to_less(ir); break; + case ir_unop_fract: + if (lowering(DOPS_TO_DTRUNC) && + ir->type->is_double()) + dfrac_to_dtrunc(ir); + break; + default: return visit_continue; } -- 2.9.5 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev