Mesa (staging/21.2): etnaviv: add stride, offset and modifier to 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: e26269535d0f3a5cf8f0fcc3f0da1e154100522a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e26269535d0f3a5cf8f0fcc3f0da1e154100522a

Author: Simon Ser <contact at emersion.fr>
Date:   Sat Aug 14 13:57:15 2021 +0200

etnaviv: add stride, offset and modifier to 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, extend 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: 9da901d2b2e7 ("etnaviv: fail in get_handle(TYPE_KMS) without a scanout resource")
Reported-by: Roman Stratiienko <r.stratiienko at gmail.com>
Reviewed-by: Lucas Stach <l.stach at pengutronix.de>
Reviewed-by: Daniel Stone <daniels at collabora.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12370>
(cherry picked from commit b5919b0b106dbdf5f5da6733e83cc532bdf257d8)

---

 .pick_status.json                              |  2 +-
 src/gallium/drivers/etnaviv/etnaviv_resource.c | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index e77597219eb..5cc2cd3582b 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -58,7 +58,7 @@
         "description": "etnaviv: add stride, offset and modifier to resource_get_param",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "9da901d2b2e7ab5d5f21a0004fc294810f69f04a"
     },
diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index aa47be8ed07..6f77b829151 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -639,8 +639,7 @@ etna_resource_get_param(struct pipe_screen *pscreen,
                         enum pipe_resource_param param,
                         unsigned usage, uint64_t *value)
 {
-   switch (param) {
-   case PIPE_RESOURCE_PARAM_NPLANES: {
+   if (param == PIPE_RESOURCE_PARAM_NPLANES) {
       unsigned count = 0;
 
       for (struct pipe_resource *cur = prsc; cur; cur = cur->next)
@@ -648,6 +647,25 @@ etna_resource_get_param(struct pipe_screen *pscreen,
       *value = count;
       return true;
    }
+
+   struct pipe_resource *cur = prsc;
+   for (int i = 0; i < plane; i++) {
+      cur = cur->next;
+      if (!cur)
+         return false;
+   }
+   struct etna_resource *rsc = etna_resource(cur);
+
+   switch (param) {
+   case PIPE_RESOURCE_PARAM_STRIDE:
+      *value = rsc->levels[level].stride;
+      return true;
+   case PIPE_RESOURCE_PARAM_OFFSET:
+      *value = rsc->levels[level].offset;
+      return true;
+   case PIPE_RESOURCE_PARAM_MODIFIER:
+      *value = layout_to_modifier(rsc->layout);
+      return true;
    default:
       return false;
    }



More information about the mesa-commit mailing list