From: Alyssa Rosenzweig Date: Thu, 28 May 2020 17:08:04 +0000 (-0400) Subject: pan/bi: Pack branch offset constants X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b9967ab6da8a1c383939752611ad564aee271cb7;p=mesa.git pan/bi: Pack branch offset constants This is not fully generic but for a single constant it will do. Extensions left for future work. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 9f8bf6b08a4..f35de67abf2 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -1705,7 +1705,18 @@ bi_pack_bundle(bi_clause *clause, bi_bundle bundle, bi_bundle prev, bool first_b } /* Packs the next two constants as a dedicated constant quadword at the end of - * the clause, returning the number packed. */ + * the clause, returning the number packed. There are two cases to consider: + * + * Case #1: Branching is not used. For a single constant copy the upper nibble + * over, easy. + * + * Case #2: Branching is used. For a single constant, it suffices to set the + * upper nibble to 4 and leave the latter constant 0, which matches what the + * blob does. + * + * Extending to multiple constants is considerably more tricky and left for + * future work. + */ static unsigned bi_pack_constants(bi_context *ctx, bi_clause *clause, @@ -1716,6 +1727,9 @@ bi_pack_constants(bi_context *ctx, bi_clause *clause, bool done = clause->constant_count <= (index + 2); bool only = clause->constant_count <= (index + 1); + /* Is the constant we're packing for a branch? */ + bool branches = clause->branch_constant && done; + /* TODO: Pos */ assert(index == 0 && clause->bundle_count == 1); assert(only); @@ -1729,6 +1743,13 @@ bi_pack_constants(bi_context *ctx, bi_clause *clause, .imm_2 = ((hi < 8) ? (hi << 60ull) : 0) >> 4, }; + if (branches) { + /* Branch offsets are less than 60-bits so this should work at + * least for now */ + quad.imm_1 |= (4ull << 60ull) >> 4; + assert (hi == 0); + } + /* XXX: On G71, Connor observed that the difference of the top 4 bits * of the second constant with the first must be less than 8, otherwise * we have to swap them. On G52, I'm able to reproduce a similar issue