mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-30 23:28:06 +02:00
glsl: Drop borrow/carry lowerings in favor of nir
Unconditionally lowering prevents GL drivers from natively implementing these ops. Drivers that need lowering should set lower_uadd_carry and lower_usub_borrow on nir_shader_compiler_options to get the nir lowerings. Tested with dEQP-GLES31.functional.shaders.builtin_functions.integer.* Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19704>
This commit is contained in:
parent
339d80d5f2
commit
f3ee9be836
7 changed files with 13 additions and 48 deletions
|
|
@ -89,8 +89,6 @@ private:
|
|||
void dldexp_to_arith(ir_expression *);
|
||||
void dfrexp_sig_to_arith(ir_expression *);
|
||||
void dfrexp_exp_to_arith(ir_expression *);
|
||||
void carry_to_arith(ir_expression *);
|
||||
void borrow_to_arith(ir_expression *);
|
||||
void double_dot_to_fma(ir_expression *);
|
||||
void double_lrp(ir_expression *);
|
||||
void dceil_to_dfrac(ir_expression *);
|
||||
|
|
@ -580,44 +578,6 @@ lower_instructions_visitor::dfrexp_exp_to_arith(ir_expression *ir)
|
|||
this->progress = true;
|
||||
}
|
||||
|
||||
void
|
||||
lower_instructions_visitor::carry_to_arith(ir_expression *ir)
|
||||
{
|
||||
/* Translates
|
||||
* ir_binop_carry x y
|
||||
* into
|
||||
* sum = ir_binop_add x y
|
||||
* bcarry = ir_binop_less sum x
|
||||
* carry = ir_unop_b2i bcarry
|
||||
*/
|
||||
|
||||
ir_rvalue *x_clone = ir->operands[0]->clone(ir, NULL);
|
||||
ir->operation = ir_unop_i2u;
|
||||
ir->init_num_operands();
|
||||
ir->operands[0] = b2i(less(add(ir->operands[0], ir->operands[1]), x_clone));
|
||||
ir->operands[1] = NULL;
|
||||
|
||||
this->progress = true;
|
||||
}
|
||||
|
||||
void
|
||||
lower_instructions_visitor::borrow_to_arith(ir_expression *ir)
|
||||
{
|
||||
/* Translates
|
||||
* ir_binop_borrow x y
|
||||
* into
|
||||
* bcarry = ir_binop_less x y
|
||||
* carry = ir_unop_b2i bcarry
|
||||
*/
|
||||
|
||||
ir->operation = ir_unop_i2u;
|
||||
ir->init_num_operands();
|
||||
ir->operands[0] = b2i(less(ir->operands[0], ir->operands[1]));
|
||||
ir->operands[1] = NULL;
|
||||
|
||||
this->progress = true;
|
||||
}
|
||||
|
||||
void
|
||||
lower_instructions_visitor::double_dot_to_fma(ir_expression *ir)
|
||||
{
|
||||
|
|
@ -1467,14 +1427,6 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
|
|||
dfrexp_sig_to_arith(ir);
|
||||
break;
|
||||
|
||||
case ir_binop_carry:
|
||||
carry_to_arith(ir);
|
||||
break;
|
||||
|
||||
case ir_binop_borrow:
|
||||
borrow_to_arith(ir);
|
||||
break;
|
||||
|
||||
case ir_unop_trunc:
|
||||
if (lowering(DOPS_TO_DFRAC) && ir->type->is_double())
|
||||
dtrunc_to_dfrac(ir);
|
||||
|
|
|
|||
|
|
@ -3656,6 +3656,8 @@ ntt_fix_nir_options(struct pipe_screen *screen, struct nir_shader *s,
|
|||
!options->lower_flrp64 ||
|
||||
!options->lower_fmod ||
|
||||
!options->lower_rotate ||
|
||||
!options->lower_uadd_carry ||
|
||||
!options->lower_usub_borrow ||
|
||||
!options->lower_uadd_sat ||
|
||||
!options->lower_usub_sat ||
|
||||
!options->lower_uniforms_to_ubo ||
|
||||
|
|
@ -3674,6 +3676,8 @@ ntt_fix_nir_options(struct pipe_screen *screen, struct nir_shader *s,
|
|||
new_options->lower_flrp64 = true;
|
||||
new_options->lower_fmod = true;
|
||||
new_options->lower_rotate = true;
|
||||
new_options->lower_uadd_carry = true;
|
||||
new_options->lower_usub_borrow = true;
|
||||
new_options->lower_uadd_sat = true;
|
||||
new_options->lower_usub_sat = true;
|
||||
new_options->lower_uniforms_to_ubo = true;
|
||||
|
|
@ -4030,6 +4034,8 @@ static const nir_shader_compiler_options nir_to_tgsi_compiler_options = {
|
|||
.lower_fmod = true,
|
||||
.lower_rotate = true,
|
||||
.lower_uniforms_to_ubo = true,
|
||||
.lower_uadd_carry = true,
|
||||
.lower_usub_borrow = true,
|
||||
.lower_uadd_sat = true,
|
||||
.lower_usub_sat = true,
|
||||
.lower_vector_cmp = true,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ etna_compiler_create(const char *renderer, const struct etna_specs *specs)
|
|||
.fuse_ffma32 = true,
|
||||
.fuse_ffma64 = true,
|
||||
.lower_uadd_carry = true,
|
||||
.lower_usub_borrow = true,
|
||||
.lower_mul_high = true,
|
||||
.lower_bitops = true,
|
||||
.lower_all_io_to_temps = true,
|
||||
|
|
|
|||
|
|
@ -1334,6 +1334,8 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen,
|
|||
.lower_isign = true,
|
||||
.lower_fsign = true,
|
||||
.lower_fmod = true,
|
||||
.lower_uadd_carry = true,
|
||||
.lower_usub_borrow = true,
|
||||
.lower_extract_byte = true,
|
||||
.lower_extract_word = true,
|
||||
.lower_insert_byte = true,
|
||||
|
|
|
|||
|
|
@ -338,6 +338,7 @@ zink_screen_init_compiler(struct zink_screen *screen)
|
|||
.lower_mul_high = true,
|
||||
.lower_rotate = true,
|
||||
.lower_uadd_carry = true,
|
||||
.lower_usub_borrow = true,
|
||||
.lower_uadd_sat = true,
|
||||
.lower_usub_sat = true,
|
||||
.lower_vector_cmp = true,
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ nir_options = {
|
|||
.lower_usub_sat = true,
|
||||
.lower_iadd_sat = true,
|
||||
.lower_uadd_carry = true,
|
||||
.lower_usub_borrow = true,
|
||||
.lower_mul_high = true,
|
||||
.lower_rotate = true,
|
||||
.lower_pack_half_2x16 = true,
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ static const nir_shader_compiler_options midgard_nir_options = {
|
|||
.lower_find_lsb = true,
|
||||
.lower_ifind_msb = true,
|
||||
.lower_fdph = true,
|
||||
.lower_uadd_carry = true,
|
||||
.lower_usub_borrow = true,
|
||||
|
||||
/* TODO: We have native ops to help here, which we'll want to look into
|
||||
* eventually */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue