panfrost: Use tiled AFBC textures
authorAlyssa Rosenzweig <alyssa@collabora.com>
Thu, 5 May 2022 15:05:32 +0000 (11:05 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 26 May 2022 15:56:32 +0000 (15:56 +0000)
On GPUs that support AFBC with tiled headers, try to use tiled headers instead
of linear headers. This should be a bit more efficient for the caches.
Additionally, on Mali, tiled headers are tied to solid colour blocks, so this
has the effect of enabling AFBC with solid colour blocks where supported.

Unfortunately, results are disappointing. Mali-G52:

-btexture from 856fps to 859fps
-bdesktop from 292fps to 294fps

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16697>

src/gallium/drivers/panfrost/pan_resource.c

index 18d82a1..cf9785b 100644 (file)
@@ -350,6 +350,20 @@ panfrost_should_afbc(struct panfrost_device *dev,
         return true;
 }
 
+/*
+ * For a resource we want to use AFBC with, should we use AFBC with tiled
+ * headers? On GPUs that support it, this is believed to be beneficial for
+ * images that are at least 128x128.
+ */
+static bool
+panfrost_should_tile_afbc(const struct panfrost_device *dev,
+                          const struct panfrost_resource *pres)
+{
+        return panfrost_afbc_can_tile(dev) &&
+               pres->base.width0 >= 128 &&
+               pres->base.height0 >= 128;
+}
+
 static bool
 panfrost_should_tile(struct panfrost_device *dev,
                      const struct panfrost_resource *pres,
@@ -395,6 +409,9 @@ panfrost_best_modifier(struct panfrost_device *dev,
                 if (panfrost_afbc_can_ytr(pres->base.format))
                         afbc |= AFBC_FORMAT_MOD_YTR;
 
+                if (panfrost_should_tile_afbc(dev, pres))
+                        afbc |= AFBC_FORMAT_MOD_TILED | AFBC_FORMAT_MOD_SC;
+
                 return DRM_FORMAT_MOD_ARM_AFBC(afbc);
         } else if (panfrost_should_tile(dev, pres, fmt))
                 return DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED;