[PATCH] compositor: Set EGL_PLATFORM env variable for each backend.

Casey Dahlin cdahlin at redhat.com
Tue May 10 13:13:45 PDT 2011


On Tue, May 10, 2011 at 08:00:19PM +0000, Egbert Eich wrote:
> I may have missed something, but - since the Wayland compositor 
> already picks a platform backend, opens a connection and initializes the
> backend specific display data structure it doesn't make sense
> to let egl pick a platform. If it picks a different one the 
> display specific data structure will most likely not match.
> Thus determine the platform in the Wayland rendering backend by setting
> the EGL_PLATFORM env variable.
> For the client any other platform than 'wayland' doesn't seem to make
> sense.
> I'm not sure if I've got the the platform ofr openfwd right.
> 
> Signed-off-by: Egbert Eich <eich at freedesktop.org>

This is one of many ways to hack around the somewhat deficient platform
selection in EGL (which in turn is a product of attempting to implement
the spec as best as they can).

Some sort of architectural fix for mesa would probably be preferred, but
nobody has yet found one that people will agree on.

--CJD

> ---
>  clients/window.c                |    1 +
>  compositor/compositor-drm.c     |    1 +
>  compositor/compositor-openwfd.c |    1 +
>  compositor/compositor-wayland.c |    1 +
>  compositor/compositor-x11.c     |    1 +
>  5 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/clients/window.c b/clients/window.c
> index 9d0b753..8c3f8d2 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -1757,6 +1757,7 @@ init_egl(struct display *d)
>  		EGL_NONE
>  	};
>  
> +	setenv("EGL_PLATFORM", "wayland", 1);
>  	d->dpy = eglGetDisplay(d->display);
>  	if (!eglInitialize(d->dpy, &major, &minor)) {
>  		fprintf(stderr, "failed to initialize display\n");
> diff --git a/compositor/compositor-drm.c b/compositor/compositor-drm.c
> index 4897b38..9fc5b49 100644
> --- a/compositor/compositor-drm.c
> +++ b/compositor/compositor-drm.c
> @@ -269,6 +269,7 @@ init_egl(struct drm_compositor *ec, struct udev_device *device)
>  		return -1;
>  	}
>  
> +	setenv("EGL_PLATFORM", "drm", 1);
>  	ec->drm.fd = fd;
>  	ec->base.display = eglGetDisplay(FD_TO_EGL_NATIVE_DPY(ec->drm.fd));
>  	if (ec->base.display == NULL) {
> diff --git a/compositor/compositor-openwfd.c b/compositor/compositor-openwfd.c
> index 0ddde52..ccd3dce 100644
> --- a/compositor/compositor-openwfd.c
> +++ b/compositor/compositor-openwfd.c
> @@ -118,6 +118,7 @@ init_egl(struct wfd_compositor *ec)
>  		return -1;
>  
>  	ec->wfd_fd = fd;
> +	setenv("EGL_PLATFORM", "drm", 1);
>  	ec->base.display = eglGetDisplay(FD_TO_EGL_NATIVE_DPY(ec->wfd_fd));
>  	if (ec->base.display == NULL) {
>  		fprintf(stderr, "failed to create display\n");
> diff --git a/compositor/compositor-wayland.c b/compositor/compositor-wayland.c
> index 1a53e8d..6cd02ed 100644
> --- a/compositor/compositor-wayland.c
> +++ b/compositor/compositor-wayland.c
> @@ -111,6 +111,7 @@ wayland_compositor_init_egl(struct wayland_compositor *c)
>  		EGL_NONE
>  	};
>  
> +	setenv("EGL_PLATFORM", "wayland", 1);
>  	c->base.display = eglGetDisplay(c->parent.display);
>  	if (c->base.display == NULL) {
>  		fprintf(stderr, "failed to create display\n");
> diff --git a/compositor/compositor-x11.c b/compositor/compositor-x11.c
> index ac31881..3517fad 100644
> --- a/compositor/compositor-x11.c
> +++ b/compositor/compositor-x11.c
> @@ -113,6 +113,7 @@ x11_compositor_init_egl(struct x11_compositor *c)
>  		EGL_NONE
>  	};
>  
> +	setenv("EGL_PLATFORM", "x11", 1);
>  	c->base.display = eglGetDisplay(c->dpy);
>  	if (c->base.display == NULL) {
>  		fprintf(stderr, "failed to create display\n");
> -- 
> 1.7.3.4
> 
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list