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

Author: Erik Faye-Lund <erik.faye-l...@collabora.com>
Date:   Tue Oct 31 09:43:16 2023 +0100

panfrost: look at correct blendable format version

We're currently looking at a mixture of v7 only and v6 and v7 versions
of the blendable formats. Let's use the one we have stored, so we always
use the most recent definition.

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

---

 src/gallium/drivers/panfrost/pan_context.c |  2 +-
 src/gallium/drivers/panfrost/pan_job.c     |  5 +++--
 src/panfrost/lib/pan_cs.c                  | 35 ++++++++++++++++--------------
 src/panfrost/lib/pan_util.c                |  5 +----
 4 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index ae5e2608909..df054502d84 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -172,7 +172,7 @@ panfrost_get_blend(struct panfrost_batch *batch, unsigned 
rti,
 
    /* Use fixed-function if the equation permits, the format is blendable,
     * and no more than one unique constant is accessed */
-   if (info.fixed_function && panfrost_blendable_formats_v7[fmt].internal &&
+   if (info.fixed_function && dev->blendable_formats[fmt].internal &&
        pan_blend_is_homogenous_constant(info.constant_mask,
                                         ctx->blend_color.color)) {
       return 0;
diff --git a/src/gallium/drivers/panfrost/pan_job.c 
b/src/gallium/drivers/panfrost/pan_job.c
index a24a081d0a3..d483b76a7ae 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -941,6 +941,7 @@ panfrost_batch_clear(struct panfrost_batch *batch, unsigned 
buffers,
                      unsigned stencil)
 {
    struct panfrost_context *ctx = batch->ctx;
+   struct panfrost_device *dev = pan_device(ctx->base.screen);
 
    if (buffers & PIPE_CLEAR_COLOR) {
       for (unsigned i = 0; i < ctx->pipe_framebuffer.nr_cbufs; ++i) {
@@ -948,8 +949,8 @@ panfrost_batch_clear(struct panfrost_batch *batch, unsigned 
buffers,
             continue;
 
          enum pipe_format format = ctx->pipe_framebuffer.cbufs[i]->format;
-         pan_pack_color(panfrost_blendable_formats_v7, batch->clear_color[i],
-                        color, format, false);
+         pan_pack_color(dev->blendable_formats, batch->clear_color[i], color,
+                        format, false);
       }
    }
 
diff --git a/src/panfrost/lib/pan_cs.c b/src/panfrost/lib/pan_cs.c
index c69b9f114dc..7e1a116555c 100644
--- a/src/panfrost/lib/pan_cs.c
+++ b/src/panfrost/lib/pan_cs.c
@@ -326,9 +326,10 @@ pan_emit_zs_crc_ext(const struct pan_fb_info *fb, int 
rt_crc, void *zs_crc_ext)
 /* Measure format as it appears in the tile buffer */
 
 static unsigned
-pan_bytes_per_pixel_tib(enum pipe_format format)
+pan_bytes_per_pixel_tib(const struct panfrost_device *dev,
+                        enum pipe_format format)
 {
-   if (panfrost_blendable_formats_v7[format].internal) {
+   if (dev->blendable_formats[format].internal) {
       /* Blendable formats are always 32-bits in the tile buffer,
        * extra bits are used as padding or to dither */
       return 4;
@@ -341,7 +342,8 @@ pan_bytes_per_pixel_tib(enum pipe_format format)
 }
 
 static unsigned
-pan_cbuf_bytes_per_pixel(const struct pan_fb_info *fb)
+pan_cbuf_bytes_per_pixel(const struct panfrost_device *dev,
+                         const struct pan_fb_info *fb)
 {
    unsigned sum = 0;
 
@@ -351,7 +353,7 @@ pan_cbuf_bytes_per_pixel(const struct pan_fb_info *fb)
       if (!rt)
          continue;
 
-      sum += pan_bytes_per_pixel_tib(rt->format) * rt->nr_samples;
+      sum += pan_bytes_per_pixel_tib(dev, rt->format) * rt->nr_samples;
    }
 
    return sum;
@@ -401,7 +403,8 @@ pan_mfbd_raw_format(unsigned bits)
 }
 
 static void
-pan_rt_init_format(const struct pan_image_view *rt,
+pan_rt_init_format(const struct panfrost_device *dev,
+                   const struct pan_image_view *rt,
                    struct MALI_RENDER_TARGET *cfg)
 {
    /* Explode details on the format */
@@ -423,7 +426,7 @@ pan_rt_init_format(const struct pan_image_view *rt,
    if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
       cfg->srgb = true;
 
-   struct pan_blendable_format fmt = panfrost_blendable_formats_v7[rt->format];
+   struct pan_blendable_format fmt = dev->blendable_formats[rt->format];
 
    if (fmt.internal) {
       cfg->internal_format = fmt.internal;
@@ -481,7 +484,8 @@ pan_afbc_compression_mode(enum pipe_format format)
 #endif
 
 static void
-pan_prepare_rt(const struct pan_fb_info *fb, unsigned idx, unsigned 
cbuf_offset,
+pan_prepare_rt(const struct panfrost_device *dev, const struct pan_fb_info *fb,
+               unsigned idx, unsigned cbuf_offset,
                struct MALI_RENDER_TARGET *cfg)
 {
    cfg->clean_pixel_write_enable = fb->rts[idx].clear;
@@ -523,7 +527,7 @@ pan_prepare_rt(const struct pan_fb_info *fb, unsigned idx, 
unsigned cbuf_offset,
 
    cfg->writeback_msaa = mali_sampling_mode(rt);
 
-   pan_rt_init_format(rt, cfg);
+   pan_rt_init_format(dev, rt, cfg);
 
    cfg->writeback_block_format = mod_to_block_fmt(image->layout.modifier);
 
@@ -649,11 +653,11 @@ pan_emit_midgard_tiler(const struct panfrost_device *dev,
 
 #if PAN_ARCH >= 5
 static void
-pan_emit_rt(const struct pan_fb_info *fb, unsigned idx, unsigned cbuf_offset,
-            void *out)
+pan_emit_rt(const struct panfrost_device *dev, const struct pan_fb_info *fb,
+            unsigned idx, unsigned cbuf_offset, void *out)
 {
    pan_pack(out, RENDER_TARGET, cfg) {
-      pan_prepare_rt(fb, idx, cbuf_offset, &cfg);
+      pan_prepare_rt(dev, fb, idx, cbuf_offset, &cfg);
    }
 }
 
@@ -733,7 +737,7 @@ GENX(pan_emit_fbd)(const struct panfrost_device *dev,
    GENX(pan_emit_tls)(tls, pan_section_ptr(fbd, FRAMEBUFFER, LOCAL_STORAGE));
 #endif
 
-   unsigned bytes_per_pixel = pan_cbuf_bytes_per_pixel(fb);
+   unsigned bytes_per_pixel = pan_cbuf_bytes_per_pixel(dev, fb);
    unsigned tile_size =
       pan_select_max_tile_size(dev->optimal_tib_size, bytes_per_pixel);
 
@@ -828,12 +832,12 @@ GENX(pan_emit_fbd)(const struct panfrost_device *dev,
    unsigned rt_count = MAX2(fb->rt_count, 1);
    unsigned cbuf_offset = 0;
    for (unsigned i = 0; i < rt_count; i++) {
-      pan_emit_rt(fb, i, cbuf_offset, rtd);
+      pan_emit_rt(dev, fb, i, cbuf_offset, rtd);
       rtd += pan_size(RENDER_TARGET);
       if (!fb->rts[i].view)
          continue;
 
-      cbuf_offset += pan_bytes_per_pixel_tib(fb->rts[i].view->format) *
+      cbuf_offset += pan_bytes_per_pixel_tib(dev, fb->rts[i].view->format) *
                      tile_size * 
pan_image_view_get_nr_samples(fb->rts[i].view);
 
       if (i != crc_rt)
@@ -887,8 +891,7 @@ GENX(pan_emit_fbd)(const struct panfrost_device *dev,
          panfrost_invert_swizzle(desc->swizzle, swizzle);
          cfg.swizzle = panfrost_translate_swizzle_4(swizzle);
 
-         struct pan_blendable_format fmt =
-            panfrost_blendable_formats_v7[rt->format];
+         struct pan_blendable_format fmt = dev->blendable_formats[rt->format];
          if (fmt.internal) {
             cfg.internal_format = fmt.internal;
             cfg.color_writeback_format = fmt.writeback;
diff --git a/src/panfrost/lib/pan_util.c b/src/panfrost/lib/pan_util.c
index 4f43d56f6be..ee0ed615c60 100644
--- a/src/panfrost/lib/pan_util.c
+++ b/src/panfrost/lib/pan_util.c
@@ -75,10 +75,7 @@ unsigned
 panfrost_format_to_bifrost_blend(const struct panfrost_device *dev,
                                  enum pipe_format format, bool dithered)
 {
-   mali_pixel_format pixfmt =
-      (dev->arch >= 7)
-         ? panfrost_blendable_formats_v7[format].bifrost[dithered]
-         : panfrost_blendable_formats_v6[format].bifrost[dithered];
+   mali_pixel_format pixfmt = dev->blendable_formats[format].bifrost[dithered];
 
    return pixfmt ?: dev->formats[format].hw;
 }

Reply via email to