From 7321a17c6abcd23a281cc4209562f919b61e7cc5 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 20 Mar 2020 11:52:43 -0400 Subject: [PATCH] pan/bi: Pack ld_ubo ops Routes some infrastructure to do so at least slightly generically but we'll see. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_pack.c | 39 ++++++++++++++++++++++++++++++++++ src/panfrost/bifrost/bifrost.h | 11 ++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 719ac2a1a24..642a77ef240 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -352,6 +352,15 @@ bi_pack_registers(struct bi_registers regs) return packed; } +static void +bi_write_data_register(bi_clause *clause, bi_instruction *ins) +{ + assert(ins->dest & BIR_INDEX_REGISTER); + unsigned reg = ins->dest & ~BIR_INDEX_REGISTER; + assert(reg <= 63); + clause->data_register = reg; +} + static enum bifrost_packed_src bi_get_src_reg_port(struct bi_registers *regs, unsigned src) { @@ -512,6 +521,34 @@ bi_pack_add_ld_vary(bi_clause *clause, bi_instruction *ins, struct bi_registers RETURN_PACKED(pack); } +static unsigned +bi_pack_add_2src(bi_instruction *ins, struct bi_registers *regs, unsigned op) +{ + struct bifrost_add_2src pack = { + .src0 = bi_get_src(ins, regs, 0, true), + .src1 = bi_get_src(ins, regs, 1, true), + .op = op + }; + + RETURN_PACKED(pack); +} + +static unsigned +bi_pack_add_ld_ubo(bi_clause *clause, bi_instruction *ins, struct bi_registers *regs) +{ + unsigned components = bi_load32_components(ins); + + const unsigned ops[4] = { + BIFROST_ADD_OP_LD_UBO_1, + BIFROST_ADD_OP_LD_UBO_2, + BIFROST_ADD_OP_LD_UBO_3, + BIFROST_ADD_OP_LD_UBO_4 + }; + + bi_write_data_register(clause, ins); + return bi_pack_add_2src(ins, regs, ops[components - 1]); +} + static unsigned bi_pack_add_atest(bi_clause *clause, bi_instruction *ins, struct bi_registers *regs) { @@ -568,7 +605,9 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) case BI_FREXP: case BI_ISUB: case BI_LOAD: + return BIFROST_ADD_NOP; case BI_LOAD_UNIFORM: + return bi_pack_add_ld_ubo(clause, bundle.add, regs); case BI_LOAD_ATTR: return BIFROST_ADD_NOP; case BI_LOAD_VAR: diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index b99115796d6..4cd47ef01ab 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -110,6 +110,17 @@ struct bifrost_add_inst { unsigned op : 17; } __attribute__((packed)); +#define BIFROST_ADD_OP_LD_UBO_1 (0x0c1a0 >> 3) +#define BIFROST_ADD_OP_LD_UBO_2 (0x0c1e0 >> 3) +#define BIFROST_ADD_OP_LD_UBO_3 (0x0caa0 >> 3) +#define BIFROST_ADD_OP_LD_UBO_4 (0x0c220 >> 3) + +struct bifrost_add_2src { + unsigned src0 : 3; + unsigned src1 : 3; + unsigned op : 14; +} __attribute__((packed)); + #define BIFROST_ADD_OP_ATEST (0xc8f) struct bifrost_add_atest { -- 2.30.2