st/dri2: Return invalid modifier when no driver support
authorDaniel Stone <daniels@collabora.com>
Fri, 21 Jul 2017 12:55:42 +0000 (13:55 +0100)
committerDaniel Stone <daniels@collabora.com>
Tue, 25 Jul 2017 17:40:07 +0000 (18:40 +0100)
Always initialise whandle.modifier for DRIImage modifier queries, so if
the driver doesn't support it then we return false for the query.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Fixes: d33fe8b84e45 ("st/dri: enable DRIimage modifier queries")
src/gallium/state_trackers/dri/dri2.c

index 3ebed7a98b46c10216dc3cd9537eeeec1c49f3db..0cbc76f7f8b256d4baa8437b645cca120adf243c 100644 (file)
@@ -1239,16 +1239,22 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
       return GL_TRUE;
    case __DRI_IMAGE_ATTRIB_MODIFIER_UPPER:
       whandle.type = DRM_API_HANDLE_TYPE_KMS;
+      whandle.modifier = DRM_FORMAT_MOD_INVALID;
       if (!image->texture->screen->resource_get_handle(image->texture->screen,
             NULL, image->texture, &whandle, usage))
          return GL_FALSE;
+      if (whandle.modifier == DRM_FORMAT_MOD_INVALID)
+         return GL_FALSE;
       *value = (whandle.modifier >> 32) & 0xffffffff;
       return GL_TRUE;
    case __DRI_IMAGE_ATTRIB_MODIFIER_LOWER:
       whandle.type = DRM_API_HANDLE_TYPE_KMS;
+      whandle.modifier = DRM_FORMAT_MOD_INVALID;
       if (!image->texture->screen->resource_get_handle(image->texture->screen,
             NULL, image->texture, &whandle, usage))
          return GL_FALSE;
+      if (whandle.modifier == DRM_FORMAT_MOD_INVALID)
+         return GL_FALSE;
       *value = whandle.modifier & 0xffffffff;
       return GL_TRUE;
    default: