summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>2020-05-28 12:39:42 -0400
committerMarge Bot <eric+marge@anholt.net>2020-05-29 20:34:55 +0000
commit9c329567508836b5b40cfbacf29a840e1e6d4c41 (patch)
tree30e951511a6ea52226d96bd77cdbe8579ac9b0c8
parentcd9a08d4f2360c227eb17f5b1f166ac46ca08ebe (diff)
pan/bi: Preliminary branch packing
Simple == 0 branch packing. Offset is still to-do. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5260>
-rw-r--r--src/panfrost/bifrost/bi_pack.c36
-rw-r--r--src/panfrost/bifrost/bifrost.h2
2 files changed, 37 insertions, 1 deletions
diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c
index b5cbc5fa948..7366b16c6c6 100644
--- a/src/panfrost/bifrost/bi_pack.c
+++ b/src/panfrost/bifrost/bi_pack.c
@@ -1620,6 +1620,40 @@ bi_pack_add_imath(bi_instruction *ins, bi_registers *regs)
}
static unsigned
+bi_pack_add_branch(bi_instruction *ins, bi_registers *regs)
+{
+ assert(ins->cond == BI_COND_EQ);
+ assert(ins->src[1] == BIR_INDEX_ZERO);
+
+ unsigned zero_ctrl = 0;
+ unsigned size = nir_alu_type_get_type_size(ins->src_types[0]);
+
+ if (size == 16) {
+ /* See BR_SIZE_ZERO swizzle disassembly */
+ zero_ctrl = ins->swizzle[0][0] ? 1 : 2;
+ } else {
+ assert(size == 32);
+ }
+
+ /* EQ swap to NE */
+ bool port_swapped = false;
+
+ /* We assigned the constant port to fetch the branch offset so we can
+ * just passthrough here. We put in the HI slot to match the blob since
+ * that's where the magic flags end up */
+ struct bifrost_branch pack = {
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = (zero_ctrl << 1) | !port_swapped,
+ .src2 = BIFROST_SRC_CONST_HI,
+ .cond = BR_COND_EQ,
+ .size = BR_SIZE_ZERO,
+ .op = BIFROST_ADD_OP_BRANCH
+ };
+
+ RETURN_PACKED(pack);
+}
+
+static unsigned
bi_pack_add(bi_clause *clause, bi_bundle bundle, bi_registers *regs, gl_shader_stage stage)
{
if (!bundle.add)
@@ -1631,7 +1665,7 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, bi_registers *regs, gl_shader_s
case BI_ATEST:
return bi_pack_add_atest(clause, bundle.add, regs);
case BI_BRANCH:
- unreachable("Packing todo");
+ return bi_pack_add_branch(bundle.add, regs);
case BI_CMP:
return bi_pack_add_cmp(bundle.add, regs);
case BI_BLEND:
diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h
index 9ccc30bd8b7..fa07b749e5e 100644
--- a/src/panfrost/bifrost/bifrost.h
+++ b/src/panfrost/bifrost/bifrost.h
@@ -734,6 +734,8 @@ enum bifrost_branch_code {
BR_ALWAYS = 63,
};
+#define BIFROST_ADD_OP_BRANCH (0x0d000 >> 12)
+
struct bifrost_branch {
unsigned src0 : 3;