From c85cbea39ef9133f52625b473bfffcced6b44a1e Mon Sep 17 00:00:00 2001 From: daxpedda Date: Thu, 5 Oct 2023 20:01:32 +0200 Subject: [PATCH] Bump `khronos-egl` to v6 (#3807) --- Cargo.lock | 6 ++-- Cargo.toml | 2 +- wgpu-hal/Cargo.toml | 4 +-- wgpu-hal/examples/raw-gles.rs | 2 +- wgpu-hal/src/gles/egl.rs | 68 +++++++++++++++++++---------------- 5 files changed, 45 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ba0a6bf3..1a2765b8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1466,12 +1466,12 @@ dependencies = [ [[package]] name = "khronos-egl" -version = "4.1.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2352bd1d0bceb871cb9d40f24360c8133c11d7486b68b5381c1dd1a32015e3" +checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" dependencies = [ "libc", - "libloading 0.7.4", + "libloading 0.8.1", "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index 96f3f1fa6..9a9e11cf4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index acc26e062..bb1ac205f 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -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 } diff --git a/wgpu-hal/examples/raw-gles.rs b/wgpu-hal/examples/raw-gles.rs index 0e89783aa..ec0212960 100644 --- a/wgpu-hal/examples/raw-gles.rs +++ b/wgpu-hal/examples/raw-gles.rs @@ -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"); diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index d6d3d621f..7e2f33083 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -790,24 +790,26 @@ impl crate::Instance 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"); @@ -818,28 +820,30 @@ impl crate::Instance 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) }; @@ -936,17 +940,19 @@ impl crate::Instance for Instance { use std::ops::DerefMut; let display_attributes = [khronos_egl::ATTRIB_NONE]; - let display = inner - .egl - .instance - .upcast::() - .unwrap() - .get_platform_display( - EGL_PLATFORM_WAYLAND_KHR, - display_handle.display, - &display_attributes, - ) - .unwrap(); + let display = unsafe { + inner + .egl + .instance + .upcast::() + .unwrap() + .get_platform_display( + EGL_PLATFORM_WAYLAND_KHR, + display_handle.display, + &display_attributes, + ) + } + .unwrap(); let new_inner = Inner::create( self.flags, @@ -1276,12 +1282,14 @@ impl crate::Surface for Surface { .into_iter() .map(|v| v as usize) .collect::>(); - 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(