Skip to content

Commit

Permalink
Bump khronos-egl to v6
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Oct 5, 2023
1 parent 1495e15 commit 7651e5c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 37 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ winapi = "0.3"
hassle-rs = "0.10.0"

# Gles dependencies
khronos-egl = "4.1"
khronos-egl = "6"
glow = "0.12.3"
glutin = "0.29.1"

Expand Down
4 changes: 2 additions & 2 deletions wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ gpu-alloc = { version = "0.6", optional = true }
gpu-descriptor = { version = "0.2", optional = true }
smallvec = { version = "1", optional = true, features = ["union"] }

khronos-egl = { version = "4.1", features = ["dynamic"], optional = true }
khronos-egl = { version = "6", features = ["dynamic"], optional = true }
libloading = { version = ">=0.7, <0.9", optional = true }
renderdoc-sys = { version = "1.0.0", optional = true }

[target.'cfg(target_os = "emscripten")'.dependencies]
khronos-egl = { version = "4.1", features = ["static", "no-pkg-config"] }
khronos-egl = { version = "6", features = ["static", "no-pkg-config"] }
#Note: it's unused by emscripten, but we keep it to have single code base in egl.rs
libloading = { version = ">=0.7, <0.9", optional = true }

Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/examples/raw-gles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn main() {

println!("Initializing external GL context");
let egl = khronos_egl::Instance::new(khronos_egl::Static);
let display = egl.get_display(khronos_egl::DEFAULT_DISPLAY).unwrap();
let display = unsafe { egl.get_display(khronos_egl::DEFAULT_DISPLAY) }.unwrap();
egl.initialize(display)
.expect("unable to initialize display");

Expand Down
68 changes: 38 additions & 30 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,24 +790,26 @@ impl crate::Instance<super::Api> for Instance {
if let (Some(library), Some(egl)) = (wayland_library, egl1_5) {
log::info!("Using Wayland platform");
let display_attributes = [khronos_egl::ATTRIB_NONE];
let display = egl
.get_platform_display(
let display = unsafe {
egl.get_platform_display(
EGL_PLATFORM_WAYLAND_KHR,
khronos_egl::DEFAULT_DISPLAY,
&display_attributes,
)
.unwrap();
}
.unwrap();
(display, Some(Arc::new(library)), WindowKind::Wayland)
} else if let (Some(display_owner), Some(egl)) = (x11_display_library, egl1_5) {
log::info!("Using X11 platform");
let display_attributes = [khronos_egl::ATTRIB_NONE];
let display = egl
.get_platform_display(
let display = unsafe {
egl.get_platform_display(
EGL_PLATFORM_X11_KHR,
display_owner.display.as_ptr(),
&display_attributes,
)
.unwrap();
}
.unwrap();
(display, Some(Arc::new(display_owner)), WindowKind::X11)
} else if let (Some(display_owner), Some(egl)) = (angle_x11_display_library, egl1_5) {
log::info!("Using Angle platform with X11");
Expand All @@ -818,28 +820,30 @@ impl crate::Instance<super::Api> for Instance {
usize::from(desc.flags.contains(crate::InstanceFlags::VALIDATION)),
khronos_egl::ATTRIB_NONE,
];
let display = egl
.get_platform_display(
let display = unsafe {
egl.get_platform_display(
EGL_PLATFORM_ANGLE_ANGLE,
display_owner.display.as_ptr(),
&display_attributes,
)
.unwrap();
}
.unwrap();
(display, Some(Arc::new(display_owner)), WindowKind::AngleX11)
} else if client_ext_str.contains("EGL_MESA_platform_surfaceless") {
log::info!("No windowing system present. Using surfaceless platform");
let egl = egl1_5.expect("Failed to get EGL 1.5 for surfaceless");
let display = egl
.get_platform_display(
let display = unsafe {
egl.get_platform_display(
EGL_PLATFORM_SURFACELESS_MESA,
std::ptr::null_mut(),
&[khronos_egl::ATTRIB_NONE],
)
.unwrap();
}
.unwrap();
(display, None, WindowKind::Unknown)
} else {
log::info!("EGL_MESA_platform_surfaceless not available. Using default platform");
let display = egl.get_display(khronos_egl::DEFAULT_DISPLAY).unwrap();
let display = unsafe { egl.get_display(khronos_egl::DEFAULT_DISPLAY) }.unwrap();
(display, None, WindowKind::Unknown)
};

Expand Down Expand Up @@ -936,17 +940,19 @@ impl crate::Instance<super::Api> for Instance {
use std::ops::DerefMut;
let display_attributes = [khronos_egl::ATTRIB_NONE];

let display = inner
.egl
.instance
.upcast::<khronos_egl::EGL1_5>()
.unwrap()
.get_platform_display(
EGL_PLATFORM_WAYLAND_KHR,
display_handle.display,
&display_attributes,
)
.unwrap();
let display = unsafe {
inner
.egl
.instance
.upcast::<khronos_egl::EGL1_5>()
.unwrap()
.get_platform_display(
EGL_PLATFORM_WAYLAND_KHR,
display_handle.display,
&display_attributes,
)
}
.unwrap();

let new_inner = Inner::create(
self.flags,
Expand Down Expand Up @@ -1276,12 +1282,14 @@ impl crate::Surface<super::Api> for Surface {
.into_iter()
.map(|v| v as usize)
.collect::<Vec<_>>();
egl.create_platform_window_surface(
self.egl.display,
self.config,
native_window_ptr,
&attributes_usize,
)
unsafe {
egl.create_platform_window_surface(
self.egl.display,
self.config,
native_window_ptr,
&attributes_usize,
)
}
}
_ => unsafe {
self.egl.instance.create_window_surface(
Expand Down

0 comments on commit 7651e5c

Please sign in to comment.