diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-06-25 08:51:48 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-06-25 13:39:18 -0700 |
commit | 5cfb4248c6eb5afdc00b3893178e87af37dcf309 (patch) | |
tree | c2022e25b05bcc936993e17caec5f8b0aecdc1bf | |
parent | b96f119d853203945c4174145679669afabc1edf (diff) |
panfrost: Invert swizzle for rendering
Fixes rendering to e.g. alpha textures.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r-- | src/gallium/drivers/panfrost/pan_mfbd.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c index 4d5fa4ad9ac..91e04a34e80 100644 --- a/src/gallium/drivers/panfrost/pan_mfbd.c +++ b/src/gallium/drivers/panfrost/pan_mfbd.c @@ -28,13 +28,41 @@ #include "util/u_format.h" +static 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? */ + if (i < PIPE_SWIZZLE_X || i > PIPE_SWIZZLE_W) + continue; + + /* Invert */ + unsigned idx = i - PIPE_SWIZZLE_X; + out[idx] = PIPE_SWIZZLE_X + c; + } +} + static struct mali_rt_format panfrost_mfbd_format(struct pipe_surface *surf) { /* Explode details on the format */ const struct util_format_description *desc = - util_format_description(surf->texture->format); + util_format_description(surf->format); + + /* The swizzle for rendering is inverted from texturing */ + + unsigned char swizzle[4]; + panfrost_invert_swizzle(desc->swizzle, swizzle); /* Fill in accordingly, defaulting to 8-bit UNORM */ @@ -44,7 +72,7 @@ panfrost_mfbd_format(struct pipe_surface *surf) .nr_channels = MALI_POSITIVE(desc->nr_channels), .unk3 = 0x4, .flags = 0x8, - .swizzle = panfrost_translate_swizzle_4(desc->swizzle), + .swizzle = panfrost_translate_swizzle_4(swizzle), .unk4 = 0x8 }; |