[Mesa-dev] [PATCH] gallium/dri: Return failures from dri2_query_image.

christopher.halse.rogers at canonical.com christopher.halse.rogers at canonical.com
Mon Apr 22 01:21:28 PDT 2013


From: Christopher James Halse Rogers <raof at ubuntu.com>

resource_get_handle can fail, so we might as well bubble that failure
up to the client.
---
 src/gallium/state_trackers/dri/drm/dri2.c | 39 +++++++++++++++++++------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index ddd9ad1..ca90bb8 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -643,27 +643,36 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
    switch (attrib) {
    case __DRI_IMAGE_ATTRIB_STRIDE:
       whandle.type = DRM_API_HANDLE_TYPE_KMS;
-      image->texture->screen->resource_get_handle(image->texture->screen,
-            image->texture, &whandle);
-      *value = whandle.stride;
-      return GL_TRUE;
+      if (image->texture->screen->resource_get_handle(image->texture->screen,
+                                                      image->texture, &whandle)) {
+         *value = whandle.stride;
+         return GL_TRUE;
+      } else
+         return GL_FALSE;
    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;
+      if (image->texture->screen->resource_get_handle(image->texture->screen,
+                                                      image->texture, &whandle)) {
+         *value = whandle.handle;
+         return GL_TRUE;
+      } else
+         return GL_FALSE;
    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;
+      if (image->texture->screen->resource_get_handle(image->texture->screen,
+                                                      image->texture, &whandle)) {
+         *value = whandle.handle;
+         return GL_TRUE;
+      } else
+         return GL_FALSE;
    case __DRI_IMAGE_ATTRIB_FD:
       whandle.type= DRM_API_HANDLE_TYPE_FD;
-      image->texture->screen->resource_get_handle(image->texture->screen,
-         image->texture, &whandle);
-      *value = whandle.handle;
+      if (image->texture->screen->resource_get_handle(image->texture->screen,
+                                                      image->texture, &whandle)) {
+         *value = whandle.handle;
+         return GL_TRUE;
+      } else
+         return GL_FALSE;
    case __DRI_IMAGE_ATTRIB_FORMAT:
       *value = image->dri_format;
       return GL_TRUE;
-- 
1.8.1.2



More information about the mesa-dev mailing list