[Mesa-dev] [PATCH v14 09/36] st/dri: enable DRIimage modifier queries

Varad Gautam varadgautam at gmail.com
Tue May 30 11:53:42 UTC 2017


From: Varad Gautam <varad.gautam at collabora.com>

return the modifier selected by the driver when creating this image.

v2: since we can use winsys_handle->modifier to serve these, remove
    DRIimage->modifier from v1.
    use DRM_API_HANDLE_TYPE_KMS instead of DRM_API_HANDLE_TYPE_FD to avoid
    ownership transfer. (Lucas)

Suggested-by: Daniel Stone <daniels at collabora.com>
Signed-off-by: Varad Gautam <varad.gautam at collabora.com>
Cc: Lucas Stach <l.stach at pengutronix.de>
---
 src/gallium/state_trackers/dri/dri2.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index f1794b7..fb1c829 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1088,6 +1088,18 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
    case __DRI_IMAGE_ATTRIB_NUM_PLANES:
       *value = 1;
       return GL_TRUE;
+   case __DRI_IMAGE_ATTRIB_MODIFIER_UPPER:
+      whandle.type = DRM_API_HANDLE_TYPE_KMS;
+      image->texture->screen->resource_get_handle(image->texture->screen,
+            NULL, image->texture, &whandle, usage);
+      *value = (whandle.modifier >> 32) & 0xffffffff;
+      return GL_TRUE;
+   case __DRI_IMAGE_ATTRIB_MODIFIER_LOWER:
+      whandle.type = DRM_API_HANDLE_TYPE_KMS;
+      image->texture->screen->resource_get_handle(image->texture->screen,
+            NULL, image->texture, &whandle, usage);
+      *value = whandle.modifier & 0xffffffff;
+      return GL_TRUE;
    default:
       return GL_FALSE;
    }
-- 
2.10.0



More information about the mesa-dev mailing list