From f25850bf5f9e83b2ae00ef283caad3c35d2fb8cb Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Mon, 12 Oct 2020 10:57:40 +0200 Subject: [PATCH] pan/bi: Use canonical name for FAU RAM sources The uniform_constant field and BIFROST_SRC_CONST_{LO,HI} definitions seem to imply that those only deal with embedded constants. Let's rename them to reflect the fact that they actually encode accesses to the Fast-Access-Uniform RAM. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_pack.c | 52 +++++++++++++++++----------------- src/panfrost/bifrost/bifrost.h | 6 ++-- src/panfrost/bifrost/bifrost_compile.c | 6 ++-- src/panfrost/bifrost/compiler.h | 5 ++-- src/panfrost/bifrost/disassemble.c | 28 +++++++++--------- 5 files changed, 49 insertions(+), 48 deletions(-) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index e1d0a4a..195cc72 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -115,17 +115,18 @@ bi_constant_field(unsigned idx) } static bool -bi_assign_uniform_constant_single( - bi_registers *regs, - bi_clause *clause, - bi_instruction *ins, bool assigned, bool fast_zero) +bi_assign_fau_idx_single(bi_registers *regs, + bi_clause *clause, + bi_instruction *ins, + bool assigned, + bool fast_zero) { if (!ins) return assigned; if (ins->type == BI_BLEND) { assert(!assigned); - regs->uniform_constant = 0x8; + regs->fau_idx = 0x8; return true; } @@ -140,10 +141,10 @@ bi_assign_uniform_constant_single( /* Build the constant */ unsigned C = bi_constant_field(idx) | lo; - if (assigned && regs->uniform_constant != C) - unreachable("Mismatched uniform/const field: branch"); + if (assigned && regs->fau_idx != C) + unreachable("Mismatched fau_idx: branch"); - regs->uniform_constant = C; + regs->fau_idx = C; return true; } @@ -163,25 +164,25 @@ bi_assign_uniform_constant_single( unsigned lo = clause->constants[idx] & 0xF; unsigned f = bi_constant_field(idx) | lo; - if (assigned && regs->uniform_constant != f) + if (assigned && regs->fau_idx != f) unreachable("Mismatched uniform/const field: imm"); - regs->uniform_constant = f; - ins->src[s] = BIR_INDEX_PASS | (hi ? BIFROST_SRC_CONST_HI : BIFROST_SRC_CONST_LO); + regs->fau_idx = f; + ins->src[s] = BIR_INDEX_PASS | (hi ? BIFROST_SRC_FAU_HI : BIFROST_SRC_FAU_LO); assigned = true; } else if (ins->src[s] & BIR_INDEX_ZERO && (ins->type == BI_LOAD_UNIFORM || ins->type == BI_LOAD_VAR)) { /* XXX: HACK UNTIL WE HAVE HI MATCHING DUE TO OVERFLOW XXX */ - ins->src[s] = BIR_INDEX_PASS | BIFROST_SRC_CONST_HI; + ins->src[s] = BIR_INDEX_PASS | BIFROST_SRC_FAU_HI; } else if (ins->src[s] & BIR_INDEX_ZERO && !fast_zero) { /* FMAs have a fast zero slot, ADD needs to use the * uniform/const slot's special 0 mode handled here */ unsigned f = 0; - if (assigned && regs->uniform_constant != f) + if (assigned && regs->fau_idx != f) unreachable("Mismatched uniform/const field: 0"); - regs->uniform_constant = f; - ins->src[s] = BIR_INDEX_PASS | BIFROST_SRC_CONST_LO; + regs->fau_idx = f; + ins->src[s] = BIR_INDEX_PASS | BIFROST_SRC_FAU_LO; assigned = true; } else if (ins->src[s] & BIR_INDEX_ZERO && fast_zero) { ins->src[s] = BIR_INDEX_PASS | BIFROST_SRC_STAGE; @@ -194,15 +195,14 @@ bi_assign_uniform_constant_single( } static void -bi_assign_uniform_constant( - bi_clause *clause, - bi_registers *regs, - bi_bundle bundle) +bi_assign_fau_idx(bi_clause *clause, + bi_registers *regs, + bi_bundle bundle) { bool assigned = - bi_assign_uniform_constant_single(regs, clause, bundle.fma, false, true); + bi_assign_fau_idx_single(regs, clause, bundle.fma, false, true); - bi_assign_uniform_constant_single(regs, clause, bundle.add, assigned, false); + bi_assign_fau_idx_single(regs, clause, bundle.add, assigned, false); } /* Assigns a slot for reading, before anything is written */ @@ -395,7 +395,7 @@ bi_pack_registers(bi_registers regs) s.reg2 = regs.slot[2]; s.reg3 = regs.slot[3]; - s.uniform_const = regs.uniform_constant; + s.fau_idx = regs.fau_idx; memcpy(&packed, &s, sizeof(s)); return packed; @@ -612,7 +612,7 @@ bi_pack_add_branch_cond(bi_instruction *ins, bi_registers *regs) struct bifrost_branch pack = { .src0 = bi_get_src(ins, regs, 0), .src1 = (zero_ctrl << 1) | !slot_swapped, - .src2 = BIFROST_SRC_CONST_HI, + .src2 = BIFROST_SRC_FAU_HI, .cond = BR_COND_EQ, .size = BR_SIZE_ZERO, .op = BIFROST_ADD_OP_BRANCH @@ -626,11 +626,11 @@ bi_pack_add_branch_uncond(bi_instruction *ins, bi_registers *regs) { struct bifrost_branch pack = { /* It's unclear what these bits actually mean */ - .src0 = BIFROST_SRC_CONST_LO, + .src0 = BIFROST_SRC_FAU_LO, .src1 = BIFROST_SRC_PASS_FMA, /* Offset, see above */ - .src2 = BIFROST_SRC_CONST_HI, + .src2 = BIFROST_SRC_FAU_HI, /* All ones in fact */ .cond = (BR_ALWAYS & 0x7), @@ -894,7 +894,7 @@ static struct bi_packed_bundle bi_pack_bundle(bi_clause *clause, bi_bundle bundle, bi_bundle prev, bool first_bundle, gl_shader_stage stage) { bi_assign_slots(&bundle, &prev); - bi_assign_uniform_constant(clause, &bundle.regs, bundle); + bi_assign_fau_idx(clause, &bundle.regs, bundle); bundle.regs.first_instruction = first_bundle; bi_flip_slots(&bundle.regs); diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index 0592cc0..55148c8 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -163,8 +163,8 @@ enum bifrost_packed_src { BIFROST_SRC_PORT1 = 1, BIFROST_SRC_PORT2 = 2, BIFROST_SRC_STAGE = 3, - BIFROST_SRC_CONST_LO = 4, - BIFROST_SRC_CONST_HI = 5, + BIFROST_SRC_FAU_LO = 4, + BIFROST_SRC_FAU_HI = 5, BIFROST_SRC_PASS_FMA = 6, BIFROST_SRC_PASS_ADD = 7, }; @@ -252,7 +252,7 @@ enum branch_bit_size { }; struct bifrost_regs { - unsigned uniform_const : 8; + unsigned fau_idx : 8; unsigned reg3 : 6; unsigned reg2 : 6; unsigned reg0 : 5; diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 0f466a6..509f9a3 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -158,8 +158,8 @@ bi_emit_frag_out(bi_context *ctx, nir_intrinsic_instr *instr) pan_src_index(&instr->src[0]), BIR_INDEX_REGISTER | 60 /* Can this be arbitrary? */, /* Blend descriptor */ - BIR_INDEX_PASS | BIFROST_SRC_CONST_LO, - BIR_INDEX_PASS | BIFROST_SRC_CONST_HI, + BIR_INDEX_PASS | BIFROST_SRC_FAU_LO, + BIR_INDEX_PASS | BIFROST_SRC_FAU_HI, }, .src_types = { nir_intrinsic_src_type(instr), @@ -343,7 +343,7 @@ bi_emit_ld_frag_coord(bi_context *ctx, nir_intrinsic_instr *instr) .dest = bi_make_temp(ctx), .src = { BIR_INDEX_CONSTANT, - BIR_INDEX_PASS | BIFROST_SRC_CONST_LO + BIR_INDEX_PASS | BIFROST_SRC_FAU_LO }, .src_types = { nir_type_uint32, nir_type_uint32 }, .constant = { diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 7b58d09..bfc58ae 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -356,8 +356,8 @@ typedef struct { /* Configuration for slots 2/3 */ struct bifrost_reg_ctrl_23 slot23; - /* Packed uniform/constant */ - uint8_t uniform_constant; + /* Fast-Access-Uniform RAM index */ + uint8_t fau_idx; /* Whether writes are actually for the last instruction */ bool first_instruction; @@ -369,6 +369,7 @@ typedef struct { */ typedef struct { + uint8_t fau_idx; bi_registers regs; bi_instruction *fma; bi_instruction *add; diff --git a/src/panfrost/bifrost/disassemble.c b/src/panfrost/bifrost/disassemble.c index acea3e0..df18746 100644 --- a/src/panfrost/bifrost/disassemble.c +++ b/src/panfrost/bifrost/disassemble.c @@ -186,9 +186,9 @@ static void dump_regs(FILE *fp, struct bifrost_regs srcs, bool first) else if (ctrl.slot23.slot3 == BIFROST_OP_WRITE_HI) fprintf(fp, "slot 3: r%d (write hi %s) ", srcs.reg3, slot3_fma); - if (srcs.uniform_const) { - if (srcs.uniform_const & 0x80) { - fprintf(fp, "uniform: u%d", (srcs.uniform_const & 0x7f) * 2); + if (srcs.fau_idx) { + if (srcs.fau_idx & 0x80) { + fprintf(fp, "uniform: u%d", (srcs.fau_idx & 0x7f) * 2); } } @@ -291,15 +291,15 @@ const_fau_to_idx(unsigned fau_value) return map[fau_value]; } -static void dump_uniform_const_src(FILE *fp, struct bifrost_regs srcs, struct bi_constants *consts, bool high32) +static void dump_fau_src(FILE *fp, struct bifrost_regs srcs, struct bi_constants *consts, bool high32) { - if (srcs.uniform_const & 0x80) { - unsigned uniform = (srcs.uniform_const & 0x7f); + if (srcs.fau_idx & 0x80) { + unsigned uniform = (srcs.fau_idx & 0x7f); fprintf(fp, "u%d.w%d", uniform, high32); - } else if (srcs.uniform_const >= 0x20) { - unsigned idx = const_fau_to_idx(srcs.uniform_const >> 4); + } else if (srcs.fau_idx >= 0x20) { + unsigned idx = const_fau_to_idx(srcs.fau_idx >> 4); uint64_t imm = consts->raw[idx]; - imm |= (srcs.uniform_const & 0xf); + imm |= (srcs.fau_idx & 0xf); if (consts->mods[idx] != BI_CONSTMOD_NONE) dump_pc_imm(fp, imm, consts->mods[idx], high32); else if (high32) @@ -307,7 +307,7 @@ static void dump_uniform_const_src(FILE *fp, struct bifrost_regs srcs, struct bi else dump_const_imm(fp, imm); } else { - switch (srcs.uniform_const) { + switch (srcs.fau_idx) { case 0: fprintf(fp, "#0"); break; @@ -337,10 +337,10 @@ static void dump_uniform_const_src(FILE *fp, struct bifrost_regs srcs, struct bi case 13: case 14: case 15: - fprintf(fp, "blend_descriptor_%u", (unsigned) srcs.uniform_const - 8); + fprintf(fp, "blend_descriptor_%u", (unsigned) srcs.fau_idx - 8); break; default: - fprintf(fp, "XXX - reserved%u", (unsigned) srcs.uniform_const); + fprintf(fp, "XXX - reserved%u", (unsigned) srcs.fau_idx); break; } @@ -371,10 +371,10 @@ dump_src(FILE *fp, unsigned src, struct bifrost_regs srcs, struct bi_constants * fprintf(fp, "t"); // i.e. the output of FMA this cycle break; case 4: - dump_uniform_const_src(fp, srcs, consts, false); + dump_fau_src(fp, srcs, consts, false); break; case 5: - dump_uniform_const_src(fp, srcs, consts, true); + dump_fau_src(fp, srcs, consts, true); break; case 6: fprintf(fp, "t0"); -- 2.7.4