egl/dri: use createImageFromRenderbuffer2 when available
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 10 Oct 2017 11:58:47 +0000 (13:58 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 10 Oct 2017 11:58:47 +0000 (13:58 +0200)
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
src/egl/drivers/dri2/egl_dri2.c

index 1407c96352e9712cbfcccfdc961deabbd4bdcf8b..171858bbcd95a438fd367d9a7698aaea0956fb61 100644 (file)
@@ -1890,9 +1890,26 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx,
       return EGL_NO_IMAGE_KHR;
    }
 
-   dri_image =
-      dri2_dpy->image->createImageFromRenderbuffer(dri2_ctx->dri_context,
-                                                   renderbuffer, NULL);
+   if (dri2_dpy->image->base.version >= 17) {
+      unsigned error = ~0;
+
+      dri_image = dri2_dpy->image->createImageFromRenderbuffer2(
+               dri2_ctx->dri_context, renderbuffer, NULL, &error);
+
+      assert(!!dri_image == (error == __DRI_IMAGE_ERROR_SUCCESS));
+
+      if (!dri_image) {
+         _eglError(egl_error_from_dri_image_error(error), "dri2_create_image_khr");
+         return EGL_NO_IMAGE_KHR;
+      }
+   } else {
+      dri_image = dri2_dpy->image->createImageFromRenderbuffer(
+               dri2_ctx->dri_context, renderbuffer, NULL);
+      if (!dri_image) {
+         _eglError(EGL_BAD_ALLOC, "dri2_create_image_khr");
+         return EGL_NO_IMAGE_KHR;
+      }
+   }
 
    return dri2_create_image_from_dri(disp, dri_image);
 }