Mesa (master): panfrost: Only checksum resources when it makes sense to

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 20 23:55:03 UTC 2021


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

Author: Icecream95 <ixn at disroot.org>
Date:   Sat Dec 12 18:41:16 2020 +1300

panfrost: Only checksum resources when it makes sense to

To simplify tracking the checksum validity, only checksum 2D
resources.

The GPU cannot do checksumming when there is too much data to be
written out, so limit the number of bytes per pixel to an architecture
specific value.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7086>

---

 src/gallium/drivers/panfrost/pan_resource.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 2a1b602328c..bf97ef67d80 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -52,6 +52,9 @@
 #include "decode.h"
 #include "panfrost-quirks.h"
 
+static bool
+panfrost_should_checksum(const struct panfrost_device *dev, const struct panfrost_resource *pres);
+
 bool
 pan_render_condition_check(struct pipe_context *pctx)
 {
@@ -117,8 +120,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
         rsc->layout.slices[0].initialized = true;
         panfrost_resource_set_damage_region(NULL, &rsc->base, 0, NULL);
 
-        if (dev->quirks & IS_BIFROST &&
-            templat->bind & PIPE_BIND_RENDER_TARGET) {
+        if (panfrost_should_checksum(dev, rsc)) {
                 unsigned size =
                         panfrost_compute_checksum_size(&rsc->layout.slices[0],
                                                        templat->width0,
@@ -618,13 +620,30 @@ panfrost_best_modifier(struct panfrost_device *dev,
                 return DRM_FORMAT_MOD_LINEAR;
 }
 
+static bool
+panfrost_should_checksum(const struct panfrost_device *dev, const struct panfrost_resource *pres)
+{
+        /* When checksumming is enabled, the tile data must fit in the
+         * size of the writeback buffer, so don't checksum formats
+         * that use too much space. */
+
+        unsigned bytes_per_pixel_max = (dev->arch == 6) ? 6 : 4;
+
+        unsigned bytes_per_pixel = MAX2(pres->base.nr_samples, 1) *
+                util_format_get_blocksize(pres->base.format);
+
+        return pres->base.bind & PIPE_BIND_RENDER_TARGET &&
+                panfrost_is_2d(pres) &&
+                bytes_per_pixel <= bytes_per_pixel_max;
+}
+
 static void
 panfrost_resource_setup(struct panfrost_device *dev, struct panfrost_resource *pres,
                         size_t *bo_size, uint64_t modifier)
 {
         pres->layout.modifier = (modifier != DRM_FORMAT_MOD_INVALID) ? modifier :
                 panfrost_best_modifier(dev, pres);
-        pres->checksummed = (pres->base.bind & PIPE_BIND_RENDER_TARGET);
+        pres->checksummed = panfrost_should_checksum(dev, pres);
 
         /* We can only switch tiled->linear if the resource isn't already
          * linear and if we control the modifier */



More information about the mesa-commit mailing list