Mesa (staging/21.1): panfrost: Fix formats converting uninit from AFBC

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Apr 24 12:31:36 UTC 2021


Module: Mesa
Branch: staging/21.1
Commit: 6b9700140f43c65d6e826a686444efc5a269e6f9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6b9700140f43c65d6e826a686444efc5a269e6f9

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Thu Apr 22 19:14:47 2021 -0400

panfrost: Fix formats converting uninit from AFBC

If no slices were valid (the resource is uninitialized), we were reading
a bogus PIPE_FORMAT_NONE format from the blit.dst.format. Fix this --
and guard against scope similar issues -- by hoisting the blit
assignments out of the loop so they're valid.

Fixes: 9d0ad7fd2e1 ("panfrost: Patch the gallium driver to use pan_image_layout_init()")
Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10415>
(cherry picked from commit c220976fd077c09bbc485ff9a29091895bd39fdf)

---

 .pick_status.json                           |  2 +-
 src/gallium/drivers/panfrost/pan_resource.c | 33 ++++++++++++++---------------
 2 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 041ec20062f..663e5168288 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -220,7 +220,7 @@
         "description": "panfrost: Fix formats converting uninit from AFBC",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "9d0ad7fd2e1c56a1771e253086a5d4862d54e358"
     },
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 960a7816a45..c189eec2686 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -999,8 +999,7 @@ pan_resource_modifier_convert(struct panfrost_context *ctx,
                 panfrost_resource_create_with_modifier(
                         ctx->base.screen, &rsrc->base, modifier);
         struct panfrost_resource *tmp_rsrc = pan_resource(tmp_prsrc);
-
-        struct pipe_blit_info blit = {0};
+        enum pipe_format blit_fmt = pan_blit_format(tmp_rsrc->base.format);
 
         unsigned depth = rsrc->base.target == PIPE_TEXTURE_3D ?
                 rsrc->base.depth0 : rsrc->base.array_size;
@@ -1008,22 +1007,22 @@ pan_resource_modifier_convert(struct panfrost_context *ctx,
         struct pipe_box box =
                 { 0, 0, 0, rsrc->base.width0, rsrc->base.height0, depth };
 
-        for (int i = 0; i <= rsrc->base.last_level; i++) {
-                if (!rsrc->state.slices[i].data_valid)
-                        continue;
+        struct pipe_blit_info blit = {
+                .dst.resource = &tmp_rsrc->base,
+                .dst.format   = blit_fmt,
+                .dst.box      = box,
+                .src.resource = &rsrc->base,
+                .src.format   = pan_blit_format(rsrc->base.format),
+                .src.box      = box,
+                .mask         = util_format_get_mask(blit_fmt),
+                .filter       = PIPE_TEX_FILTER_NEAREST
+        };
 
-                blit.dst.resource = &tmp_rsrc->base;
-                blit.dst.format   = pan_blit_format(tmp_rsrc->base.format);
-                blit.dst.level    = i;
-                blit.dst.box      = box;
-                blit.src.resource = &rsrc->base;
-                blit.src.format   = pan_blit_format(rsrc->base.format);
-                blit.src.level    = i;
-                blit.src.box      = box;
-                blit.mask = util_format_get_mask(blit.dst.format);
-                blit.filter = PIPE_TEX_FILTER_NEAREST;
-
-                panfrost_blit(&ctx->base, &blit);
+        for (int i = 0; i <= rsrc->base.last_level; i++) {
+                if (rsrc->state.slices[i].data_valid) {
+                        blit.dst.level = blit.src.level  = i;
+                        panfrost_blit(&ctx->base, &blit);
+                }
         }
 
         panfrost_bo_unreference(rsrc->image.data.bo);



More information about the mesa-commit mailing list