nir,panfrost: Suffix fsat_signed and fclamp_pos with _mali
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11463>
This commit is contained in:
@@ -217,8 +217,6 @@ unop("isign", tint, "(src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1)")
|
||||
unop("iabs", tint, "(src0 < 0) ? -src0 : src0")
|
||||
unop("fabs", tfloat, "fabs(src0)")
|
||||
unop("fsat", tfloat, ("fmin(fmax(src0, 0.0), 1.0)"))
|
||||
unop("fsat_signed", tfloat, ("fmin(fmax(src0, -1.0), 1.0)"))
|
||||
unop("fclamp_pos", tfloat, ("fmax(src0, 0.0)"))
|
||||
unop("frcp", tfloat, "bit_size == 64 ? 1.0 / src0 : 1.0f / src0")
|
||||
unop("frsq", tfloat, "bit_size == 64 ? 1.0 / sqrt(src0) : 1.0f / sqrtf(src0)")
|
||||
unop("fsqrt", tfloat, "bit_size == 64 ? sqrt(src0) : sqrtf(src0)")
|
||||
@@ -1288,6 +1286,10 @@ binop("umul24_relaxed", tuint32, _2src_commutative + associative, "src0 * src1")
|
||||
unop_convert("fisnormal", tbool1, tfloat, "isnormal(src0)")
|
||||
unop_convert("fisfinite", tbool1, tfloat, "isfinite(src0)")
|
||||
|
||||
# Mali-specific opcodes
|
||||
unop("fsat_signed_mali", tfloat, ("fmin(fmax(src0, -1.0), 1.0)"))
|
||||
unop("fclamp_pos_mali", tfloat, ("fmax(src0, 0.0)"))
|
||||
|
||||
# DXIL specific double [un]pack
|
||||
# DXIL doesn't support generic [un]pack instructions, so we want those
|
||||
# lowered to bit ops. HLSL doesn't support 64bit bitcasts to/from
|
||||
|
||||
@@ -1785,13 +1785,13 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr)
|
||||
break;
|
||||
}
|
||||
|
||||
case nir_op_fsat_signed: {
|
||||
case nir_op_fsat_signed_mali: {
|
||||
bi_instr *I = bi_fadd_to(b, sz, dst, s0, bi_negzero(), BI_ROUND_NONE);
|
||||
I->clamp = BI_CLAMP_CLAMP_M1_1;
|
||||
break;
|
||||
}
|
||||
|
||||
case nir_op_fclamp_pos: {
|
||||
case nir_op_fclamp_pos_mali: {
|
||||
bi_instr *I = bi_fadd_to(b, sz, dst, s0, bi_negzero(), BI_ROUND_NONE);
|
||||
I->clamp = BI_CLAMP_CLAMP_0_INF;
|
||||
break;
|
||||
|
||||
@@ -33,9 +33,9 @@ algebraic_late = [
|
||||
(('fmul', a, 2.0), ('fadd', a, a)),
|
||||
|
||||
# Fuse Mali-specific clamps
|
||||
(('fmin', ('fmax', a, -1.0), 1.0), ('fsat_signed', a)),
|
||||
(('fmax', ('fmin', a, 1.0), -1.0), ('fsat_signed', a)),
|
||||
(('fmax', a, 0.0), ('fclamp_pos', a)),
|
||||
(('fmin', ('fmax', a, -1.0), 1.0), ('fsat_signed_mali', a)),
|
||||
(('fmax', ('fmin', a, 1.0), -1.0), ('fsat_signed_mali', a)),
|
||||
(('fmax', a, 0.0), ('fclamp_pos_mali', a)),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -585,9 +585,9 @@ mir_accept_dest_mod(compiler_context *ctx, nir_dest **dest, nir_op op)
|
||||
static unsigned
|
||||
mir_determine_float_outmod(compiler_context *ctx, nir_dest **dest, unsigned prior_outmod)
|
||||
{
|
||||
bool clamp_0_inf = mir_accept_dest_mod(ctx, dest, nir_op_fclamp_pos);
|
||||
bool clamp_0_inf = mir_accept_dest_mod(ctx, dest, nir_op_fclamp_pos_mali);
|
||||
bool clamp_0_1 = mir_accept_dest_mod(ctx, dest, nir_op_fsat);
|
||||
bool clamp_m1_1 = mir_accept_dest_mod(ctx, dest, nir_op_fsat_signed);
|
||||
bool clamp_m1_1 = mir_accept_dest_mod(ctx, dest, nir_op_fsat_signed_mali);
|
||||
bool prior = (prior_outmod != midgard_outmod_none);
|
||||
int count = (int) prior + (int) clamp_0_inf + (int) clamp_0_1 + (int) clamp_m1_1;
|
||||
|
||||
@@ -659,7 +659,7 @@ mir_is_bcsel_float(nir_alu_instr *instr)
|
||||
};
|
||||
|
||||
nir_op floatdestmods[] = {
|
||||
nir_op_fsat, nir_op_fsat_signed, nir_op_fclamp_pos,
|
||||
nir_op_fsat, nir_op_fsat_signed_mali, nir_op_fclamp_pos_mali,
|
||||
nir_op_f2f16, nir_op_f2f32
|
||||
};
|
||||
|
||||
@@ -847,8 +847,8 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
|
||||
ALU_CASE(fabs, fmov);
|
||||
ALU_CASE(fneg, fmov);
|
||||
ALU_CASE(fsat, fmov);
|
||||
ALU_CASE(fsat_signed, fmov);
|
||||
ALU_CASE(fclamp_pos, fmov);
|
||||
ALU_CASE(fsat_signed_mali, fmov);
|
||||
ALU_CASE(fclamp_pos_mali, fmov);
|
||||
|
||||
/* For size conversion, we use a move. Ideally though we would squash
|
||||
* these ops together; maybe that has to happen after in NIR as part of
|
||||
@@ -939,9 +939,9 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
|
||||
outmod = midgard_outmod_keeplo;
|
||||
} else if (instr->op == nir_op_fsat) {
|
||||
outmod = midgard_outmod_clamp_0_1;
|
||||
} else if (instr->op == nir_op_fsat_signed) {
|
||||
} else if (instr->op == nir_op_fsat_signed_mali) {
|
||||
outmod = midgard_outmod_clamp_m1_1;
|
||||
} else if (instr->op == nir_op_fclamp_pos) {
|
||||
} else if (instr->op == nir_op_fclamp_pos_mali) {
|
||||
outmod = midgard_outmod_clamp_0_inf;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,11 +53,11 @@ algebraic_late = [
|
||||
(('b32csel', a, 0, 'b@32'), ('iand', ('inot', a), b)),
|
||||
|
||||
# Fuse sat_signed. This should probably be shared with Bifrost
|
||||
(('~fmin', ('fmax', a, -1.0), 1.0), ('fsat_signed', a)),
|
||||
(('~fmax', ('fmin', a, 1.0), -1.0), ('fsat_signed', a)),
|
||||
(('~fmin', ('fmax', a, -1.0), 1.0), ('fsat_signed_mali', a)),
|
||||
(('~fmax', ('fmin', a, 1.0), -1.0), ('fsat_signed_mali', a)),
|
||||
|
||||
# Fuse clamp_positive. This should probably be shared with Utgard/bifrost
|
||||
(('fmax', a, 0.0), ('fclamp_pos', a)),
|
||||
(('fmax', a, 0.0), ('fclamp_pos_mali', a)),
|
||||
|
||||
(('ishl', 'a@16', b), ('u2u16', ('ishl', ('u2u32', a), b))),
|
||||
(('ishr', 'a@16', b), ('i2i16', ('ishr', ('i2i32', a), b))),
|
||||
|
||||
Reference in New Issue
Block a user