[Mesa-dev] [PATCH 3/6] egl/dri: use createImageFromRenderbuffer2 when available

Nicolai Hähnle nhaehnle at gmail.com
Fri Oct 6 20:16:05 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/egl/drivers/dri2/egl_dri2.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 1407c96352e..171858bbcd9 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1883,23 +1883,40 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx,
    if (renderbuffer == 0) {
       _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr");
       return EGL_NO_IMAGE_KHR;
    }
 
    if (!disp->Extensions.KHR_gl_renderbuffer_image) {
       _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr");
       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);
 }
 
 #ifdef HAVE_WAYLAND_PLATFORM
 
 /* This structure describes how a wl_buffer maps to one or more
  * __DRIimages.  A wl_drm_buffer stores the wl_drm format code and the
  * offsets and strides of the planes in the buffer.  This table maps a
  * wl_drm format code to a description of the planes in the buffer
-- 
2.11.0



More information about the mesa-dev mailing list