Commit 1545e2db authored by Lyude Paul's avatar Lyude Paul Committed by Adam Jackson
Browse files

xwayland: Decouple GBM from glamor

This takes all of the gbm related code in wayland-glamor.c and moves it
into it's own EGL backend for Xwayland, xwayland-glamor-gbm.c.
Additionally, we add the egl_backend struct into xwl_screen in order to
provide hooks for alternative EGL backends such as nvidia's EGLStreams.
Signed-off-by: Lyude Paul's avatarLyude Paul <>
Reviewed-by: Lyude Paul's avatarLyude Paul <>
Reviewed-by: Daniel Stone's avatarDaniel Stone <>
Reviewed-by: Adam Jackson's avatarAdam Jackson <>
parent d2d664df
......@@ -35,6 +35,7 @@ Xwayland_built_sources =
Xwayland_SOURCES += \
xwayland-glamor.c \
xwayland-glamor-gbm.c \
if XV
Xwayland_SOURCES += \
......@@ -52,7 +52,11 @@ srcs += code.process(dmabuf_xml)
xwayland_glamor = []
if gbm_dep.found()
srcs += [ 'xwayland-glamor.c', 'xwayland-present.c' ]
srcs += [
if build_xv
srcs += 'xwayland-glamor-xv.c'
This diff is collapsed.
This diff is collapsed.
......@@ -755,13 +755,9 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
else if (xwl_screen->glamor &&
strcmp(interface, "wl_drm") == 0 && version >= 2) {
xwl_screen_set_drm_interface(xwl_screen, id, version);
else if (xwl_screen->glamor &&
strcmp(interface, "zwp_linux_dmabuf_v1") == 0 && version >= 3) {
xwl_screen_set_dmabuf_interface(xwl_screen, id, version);
else if (xwl_screen->glamor) {
xwl_glamor_init_wl_registry(xwl_screen, registry, id, interface,
......@@ -970,6 +966,13 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
if (xwl_screen->glamor) {
if (!xwl_glamor_init_gbm(xwl_screen)) {
ErrorF("xwayland glamor: failed to setup GBM backend, falling back to sw accel\n");
xwl_screen->glamor = 0;
/* In rootless mode, we don't have any screen storage, and the only
* rendering should be to redirected mode. */
if (xwl_screen->rootless)
......@@ -55,6 +55,9 @@ struct xwl_format {
uint64_t *modifiers;
struct xwl_pixmap;
struct xwl_window;
struct xwl_screen {
int width;
int height;
......@@ -101,19 +104,46 @@ struct xwl_screen {
int prepare_read;
int wait_flush;
char *device_name;
int drm_fd;
int fd_render_node;
int drm_authenticated;
struct wl_drm *drm;
struct zwp_linux_dmabuf_v1 *dmabuf;
uint32_t num_formats;
struct xwl_format *formats;
uint32_t capabilities;
void *egl_display, *egl_context;
struct gbm_device *gbm;
/* the current backend for creating pixmaps on wayland */
struct {
/* Called once for each interface in the global registry. Backends
* should use this to bind to any wayland interfaces they need. This
* callback is optional.
void (*init_wl_registry)(struct xwl_screen *xwl_screen,
struct wl_registry *wl_registry,
const char *name, uint32_t id,
uint32_t version);
/* Called before glamor has been initialized. Backends should setup a
* valid, glamor compatible EGL context in this hook.
Bool (*init_egl)(struct xwl_screen *xwl_screen);
/* Called after glamor has been initialized, and after all of the
* common Xwayland DDX hooks have been connected. Backends should use
* this to setup any required wraps around X server callbacks like
* CreatePixmap.
Bool (*init_screen)(struct xwl_screen *xwl_screen);
/* Called by Xwayland to retrieve a pointer to a valid wl_buffer for
* the given window/pixmap combo so that damage to the pixmap may be
* displayed on-screen. Backends should use this to create a new
* wl_buffer for a currently buffer-less pixmap, or simply return the
* pixmap they've prepared beforehand.
struct wl_buffer *(*get_wl_buffer_for_pixmap)(PixmapPtr pixmap,
unsigned short width,
unsigned short height,
Bool *created);
} egl_backend;
struct glamor_context *glamor_ctx;
int dmabuf_capable;
Atom allow_commits_prop;
......@@ -318,8 +348,6 @@ struct xwl_output {
Bool xdg_output_done;
struct xwl_pixmap;
void xwl_sync_events (struct xwl_screen *xwl_screen);
Bool xwl_screen_init_cursor(struct xwl_screen *xwl_screen);
......@@ -380,6 +408,10 @@ struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
unsigned short width,
unsigned short height,
Bool *created);
void xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
struct wl_registry *registry,
uint32_t id, const char *interface,
uint32_t version);
Bool xwl_present_init(ScreenPtr screen);
......@@ -400,4 +432,8 @@ Bool xwl_glamor_xv_init(ScreenPtr pScreen);
void xwlVidModeExtensionInit(void);
Bool xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment