Mesa (staging/21.2): lima: Implement lima_resource_get_param() callback

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 18 16:12:33 UTC 2021


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

Author: Roman Stratiienko <r.stratiienko at gmail.com>
Date:   Fri Aug 13 20:04:51 2021 +0300

lima: Implement lima_resource_get_param() callback

Currently stride, offset, modifier is obtained by invoking
lima_resource_get_handle() with WINSYS_HANDLE_TYPE_KMS.

Before commit 47f000c170cc this path was working. Obtained handle
was simply ignored by DRI frontend and only requested data used.

After commit 47f000c170cc such requests started to fail when
DRI is initialized using KMSRO and resource has no scanout data.

When lima_resource_get_param() is implemented, it will be used in
a first place to obtain resource data.

Fixes: 47f000c170cc ("lima: fail in get_handle(TYPE_KMS) without a scanout resource")
Signed-off-by: Roman Stratiienko <r.stratiienko at gmail.com>
Reviewed-by: Simon Ser <contact at emersion.fr>
Reviewed-by: Erico Nunes <nunes.erico at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12362>
(cherry picked from commit 5ec6b6e9bbf607935cf864e63c9b555621fca590)

---

 .pick_status.json                        |  2 +-
 src/gallium/drivers/lima/lima_resource.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 06a2ea0dfbd..e08b9c6b7d4 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -103,7 +103,7 @@
         "description": "lima: Implement lima_resource_get_param() callback",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "47f000c170ccb824b308e02db8c2c955a8c00217"
     },
diff --git a/src/gallium/drivers/lima/lima_resource.c b/src/gallium/drivers/lima/lima_resource.c
index 7b94dd48320..946edc86df8 100644
--- a/src/gallium/drivers/lima/lima_resource.c
+++ b/src/gallium/drivers/lima/lima_resource.c
@@ -427,6 +427,35 @@ lima_resource_get_handle(struct pipe_screen *pscreen,
    return true;
 }
 
+static bool
+lima_resource_get_param(struct pipe_screen *pscreen,
+                        struct pipe_context *pctx,
+                        struct pipe_resource *pres,
+                        unsigned plane, unsigned layer, unsigned level,
+                        enum pipe_resource_param param,
+                        unsigned usage, uint64_t *value)
+{
+   struct lima_resource *res = lima_resource(pres);
+
+   switch (param) {
+   case PIPE_RESOURCE_PARAM_STRIDE:
+      *value = res->levels[level].stride;
+      return true;
+   case PIPE_RESOURCE_PARAM_OFFSET:
+      *value = res->levels[level].offset;
+      return true;
+   case PIPE_RESOURCE_PARAM_MODIFIER:
+      if (res->tiled)
+         *value = DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED;
+      else
+         *value = DRM_FORMAT_MOD_LINEAR;
+
+      return true;
+   default:
+      return false;
+   }
+}
+
 static void
 get_scissor_from_box(struct pipe_scissor_state *s,
                      const struct pipe_box *b, int h)
@@ -522,6 +551,7 @@ lima_resource_screen_init(struct lima_screen *screen)
    screen->base.resource_from_handle = lima_resource_from_handle;
    screen->base.resource_destroy = lima_resource_destroy;
    screen->base.resource_get_handle = lima_resource_get_handle;
+   screen->base.resource_get_param = lima_resource_get_param;
    screen->base.set_damage_region = lima_resource_set_damage_region;
 }
 



More information about the mesa-commit mailing list