Mesa (main): etnaviv: fix gbm_bo_get_handle_for_plane for multiplanar images

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 27 21:54:59 UTC 2021


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

Author: Philipp Zabel <p.zabel at pengutronix.de>
Date:   Thu Jul 22 12:47:15 2021 +0200

etnaviv: fix gbm_bo_get_handle_for_plane for multiplanar images

Implement resource_get_param for PIPE_RESOURCE_PARAM_NPLANES and fix
resource_get_handle to walk to the correct linked resource for
multiplanar images, allowing gbm_bo_get_handle_for_plane to be called
with plane > 0.

This fixes an assert that is triggered when a wayland client tries
to send weston an NV12 dmabuf, for example:

  weston: .../mesa/src/gbm/backends/dri/gbm_dri.c:752: gbm_dri_bo_get_handle_for_plane: Assertion `plane == 0' failed.

Fixes: 788f6dc85781 ('Revert "gallium/dri: fix dri2_from_planar for multiplanar images"')
Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12037>

---

 src/gallium/drivers/etnaviv/etnaviv_resource.c | 37 +++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 0c8c28e66aa..ce37b0e779c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -581,8 +581,21 @@ etna_resource_get_handle(struct pipe_screen *pscreen,
                          struct winsys_handle *handle, unsigned usage)
 {
    struct etna_resource *rsc = etna_resource(prsc);
+   struct renderonly_scanout *scanout;
+
+   if (handle->plane) {
+      struct pipe_resource *cur = prsc;
+
+      for (int i = 0; i < handle->plane; i++) {
+         cur = cur->next;
+         if (!cur)
+            return false;
+      }
+      rsc = etna_resource(cur);
+   }
+
    /* Scanout is always attached to the base resource */
-   struct renderonly_scanout *scanout = rsc->scanout;
+   scanout = rsc->scanout;
 
    handle->stride = rsc->levels[0].stride;
    handle->offset = rsc->levels[0].offset;
@@ -608,6 +621,27 @@ etna_resource_get_handle(struct pipe_screen *pscreen,
    }
 }
 
+static bool
+etna_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)
+{
+   switch (param) {
+   case PIPE_RESOURCE_PARAM_NPLANES: {
+      unsigned count = 0;
+
+      for (struct pipe_resource *cur = prsc; cur; cur = cur->next)
+         count++;
+      *value = count;
+      return true;
+   }
+   default:
+      return false;
+   }
+}
+
 void
 etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc,
                    enum etna_resource_status status)
@@ -707,6 +741,7 @@ etna_resource_screen_init(struct pipe_screen *pscreen)
    pscreen->resource_create_with_modifiers = etna_resource_create_modifiers;
    pscreen->resource_from_handle = etna_resource_from_handle;
    pscreen->resource_get_handle = etna_resource_get_handle;
+   pscreen->resource_get_param = etna_resource_get_param;
    pscreen->resource_changed = etna_resource_changed;
    pscreen->resource_destroy = etna_resource_destroy;
 }



More information about the mesa-commit mailing list