gallium/dri2: Pass the resource that corresponds to the plane
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Fri, 19 Feb 2021 14:28:29 +0000 (15:28 +0100)
committerMarge Bot <eric+marge@anholt.net>
Thu, 25 Mar 2021 05:48:00 +0000 (05:48 +0000)
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>

src/gallium/frontends/dri/dri2.c

index a5bcbe1..b88af6a 100644 (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);
 }