Commit d86973d9 authored by Boris Brezillon's avatar Boris Brezillon
Browse files

pan/bi: Stop passing special varying names through src0



It's just clearer to have dedicated fields encoding the fact that the
LD_VAR should be SPECIAL, and another field storing the special var id.

With this change, the source index know matches the ISA.xml definition.
Signed-off-by: Boris Brezillon's avatarBoris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <mesa/mesa!7636>
parent 1176cc12
......@@ -715,7 +715,7 @@ bi_pack_add_ld_var(bi_clause *clause, bi_instruction *ins, bi_registers *regs)
{
bool imm = ins->src[0] & BIR_INDEX_CONSTANT;
if (imm && bi_get_immediate(ins, 0) >= 20)
if (ins->load_vary.special)
return pan_pack_add_ld_var_special(clause, ins, regs);
if (ins->load_vary.flat) {
......
......@@ -240,6 +240,15 @@ bi_print_load_vary(struct bi_load_vary *load, FILE *fp)
{
fprintf(fp, "%s", bi_interp_mode_name(load->interp_mode));
if (load->special) {
switch (load->var_id) {
case BIFROST_SPECIAL_VAR_POINT: fprintf(fp, ".point"); break;
case BIFROST_SPECIAL_VAR_FRAGZ: fprintf(fp, ".fragz"); break;
case BIFROST_SPECIAL_VAR_FRAGW: fprintf(fp, ".fragw"); break;
default: unreachable("Invalid varying ID");
}
}
if (load->reuse)
fprintf(fp, ".reuse");
......
......@@ -31,10 +31,8 @@
static bool
bi_is_fragz(bi_instruction *ins)
{
if (!(ins->src[0] & BIR_INDEX_CONSTANT))
return false;
return (ins->constant.u32 == BIFROST_FRAGZ);
return ins->load_vary.special &&
ins->load_vary.var_id == BIFROST_SPECIAL_VAR_FRAGZ;
}
static enum bifrost_message_type
......
......@@ -236,8 +236,11 @@ enum bifrost_update_mode {
};
/* Fixed location for gl_FragCoord.zw */
#define BIFROST_FRAGZ (23)
#define BIFROST_FRAGW (22)
enum bifrost_special_var_id {
BIFROST_SPECIAL_VAR_POINT = 0,
BIFROST_SPECIAL_VAR_FRAGW = 2,
BIFROST_SPECIAL_VAR_FRAGZ = 3,
};
enum branch_bit_size {
BR_SIZE_32 = 0,
......
......@@ -568,6 +568,10 @@ bi_emit_ld_frag_coord(bi_context *ctx, nir_intrinsic_instr *instr)
.load_vary = {
.interp_mode = BIFROST_INTERP_CENTER,
.update_mode = BIFROST_UPDATE_CLOBBER,
.var_id = (i == 0) ?
BIFROST_SPECIAL_VAR_FRAGZ :
BIFROST_SPECIAL_VAR_FRAGW,
.special = true,
.reuse = false,
.flat = true
},
......@@ -575,14 +579,8 @@ bi_emit_ld_frag_coord(bi_context *ctx, nir_intrinsic_instr *instr)
.dest_type = nir_type_float32,
.format = nir_type_float32,
.dest = bi_make_temp(ctx),
.src = {
BIR_INDEX_CONSTANT,
BIR_INDEX_PASS | BIFROST_SRC_FAU_LO
},
.src_types = { nir_type_uint32, nir_type_uint32 },
.constant = {
.u32 = (i == 0) ? BIFROST_FRAGZ : BIFROST_FRAGW
}
.src[0] = BIR_INDEX_PASS | BIFROST_SRC_FAU_LO,
.src_types[0] = nir_type_uint32,
};
bi_emit(ctx, load);
......@@ -727,19 +725,15 @@ bi_emit_point_coord(bi_context *ctx, nir_intrinsic_instr *instr)
.type = BI_LOAD_VAR,
.load_vary = {
.update_mode = BIFROST_UPDATE_CLOBBER,
.var_id = BIFROST_SPECIAL_VAR_POINT,
.special = true,
},
.vector_channels = 2,
.dest = pan_dest_index(&instr->dest),
.dest_type = nir_type_float32,
.format = nir_type_float32,
.src = {
BIR_INDEX_CONSTANT,
BIR_INDEX_ZERO,
},
.src_types = {
nir_type_uint32,
},
.constant.u64 = 20,
.src[0] = BIR_INDEX_ZERO,
.src_types[0] = nir_type_uint32,
};
bi_emit(ctx, ins);
......
......@@ -135,6 +135,8 @@ extern unsigned bi_class_props[BI_NUM_CLASSES];
struct bi_load_vary {
enum bifrost_interp_mode interp_mode;
enum bifrost_update_mode update_mode;
enum bifrost_special_var_id var_id;
bool special;
bool reuse;
bool flat;
};
......
......@@ -153,12 +153,6 @@ def pack_extend(mod, opts, body, pack_exprs):
body.append('assert({}_small);'.format(mod))
return '{}_signed ? 1 : 0'.format(mod)
# Packs special varying loads. Our BIFROST_FRAGZ etc defines match the hw in
# the bottom two bits (TODO drop upper bits)
def pack_varying_name(mod, opts, body, pack_exprs):
assert(opts[0] == 'point' and opts[2] == 'frag_w' and opts[3] == 'frag_z')
return 'ins->constant.u64 & 0x3'
def pack_not_src1(mod, opts, body, pack_exprs):
return 'ins->bitwise.src1_invert ? {} : {}'.format(opts.index('not'), opts.index('none'))
......@@ -259,7 +253,7 @@ modifier_map = {
"clamp": pack_clamp,
"round": pack_round,
"cmpf": pack_cmpf,
"varying_name": pack_varying_name,
"varying_name": lambda a,b,c,d: 'ins->load_vary.var_id',
"not1": pack_not_src1,
"not_result": pack_not_result,
"register_format": pack_register_format,
......@@ -460,9 +454,6 @@ def pack_variant(opname, states):
offset += len(set(["attribute_index", "varying_index", "index"]) & set([x[0] for x in states[0][1].get("immediates", [])]))
if opname == '+LD_VAR_SPECIAL':
offset += 1
pack_sources(states[0][1].get("srcs", []), common_body, pack_exprs, offset)
modifiers_handled = []
......
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