[Mesa-dev] EGL: Add pbuffer support for drm platform

Ying Liu ying2.liu at intel.com
Wed Jun 10 16:05:04 PDT 2015


Add pbuffer support for drm platform, because some customers are still using this feature.

Signed-off-by: Ying Liu <ying2.liu at intel.com>
---
 src/egl/drivers/dri2/egl_dri2.c     |  3 +++
 src/egl/drivers/dri2/platform_drm.c | 30 +++++++++++++++++++++++-------
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 44a6c96..d56795e 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -909,6 +909,9 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
        */
       if (conf->SurfaceType & EGL_WINDOW_BIT)
          dri2_ctx->base.WindowRenderBuffer = EGL_BACK_BUFFER;
+
+      if (conf->SurfaceType & EGL_PBUFFER_BIT)
+         dri2_ctx->base.WindowRenderBuffer = EGL_BACK_BUFFER;
    }
    else
       dri_config = NULL;
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 3391afc..c8b7e92 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -123,16 +123,23 @@ dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
       dri2_surf->base.Height = surf->base.height;
       surf->dri_private = dri2_surf;
       break;
+   case EGL_PBUFFER_BIT:
+      break;
    default:
       goto cleanup_surf;
    }
 
    if (dri2_dpy->dri2) {
-      dri2_surf->dri_drawable =
-         (*dri2_dpy->dri2->createNewDrawable) (dri2_dpy->dri_screen,
-                                               dri2_conf->dri_double_config,
-                                               dri2_surf->gbm_surf);
-
+      if (type == EGL_PBUFFER_BIT)
+         dri2_surf->dri_drawable =
+            (*dri2_dpy->dri2->createNewDrawable) (dri2_dpy->dri_screen,
+                                                  dri2_conf->dri_double_config,
+                                                  dri2_surf);
+      else
+	 dri2_surf->dri_drawable =
+            (*dri2_dpy->dri2->createNewDrawable) (dri2_dpy->dri_screen,
+                                                  dri2_conf->dri_double_config,
+                                                  dri2_surf->gbm_surf);
    } else {
       assert(dri2_dpy->swrast != NULL);
       dri2_surf->dri_drawable =
@@ -155,6 +162,15 @@ dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
 }
 
 static _EGLSurface *
+dri2_drm_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
+                                _EGLConfig *conf,
+                                const EGLint *attrib_list)
+{
+   return dri2_drm_create_surface(drv, disp, EGL_PBUFFER_BIT, conf,
+                                  NULL, attrib_list);
+}
+
+static _EGLSurface *
 dri2_drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
                                _EGLConfig *conf, void *native_window,
                                const EGLint *attrib_list)
@@ -576,7 +592,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
    .authenticate = dri2_drm_authenticate,
    .create_window_surface = dri2_drm_create_window_surface,
    .create_pixmap_surface = dri2_drm_create_pixmap_surface,
-   .create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
+   .create_pbuffer_surface = dri2_drm_create_pbuffer_surface,
    .destroy_surface = dri2_drm_destroy_surface,
    .create_image = dri2_drm_create_image_khr,
    .swap_interval = dri2_fallback_swap_interval,
@@ -693,7 +709,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
       attr_list[2] = EGL_NONE;
 
       dri2_add_config(disp, dri2_dpy->driver_configs[i],
-                      i + 1, EGL_WINDOW_BIT, attr_list, NULL);
+                      i + 1, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, attr_list, NULL);
    }
 
    disp->Extensions.KHR_image_pixmap = EGL_TRUE;
-- 
2.1.0



More information about the mesa-dev mailing list