Module: Mesa
Branch: main
Commit: 40656b6fa05faaa6582a3fc40abdc3a9d99dcf85
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=40656b6fa05faaa6582a3fc40abdc3a9d99dcf85

Author: Erik Faye-Lund <erik.faye-l...@collabora.com>
Date:   Wed Nov  1 15:24:20 2023 +0100

panfrost: pass blendable formats to pan_pack_color

This allows us to specify the correct array later on, while still being
able to use the function as-is from call-sites that doesn't have a
panfrost_device.

Reviewed-by: Boris Brezillon <boris.brezil...@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25968>

---

 src/gallium/drivers/panfrost/pan_job.c    | 3 ++-
 src/panfrost/lib/pan_clear.c              | 6 +++---
 src/panfrost/lib/pan_util.h               | 4 +++-
 src/panfrost/lib/tests/test-clear.c       | 4 +++-
 src/panfrost/vulkan/panvk_cmd_buffer.c    | 3 ++-
 src/panfrost/vulkan/panvk_vX_meta_clear.c | 5 +++--
 6 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_job.c 
b/src/gallium/drivers/panfrost/pan_job.c
index 717e7db9f36..a24a081d0a3 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -948,7 +948,8 @@ panfrost_batch_clear(struct panfrost_batch *batch, unsigned 
buffers,
             continue;
 
          enum pipe_format format = ctx->pipe_framebuffer.cbufs[i]->format;
-         pan_pack_color(batch->clear_color[i], color, format, false);
+         pan_pack_color(panfrost_blendable_formats_v7, batch->clear_color[i],
+                        color, format, false);
       }
    }
 
diff --git a/src/panfrost/lib/pan_clear.c b/src/panfrost/lib/pan_clear.c
index eed14e3c2a3..a1d479f3b4f 100644
--- a/src/panfrost/lib/pan_clear.c
+++ b/src/panfrost/lib/pan_clear.c
@@ -118,12 +118,12 @@ pan_pack_raw(uint32_t *packed, const union 
pipe_color_union *color,
 }
 
 void
-pan_pack_color(uint32_t *packed, const union pipe_color_union *color,
+pan_pack_color(const struct pan_blendable_format *blendable_formats,
+               uint32_t *packed, const union pipe_color_union *color,
                enum pipe_format format, bool dithered)
 {
-   /* Set of blendable formats is common across versions. TODO: v9 */
    enum mali_color_buffer_internal_format internal =
-      panfrost_blendable_formats_v7[format].internal;
+      blendable_formats[format].internal;
 
    if (internal == MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW_VALUE) {
       pan_pack_raw(packed, color, format);
diff --git a/src/panfrost/lib/pan_util.h b/src/panfrost/lib/pan_util.h
index 22f84d12b91..48cca9b879d 100644
--- a/src/panfrost/lib/pan_util.h
+++ b/src/panfrost/lib/pan_util.h
@@ -56,6 +56,7 @@
 #define PAN_DBG_FORCE_PACK 0x40000
 
 struct panfrost_device;
+struct pan_blendable_format;
 
 unsigned panfrost_translate_swizzle_4(const unsigned char swizzle[4]);
 
@@ -65,7 +66,8 @@ unsigned panfrost_format_to_bifrost_blend(const struct 
panfrost_device *dev,
                                           enum pipe_format format,
                                           bool dithered);
 
-void pan_pack_color(uint32_t *packed, const union pipe_color_union *color,
+void pan_pack_color(const struct pan_blendable_format *blendable_formats,
+                    uint32_t *packed, const union pipe_color_union *color,
                     enum pipe_format format, bool dithered);
 
 /* Get the last blend shader, for an erratum workaround on v5 */
diff --git a/src/panfrost/lib/tests/test-clear.c 
b/src/panfrost/lib/tests/test-clear.c
index 91199199149..cf864c4c78a 100644
--- a/src/panfrost/lib/tests/test-clear.c
+++ b/src/panfrost/lib/tests/test-clear.c
@@ -21,6 +21,7 @@
  * SOFTWARE.
  */
 
+#include "pan_texture.h"
 #include "pan_util.h"
 
 /* A test consists of a render target format, clear colour, dither state, and
@@ -175,7 +176,8 @@ main(int argc, const char **argv)
    for (unsigned i = 0; i < ARRAY_SIZE(clear_tests); ++i) {
       struct test T = clear_tests[i];
       uint32_t packed[4];
-      pan_pack_color(&packed[0], &T.colour, T.format, T.dithered);
+      pan_pack_color(panfrost_blendable_formats_v7, &packed[0], &T.colour,
+                     T.format, T.dithered);
 
       ASSERT_EQ(T.packed, packed);
    }
diff --git a/src/panfrost/vulkan/panvk_cmd_buffer.c 
b/src/panfrost/vulkan/panvk_cmd_buffer.c
index 05d9604ed0d..69c7651127f 100644
--- a/src/panfrost/vulkan/panvk_cmd_buffer.c
+++ b/src/panfrost/vulkan/panvk_cmd_buffer.c
@@ -408,7 +408,8 @@ panvk_cmd_prepare_clear_values(struct panvk_cmd_buffer 
*cmdbuf,
          if (attachment->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
             union pipe_color_union *col =
                (union pipe_color_union *)&in[i].color;
-            pan_pack_color(cmdbuf->state.clear[i].color, col, fmt, false);
+            pan_pack_color(panfrost_blendable_formats_v7,
+                           cmdbuf->state.clear[i].color, col, fmt, false);
          } else {
             memset(cmdbuf->state.clear[i].color, 0,
                    sizeof(cmdbuf->state.clear[0].color));
diff --git a/src/panfrost/vulkan/panvk_vX_meta_clear.c 
b/src/panfrost/vulkan/panvk_vX_meta_clear.c
index b3a92a73de3..4db34d53342 100644
--- a/src/panfrost/vulkan/panvk_vX_meta_clear.c
+++ b/src/panfrost/vulkan/panvk_vX_meta_clear.c
@@ -341,8 +341,9 @@ panvk_meta_clear_color_img(struct panvk_cmd_buffer *cmdbuf,
    };
 
    uint32_t clearval[4];
-   pan_pack_color(clearval, (union pipe_color_union *)color,
-                  img->pimage.layout.format, false);
+   pan_pack_color(panfrost_blendable_formats_v7, clearval,
+                  (union pipe_color_union *)color, img->pimage.layout.format,
+                  false);
    memcpy(fbinfo->rts[0].clear_value, clearval,
           sizeof(fbinfo->rts[0].clear_value));
 

Reply via email to