[Mesa-dev] [PATCH 3/6] st/dri: fix dri2_from_planar for multiplanar images
Lucas Stach
l.stach at pengutronix.de
Fri Apr 12 17:33:32 UTC 2019
From: Philipp Zabel <p.zabel at pengutronix.de>
Fix the gbm_dri_bo_get_handle_for_plane use case by allowing plane > 0
in dri2_from_planar for images with multiple planes in separate chained
texture resources.
Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
---
src/gallium/state_trackers/dri/dri2.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 4c8ea485cc70..f139bd6722b9 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1275,10 +1275,18 @@ static __DRIimage *
dri2_from_planar(__DRIimage *image, int plane, void *loaderPrivate)
{
__DRIimage *img;
+ struct pipe_resource *tex = image->texture;
+ int i;
- if (plane != 0)
+ if (plane >= 3)
return NULL;
+ for (i = 0; i < plane; i++) {
+ tex = tex->next;
+ if (!tex)
+ return NULL;
+ }
+
if (image->dri_components == 0)
return NULL;
@@ -1286,6 +1294,8 @@ dri2_from_planar(__DRIimage *image, int plane, void *loaderPrivate)
if (img == NULL)
return NULL;
+ pipe_resource_reference(&img->texture, tex);
+
if (img->texture->screen->resource_changed)
img->texture->screen->resource_changed(img->texture->screen,
img->texture);
--
2.20.1
More information about the mesa-dev
mailing list