From: Elie Tournier <elie.tourn...@collabora.com> This lowers to floor using the same code as the float lowering, it also fixes things to avoid creating more instructions that need lowering.
Signed-off-by: Dave Airlie <airl...@redhat.com> --- src/compiler/glsl/ir_optimization.h | 1 + src/compiler/glsl/lower_instructions.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h index 38e35e3..5e6c82a 100644 --- a/src/compiler/glsl/ir_optimization.h +++ b/src/compiler/glsl/ir_optimization.h @@ -58,6 +58,7 @@ #define DOPS_TO_DTRUNC 0x800000 #define DRSQ_TO_DRCP 0x1000000 #define DFMA_TO_DMULADD 0x2000000 +#define DMOD_TO_FLOOR 0x4000000 /* Opertaions for lower_64bit_integer_instructions() */ #define MUL64 (1U << 0) diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp index b8f7224..d2a838c 100644 --- a/src/compiler/glsl/lower_instructions.cpp +++ b/src/compiler/glsl/lower_instructions.cpp @@ -359,6 +359,8 @@ lower_instructions_visitor::mod_to_floor(ir_expression *ir) if (lowering(DOPS_TO_DFRAC) && ir->type->is_double()) dfloor_to_dfrac(floor_expr); + else if (lowering(DOPS_TO_DTRUNC) && ir->type->is_double()) + dfloor_to_dtrunc(floor_expr); ir_expression *const mul_expr = new(ir) ir_expression(ir_binop_mul, @@ -369,6 +371,8 @@ lower_instructions_visitor::mod_to_floor(ir_expression *ir) ir->init_num_operands(); ir->operands[0] = new(ir) ir_dereference_variable(x); ir->operands[1] = mul_expr; + if (ir->type->is_double()) + sub_to_add_neg(ir); this->progress = true; } @@ -1855,8 +1859,9 @@ lower_instructions_visitor::visit_leave(ir_expression *ir) break; case ir_binop_mod: - if (lowering(MOD_TO_FLOOR) && (ir->type->is_float() || ir->type->is_double())) - mod_to_floor(ir); + if ((lowering(MOD_TO_FLOOR) && ir->type->is_float()) || + (lowering(DMOD_TO_FLOOR) && ir->type->is_double())) + mod_to_floor(ir); break; case ir_binop_pow: -- 2.9.5 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev