-
-
Notifications
You must be signed in to change notification settings - Fork 476
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
egl: Use EGL_KHR_display_reference #1609
Conversation
This resolves a past issue where glutin would not be able to terminate a display due to risk of two displays being created from the same native display.
I think you'd need this to make it work from how I read the extension. diff --git a/glutin/src/api/egl/display.rs b/glutin/src/api/egl/display.rs
index 43d043a..94c3dbd 100644
--- a/glutin/src/api/egl/display.rs
+++ b/glutin/src/api/egl/display.rs
@@ -125,10 +125,11 @@ impl Display {
.into());
}
- let mut attrs = Vec::<EGLint>::with_capacity(2);
+ let mut attrs = Vec::<EGLint>::with_capacity(3);
if extensions.contains("EGL_KHR_display_reference") {
attrs.push(egl::TRACK_REFERENCES_KHR as _);
+ attrs.push(egl::TRUE as _);
}
// TODO: Some extensions exist like EGL_EXT_device_drm which allow specifying
@@ -198,7 +199,7 @@ impl Display {
let extensions = NO_DISPLAY_EXTENSIONS.get().unwrap();
// Preallocate space for the terminator and to track references.
- let mut attrs = Vec::<EGLAttrib>::with_capacity(2);
+ let mut attrs = Vec::<EGLAttrib>::with_capacity(3);
let (platform, mut display) = match display {
#[cfg(wayland_platform)]
RawDisplayHandle::Wayland(handle)
@@ -227,6 +228,7 @@ impl Display {
if extensions.contains("EGL_KHR_display_reference") {
attrs.push(egl::TRACK_REFERENCES_KHR as _);
+ attrs.push(egl::TRUE as _);
}
// Be explicit here.
@@ -251,7 +253,7 @@ impl Display {
let extensions = NO_DISPLAY_EXTENSIONS.get().unwrap();
// Preallocate space for the terminator and to track references.
- let mut attrs = Vec::<EGLint>::with_capacity(2);
+ let mut attrs = Vec::<EGLint>::with_capacity(3);
let (platform, mut display) = match display {
#[cfg(wayland_platform)]
RawDisplayHandle::Wayland(handle)
@@ -286,6 +288,7 @@ impl Display {
if extensions.contains("EGL_KHR_display_reference") {
attrs.push(egl::TRACK_REFERENCES_KHR as _);
+ attrs.push(egl::TRUE as _);
}
// Be explicit here.
@@ -509,15 +512,21 @@ impl Drop for DisplayInner {
if self.client_extensions.contains("EGL_KHR_display_reference") {
let mut track_references = MaybeUninit::<u32>::uninit();
unsafe {
- self.egl.QueryDisplayAttribEXT(
- *self.raw,
- egl::TRACK_REFERENCES_KHR as _,
- track_references.as_mut_ptr().cast(),
- );
-
- if track_references.assume_init() == egl::TRUE {
+ if match self.raw {
+ EglDisplay::Khr(khr) => self.egl.QueryDisplayAttribKHR(
+ khr,
+ egl::TRACK_REFERENCES_KHR as _,
+ track_references.as_mut_ptr().cast(),
+ ),
+ EglDisplay::Ext(ext) => self.egl.QueryDisplayAttribEXT(
+ ext,
+ egl::TRACK_REFERENCES_KHR as _,
+ track_references.as_mut_ptr().cast(),
+ ),
+ EglDisplay::Legacy(_) => return,
+ } == egl::TRUE
+ {
self.egl.Terminate(*self.raw);
- return;
}
}
}
|
@MarijnS95 could you test this? The extension is not present for me with mesa, but from what I've see it was default on Android. With my patch applied likely and test that it actually calls |
Indeed, the documentation seems rather clear on requiring a Unfortunately my Android 13 phone does not advertise I bluntly tried to retrieve the value, but since Strangely there's no |
Yeah, it'll need more work in general. How did you test it @i509VCB , do you have nvidia card? mesa doesn't provide this extension from what I can see. |
Indeed, Mesa doesn't even support it on my Intel laptop nor on Freedreno for one of the many "mainlined" phones I have lining around (there's a PR open, though...). It seems NVidia should support it? |
I plan to try to test on some nvidia hardware I have, I need to install a new distro on the machine though |
See #1632. |
This resolves a past issue where glutin would not be able to terminate a display due to risk of two displays being created from the same native display.
CHANGELOG.md
if knowledge of this change could be valuable to users