Skip to content

Commit

Permalink
egl/display: ensure provider after version check
Browse files Browse the repository at this point in the history
EGL doesn't differentiate between objects created by different extensions,
and the display version check could be done, after we've created it, so
ensure what display we actually created and use its functions.
  • Loading branch information
janKilika authored Sep 10, 2024
1 parent 6eded55 commit dae89a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,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
- Fixed EGL's `Display::device()` always returning an error due to invalid pointer-argument passing inside
- 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

Expand Down
20 changes: 20 additions & 0 deletions glutin/src/api/egl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,26 @@ impl Display {
Version::new(major as u8, minor as u8)
};

let display = match display {
// `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")
&& (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)
}
},
// We do not do anything otherwise.
display => display,
};

// Load extensions.
let display_extensions = get_extensions(egl, *display);
let features = Self::extract_display_features(&display_extensions, version);
Expand Down

0 comments on commit dae89a5

Please sign in to comment.