Mesa (main): panfrost: Detect implementations support AFBC

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 22 23:58:25 UTC 2021


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

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Tue Oct  5 16:01:00 2021 -0400

panfrost: Detect implementations support AFBC

AFBC is an optional feature on Bifrost. If it is missing, a bit will be
set in the poorly named AFBC_FEATURES register. Check this so we can act
appropriately.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13497>

---

 src/panfrost/lib/pan_device.h |  1 +
 src/panfrost/lib/pan_props.c  | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/src/panfrost/lib/pan_device.h b/src/panfrost/lib/pan_device.h
index eddd96a1788..5de3dcbdbc6 100644
--- a/src/panfrost/lib/pan_device.h
+++ b/src/panfrost/lib/pan_device.h
@@ -160,6 +160,7 @@ struct panfrost_device {
         unsigned thread_tls_alloc;
         struct panfrost_tiler_features tiler_features;
         unsigned quirks;
+        bool has_afbc;
 
         /* Table of formats, indexed by a PIPE format */
         const struct panfrost_format *formats;
diff --git a/src/panfrost/lib/pan_props.c b/src/panfrost/lib/pan_props.c
index 551d9713d3e..44d626fd6ff 100644
--- a/src/panfrost/lib/pan_props.c
+++ b/src/panfrost/lib/pan_props.c
@@ -214,6 +214,19 @@ panfrost_model_name(unsigned gpu_id)
         }
 }
 
+/* Check for AFBC hardware support. AFBC is introduced in v5. Implementations
+ * may omit it, signaled as a nonzero value in the AFBC_FEATURES property. */
+
+static bool
+panfrost_query_afbc(int fd, unsigned arch)
+{
+        unsigned reg = panfrost_query_raw(fd,
+                                          DRM_PANFROST_PARAM_AFBC_FEATURES,
+                                          false, 0);
+
+        return (arch >= 5) && (reg == 0);
+}
+
 void
 panfrost_open_device(void *memctx, int fd, struct panfrost_device *dev)
 {
@@ -228,6 +241,7 @@ panfrost_open_device(void *memctx, int fd, struct panfrost_device *dev)
         dev->quirks = panfrost_get_quirks(dev->gpu_id, revision);
         dev->compressed_formats = panfrost_query_compressed_formats(fd);
         dev->tiler_features = panfrost_query_tiler_features(fd);
+        dev->has_afbc = panfrost_query_afbc(fd, dev->arch);
 
         if (dev->quirks & HAS_SWIZZLES)
                 dev->formats = panfrost_pipe_format_v6;



More information about the mesa-commit mailing list