[Mesa-dev] [PATCH] egl: Introduce alternative native display types

Kristian Høgsberg krh at bitplanet.net
Tue May 18 10:58:17 PDT 2010


2010/5/17 Kristian Høgsberg <krh at bitplanet.net>:
> The EGL native platform API is determined at compile time and resolves
> to Win32, X11 or Symbian at this point.   This means that if we want to
> support XCB or a native DRM implementation, they have to be their platforms
> and result in different libEGL.so's with identical ABI but different
> entrypoint semantics.  From a distro point of view, and really, any point
> of view, this is a mess, since the different libraries can't easily co-exist
> without fiddling with linker paths.  And if you get it wrong, an application
> requiring the X11 platform libEGL.so will happily link against any other
> libEGL.so and segfault when eglGetDisplay() doesn't do what it expects.
>
> We can get around this by overloading the X11 native entrypoints instead.
> The X Display struct has as its first member a pointer to XExtData.  The
> pointer will always have bits 0 and 1 set to 0, which we can use to
> distinguish a struct that's not an X display.  This lets us pass in a
> custom struct that can provide initialization data for other platforms
> in the same libEGL.so.
>
> The convention we're establishing is that the first field of such a struct
> must be a pointer, so as to overlap with the layout of the X display
> struct.  We can then enummerate the different display types using odd
> numbers cast to a pointer (ensuring bit 0 is set).  This patch introduces
> two new types of displays: EGL_DISPLAY_TYPE_DRM_MESA which lets us
> initialize EGL directly on a DRM file descriptor or device filename and
> EGL_DISPLAY_TYPE_XCB_MESA which lets us initialize EGL on X using an
> xcb_connection_t instead of a classic Xlib Display.
...
> +   } else if (generic->pointer == EGL_DISPLAY_TYPE_DRM_MESA) {
> +      drm_display = (EGLDisplayTypeDRMMESA *) disp->NativeDisplay;
> +      if (drm_display->device) {
> +        dri2_dpy->device_name = strdup(drm_display->device);
> +      } else {
> +        dri2_dpy->fd = drm_display->fd;
> +      }
> +      dri2_dpy->driver_name = strdup("i965");

Okay, this part here obviously isn't fully baked yet.  What I'd like
to do for this is to have the DRI drivers expose the list of PCI IDs
they support at build time and compile that info into a text file on
disk.  Then at this point in the initialization we'll get the PCI ID
of the DRM device (libudev can do that) and look up the driver name
from the PCI ID in the text file.  Essentially similar to how the
Linux kernel extracts PCI (or other bus) IDs from the kernel modules
at build time, which is then used by userspace to locate and load the
right drivers.

Kristian


More information about the mesa-dev mailing list