Mesa (staging/21.2): etnaviv: fix gbm_bo_get_handle_for_plane for multiplanar images
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jul 28 23:00:07 UTC 2021
Module: Mesa
Branch: staging/21.2
Commit: 0e7985a7deb7063b2a77ad821cc339cc6cbdd4ae
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0e7985a7deb7063b2a77ad821cc339cc6cbdd4ae
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>
(cherry picked from commit 8ba44103b31d90b0c7531d66aa74254412485c85)
---
.pick_status.json | 2 +-
src/gallium/drivers/etnaviv/etnaviv_resource.c | 37 +++++++++++++++++++++++++-
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index f039e7dfbbf..48ffb3f0bc6 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -670,7 +670,7 @@
"description": "etnaviv: fix gbm_bo_get_handle_for_plane for multiplanar images",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "788f6dc85781c58b37c0d762085090d2d5d8d3d5"
},
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