From 01d0fb1cdeef106e430f9c35afe2364cc98cff7f Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 30 Nov 2023 19:00:40 -0400 Subject: [PATCH] asahi: fix pbe swizzling fixes cases in KHR-GL33.packed_pixels.rectangle.*. matches what the powervr driver does. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_state.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 4e2fb95e063..86dfbb37d9a 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -1257,16 +1257,17 @@ agx_batch_upload_pbe(struct agx_batch *batch, struct agx_pbe_packed *out, cfg.srgb = util_format_is_srgb(view->format); assert(desc->nr_channels >= 1 && desc->nr_channels <= 4); - cfg.swizzle_r = agx_channel_from_pipe(desc->swizzle[0]) & 3; - if (desc->nr_channels >= 2) - cfg.swizzle_g = agx_channel_from_pipe(desc->swizzle[1]) & 3; - - if (desc->nr_channels >= 3) - cfg.swizzle_b = agx_channel_from_pipe(desc->swizzle[2]) & 3; - - if (desc->nr_channels >= 4) - cfg.swizzle_a = agx_channel_from_pipe(desc->swizzle[3]) & 3; + for (unsigned i = 0; i < desc->nr_channels; ++i) { + if (desc->swizzle[i] == 0) + cfg.swizzle_r = i; + else if (desc->swizzle[i] == 1) + cfg.swizzle_g = i; + else if (desc->swizzle[i] == 2) + cfg.swizzle_b = i; + else if (desc->swizzle[i] == 3) + cfg.swizzle_a = i; + } cfg.buffer = agx_map_texture_gpu(tex, layer); cfg.unk_mipmapped = tex->mipmapped;