panfrost: Create additional BO for the checksum of imported BOs (Bifrost)
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Mon, 27 Apr 2020 14:49:22 +0000 (16:49 +0200)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Fri, 1 May 2020 14:52:03 +0000 (16:52 +0200)
Similar to what the blob does. My reason for doing this was mainly so
traces weren't as different, which makes it more work to spot
relevant differences.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4832>

src/gallium/drivers/panfrost/pan_mfbd.c
src/gallium/drivers/panfrost/pan_resource.c
src/panfrost/encoder/pan_texture.h

index 2c011fda0029f070a1542df396c6a744b9e3e6b8..1350e17485a4affb5983e8160187e17464a06cb6 100644 (file)
@@ -502,7 +502,6 @@ panfrost_mfbd_fragment(struct panfrost_batch *batch, bool has_draws)
         if (batch->key.nr_cbufs == 1) {
                 struct pipe_surface *surf = batch->key.cbufs[0];
                 struct panfrost_resource *rsrc = pan_resource(surf->texture);
-                struct panfrost_bo *bo = rsrc->bo;
 
                 if (rsrc->checksummed) {
                         unsigned level = surf->u.tex.level;
@@ -511,7 +510,10 @@ panfrost_mfbd_fragment(struct panfrost_batch *batch, bool has_draws)
                         fb.mfbd_flags |= MALI_MFBD_EXTRA;
                         fbx.flags_lo |= MALI_EXTRA_PRESENT;
                         fbx.checksum_stride = slice->checksum_stride;
-                        fbx.checksum = bo->gpu + slice->checksum_offset;
+                        if (slice->checksum_bo)
+                                fbx.checksum = slice->checksum_bo->gpu;
+                        else
+                                fbx.checksum = rsrc->bo->gpu + slice->checksum_offset;
                 }
         }
 
index 3505f373788eb438ab8d6f734748186874d4da84..443df15d257e0aee2d8cc45ac83670bb8dd4033d 100644 (file)
@@ -109,6 +109,14 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
         rsc->slices[0].initialized = true;
         panfrost_resource_reset_damage(rsc);
 
+        if (dev->quirks & IS_BIFROST &&
+            templat->bind & PIPE_BIND_RENDER_TARGET) {
+                unsigned size = panfrost_compute_checksum_size(
+                                        &rsc->slices[0], templat->width0, templat->height0);
+                rsc->slices[0].checksum_bo = pan_bo_create(dev, size, 0);
+                rsc->checksummed = true;
+        }
+
         if (dev->ro) {
                 rsc->scanout =
                         renderonly_create_gpu_import_for_resource(prsc, dev->ro, NULL);
@@ -550,6 +558,9 @@ panfrost_resource_destroy(struct pipe_screen *screen,
         if (rsrc->bo)
                 panfrost_bo_unreference(rsrc->bo);
 
+        if (rsrc->slices[0].checksum_bo)
+                panfrost_bo_unreference(rsrc->slices[0].checksum_bo);
+
         util_range_destroy(&rsrc->valid_buffer_range);
         ralloc_free(rsrc);
 }
index 5bcda798ac3f3cf1899a6826262691cdab091a6d..591efd86c68a2e1e9e651f692f0e7f8295a65fb9 100644 (file)
@@ -46,6 +46,7 @@ struct panfrost_slice {
          * is its offset/stride? */
         unsigned checksum_offset;
         unsigned checksum_stride;
+        struct panfrost_bo *checksum_bo;
 
         /* Has anything been written to this slice? */
         bool initialized;