Mesa (main): panfrost: support PIPE_RESOURCE_PARAM_NPLANES query

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 26 12:34:15 UTC 2021


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

Author: Derek Foreman <derek.foreman at collabora.com>
Date:   Mon Oct 25 15:58:13 2021 -0500

panfrost: support PIPE_RESOURCE_PARAM_NPLANES query

While panfrost doesn't support multi-planar formats directly, we might
still import multi-planar BOs through GBM (for example, when doing direct
scanout in weston).

We can support PIPE_RESOURCE_PARAM_NPLANES by simply counting the
planes we have.

Signed-off-by: Derek Foreman <derek.foreman at collabora.com>
Reviewed-by: Daniel Stone <daniels at collabora.com>
Reviewed-by: Simon Ser <contact at emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13039>

---

 src/gallium/drivers/panfrost/pan_resource.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 84120be64a0..b6a6d811387 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -204,6 +204,8 @@ panfrost_resource_get_param(struct pipe_screen *pscreen,
                             unsigned usage, uint64_t *value)
 {
         struct panfrost_resource *rsrc = (struct panfrost_resource *) prsc;
+        struct pipe_resource *cur;
+        unsigned count;
 
         switch (param) {
         case PIPE_RESOURCE_PARAM_STRIDE:
@@ -215,6 +217,16 @@ panfrost_resource_get_param(struct pipe_screen *pscreen,
         case PIPE_RESOURCE_PARAM_MODIFIER:
                 *value = rsrc->image.layout.modifier;
                 return true;
+        case PIPE_RESOURCE_PARAM_NPLANES:
+                /* Panfrost doesn't directly support multi-planar formats,
+                 * but we should still handle this case for gbm users
+                 * that might want to use resources shared with panfrost
+                 * on video processing hardware that does.
+                 */
+                for (count = 0, cur = prsc; cur; cur = cur->next)
+                        count++;
+                *value = count;
+                return true;
         default:
                 return false;
         }



More information about the mesa-commit mailing list