[Mesa-dev] [PATCH RFC 3/3] egl: add support for EGL_MESA_drm_image_formats

Nicolai Hähnle nhaehnle at gmail.com
Thu Jan 26 11:50:25 UTC 2017


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

XXX do we need a separate enable bit?
---
 src/egl/drivers/dri2/egl_dri2.c | 21 ++++++++++++++++++++-
 src/egl/main/eglapi.c           |  2 ++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 94b7c20..98f2adc 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1883,28 +1883,38 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx,
    if (attrs.Width <= 0 || attrs.Height <= 0 ||
        attrs.DRMBufferStrideMESA <= 0) {
       _eglError(EGL_BAD_PARAMETER,
                 "bad width, height or stride");
       return NULL;
    }
 
    switch (attrs.DRMBufferFormatMESA) {
    case EGL_DRM_BUFFER_FORMAT_ARGB32_MESA:
       format = __DRI_IMAGE_FORMAT_ARGB8888;
-      pitch = attrs.DRMBufferStrideMESA;
+      break;
+   case EGL_DRM_BUFFER_FORMAT_ARGB2101010_MESA:
+      format = __DRI_IMAGE_FORMAT_ARGB2101010;
+      break;
+   case EGL_DRM_BUFFER_FORMAT_ARGB1555_MESA:
+      format = __DRI_IMAGE_FORMAT_ARGB1555;
+      break;
+   case EGL_DRM_BUFFER_FORMAT_RGB565_MESA:
+      format = __DRI_IMAGE_FORMAT_RGB565;
       break;
    default:
       _eglError(EGL_BAD_PARAMETER,
                 "dri2_create_image_khr: unsupported pixmap depth");
       return NULL;
    }
 
+   pitch = attrs.DRMBufferStrideMESA;
+
    dri_image =
       dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen,
                                            attrs.Width,
                                            attrs.Height,
                                            format,
                                            name,
                                            pitch,
                                            NULL);
 
    return dri2_create_image_from_dri(disp, dri_image);
@@ -2180,20 +2190,29 @@ dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp,
    if (attrs.Width <= 0 || attrs.Height <= 0) {
       _eglLog(_EGL_WARNING, "bad width or height (%dx%d)",
             attrs.Width, attrs.Height);
       goto cleanup_img;
    }
 
    switch (attrs.DRMBufferFormatMESA) {
    case EGL_DRM_BUFFER_FORMAT_ARGB32_MESA:
       format = __DRI_IMAGE_FORMAT_ARGB8888;
       break;
+   case EGL_DRM_BUFFER_FORMAT_ARGB2101010_MESA:
+      format = __DRI_IMAGE_FORMAT_ARGB2101010;
+      break;
+   case EGL_DRM_BUFFER_FORMAT_ARGB1555_MESA:
+      format = __DRI_IMAGE_FORMAT_ARGB1555;
+      break;
+   case EGL_DRM_BUFFER_FORMAT_RGB565_MESA:
+      format = __DRI_IMAGE_FORMAT_RGB565;
+      break;
    default:
       _eglLog(_EGL_WARNING, "bad image format value 0x%04x",
             attrs.DRMBufferFormatMESA);
       goto cleanup_img;
    }
 
    valid_mask =
       EGL_DRM_BUFFER_USE_SCANOUT_MESA |
       EGL_DRM_BUFFER_USE_SHARE_MESA |
       EGL_DRM_BUFFER_USE_CURSOR_MESA;
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index cab05c2..d998c7a 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -501,20 +501,22 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
    _EGL_CHECK_EXTENSION(KHR_no_config_context);
    _EGL_CHECK_EXTENSION(KHR_reusable_sync);
    _EGL_CHECK_EXTENSION(KHR_surfaceless_context);
    if (dpy->Extensions.EXT_swap_buffers_with_damage)
       _eglAppendExtension(&exts, "EGL_KHR_swap_buffers_with_damage");
    _EGL_CHECK_EXTENSION(KHR_wait_sync);
 
    if (dpy->Extensions.KHR_no_config_context)
       _eglAppendExtension(&exts, "EGL_MESA_configless_context");
    _EGL_CHECK_EXTENSION(MESA_drm_image);
+   if (dpy->Extensions.MESA_drm_image)
+      _eglAppendExtension(&exts, "EGL_MESA_drm_image_formats");
    _EGL_CHECK_EXTENSION(MESA_image_dma_buf_export);
 
    _EGL_CHECK_EXTENSION(NOK_swap_region);
    _EGL_CHECK_EXTENSION(NOK_texture_from_pixmap);
 
    _EGL_CHECK_EXTENSION(NV_post_sub_buffer);
 
    _EGL_CHECK_EXTENSION(WL_bind_wayland_display);
    _EGL_CHECK_EXTENSION(WL_create_wayland_buffer_from_image);
 
-- 
2.7.4



More information about the mesa-dev mailing list