glamor: Trust eglGetPlatformDisplayEXT if it exists

If the libEGL we are using has eglGetPlatformDisplayEXT, yet it still
returns NULL, then this very likely means that it does not support the
type (e.g. EGL_PLATFORM_GBM_MESA) passed in, and then returning NULL is
the right thing to do.

This avoids falling back to an eglGetDisplay() implementation which does
not understands the passed in gbm handle, treats it as a pointer to
something else completely, followed by a crash sooner or later.

Specifically this fixes using the nvidia binary driver, with nvidia's
libEGL + the modesetting driver on a secondary GPU crashing inside
glamor_egl_init() sometimes.

[1.19: squash in typo fix from 29a4f3db - ajax]

Cc: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 05e1964425)
This commit is contained in:
Hans De Goede 2016-12-20 13:00:43 +01:00 committed by Adam Jackson
parent 8790bd993a
commit 862c1c43c1
2 changed files with 5 additions and 5 deletions

View File

@ -769,6 +769,10 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
glamor_egl->display = glamor_egl_get_display(EGL_PLATFORM_GBM_MESA,
glamor_egl->gbm);
if (!glamor_egl->display) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglGetDisplay() failed\n");
goto error;
}
#else
glamor_egl->display = eglGetDisplay((EGLNativeDisplayType) (intptr_t) fd);
#endif

View File

@ -60,16 +60,12 @@
static inline EGLDisplay
glamor_egl_get_display(EGLint type, void *native)
{
EGLDisplay dpy = NULL;
/* In practise any EGL 1.5 implementation would support the EXT extension */
if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")) {
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT =
(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
if (getPlatformDisplayEXT)
dpy = getPlatformDisplayEXT(type, native, NULL);
if (dpy)
return dpy;
return getPlatformDisplayEXT(type, native, NULL);
}
/* Welp, everything is awful. */