aboutsummaryrefslogtreecommitdiffstats
path: root/src/panfrost/util
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2020-05-13 13:55:51 -0400
committerMarge Bot <[email protected]>2020-06-01 15:46:23 +0000
commitf01aabb82968077e7ed690276394074cca14bf3e (patch)
tree8140a10ee04bc713dfa7aacda9c33bf1785c84bb /src/panfrost/util
parent9a6483bb47fb654e3c78e5d81e8500b993d51cbd (diff)
panfrost: Un/pack pure 8-bit
Signed-off-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5265>
Diffstat (limited to 'src/panfrost/util')
-rw-r--r--src/panfrost/util/pan_lower_framebuffer.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/panfrost/util/pan_lower_framebuffer.c b/src/panfrost/util/pan_lower_framebuffer.c
index aa1d6fc85fa..e791ff5ea08 100644
--- a/src/panfrost/util/pan_lower_framebuffer.c
+++ b/src/panfrost/util/pan_lower_framebuffer.c
@@ -194,6 +194,43 @@ pan_unpack_pure_16(nir_builder *b, nir_ssa_def *pack, unsigned num_components)
return nir_vec(b, unpacked, 4);
}
+/* And likewise for x8. pan_fill_4 fills a 4-channel vector with a n-channel
+ * vector (n <= 4), replicating as needed. pan_replicate_4 constructs a
+ * 4-channel vector from a scalar via replication */
+
+static nir_ssa_def *
+pan_fill_4(nir_builder *b, nir_ssa_def *v)
+{
+ nir_ssa_def *q[4];
+ assert(v->num_components <= 4);
+
+ for (unsigned j = 0; j < 4; ++j)
+ q[j] = nir_channel(b, v, j % v->num_components);
+
+ return nir_vec(b, q, 4);
+}
+
+static nir_ssa_def *
+pan_replicate_4(nir_builder *b, nir_ssa_def *v)
+{
+ nir_ssa_def *replicated[4] = { v, v, v, v };
+ return nir_vec(b, replicated, 4);
+}
+
+static nir_ssa_def *
+pan_pack_pure_8(nir_builder *b, nir_ssa_def *v)
+{
+ return pan_replicate_4(b, nir_pack_32_4x8(b, pan_fill_4(b, v)));
+}
+
+static nir_ssa_def *
+pan_unpack_pure_8(nir_builder *b, nir_ssa_def *pack, unsigned num_components)
+{
+ assert(num_components <= 4);
+ nir_ssa_def *unpacked = nir_unpack_32_4x8(b, nir_channel(b, pack, 0));
+ return nir_channels(b, unpacked, (1 << num_components) - 1);
+}
+
/* Generic dispatches for un/pack regardless of format */
static nir_ssa_def *