panfrost: Pass a pipe-like swizzle to panfrost_new_texture()
authorBoris Brezillon <boris.brezillon@collabora.com>
Fri, 18 Dec 2020 09:37:11 +0000 (10:37 +0100)
committerBoris Brezillon <boris.brezillon@collabora.com>
Mon, 4 Jan 2021 16:05:42 +0000 (17:05 +0100)
And let the function translate it to a mali swizzle. This way we will
be able to adjust the swizzle if needed.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8125>

src/gallium/drivers/panfrost/pan_context.c
src/panfrost/lib/pan_blit.c
src/panfrost/lib/pan_texture.c
src/panfrost/lib/pan_texture.h

index 70dc76e..9c79721 100644 (file)
@@ -1070,7 +1070,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
                              so->base.u.tex.first_layer,
                              so->base.u.tex.last_layer,
                              texture->nr_samples,
-                             panfrost_translate_swizzle_4(user_swizzle),
+                             user_swizzle,
                              prsrc->bo->ptr.gpu, &payload);
 }
 
index e3c7c2b..2ba20cd 100644 (file)
@@ -321,6 +321,10 @@ midgard_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw,
                 image->first_layer *
                 panfrost_get_layer_stride(image->layout, image->first_level);
 
+        unsigned char swizzle[4] = {
+                PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W
+        };
+
         panfrost_new_texture(pool->dev, image->layout, texture.cpu,
                              image->width0, image->height0,
                              MAX2(image->nr_samples, 1), 1,
@@ -328,7 +332,7 @@ midgard_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw,
                              image->first_level, image->last_level,
                              0, 0,
                              image->nr_samples,
-                             PAN_V6_SWIZZLE(R, G, B, A),
+                             swizzle,
                              image->bo->ptr.gpu + offset, &payload);
 
         pan_pack(sampler.cpu, MIDGARD_SAMPLER, cfg)
@@ -495,6 +499,10 @@ bifrost_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw,
                 image->first_layer *
                 panfrost_get_layer_stride(image->layout, image->first_level);
 
+        unsigned char swizzle[4] = {
+                PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W
+        };
+
         panfrost_new_texture(pool->dev, image->layout, texture.cpu,
                              image->width0, image->height0,
                              MAX2(image->nr_samples, 1), 1,
@@ -502,7 +510,7 @@ bifrost_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw,
                              image->first_level, image->last_level,
                              0, 0,
                              image->nr_samples,
-                             PAN_V6_SWIZZLE(R, G, B, A),
+                             swizzle,
                              image->bo->ptr.gpu + offset, &payload);
 
         pan_pack(sampler.cpu, BIFROST_SAMPLER, cfg) {
index 5c8fc4d..5075774 100644 (file)
@@ -409,10 +409,11 @@ panfrost_new_texture(const struct panfrost_device *dev,
                      unsigned first_level, unsigned last_level,
                      unsigned first_layer, unsigned last_layer,
                      unsigned nr_samples,
-                     unsigned swizzle,
+                     const unsigned char user_swizzle[4],
                      mali_ptr base,
                      const struct panfrost_ptr *payload)
 {
+        unsigned swizzle = panfrost_translate_swizzle_4(user_swizzle);
         const struct util_format_description *desc =
                 util_format_description(format);
 
index aa5440a..db7f90c 100644 (file)
@@ -133,7 +133,7 @@ panfrost_new_texture(const struct panfrost_device *dev,
                      unsigned first_level, unsigned last_level,
                      unsigned first_layer, unsigned last_layer,
                      unsigned nr_samples,
-                     unsigned swizzle,
+                     const unsigned char swizzle[4],
                      mali_ptr base,
                      const struct panfrost_ptr *payload);