glsl: Drop INT_DIV_TO_MUL_RCP lowering.
nir_lower_int_to_float() does this at the end of compilation, no need to do it up front. Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16823>
This commit is contained in:
parent
5ec0301ec7
commit
ab3a1d41c5
|
@ -35,7 +35,6 @@ struct gl_shader_program;
|
|||
|
||||
/* Operations for lower_instructions() */
|
||||
#define SUB_TO_ADD_NEG 0x01
|
||||
#define INT_DIV_TO_MUL_RCP 0x40
|
||||
#define LDEXP_TO_ARITH 0x80
|
||||
#define CARRY_TO_ARITH 0x100
|
||||
#define BORROW_TO_ARITH 0x200
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
*
|
||||
* Currently supported transformations:
|
||||
* - SUB_TO_ADD_NEG
|
||||
* - INT_DIV_TO_MUL_RCP
|
||||
* - LDEXP_TO_ARITH
|
||||
* - CARRY_TO_ARITH
|
||||
* - BORROW_TO_ARITH
|
||||
|
@ -47,11 +46,6 @@
|
|||
* want to recognize add(op0, neg(op1)) or the other way around to
|
||||
* produce a subtract anyway.
|
||||
*
|
||||
* INT_DIV_TO_MUL_RCP:
|
||||
* ---------------------------------------------------------
|
||||
* Breaks an ir_binop_div expression down to f2i(i2f(op0) * (rcp(i2f(op1))).
|
||||
* Used for !NativeIntegers HW.
|
||||
*
|
||||
* LDEXP_TO_ARITH:
|
||||
* -------------
|
||||
* Converts ir_binop_ldexp to arithmetic and bit operations for float sources.
|
||||
|
@ -100,7 +94,6 @@ private:
|
|||
unsigned lower; /** Bitfield of which operations to lower */
|
||||
|
||||
void sub_to_add_neg(ir_expression *);
|
||||
void int_div_to_mul_rcp(ir_expression *);
|
||||
void ldexp_to_arith(ir_expression *);
|
||||
void dldexp_to_arith(ir_expression *);
|
||||
void dfrexp_sig_to_arith(ir_expression *);
|
||||
|
@ -157,57 +150,6 @@ lower_instructions_visitor::sub_to_add_neg(ir_expression *ir)
|
|||
this->progress = true;
|
||||
}
|
||||
|
||||
void
|
||||
lower_instructions_visitor::int_div_to_mul_rcp(ir_expression *ir)
|
||||
{
|
||||
assert(ir->operands[1]->type->is_integer_32());
|
||||
|
||||
/* Be careful with integer division -- we need to do it as a
|
||||
* float and re-truncate, since rcp(n > 1) of an integer would
|
||||
* just be 0.
|
||||
*/
|
||||
ir_rvalue *op0, *op1;
|
||||
const struct glsl_type *vec_type;
|
||||
|
||||
vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
|
||||
ir->operands[1]->type->vector_elements,
|
||||
ir->operands[1]->type->matrix_columns);
|
||||
|
||||
if (ir->operands[1]->type->base_type == GLSL_TYPE_INT)
|
||||
op1 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[1], NULL);
|
||||
else
|
||||
op1 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[1], NULL);
|
||||
|
||||
op1 = new(ir) ir_expression(ir_unop_rcp, op1->type, op1, NULL);
|
||||
|
||||
vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
|
||||
ir->operands[0]->type->vector_elements,
|
||||
ir->operands[0]->type->matrix_columns);
|
||||
|
||||
if (ir->operands[0]->type->base_type == GLSL_TYPE_INT)
|
||||
op0 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[0], NULL);
|
||||
else
|
||||
op0 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[0], NULL);
|
||||
|
||||
vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
|
||||
ir->type->vector_elements,
|
||||
ir->type->matrix_columns);
|
||||
|
||||
op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1);
|
||||
|
||||
if (ir->operands[1]->type->base_type == GLSL_TYPE_INT) {
|
||||
ir->operation = ir_unop_f2i;
|
||||
ir->operands[0] = op0;
|
||||
} else {
|
||||
ir->operation = ir_unop_i2u;
|
||||
ir->operands[0] = new(ir) ir_expression(ir_unop_f2i, op0);
|
||||
}
|
||||
ir->init_num_operands();
|
||||
ir->operands[1] = NULL;
|
||||
|
||||
this->progress = true;
|
||||
}
|
||||
|
||||
void
|
||||
lower_instructions_visitor::ldexp_to_arith(ir_expression *ir)
|
||||
{
|
||||
|
@ -1515,11 +1457,6 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
|
|||
sub_to_add_neg(ir);
|
||||
break;
|
||||
|
||||
case ir_binop_div:
|
||||
if (ir->operands[1]->type->is_integer_32() && lowering(INT_DIV_TO_MUL_RCP))
|
||||
int_div_to_mul_rcp(ir);
|
||||
break;
|
||||
|
||||
case ir_binop_ldexp:
|
||||
if (lowering(LDEXP_TO_ARITH) && ir->type->is_float())
|
||||
ldexp_to_arith(ir);
|
||||
|
|
|
@ -108,7 +108,6 @@ link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
CARRY_TO_ARITH |
|
||||
BORROW_TO_ARITH |
|
||||
(have_dround ? 0 : DOPS_TO_DFRAC) |
|
||||
(!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0) |
|
||||
(ctx->Const.ForceGLSLAbsSqrt ? SQRT_TO_ABS_SQRT : 0) |
|
||||
/* Assume that if ARB_gpu_shader5 is not supported
|
||||
* then all of the extended integer functions need
|
||||
|
|
Loading…
Reference in New Issue