mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 06:58:05 +02:00
pan/bi: Use canonical names for rounding modes
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8213>
This commit is contained in:
parent
6e481500d0
commit
030854a3b8
9 changed files with 33 additions and 33 deletions
|
|
@ -347,7 +347,7 @@ bi_print_instruction(bi_instruction *ins, FILE *fp)
|
|||
fprintf(fp, "%s", bi_output_mod_name(ins->clamp));
|
||||
|
||||
if (bi_class_props[ins->type] & BI_ROUNDMODE)
|
||||
fprintf(fp, "%s", bi_round_mode_name(ins->roundmode));
|
||||
fprintf(fp, "%s", bi_round_mode_name(ins->round));
|
||||
|
||||
if (ins->type == BI_BITWISE && ins->bitwise.dest_invert)
|
||||
fprintf(fp, ".not");
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
const char * bi_message_type_name(enum bifrost_message_type T);
|
||||
const char * bi_output_mod_name(enum bi_clamp mod);
|
||||
const char * bi_minmax_mode_name(enum bifrost_minmax_mode mod);
|
||||
const char * bi_round_mode_name(enum bifrost_roundmode mod);
|
||||
const char * bi_round_mode_name(enum bi_round mod);
|
||||
const char * bi_interp_mode_name(enum bifrost_interp_mode mode);
|
||||
const char * bi_class_name(enum bi_class cl);
|
||||
const char * bi_cond_name(enum bi_cond cond);
|
||||
|
|
|
|||
|
|
@ -76,13 +76,13 @@ bi_minmax_mode_name(enum bifrost_minmax_mode mod)
|
|||
}
|
||||
|
||||
const char *
|
||||
bi_round_mode_name(enum bifrost_roundmode mod)
|
||||
bi_round_mode_name(enum bi_round mod)
|
||||
{
|
||||
switch (mod) {
|
||||
case BIFROST_RTE: return "";
|
||||
case BIFROST_RTP: return ".rtp";
|
||||
case BIFROST_RTN: return ".rtn";
|
||||
case BIFROST_RTZ: return ".rtz";
|
||||
case BI_ROUND_NONE: return "";
|
||||
case BI_ROUND_RTP: return ".rtp";
|
||||
case BI_ROUND_RTN: return ".rtn";
|
||||
case BI_ROUND_RTZ: return ".rtz";
|
||||
default: return "invalid";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
const char * bi_message_type_name(enum bifrost_message_type T);
|
||||
const char * bi_output_mod_name(enum bi_clamp mod);
|
||||
const char * bi_minmax_mode_name(enum bifrost_minmax_mode mod);
|
||||
const char * bi_round_mode_name(enum bifrost_roundmode mod);
|
||||
const char * bi_round_mode_name(enum bi_round mod);
|
||||
const char * bi_interp_mode_name(enum bifrost_interp_mode mode);
|
||||
const char * bi_flow_control_name(enum bifrost_flow mode);
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ bi_emit_fexp2_new(bi_context *ctx, nir_alu_instr *instr)
|
|||
.dest_type = nir_type_int32,
|
||||
.src = { mscale.dest },
|
||||
.src_types = { nir_type_float32 },
|
||||
.roundmode = BIFROST_RTE
|
||||
.round = BI_ROUND_NONE
|
||||
};
|
||||
|
||||
/* FEXP2_FAST T, T, X */
|
||||
|
|
@ -113,7 +113,7 @@ bi_emit_flog2_new(bi_context *ctx, nir_alu_instr *instr)
|
|||
.dest_type = nir_type_float32,
|
||||
.src = { frexpe.dest },
|
||||
.src_types = { nir_type_int32 },
|
||||
.roundmode = BIFROST_RTZ
|
||||
.round = BI_ROUND_RTZ
|
||||
};
|
||||
|
||||
/* ADD_FREXPM (x-1), -1.0, X */
|
||||
|
|
|
|||
|
|
@ -188,11 +188,11 @@ enum bi_clamp {
|
|||
BI_CLAMP_CLAMP_0_1 = 3,
|
||||
};
|
||||
|
||||
enum bifrost_roundmode {
|
||||
BIFROST_RTE = 0x0, /* round to even */
|
||||
BIFROST_RTP = 0x1, /* round to positive */
|
||||
BIFROST_RTN = 0x2, /* round to negative */
|
||||
BIFROST_RTZ = 0x3 /* round to zero */
|
||||
enum bi_round {
|
||||
BI_ROUND_NONE = 0x0, /* round to even */
|
||||
BI_ROUND_RTP = 0x1, /* round to positive */
|
||||
BI_ROUND_RTN = 0x2, /* round to negative */
|
||||
BI_ROUND_RTZ = 0x3 /* round to zero */
|
||||
};
|
||||
|
||||
/* NONE: Same as fmax() and fmin() -- return the other
|
||||
|
|
|
|||
|
|
@ -1330,16 +1330,16 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr)
|
|||
alu.cond = bi_cond_for_nir(instr->op, false);
|
||||
break;
|
||||
case nir_op_fround_even:
|
||||
alu.roundmode = BIFROST_RTE;
|
||||
alu.round = BI_ROUND_NONE;
|
||||
break;
|
||||
case nir_op_fceil:
|
||||
alu.roundmode = BIFROST_RTP;
|
||||
alu.round = BI_ROUND_RTP;
|
||||
break;
|
||||
case nir_op_ffloor:
|
||||
alu.roundmode = BIFROST_RTN;
|
||||
alu.round = BI_ROUND_RTN;
|
||||
break;
|
||||
case nir_op_ftrunc:
|
||||
alu.roundmode = BIFROST_RTZ;
|
||||
alu.round = BI_ROUND_RTZ;
|
||||
break;
|
||||
case nir_op_iand:
|
||||
alu.op.bitwise = BI_BITWISE_AND;
|
||||
|
|
@ -1361,7 +1361,7 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr)
|
|||
break;
|
||||
case nir_op_f2i32:
|
||||
case nir_op_f2u32:
|
||||
alu.roundmode = BIFROST_RTZ;
|
||||
alu.round = BI_ROUND_RTZ;
|
||||
break;
|
||||
|
||||
case nir_op_f2f16:
|
||||
|
|
@ -1508,7 +1508,7 @@ bi_emit_array_index(bi_context *ctx, unsigned idx, nir_alu_type T, unsigned *c)
|
|||
|
||||
/* OpenGL ES 3.2 specification section 8.14.2 ("Coordinate Wrapping and
|
||||
* Texel Selection") defines the layer to be taken from clamp(RNE(r),
|
||||
* 0, dt - 1). So we use roundmode RTE, clamping is handled at the data
|
||||
* 0, dt - 1). So we use round RTE, clamping is handled at the data
|
||||
* structure level */
|
||||
bi_instruction f2i = {
|
||||
.type = BI_CONVERT,
|
||||
|
|
@ -1517,7 +1517,7 @@ bi_emit_array_index(bi_context *ctx, unsigned idx, nir_alu_type T, unsigned *c)
|
|||
.src = { idx },
|
||||
.src_types = { T },
|
||||
.swizzle = { { 2 } },
|
||||
.roundmode = BIFROST_RTE
|
||||
.round = BI_ROUND_NONE
|
||||
};
|
||||
|
||||
*c = 0;
|
||||
|
|
@ -1550,7 +1550,7 @@ bi_emit_lod_88(bi_context *ctx, unsigned lod, bool fp16)
|
|||
.src = { lod, BIR_INDEX_CONSTANT, BIR_INDEX_ZERO },
|
||||
.src_types = { T, nir_type_float32, nir_type_float32 },
|
||||
.clamp = BI_CLAMP_CLAMP_M1_1,
|
||||
.roundmode = BIFROST_RTE,
|
||||
.round = BI_ROUND_NONE,
|
||||
.constant = {
|
||||
.u64 = fui(1.0 / max_lod)
|
||||
},
|
||||
|
|
@ -1563,7 +1563,7 @@ bi_emit_lod_88(bi_context *ctx, unsigned lod, bool fp16)
|
|||
.dest_type = T,
|
||||
.src = { fsat.dest, BIR_INDEX_CONSTANT, BIR_INDEX_ZERO },
|
||||
.src_types = { nir_type_float32, nir_type_float32, nir_type_float32 },
|
||||
.roundmode = BIFROST_RTE,
|
||||
.round = BI_ROUND_NONE,
|
||||
.constant = {
|
||||
.u64 = fui(max_lod * 256.0)
|
||||
},
|
||||
|
|
@ -1576,7 +1576,7 @@ bi_emit_lod_88(bi_context *ctx, unsigned lod, bool fp16)
|
|||
.dest_type = nir_type_int32,
|
||||
.src = { fmul.dest },
|
||||
.src_types = { T },
|
||||
.roundmode = BIFROST_RTZ
|
||||
.round = BI_ROUND_RTZ
|
||||
};
|
||||
|
||||
/* MKVEC.v2i16 s32.h0, #0 */
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ extern unsigned bi_class_props[BI_NUM_CLASSES];
|
|||
/* Accepts a bi_cond */
|
||||
#define BI_CONDITIONAL (1 << 1)
|
||||
|
||||
/* Accepts a bifrost_roundmode */
|
||||
/* Accepts a bi_round */
|
||||
#define BI_ROUNDMODE (1 << 2)
|
||||
|
||||
/* Can be scheduled to FMA */
|
||||
|
|
@ -341,7 +341,7 @@ typedef struct {
|
|||
bool src_neg[BIR_SRC_COUNT];
|
||||
|
||||
/* Round mode (requires BI_ROUNDMODE) */
|
||||
enum bifrost_roundmode roundmode;
|
||||
enum bi_round round;
|
||||
|
||||
/* Destination type. Usually the type of the instruction
|
||||
* itself, but if sources and destination have different
|
||||
|
|
|
|||
|
|
@ -88,19 +88,19 @@ def pack_widen(mod, opts, body, pack_exprs):
|
|||
def pack_absneg(mod, opts, body, pack_exprs):
|
||||
return 'ins->src_{}[{}]'.format(mod[0:-1] if mod[-1] in "0123" else mod, mod_arg(mod))
|
||||
|
||||
# ins->roundmode is the native format (RTE/RTP/RTN/RTZ) for most ops. But there
|
||||
# ins->round is the native format (RTE/RTP/RTN/RTZ) for most ops. But there
|
||||
# are some others we might encounter that we don't support in the IR at this
|
||||
# point, and there are a few that force a subset of round modes.
|
||||
|
||||
def pack_round(mod, opts, body, pack_exprs):
|
||||
if opts == ['none', 'rtz']:
|
||||
body.append('assert(ins->roundmode == BIFROST_RTE || ins->roundmode == BIFROST_RTZ);')
|
||||
return '(ins->roundmode == BIFROST_RTZ) ? 1 : 0'
|
||||
body.append('assert(ins->round == BI_ROUND_NONE || ins->round == BI_ROUND_RTZ);')
|
||||
return '(ins->round == BI_ROUND_RTZ) ? 1 : 0'
|
||||
elif opts == ['rtn', 'rtp']:
|
||||
body.append('assert(ins->roundmode == BIFROST_RTN || ins->roundmode == BIFROST_RTP);')
|
||||
return '(ins->roundmode == BIFROST_RTP) ? 1 : 0'
|
||||
body.append('assert(ins->round == BI_ROUND_RTN || ins->round == BI_ROUND_RTP);')
|
||||
return '(ins->round == BI_ROUND_RTP) ? 1 : 0'
|
||||
elif opts[0:4] == ['none', 'rtp', 'rtn', 'rtz']:
|
||||
return 'ins->roundmode'
|
||||
return 'ins->round'
|
||||
else:
|
||||
assert False
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue