Commit 6e481500 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜 Committed by Marge Bot
Browse files

pan/bi: Use canonical names for clamps



Prepare to generate this enum by correctly naming the open-coded
variant.
Signed-off-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <mesa/mesa!8213>
parent 56988635
......@@ -343,8 +343,8 @@ bi_print_instruction(bi_instruction *ins, FILE *fp)
if (ins->format && ins->dest != ins->format)
pan_print_alu_type(ins->format, fp);
if (bi_has_outmod(ins))
fprintf(fp, "%s", bi_output_mod_name(ins->outmod));
if (bi_has_clamp(ins))
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));
......
......@@ -32,7 +32,7 @@
#include "compiler.h"
const char * bi_message_type_name(enum bifrost_message_type T);
const char * bi_output_mod_name(enum bifrost_outmod mod);
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_interp_mode_name(enum bifrost_interp_mode mode);
......
......@@ -52,13 +52,13 @@ bi_message_type_name(enum bifrost_message_type T)
}
const char *
bi_output_mod_name(enum bifrost_outmod mod)
bi_output_mod_name(enum bi_clamp mod)
{
switch (mod) {
case BIFROST_NONE: return "";
case BIFROST_POS: return ".pos";
case BIFROST_SAT_SIGNED: return ".sat_signed";
case BIFROST_SAT: return ".sat";
case BI_CLAMP_NONE: return "";
case BI_CLAMP_CLAMP_0_INF: return ".pos";
case BI_CLAMP_CLAMP_M1_1: return ".sat_signed";
case BI_CLAMP_CLAMP_0_1: return ".sat";
default: return "invalid";
}
}
......
......@@ -31,7 +31,7 @@
#include "bifrost.h"
const char * bi_message_type_name(enum bifrost_message_type T);
const char * bi_output_mod_name(enum bifrost_outmod mod);
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_interp_mode_name(enum bifrost_interp_mode mode);
......
......@@ -181,11 +181,11 @@ struct bifrost_add_inst {
unsigned op : 17;
} __attribute__((packed));
enum bifrost_outmod {
BIFROST_NONE = 0x0,
BIFROST_POS = 0x1,
BIFROST_SAT_SIGNED = 0x2,
BIFROST_SAT = 0x3,
enum bi_clamp {
BI_CLAMP_NONE = 0,
BI_CLAMP_CLAMP_0_INF = 1,
BI_CLAMP_CLAMP_M1_1 = 2,
BI_CLAMP_CLAMP_0_1 = 3,
};
enum bifrost_roundmode {
......
......@@ -1252,7 +1252,7 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr)
alu.src_types[2] = alu.src_types[1];
break;
case nir_op_fsat:
alu.outmod = BIFROST_SAT; /* FMOV */
alu.clamp = BI_CLAMP_CLAMP_0_1; /* FMOV */
break;
case nir_op_fneg:
alu.src_neg[0] = true; /* FMOV */
......@@ -1479,11 +1479,11 @@ bifrost_tex_format(enum glsl_sampler_dim dim)
}
static enum bifrost_texture_format_full
bi_texture_format(nir_alu_type T, enum bifrost_outmod outmod)
bi_texture_format(nir_alu_type T, enum bi_clamp clamp)
{
switch (T) {
case nir_type_float16: return BIFROST_TEXTURE_FORMAT_F16 + outmod;
case nir_type_float32: return BIFROST_TEXTURE_FORMAT_F32 + outmod;
case nir_type_float16: return BIFROST_TEXTURE_FORMAT_F16 + clamp;
case nir_type_float32: return BIFROST_TEXTURE_FORMAT_F32 + clamp;
case nir_type_uint16: return BIFROST_TEXTURE_FORMAT_U16;
case nir_type_int16: return BIFROST_TEXTURE_FORMAT_S16;
case nir_type_uint32: return BIFROST_TEXTURE_FORMAT_U32;
......@@ -1549,7 +1549,7 @@ bi_emit_lod_88(bi_context *ctx, unsigned lod, bool fp16)
.dest_type = nir_type_float32,
.src = { lod, BIR_INDEX_CONSTANT, BIR_INDEX_ZERO },
.src_types = { T, nir_type_float32, nir_type_float32 },
.outmod = BIFROST_SAT_SIGNED,
.clamp = BI_CLAMP_CLAMP_M1_1,
.roundmode = BIFROST_RTE,
.constant = {
.u64 = fui(1.0 / max_lod)
......@@ -1780,7 +1780,7 @@ bi_lower_cube_coord(bi_context *ctx, unsigned coord,
/* Transform the s coordinate */
bi_instruction fma2 = {
.type = BI_FMA,
.outmod = BIFROST_SAT,
.clamp = BI_CLAMP_CLAMP_0_1,
.dest = bi_make_temp(ctx),
.dest_type = nir_type_float32,
.src = { fma1.dest, cube_ssel.dest, BIR_INDEX_CONSTANT | 0 },
......@@ -1791,7 +1791,7 @@ bi_lower_cube_coord(bi_context *ctx, unsigned coord,
/* Transform the t coordinate */
bi_instruction fma3 = {
.type = BI_FMA,
.outmod = BIFROST_SAT,
.clamp = BI_CLAMP_CLAMP_0_1,
.dest = bi_make_temp(ctx),
.dest_type = nir_type_float32,
.src = { fma1.dest, cube_tsel.dest, BIR_INDEX_CONSTANT | 0 },
......@@ -1952,7 +1952,7 @@ emit_texc(bi_context *ctx, nir_tex_instr *instr)
.shadow_or_clamp_disable = instr->is_shadow,
.array = instr->is_array,
.dimension = bifrost_tex_format(instr->sampler_dim),
.format = bi_texture_format(instr->dest_type, BIFROST_NONE), /* TODO */
.format = bi_texture_format(instr->dest_type, BI_CLAMP_NONE), /* TODO */
.mask = (1 << tex.vector_channels) - 1
};
......
......@@ -26,11 +26,11 @@
#include "compiler.h"
/* Does an instruction respect outmods and source mods? Depend
/* Does an instruction respect clamps and source mods? Depend
* on the types involved */
bool
bi_has_outmod(bi_instruction *ins)
bi_has_clamp(bi_instruction *ins)
{
bool classy = bi_class_props[ins->type] & BI_MODS;
bool floaty = nir_alu_type_get_base_type(ins->dest_type) == nir_type_float;
......
......@@ -88,7 +88,7 @@ enum bi_class {
/* Properties of a class... */
extern unsigned bi_class_props[BI_NUM_CLASSES];
/* abs/neg/outmod valid for a float op */
/* abs/neg/clamp valid for a float op */
#define BI_MODS (1 << 0)
/* Accepts a bi_cond */
......@@ -336,7 +336,7 @@ typedef struct {
/* Floating-point modifiers, type/class permitting. If not
* allowed for the type/class, these are ignored. */
enum bifrost_outmod outmod;
enum bi_clamp clamp;
bool src_abs[BIR_SRC_COUNT];
bool src_neg[BIR_SRC_COUNT];
......@@ -721,7 +721,7 @@ void bi_emit_deriv(bi_context *ctx, nir_alu_instr *instr);
/* BIR manipulation */
bool bi_has_outmod(bi_instruction *ins);
bool bi_has_clamp(bi_instruction *ins);
bool bi_has_source_mods(bi_instruction *ins);
bool bi_is_src_swizzled(bi_instruction *ins, unsigned s);
bool bi_has_arg(bi_instruction *ins, unsigned arg);
......
......@@ -108,10 +108,10 @@ def pack_round(mod, opts, body, pack_exprs):
def pack_clamp(mod, opts, body, pack_exprs):
if opts == ['none', 'clamp_0_inf', 'clamp_m1_1', 'clamp_0_1']:
return 'ins->outmod'
return 'ins->clamp'
elif opts == ['none', 'clamp_0_1']:
body.append('assert(ins->outmod == BIFROST_NONE || ins->outmod == BIFROST_SAT);')
return '(ins->outmod == BIFROST_SAT) ? 1 : 0'
body.append('assert(ins->clamp == BI_CLAMP_NONE || ins->clamp == BI_CLAMP_CLAMP_0_1);')
return '(ins->clamp == BI_CLAMP_CLAMP_0_1) ? 1 : 0'
else:
assert False
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment