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

egl/display: Pass *pointer to* output variable when querying DEVICE_EXT #1696

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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
- Fixed EGL's `Display::device()` always returning an error due to invalid pointer-argument passing inside

# Version 0.32.0

Expand Down
13 changes: 10 additions & 3 deletions glutin/src/api/egl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

use std::collections::HashSet;
use std::ffi::{self, CStr};
use std::fmt;
use std::mem::MaybeUninit;
use std::ops::Deref;
use std::os::raw::c_char;
use std::sync::Arc;
use std::{fmt, ptr};

use glutin_egl_sys::egl;
use glutin_egl_sys::egl::types::{EGLAttrib, EGLDisplay, EGLint};
Expand Down Expand Up @@ -193,12 +193,12 @@ impl Display {
.into());
}

let device = ptr::null_mut();
let mut device = MaybeUninit::uninit();
if unsafe {
self.inner.egl.QueryDisplayAttribEXT(
*self.inner.raw,
egl::DEVICE_EXT as EGLint,
device as *mut _,
device.as_mut_ptr(),
)
} == egl::FALSE
{
Expand All @@ -211,6 +211,13 @@ impl Display {
}));
}

let device = unsafe { device.assume_init() } as egl::types::EGLDeviceEXT;
debug_assert_ne!(
device,
egl::NO_DEVICE_EXT,
"eglQueryDisplayAttribEXT(EGL_DEVICE_EXT) should never return EGL_NO_DEVICE_EXT on \
success"
);
Device::from_ptr(self.inner.egl, device)
}

Expand Down
Loading