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
25 changes: 15 additions & 10 deletions glutin/src/api/egl/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,24 @@ 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.
// Querying devices requires EGL_EXT_device_enumeration or EGL_EXT_device_base.
//
// 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());
// The former depends on EGL_EXT_device_query, so also check that just in case.
quaternic marked this conversation as resolved.
Show resolved Hide resolved
if !client_extensions.contains("EGL_EXT_device_base") {
let query = client_extensions.contains("EGL_EXT_device_query");
let enumr = client_extensions.contains("EGL_EXT_device_enumeration");
if !(query & enumr) {
quaternic marked this conversation as resolved.
Show resolved Hide resolved
let msg = if !enumr {
"Enumerating devices is not supported by the EGL instance"
} else {
// this should not happen as device_enumeration depends on device_query
quaternic marked this conversation as resolved.
Show resolved Hide resolved
"EGL_EXT_device_enumeration without EGL_EXT_device_query, buggy driver?"
};
return Err(ErrorKind::NotSupported(msg).into());
}
}

let mut device_count = 0;
Expand Down
Loading