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 <tomeu.vizoso@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5442>
This commit is contained in:
Tomeu Vizoso 2021-02-19 15:28:29 +01:00 committed by Marge Bot
parent 382e5f2737
commit ab7744b280

View file

@ -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);
}