From 283514a8bd39f10f2333656b36c9fb9ff5891937 Mon Sep 17 00:00:00 2001 From: Igor Shaposhnik Date: Tue, 23 Nov 2021 12:42:22 +0300 Subject: [PATCH] Update raw-window-handle to 0.4 --- Cargo.lock | 25 ++++++++++++++++++++----- player/Cargo.toml | 2 +- wgpu-core/Cargo.toml | 2 +- wgpu-hal/Cargo.toml | 2 +- wgpu-hal/src/dx12/instance.rs | 2 +- wgpu-hal/src/gles/egl.rs | 21 ++------------------- wgpu-hal/src/metal/mod.rs | 4 ++-- wgpu-hal/src/vulkan/instance.rs | 33 +++++++++------------------------ wgpu/Cargo.toml | 2 +- 9 files changed, 38 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 06ae2c3b87..1aa52a9631 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -466,6 +466,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "cty" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" + [[package]] name = "d3d12" version = "0.4.1" @@ -1245,7 +1251,7 @@ version = "0.1.0" dependencies = [ "env_logger", "log", - "raw-window-handle", + "raw-window-handle 0.4.1", "ron", "serde", "wgpu-core", @@ -1394,6 +1400,15 @@ dependencies = [ "libc", ] +[[package]] +name = "raw-window-handle" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "503bdbfa9605024fdc97f845002e3690d14c5f553594f1cd0f819317a70de02c" +dependencies = [ + "cty", +] + [[package]] name = "redox_syscall" version = "0.2.10" @@ -1817,7 +1832,7 @@ dependencies = [ "png", "pollster", "rand", - "raw-window-handle", + "raw-window-handle 0.4.1", "serde", "smallvec", "wasm-bindgen", @@ -1843,7 +1858,7 @@ dependencies = [ "naga", "parking_lot", "profiling", - "raw-window-handle", + "raw-window-handle 0.4.1", "ron", "serde", "smallvec", @@ -1880,7 +1895,7 @@ dependencies = [ "parking_lot", "profiling", "range-alloc", - "raw-window-handle", + "raw-window-handle 0.4.1", "renderdoc-sys", "thiserror", "wasm-bindgen", @@ -1962,7 +1977,7 @@ dependencies = [ "objc", "parking_lot", "percent-encoding", - "raw-window-handle", + "raw-window-handle 0.3.3", "scopeguard", "smithay-client-toolkit", "wasm-bindgen", diff --git a/player/Cargo.toml b/player/Cargo.toml index 1ba574acb1..3ef7abb080 100644 --- a/player/Cargo.toml +++ b/player/Cargo.toml @@ -17,7 +17,7 @@ publish = false [dependencies] env_logger = "0.8" log = "0.4" -raw-window-handle = "0.3" +raw-window-handle = "0.4" ron = "0.7" winit = { version = "0.25", optional = true } diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 1c4519d184..10b5fcd285 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -29,7 +29,7 @@ fxhash = "0.2" log = "0.4" parking_lot = "0.11" profiling = { version = "1", default-features = false } -raw-window-handle = { version = "0.3", optional = true } +raw-window-handle = { version = "0.4", optional = true } ron = { version = "0.7", optional = true } serde = { version = "1.0", features = ["serde_derive"], optional = true } smallvec = "1" diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 7b1e83ffae..f70d84cadd 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -23,7 +23,7 @@ renderdoc = ["libloading", "renderdoc-sys"] bitflags = "1.0" parking_lot = "0.11" profiling = { version = "1", default-features = false } -raw-window-handle = "0.3" +raw-window-handle = "0.4" thiserror = "1" # backends common diff --git a/wgpu-hal/src/dx12/instance.rs b/wgpu-hal/src/dx12/instance.rs index 267e50264d..c00fce84ce 100644 --- a/wgpu-hal/src/dx12/instance.rs +++ b/wgpu-hal/src/dx12/instance.rs @@ -151,7 +151,7 @@ impl crate::Instance for super::Instance { has_handle: &impl raw_window_handle::HasRawWindowHandle, ) -> Result { match has_handle.raw_window_handle() { - raw_window_handle::RawWindowHandle::Windows(handle) => Ok(super::Surface { + raw_window_handle::RawWindowHandle::Win32(handle) => Ok(super::Surface { factory: self.factory, wnd_handle: handle.hwnd as *mut _, swap_chain: None, diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 5852907638..a36e35cbe7 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -23,14 +23,12 @@ type WlDisplayConnectFun = type WlDisplayDisconnectFun = unsafe extern "system" fn(display: *const raw::c_void); -#[cfg(not(any(target_os = "android", target_os = "macos")))] type WlEglWindowCreateFun = unsafe extern "system" fn( surface: *const raw::c_void, width: raw::c_int, height: raw::c_int, ) -> *mut raw::c_void; -#[cfg(not(any(target_os = "android", target_os = "macos")))] type WlEglWindowResizeFun = unsafe extern "system" fn( window: *const raw::c_void, width: raw::c_int, @@ -41,7 +39,6 @@ type WlEglWindowResizeFun = unsafe extern "system" fn( type WlEglWindowDestroyFun = unsafe extern "system" fn(window: *const raw::c_void); -#[cfg(target_os = "android")] extern "C" { pub fn ANativeWindow_setBuffersGeometry( window: *mut raw::c_void, @@ -597,12 +594,9 @@ impl crate::Instance for Instance { let mut inner = self.inner.lock(); match raw_window_handle { - #[cfg(not(any(target_os = "android", target_os = "macos")))] Rwh::Xlib(_) => {} - #[cfg(not(any(target_os = "android", target_os = "macos")))] Rwh::Xcb(_) => {} - #[cfg(target_os = "android")] - Rwh::Android(handle) => { + Rwh::AndroidNdk(handle) => { let format = inner .egl .get_config_attrib(inner.display, inner.config, egl::NATIVE_VISUAL_ID) @@ -615,7 +609,6 @@ impl crate::Instance for Instance { return Err(crate::InstanceError); } } - #[cfg(not(any(target_os = "android", target_os = "macos", target_os = "solaris")))] Rwh::Wayland(handle) => { /* Wayland displays are not sharable between surfaces so if the * surface we receive from this handle is from a different @@ -849,29 +842,19 @@ impl crate::Surface for Surface { let (surface, wl_window) = match self.unconfigure_impl(device) { Some(pair) => pair, None => { - #[cfg_attr(any(target_os = "android", target_os = "macos"), allow(unused_mut))] let mut wl_window = None; - #[cfg(not(any(target_os = "android", target_os = "macos")))] let (mut temp_xlib_handle, mut temp_xcb_handle); #[allow(trivial_casts)] let native_window_ptr = match self.raw_window_handle { - #[cfg(not(any(target_os = "android", target_os = "macos")))] Rwh::Xlib(handle) => { temp_xlib_handle = handle.window; &mut temp_xlib_handle as *mut _ as *mut std::ffi::c_void } - #[cfg(not(any(target_os = "android", target_os = "macos")))] Rwh::Xcb(handle) => { temp_xcb_handle = handle.window; &mut temp_xcb_handle as *mut _ as *mut std::ffi::c_void } - #[cfg(target_os = "android")] - Rwh::Android(handle) => handle.a_native_window, - #[cfg(not(any( - target_os = "android", - target_os = "macos", - target_os = "solaris" - )))] + Rwh::AndroidNdk(handle) => handle.a_native_window, Rwh::Wayland(handle) => { let library = self.wsi_library.as_ref().expect("unsupported window"); let wl_egl_window_create: libloading::Symbol = diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index fb3f41dc4d..3099991f91 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -85,12 +85,12 @@ impl crate::Instance for Instance { ) -> Result { match has_handle.raw_window_handle() { #[cfg(target_os = "ios")] - raw_window_handle::RawWindowHandle::IOS(handle) => { + raw_window_handle::RawWindowHandle::UiKit(handle) => { let _ = &self.managed_metal_layer_delegate; Ok(Surface::from_uiview(handle.ui_view)) } #[cfg(target_os = "macos")] - raw_window_handle::RawWindowHandle::MacOS(handle) => Ok(Surface::from_nsview( + raw_window_handle::RawWindowHandle::AppKit(handle) => Ok(Surface::from_nsview( handle.ns_view, &self.managed_metal_layer_delegate, )), diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index af4cc03b0f..0412617946 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -547,56 +547,41 @@ impl crate::Instance for super::Instance { use raw_window_handle::RawWindowHandle; match has_handle.raw_window_handle() { - #[cfg(all( - unix, - not(target_os = "android"), - not(target_os = "macos"), - not(target_os = "ios"), - not(target_os = "solaris") - ))] RawWindowHandle::Wayland(handle) if self.extensions.contains(&khr::WaylandSurface::name()) => { Ok(self.create_surface_from_wayland(handle.display, handle.surface)) } - #[cfg(all( - unix, - not(target_os = "android"), - not(target_os = "macos"), - not(target_os = "ios"), - not(target_os = "solaris") - ))] RawWindowHandle::Xlib(handle) if self.extensions.contains(&khr::XlibSurface::name()) => { Ok(self.create_surface_from_xlib(handle.display as *mut _, handle.window)) } - #[cfg(all( - unix, - not(target_os = "android"), - not(target_os = "macos"), - not(target_os = "ios") - ))] RawWindowHandle::Xcb(handle) if self.extensions.contains(&khr::XcbSurface::name()) => { Ok(self.create_surface_from_xcb(handle.connection, handle.window)) } - #[cfg(target_os = "android")] - RawWindowHandle::Android(handle) => { + RawWindowHandle::AndroidNdk(handle) => { Ok(self.create_surface_android(handle.a_native_window)) } #[cfg(windows)] - RawWindowHandle::Windows(handle) => { + RawWindowHandle::Win32(handle) => { use winapi::um::libloaderapi::GetModuleHandleW; let hinstance = GetModuleHandleW(std::ptr::null()); Ok(self.create_surface_from_hwnd(hinstance as *mut _, handle.hwnd)) } #[cfg(target_os = "macos")] - RawWindowHandle::MacOS(handle) + RawWindowHandle::AppKit(handle) if self.extensions.contains(&ext::MetalSurface::name()) => { Ok(self.create_surface_from_ns_view(handle.ns_view)) } + #[cfg(target_os = "ios")] + RawWindowHandle::UiKit(handle) + if self.extensions.contains(&ext::MetalSurface::name()) => + { + Ok(self.create_surface_from_ns_view(handle.ui_view)) + } _ => Err(crate::InstanceError), } } diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index c6f6e96c7f..617fde04b9 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -110,7 +110,7 @@ version = "0.11" arrayvec = "0.7" log = "0.4" parking_lot = "0.11" -raw-window-handle = "0.3" +raw-window-handle = "0.4" serde = { version = "1", features = ["derive"], optional = true } smallvec = "1"