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

Casey Dahlin cdahlin at redhat.com
Tue May 10 20:35:10 PDT 2011

On Tue, May 10, 2011 at 04:42:56PM -0400, Kristian Høgsberg wrote:
> Indeed.  I'll commit this patch for now, since I've had enough of
> failing to set EGL_PLATFORM and then trying to figure out why it
> breaks.  The best solution I know of at this point is a "magic" way to
> look at the native display argument and detect what kind it is.  So
> for example, stat it to see if it's a char device, in which case we
> decide it's the drm platform.  If not, assume it's a pointer a struct
> and see if the first field looks like a valid pointer (not NULL and a
> multiple of 4), in which case we assume it's a X display pointer
> (Xlib.h, line 506).  For the wl_display struct we can make the first
> field a pointer to a wayland symbol which will let us distinguish it
> from an X display pointer.

The way I thought to do it was to make eglDisplay take none of those as
arguments, but instead take a struct mesaEglDisplay * where said struct was

struct mesaEglDisplay {
	/* uint64_t magic; */
	char[8] platform;
	void *display;

The reason it works is obvious, and its well within the egl spec. If you wanted
backward compatiblity, you could leave the magic uncommented and always fill
with 0xdeadbeefb4b3f00d, which would let you distinguish the new mechanism with
magic detection (though much more deterministic magic detection than what you
outlined) and otherwise just use the present system.


More information about the wayland-devel mailing list