Cloudef / wlc

High-level Wayland compositor library
MIT License
331 stars 58 forks source link

wlc: Use eglGetPlatformDisplayEXT where available #233

Closed jwrdegoede closed 7 years ago

jwrdegoede commented 7 years ago

eglGetDisplay does not know what sort of handle it is getting passed in (a gbm device handle or an X11 display pointer) on systems without glvnd some poking into internal X11 / gbm structures is used to figure this out, which is somewhat dangerous but works.

On system using glvnd this does not work and eglGetDisplay returns NULL.

This commit makes wlc track the EGLNativeDisplayType pointer's underlying type and uses eglGetPlatformDisplayEXT where available so that the EGL implementation does not need to guess the type of the handle it is being passed.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1413579 Signed-off-by: Hans de Goede hdegoede@redhat.com

jwrdegoede commented 7 years ago

Hi,

On 31-01-17 15:07, Jari Vetoniemi wrote:

@Cloudef commented on this pull request.


In src/platform/context/egl.c https://github.com/Cloudef/wlc/pull/233#pullrequestreview-19320318:

    • 2: You can't tell whether you have EGL 1.5 at this point, because
    • eglQueryString(EGL_VERSION) is a property of the display, which we don't
    • have yet. So you have to query for extensions no matter what.
  • *
      1. There is no EGL_KHR_platform_base to complement the EXT one, thus one
    • needs to know EGL 1.5 is supported in order to use the eglGetPlatformDisplay
    • function pointer.
  • *
    • We can workaround this (circular dependency) by probing for the EGL 1.5
    • platform extensions (EGL_KHR_platform_gbm and friends) yet it doesn't seem
    • like mesa will be able to adverise these (even though it can do EGL 1.5).
  • / +static EGLDisplay +get_display(struct ctx context, EGLint type, void *native) +{
  • PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT;

Was this accidental duplicate definition? Otherwise this looks quite good. Scary but good :)

Yes, that was a copy paste mistake the top level one can be removed.

Regards,

Hans