[Mesa-dev] [PATCH] st/egl: expose EGL_MESA_drm_image on x11 displays
nobled
nobled at dreamwidth.org
Tue Apr 19 11:22:32 PDT 2011
Date: Sun, 13 Feb 2011 23:45:47 +0000
This makes it useable with the egl_gallium driver in X11.
It only works for the DRI2 backend, not ximage.
---
src/gallium/state_trackers/egl/common/egl_g3d.c | 3 ++
.../state_trackers/egl/common/native_buffer.h | 3 +-
src/gallium/state_trackers/egl/x11/native_dri2.c | 24 ++++++++++++++++++++
3 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c
b/src/gallium/state_trackers/egl/common/egl_g3d.c
index ddca140..f0fb22b 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -551,6 +551,9 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy)
dpy->Extensions.MESA_drm_image = EGL_TRUE;
}
+ if (dpy->Platform == _EGL_PLATFORM_X11 && gdpy->native->buffer)
+ dpy->Extensions.MESA_drm_image = EGL_TRUE;
+
if (dpy->Platform == _EGL_PLATFORM_WAYLAND && gdpy->native->buffer)
dpy->Extensions.MESA_drm_image = EGL_TRUE;
diff --git a/src/gallium/state_trackers/egl/common/native_buffer.h
b/src/gallium/state_trackers/egl/common/native_buffer.h
index 5c29ab9..2c99381 100644
--- a/src/gallium/state_trackers/egl/common/native_buffer.h
+++ b/src/gallium/state_trackers/egl/common/native_buffer.h
@@ -41,7 +41,8 @@ struct pipe_resource;
* Just like a native window or a native pixmap, a native buffer is another
* native type. Its definition depends on the native display.
*
- * For DRM platform, the type of a native buffer is struct winsys_handle.
+ * For DRM, Wayland, and X11 platforms, the type of a native buffer
+ * is struct winsys_handle.
*/
struct native_display_buffer {
struct pipe_resource *(*import_buffer)(struct native_display *ndpy,
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c
b/src/gallium/state_trackers/egl/x11/native_dri2.c
index b18c313..46c7bb9 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -789,6 +789,29 @@ dri2_display_init_screen(struct native_display *ndpy)
return TRUE;
}
+static struct pipe_resource *
+dri2_display_import_buffer(struct native_display *ndpy,
+ const struct pipe_resource *templ,
+ void *buf)
+{
+ return ndpy->screen->resource_from_handle(ndpy->screen,
+ templ, (struct winsys_handle *) buf);
+}
+
+static boolean
+dri2_display_export_buffer(struct native_display *ndpy,
+ struct pipe_resource *res,
+ void *buf)
+{
+ return ndpy->screen->resource_get_handle(ndpy->screen,
+ res, (struct winsys_handle *) buf);
+}
+
+static struct native_display_buffer dri2_display_buffer = {
+ dri2_display_import_buffer,
+ dri2_display_export_buffer
+};
+
static unsigned
dri2_display_hash_table_hash(void *key)
{
@@ -851,6 +874,7 @@ x11_create_dri2_display(Display *dpy,
dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported;
dri2dpy->base.create_window_surface = dri2_display_create_window_surface;
dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface;
+ dri2dpy->base.buffer = &dri2_display_buffer;
return &dri2dpy->base;
}
--
1.7.0.4
More information about the mesa-dev
mailing list