Mesa (staging/21.2): panfrost: implement resource_get_param

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 19 18:16:10 UTC 2021


Module: Mesa
Branch: staging/21.2
Commit: 5aa0faf5123a50b5eb3a21cb372d9335cd36bbe2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5aa0faf5123a50b5eb3a21cb372d9335cd36bbe2

Author: Simon Ser <contact at emersion.fr>
Date:   Sat Aug 14 14:03:58 2021 +0200

panfrost: implement resource_get_param

Prior to this commit, the stride, offset and modifier were fetched
via WINSYS_HANDLE_TYPE_KMS. However we can't make such a query
succeed if the buffer couldn't be imported to the KMS device.

Instead, implement the resource_get_param hook to allow users to
fetch this information without WINSYS_HANDLE_TYPE_KMS.

Signed-off-by: Simon Ser <contact at emersion.fr>
Fixes: 4c092947df30 ("panfrost: fail in get_handle(TYPE_KMS) without a scanout resource")
Reported-by: Roman Stratiienko <r.stratiienko at gmail.com>
Reviewed-by: Daniel Stone <daniels at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12370>
(cherry picked from commit 99fc6f7271c611b58779a0e5c8a7d1764570449d)

---

 .pick_status.json                           |  2 +-
 src/gallium/drivers/panfrost/pan_resource.c | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 5cc2cd3582b..038b7376862 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -49,7 +49,7 @@
         "description": "panfrost: implement resource_get_param",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "4c092947df308f20e288bb5baf50bff181e5d3fa"
     },
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index b56e5c428b1..1a9d5274f27 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -183,6 +183,30 @@ panfrost_resource_get_handle(struct pipe_screen *pscreen,
         return false;
 }
 
+static bool
+panfrost_resource_get_param(struct pipe_screen *pscreen,
+                            struct pipe_context *pctx, struct pipe_resource *prsc,
+                            unsigned plane, unsigned layer, unsigned level,
+                            enum pipe_resource_param param,
+                            unsigned usage, uint64_t *value)
+{
+        struct panfrost_resource *rsrc = (struct panfrost_resource *) prsc;
+
+        switch (param) {
+        case PIPE_RESOURCE_PARAM_STRIDE:
+                *value = rsrc->image.layout.slices[level].line_stride;
+                return true;
+        case PIPE_RESOURCE_PARAM_OFFSET:
+                *value = rsrc->image.layout.slices[level].offset;
+                return true;
+        case PIPE_RESOURCE_PARAM_MODIFIER:
+                *value = rsrc->image.layout.modifier;
+                return true;
+        default:
+                return false;
+        }
+}
+
 static void
 panfrost_flush_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
 {
@@ -1314,6 +1338,7 @@ panfrost_resource_screen_init(struct pipe_screen *pscreen)
         pscreen->resource_destroy = u_transfer_helper_resource_destroy;
         pscreen->resource_from_handle = panfrost_resource_from_handle;
         pscreen->resource_get_handle = panfrost_resource_get_handle;
+        pscreen->resource_get_param = panfrost_resource_get_param;
         pscreen->transfer_helper = u_transfer_helper_create(&transfer_vtbl,
                                         true, false,
                                         fake_rgtc, true);



More information about the mesa-commit mailing list