Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logic in egl Device::query_device #1686

Merged
merged 11 commits into from
Jul 21, 2024
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Fixed EGL's `Device::query_devices()` being too strict about required extensions

# Version 0.32.0

- **Breaking:** updated `raw-window-handle` dependency to `0.6`.
Expand Down
28 changes: 17 additions & 11 deletions glutin/src/api/egl/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ impl Device {
None => return Err(ErrorKind::NotFound.into()),
};

let no_display_extensions =
let client_extensions =
CLIENT_EXTENSIONS.get_or_init(|| get_extensions(egl, egl::NO_DISPLAY));

// Querying devices requires EGL_EXT_device_enumeration and
// EGL_EXT_device_query.
//
// Or we can check for the EGL_EXT_device_base extension since it contains both
// extensions.
if (!no_display_extensions.contains("EGL_EXT_device_enumeration")
&& !no_display_extensions.contains("EGL_EXT_device_query"))
|| !no_display_extensions.contains("EGL_EXT_device_base")
{
return Err(ErrorKind::NotSupported("EGL does not support EGL_EXT_device_base").into());
// Querying devices requires EGL_EXT_device_enumeration or EGL_EXT_device_base.
if !client_extensions.contains("EGL_EXT_device_base") {
if !client_extensions.contains("EGL_EXT_device_enumeration") {
return Err(ErrorKind::NotSupported(
"Enumerating devices is not supported by the EGL instance",
)
.into());
}
// EGL_EXT_device_enumeration depends on EGL_EXT_device_query,
// so also check that just in case.
if !client_extensions.contains("EGL_EXT_device_query") {
return Err(ErrorKind::NotSupported(
"EGL_EXT_device_enumeration without EGL_EXT_device_query, buggy driver?",
)
.into());
}
}

let mut device_count = 0;
Expand Down
Loading