From ab7744b280184d623cf5a67a50880bf871d8c6db Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Fri, 19 Feb 2021 15:28:29 +0100 Subject: [PATCH] gallium/dri2: Pass the resource that corresponds to the plane Previously, we were calling resource_get_handle for the first plane in the image, regardless of what plane was being requested. v2: - Add assert (Simon) Signed-off-by: Tomeu Vizoso Reviewed-by: Simon Ser Part-of: --- src/gallium/frontends/dri/dri2.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c index a5bcbe12a32..b88af6a6628 100644 --- a/src/gallium/frontends/dri/dri2.c +++ b/src/gallium/frontends/dri/dri2.c @@ -1164,8 +1164,12 @@ dri2_query_image_by_resource_handle(__DRIimage *image, int attrib, int *value) if (image->use & __DRI_IMAGE_USE_BACKBUFFER) usage |= PIPE_HANDLE_USAGE_EXPLICIT_FLUSH; - if (!pscreen->resource_get_handle(pscreen, NULL, image->texture, - &whandle, usage)) + for (i = 0, tex = image->texture; tex; i++, tex = tex->next) + if (i == image->plane) + break; + assert(tex); + + if (!pscreen->resource_get_handle(pscreen, NULL, tex, &whandle, usage)) return false; switch (attrib) { @@ -1200,10 +1204,18 @@ dri2_resource_get_param(__DRIimage *image, enum pipe_resource_param param, unsigned handle_usage, uint64_t *value) { struct pipe_screen *pscreen = image->texture->screen; + struct pipe_resource *tex; + int i; + if (!pscreen->resource_get_param) return false; - return pscreen->resource_get_param(pscreen, NULL, image->texture, + for (i = 0, tex = image->texture; tex; i++, tex = tex->next) + if (i == image->plane) + break; + assert(tex); + + return pscreen->resource_get_param(pscreen, NULL, tex, image->plane, 0, 0, param, handle_usage, value); }