[Mesa-dev] enable pbuffer for drm platform

Liu, Ying2 ying2.liu at intel.com
Fri May 29 15:17:38 PDT 2015


When we tried to enable EGL on our project, we found that there was no pbuffer support for drm platform. I got some help from Alan and Kristian. Thank you so much! I studied platform_drm.c and compared it to other platforms' code. Finally I was able to create this patch to enable pbuffer for drm platform. Our QA team has run full cycle testing and didn't find any regression.  I wonder if anybody could review this patch to see if we could submit it to mesa.

Thanks

Ying

--- mesa-10.5.5.orig/src/egl/drivers/dri2/egl_dri2.c              2015-05-11 12:10:59.000000000 -0700
+++ mesa-10.5.5/src/egl/drivers/dri2/egl_dri2.c   2015-05-26 04:06:16.353346946 -0700
@@ -869,6 +869,10 @@ dri2_create_context(_EGLDriver *drv, _EG
        */
       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 -rupN mesa-10.5.5.orig/src/egl/drivers/dri2/platform_drm.c mesa-10.5.5/src/egl/drivers/dri2/platform_drm.c
--- mesa-10.5.5.orig/src/egl/drivers/dri2/platform_drm.c    2015-05-11 12:10:59.000000000 -0700
+++ mesa-10.5.5/src/egl/drivers/dri2/platform_drm.c         2015-05-26 04:04:25.293346505 -0700
@@ -122,6 +122,8 @@ dri2_drm_create_surface(_EGLDriver *drv,
       dri2_surf->base.Height = surf->base.height;
       surf->dri_private = dri2_surf;
       break;
+   case EGL_PBUFFER_BIT:
+      break;
    default:
       goto cleanup_surf;
    }
@@ -130,7 +132,7 @@ dri2_drm_create_surface(_EGLDriver *drv,
       dri2_surf->dri_drawable =
          (*dri2_dpy->dri2->createNewDrawable) (dri2_dpy->dri_screen,
                                                dri2_conf->dri_double_config,
-                                               dri2_surf->gbm_surf);
+                                               dri2_surf);
    } else {
       assert(dri2_dpy->swrast != NULL);
@@ -153,6 +155,15 @@ dri2_drm_create_surface(_EGLDriver *drv,
    return NULL;
}
+static inline _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,
@@ -575,7 +586,7 @@ static struct dri2_egl_display_vtbl dri2
    .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,
@@ -596,6 +607,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EG
    struct gbm_device *gbm;
    int fd = -1;
    int i;
+   EGLint surface_type;
    loader_set_logger(_eglLog);
@@ -691,8 +703,9 @@ dri2_initialize_drm(_EGLDriver *drv, _EG
       attr_list[1] = format;
       attr_list[2] = EGL_NONE;
+      surface_type =  EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
       dri2_add_config(disp, dri2_dpy->driver_configs[i],
-                      i + 1, EGL_WINDOW_BIT, attr_list, NULL);
+                      i + 1, surface_type, attr_list, NULL);
    }
    disp->Extensions.KHR_image_pixmap = EGL_TRUE;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150529/05a6b27c/attachment-0001.html>


More information about the mesa-dev mailing list