From cb7d8b04938d06cf60e307dedf98f35eb01f2c1a Mon Sep 17 00:00:00 2001 From: Kilika Date: Thu, 5 Sep 2024 16:04:36 +0300 Subject: [PATCH] Modified changelog entry and the inlined sanitization. --- CHANGELOG.md | 2 +- glutin/src/api/egl/display.rs | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62c24bbf18..5b4baf1933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ - Fixed EGL's `Device::query_devices()` being too strict about required extensions - Fixed crash in `EglGetProcAddress` on Win32-x86 platform due to wrong calling convention -- Implement a workaround for EGL's `Display::new()` making an `EGLDisplay::Khr` when the underlying platform only supports `EGLDisplay::Ext` due to `libglvnd` using the same vendor functions for obtaining a display connection for both `eglGetPlatformDisplay()` and `eglGetPlatformDisplayEXT()`. +- Fixed EGL's `Display::new()` making an `EGLDisplay::Khr` when the EGL version for the display is 1.4 or lower. # Version 0.32.0 diff --git a/glutin/src/api/egl/display.rs b/glutin/src/api/egl/display.rs index 6a30f7fbe2..27e4dbc63b 100644 --- a/glutin/src/api/egl/display.rs +++ b/glutin/src/api/egl/display.rs @@ -487,18 +487,18 @@ impl Display { // Sanitize the display provider, as the received EGL 1.4 display could have // been marked incorrectly as `EglDisplay::Khr`. - #[cfg(free_unix)] + // See pull request #1690. let display = match display { - // Since according to libglvnd, `eglGetPlatformDisplay` and `GetPlatformDisplayEXT` - // aren't really differentiated under the hood, we must check if the version of the - // initialized display is not sensible for the EglDisplay type and downgrade it if so - // See: https://gitlab.freedesktop.org/glvnd/libglvnd/-/blob/606f6627cf481ee6dcb32387edc010c502cdf38b/src/EGL/libegl.c#L270-358 - // https://gitlab.freedesktop.org/glvnd/libglvnd/-/blob/606f6627cf481ee6dcb32387edc010c502cdf38b/src/EGL/libegl.c#L409-461 - // https://gitlab.freedesktop.org/glvnd/libglvnd/-/blob/606f6627cf481ee6dcb32387edc010c502cdf38b/include/glvnd/libeglabi.h#L231-232 - // https://gitlab.freedesktop.org/glvnd/libglvnd/-/issues/251 - EglDisplay::Khr(display) if version == Version { major: 1, minor: 4 } => { + // `eglGetPlatformDisplay` and `GetPlatformDisplayEXT` aren't really differentiated, + // we must check if the version of the initialized display is not sensible for the + // EglDisplay type and downgrade it if so. + EglDisplay::Khr(display) if version <= Version { major: 1, minor: 4 } => { let client_extensions = CLIENT_EXTENSIONS.get().unwrap(); - if client_extensions.contains("EGL_EXT_platform_base") { + if client_extensions.contains("EGL_EXT_platform_base") + && (version == Version { major: 1, minor: 4 }) + { + // `EGL_EXT_platform_base` requires EGL 1.4 per specification; we cannot safely + // presume that an `Ext` display would be valid for older versions. EglDisplay::Ext(display) } else { EglDisplay::Legacy(display)