From e06426ea85fa9092e3488c9e4600181f534454b6 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 18 Mar 2020 23:03:07 -0400 Subject: [PATCH] pan/bi: Add ATEST packing Only fp32 for now. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_pack.c | 22 ++++++++++++++++++++++ src/panfrost/bifrost/bifrost.h | 16 ++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 2f961650d3e..705a43e3531 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -435,6 +435,26 @@ bi_pack_add_ld_vary(bi_clause *clause, bi_instruction *ins, struct bi_registers RETURN_PACKED(pack); } +static unsigned +bi_pack_add_atest(bi_clause *clause, bi_instruction *ins, struct bi_registers *regs) +{ + /* TODO: fp16 */ + assert(ins->src_types[1] == nir_type_float32); + + struct bifrost_add_atest pack = { + .src0 = bi_get_src(ins, regs, 0, false), + .src1 = bi_get_src(ins, regs, 1, false), + .component = 1, /* Set for fp32 */ + .op = BIFROST_ADD_OP_ATEST, + }; + + /* Despite *also* writing with the usual mechanism... quirky and + * perhaps unnecessary, but let's match the blob */ + clause->data_register = ins->dest & ~BIR_INDEX_REGISTER; + + RETURN_PACKED(pack); +} + static unsigned bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) { @@ -443,7 +463,9 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) switch (bundle.add->type) { case BI_ADD: + return BIFROST_ADD_NOP; case BI_ATEST: + return bi_pack_add_atest(clause, bundle.add, regs); case BI_BRANCH: case BI_CMP: case BI_BLEND: diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index 959ef94f6c1..9fb063c32af 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -105,6 +105,22 @@ struct bifrost_add_inst { unsigned op : 17; } __attribute__((packed)); +#define BIFROST_ADD_OP_ATEST (0xc8f) + +struct bifrost_add_atest { + /* gl_SampleMask (R60) */ + unsigned src0 : 3; + + /* Alpha value */ + unsigned src1 : 3; + + /* If half, X/Y select. If !half, always set */ + unsigned component : 1; + unsigned half : 1; + + unsigned op : 12; +} __attribute__((packed)); + enum bifrost_outmod { BIFROST_NONE = 0x0, BIFROST_POS = 0x1, -- 2.30.2