st/dri: support EGL_MESA_image_drm: queryImage
authorben <benjaminfranzke@googlemail.com>
Thu, 26 Aug 2010 15:32:32 +0000 (17:32 +0200)
committerJakob Bornecrantz <wallbraker@gmail.com>
Thu, 9 Sep 2010 20:47:38 +0000 (22:47 +0200)
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
src/gallium/state_trackers/dri/drm/dri2.c

index 2fa71ba4eda6212eedef93a91636835ba0015ee0..3ba7961d7c7c2dccc66ef34321580b1620357b2e 100644 (file)
@@ -437,6 +437,35 @@ dri2_create_image(__DRIscreen *_screen,
    return img;
 }
 
+static GLboolean
+dri2_query_image(__DRIimage *image, int attrib, int *value)
+{
+   struct winsys_handle whandle;
+   memset(&whandle, 0, sizeof(whandle));
+
+   switch (attrib) {
+   case __DRI_IMAGE_ATTRIB_STRIDE:
+      image->texture->screen->resource_get_handle(image->texture->screen,
+            image->texture, &whandle);
+      *value = whandle.stride;
+      return GL_TRUE;
+   case __DRI_IMAGE_ATTRIB_HANDLE:
+      whandle.type = DRM_API_HANDLE_TYPE_KMS;
+      image->texture->screen->resource_get_handle(image->texture->screen,
+         image->texture, &whandle);
+      *value = whandle.handle;
+      return GL_TRUE;
+   case __DRI_IMAGE_ATTRIB_NAME:
+      whandle.type = DRM_API_HANDLE_TYPE_SHARED;
+      image->texture->screen->resource_get_handle(image->texture->screen,
+         image->texture, &whandle);
+      *value = whandle.handle;
+      return GL_TRUE;
+   default:
+      return GL_FALSE;
+   }
+}
+
 static void
 dri2_destroy_image(__DRIimage *img)
 {
@@ -450,6 +479,7 @@ static struct __DRIimageExtensionRec dri2ImageExtension = {
     dri2_create_image_from_renderbuffer,
     dri2_destroy_image,
     dri2_create_image,
+    dri2_query_image,
 };
 
 /*