aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/panfrost/pan_format.c
diff options
context:
space:
mode:
authorTomeu Vizoso <[email protected]>2019-10-30 12:05:30 +0100
committerTomeu Vizoso <[email protected]>2019-11-06 16:18:46 +0100
commit9447a84f69c639cdd84fccec7e9447b88be35e30 (patch)
tree52f33bf0c1b59b0b3ae30bed8a7bee1e61325b3c /src/gallium/drivers/panfrost/pan_format.c
parente40d11ccb27f4ebfc2d7874443fe44969a3f28df (diff)
panfrost: Rework format encoding on SFBD
Signed-off-by: Alyssa Rosenzweig <[email protected]> Signed-off-by: Tomeu Vizoso <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost/pan_format.c')
-rw-r--r--src/gallium/drivers/panfrost/pan_format.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gallium/drivers/panfrost/pan_format.c b/src/gallium/drivers/panfrost/pan_format.c
index f272e3a3716..2596b41feac 100644
--- a/src/gallium/drivers/panfrost/pan_format.c
+++ b/src/gallium/drivers/panfrost/pan_format.c
@@ -247,4 +247,26 @@ panfrost_find_format(const struct util_format_description *desc) {
return (enum mali_format) format;
}
+void
+panfrost_invert_swizzle(const unsigned char *in, unsigned char *out)
+{
+ /* First, default to all zeroes to prevent uninitialized junk */
+
+ for (unsigned c = 0; c < 4; ++c)
+ out[c] = PIPE_SWIZZLE_0;
+
+ /* Now "do" what the swizzle says */
+
+ for (unsigned c = 0; c < 4; ++c) {
+ unsigned char i = in[c];
+ /* Who cares? */
+ assert(PIPE_SWIZZLE_X == 0);
+ if (i > PIPE_SWIZZLE_W)
+ continue;
+
+ /* Invert */
+ unsigned idx = i - PIPE_SWIZZLE_X;
+ out[idx] = PIPE_SWIZZLE_X + c;
+ }
+}