From 8f5063c65f5f8c90a8e0710a25b3fe4dacf286f3 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Tue, 26 Jul 2022 19:37:15 -0400 Subject: [PATCH 01/13] winit 0.27 Update and raw-window-handle 0.5 --- Cargo.lock | 401 +++++++++++++++++++++++++++++--- player/Cargo.toml | 4 +- wgpu-core/Cargo.toml | 2 +- wgpu-core/src/instance.rs | 5 +- wgpu-hal/Cargo.toml | 6 +- wgpu-hal/src/lib.rs | 2 +- wgpu-hal/src/vulkan/instance.rs | 22 +- wgpu/Cargo.toml | 4 +- wgpu/src/backend/direct.rs | 2 +- wgpu/src/lib.rs | 6 +- 10 files changed, 402 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e16d6af4d1..a33e63ad5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,6 +55,18 @@ version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "arrayvec" version = "0.7.2" @@ -208,7 +220,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf2eec61efe56aa1e813f5126959296933cf0700030e4314786c48779a66ab82" dependencies = [ "log", - "nix", + "nix 0.22.3", +] + +[[package]] +name = "calloop" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a22a6a8f622f797120d452c630b0ab12e1331a1a753e2039ce7868d4ac77b4ee" +dependencies = [ + "log", + "nix 0.24.2", + "slotmap", + "thiserror", + "vec_map", ] [[package]] @@ -255,6 +280,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cmake" +version = "0.1.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" +dependencies = [ + "cc", +] + [[package]] name = "cocoa" version = "0.24.0" @@ -266,7 +300,7 @@ dependencies = [ "cocoa-foundation", "core-foundation 0.9.3", "core-graphics 0.22.3", - "foreign-types", + "foreign-types 0.3.2", "libc", "objc", ] @@ -281,7 +315,7 @@ dependencies = [ "block", "core-foundation 0.9.3", "core-graphics-types", - "foreign-types", + "foreign-types 0.3.2", "libc", "objc", ] @@ -371,7 +405,7 @@ checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923" dependencies = [ "bitflags", "core-foundation 0.7.0", - "foreign-types", + "foreign-types 0.3.2", "libc", ] @@ -384,7 +418,7 @@ dependencies = [ "bitflags", "core-foundation 0.9.3", "core-graphics-types", - "foreign-types", + "foreign-types 0.3.2", "libc", ] @@ -396,7 +430,19 @@ checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" dependencies = [ "bitflags", "core-foundation 0.9.3", - "foreign-types", + "foreign-types 0.3.2", + "libc", +] + +[[package]] +name = "core-text" +version = "19.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25" +dependencies = [ + "core-foundation 0.9.3", + "core-graphics 0.22.3", + "foreign-types 0.3.2", "libc", ] @@ -422,6 +468,29 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "crossfont" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f66b1c1979c4362323f03ab6bf7fb522902bfc418e0c37319ab347f9561d980f" +dependencies = [ + "cocoa", + "core-foundation 0.9.3", + "core-foundation-sys 0.8.3", + "core-graphics 0.22.3", + "core-text", + "dwrote", + "foreign-types 0.5.0", + "freetype-rs", + "libc", + "log", + "objc", + "once_cell", + "pkg-config", + "servo-fontconfig", + "winapi", +] + [[package]] name = "cty" version = "0.2.2" @@ -528,6 +597,20 @@ dependencies = [ "wgpu-core", ] +[[package]] +name = "dwrote" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" +dependencies = [ + "lazy_static", + "libc", + "serde", + "serde_derive", + "winapi", + "wio", +] + [[package]] name = "enum_primitive" version = "0.1.1" @@ -550,6 +633,16 @@ dependencies = [ "termcolor", ] +[[package]] +name = "expat-sys" +version = "2.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa" +dependencies = [ + "cmake", + "pkg-config", +] + [[package]] name = "fastrand" version = "1.7.0" @@ -577,7 +670,28 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" dependencies = [ - "foreign-types-shared", + "foreign-types-shared 0.1.1", +] + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared 0.3.1", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8469d0d40519bc608ec6863f1cc88f3f1deee15913f2f3b3e573d81ed38cccc" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -586,6 +700,34 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + +[[package]] +name = "freetype-rs" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74eadec9d0a5c28c54bb9882e54787275152a4e36ce206b45d7451384e5bf5fb" +dependencies = [ + "bitflags", + "freetype-sys", + "libc", +] + +[[package]] +name = "freetype-sys" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a" +dependencies = [ + "cmake", + "libc", + "pkg-config", +] + [[package]] name = "futures-core" version = "0.3.21" @@ -708,7 +850,7 @@ dependencies = [ "wayland-client", "wayland-egl", "winapi", - "winit", + "winit 0.26.1", ] [[package]] @@ -990,6 +1132,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memmap2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a79b39c93a7a5a27eeaf9a23b5ff43f1b9e0ad6b1cdd441140ae53c35613fc7" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.6.5" @@ -1008,7 +1159,7 @@ dependencies = [ "bitflags", "block", "core-graphics-types", - "foreign-types", + "foreign-types 0.3.2", "log", "objc", ] @@ -1077,11 +1228,25 @@ checksum = "96d868f654c72e75f8687572699cdabe755f03effbb62542768e995d5b8d699d" dependencies = [ "bitflags", "jni-sys", - "ndk-sys", + "ndk-sys 0.2.2", "num_enum", "thiserror", ] +[[package]] +name = "ndk" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" +dependencies = [ + "bitflags", + "jni-sys", + "ndk-sys 0.4.0", + "num_enum", + "raw-window-handle 0.5.0", + "thiserror", +] + [[package]] name = "ndk-context" version = "0.1.1" @@ -1097,10 +1262,26 @@ dependencies = [ "lazy_static", "libc", "log", - "ndk", + "ndk 0.5.0", "ndk-context", "ndk-macro", - "ndk-sys", + "ndk-sys 0.2.2", +] + +[[package]] +name = "ndk-glue" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f" +dependencies = [ + "libc", + "log", + "ndk 0.7.0", + "ndk-context", + "ndk-macro", + "ndk-sys 0.4.0", + "once_cell", + "parking_lot 0.12.1", ] [[package]] @@ -1122,6 +1303,15 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121" +[[package]] +name = "ndk-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21d83ec9c63ec5bf950200a8e508bdad6659972187b625469f58ef8c08e29046" +dependencies = [ + "jni-sys", +] + [[package]] name = "nix" version = "0.22.3" @@ -1135,6 +1325,18 @@ dependencies = [ "memoffset", ] +[[package]] +name = "nix" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "libc", + "memoffset", +] + [[package]] name = "noise" version = "0.7.0" @@ -1328,12 +1530,12 @@ version = "0.1.0" dependencies = [ "env_logger", "log", - "raw-window-handle", + "raw-window-handle 0.5.0", "ron", "serde", "wgpu-core", "wgpu-types", - "winit", + "winit 0.27.0", ] [[package]] @@ -1468,6 +1670,15 @@ dependencies = [ "cty", ] +[[package]] +name = "raw-window-handle" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed7e3d950b66e19e0c372f3fa3fbbcf85b1746b571f74e0c2af6042a5c93420a" +dependencies = [ + "cty", +] + [[package]] name = "redox_syscall" version = "0.2.13" @@ -1545,6 +1756,15 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +[[package]] +name = "safe_arch" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ff3d6d9696af502cc3110dacce942840fb06ff4514cad92236ecc455f2ce05" +dependencies = [ + "bytemuck", +] + [[package]] name = "safemem" version = "0.3.3" @@ -1563,6 +1783,18 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sctk-adwaita" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8cdeb3fbbd384de045d5683bfc3cadfc4c6ed1e6471f201ede801f31571581a" +dependencies = [ + "crossfont", + "log", + "smithay-client-toolkit 0.16.0", + "tiny-skia", +] + [[package]] name = "serde" version = "1.0.137" @@ -1594,6 +1826,27 @@ dependencies = [ "serde", ] +[[package]] +name = "servo-fontconfig" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e3e22fe5fd73d04ebf0daa049d3efe3eae55369ce38ab16d07ddd9ac5c217c" +dependencies = [ + "libc", + "servo-fontconfig-sys", +] + +[[package]] +name = "servo-fontconfig-sys" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36b879db9892dfa40f95da1c38a835d41634b825fbd8c4c418093d53c24b388" +dependencies = [ + "expat-sys", + "freetype-sys", + "pkg-config", +] + [[package]] name = "shared_library" version = "0.1.9" @@ -1632,12 +1885,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a28f16a97fa0e8ce563b2774d1e732dd5d4025d2772c5dba0a41a0f90a29da3" dependencies = [ "bitflags", - "calloop", + "calloop 0.9.3", + "dlib", + "lazy_static", + "log", + "memmap2 0.3.1", + "nix 0.22.3", + "pkg-config", + "wayland-client", + "wayland-cursor", + "wayland-protocols", +] + +[[package]] +name = "smithay-client-toolkit" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f307c47d32d2715eb2e0ece5589057820e0e5e70d07c247d1063e844e107f454" +dependencies = [ + "bitflags", + "calloop 0.10.1", "dlib", "lazy_static", "log", - "memmap2", - "nix", + "memmap2 0.5.5", + "nix 0.24.2", "pkg-config", "wayland-client", "wayland-cursor", @@ -1714,6 +1986,20 @@ dependencies = [ "syn", ] +[[package]] +name = "tiny-skia" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d049bfef0eaa2521e75d9ffb5ce86ad54480932ae19b85f78bec6f52c4d30d78" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "bytemuck", + "cfg-if 1.0.0", + "png", + "safe_arch", +] + [[package]] name = "toml" version = "0.5.9" @@ -1747,6 +2033,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + [[package]] name = "version_check" version = "0.9.4" @@ -1970,7 +2262,7 @@ dependencies = [ "bitflags", "downcast-rs", "libc", - "nix", + "nix 0.22.3", "scoped-tls", "wayland-commons", "wayland-scanner", @@ -1983,7 +2275,7 @@ version = "0.29.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94f6e5e340d7c13490eca867898c4cec5af56c27a5ffe5c80c6fc4708e22d33e" dependencies = [ - "nix", + "nix 0.22.3", "once_cell", "smallvec", "wayland-sys", @@ -1995,7 +2287,7 @@ version = "0.29.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c52758f13d5e7861fc83d942d3d99bf270c83269575e52ac29e5b73cb956a6bd" dependencies = [ - "nix", + "nix 0.22.3", "wayland-client", "xcursor", ] @@ -2058,7 +2350,7 @@ dependencies = [ name = "wgpu" version = "0.13.0" dependencies = [ - "arrayvec", + "arrayvec 0.7.2", "async-executor", "bitflags", "bytemuck", @@ -2077,7 +2369,7 @@ dependencies = [ "parking_lot 0.12.1", "png", "pollster", - "raw-window-handle", + "raw-window-handle 0.5.0", "serde", "smallvec", "wasm-bindgen", @@ -2086,14 +2378,14 @@ dependencies = [ "wgpu-core", "wgpu-hal", "wgpu-types", - "winit", + "winit 0.27.0", ] [[package]] name = "wgpu-core" version = "0.13.0" dependencies = [ - "arrayvec", + "arrayvec 0.7.2", "bit-vec", "bitflags", "cfg_aliases", @@ -2104,7 +2396,7 @@ dependencies = [ "naga", "parking_lot 0.12.1", "profiling", - "raw-window-handle", + "raw-window-handle 0.5.0", "ron", "serde", "smallvec", @@ -2119,7 +2411,7 @@ name = "wgpu-hal" version = "0.13.0" dependencies = [ "android_system_properties", - "arrayvec", + "arrayvec 0.7.2", "ash", "bit-set", "bitflags", @@ -2127,7 +2419,7 @@ dependencies = [ "core-graphics-types", "d3d12", "env_logger", - "foreign-types", + "foreign-types 0.3.2", "fxhash", "glow", "glutin", @@ -2144,14 +2436,14 @@ dependencies = [ "parking_lot 0.12.1", "profiling", "range-alloc", - "raw-window-handle", + "raw-window-handle 0.5.0", "renderdoc-sys", "thiserror", "wasm-bindgen", "web-sys", "wgpu-types", "winapi", - "winit", + "winit 0.27.0", ] [[package]] @@ -2262,14 +2554,14 @@ dependencies = [ "libc", "log", "mio", - "ndk", - "ndk-glue", - "ndk-sys", + "ndk 0.5.0", + "ndk-glue 0.5.2", + "ndk-sys 0.2.2", "objc", "parking_lot 0.11.2", "percent-encoding", - "raw-window-handle", - "smithay-client-toolkit", + "raw-window-handle 0.4.3", + "smithay-client-toolkit 0.15.4", "wasm-bindgen", "wayland-client", "wayland-protocols", @@ -2278,6 +2570,47 @@ dependencies = [ "x11-dl", ] +[[package]] +name = "winit" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3464a81db85deec66bc170b5a4ca6413d4a5f43df460ff80b550c9207031ea7e" +dependencies = [ + "bitflags", + "cocoa", + "core-foundation 0.9.3", + "core-graphics 0.22.3", + "dispatch", + "instant", + "libc", + "log", + "mio", + "ndk 0.7.0", + "ndk-glue 0.7.0", + "objc", + "once_cell", + "parking_lot 0.12.1", + "percent-encoding", + "raw-window-handle 0.5.0", + "sctk-adwaita", + "smithay-client-toolkit 0.16.0", + "wasm-bindgen", + "wayland-client", + "wayland-protocols", + "web-sys", + "windows-sys", + "x11-dl", +] + +[[package]] +name = "wio" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" +dependencies = [ + "winapi", +] + [[package]] name = "wit-parser" version = "0.2.0" diff --git a/player/Cargo.toml b/player/Cargo.toml index d5e712f4f7..c2915ab8d2 100644 --- a/player/Cargo.toml +++ b/player/Cargo.toml @@ -17,9 +17,9 @@ publish = false [dependencies] env_logger = "0.9" log = "0.4" -raw-window-handle = "0.4" +raw-window-handle = "0.5" ron = "0.7" -winit = { version = "0.26", optional = true } +winit = { version = "0.27", optional = true } [dependencies.wgt] path = "../wgpu-types" diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 7b5b5e4b67..6c93ad272c 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -34,7 +34,7 @@ log = "0.4" # parking_lot 0.12 switches from `winapi` to `windows`; permit either parking_lot = ">=0.11,<0.13" profiling = { version = "1", default-features = false } -raw-window-handle = { version = "0.4", optional = true } +raw-window-handle = { version = "0.5", optional = true } ron = { version = "0.7", optional = true } serde = { version = "1.0", features = ["serde_derive"], optional = true } smallvec = "1" diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 03ec97192b..8ad4774c63 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -424,7 +424,7 @@ impl Global { #[cfg(feature = "raw-window-handle")] pub fn instance_create_surface( &self, - handle: &impl raw_window_handle::HasRawWindowHandle, + handle: &(impl raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle), id_in: Input, ) -> SurfaceId { profiling::scope!("Instance::create_surface"); @@ -434,7 +434,8 @@ impl Global { fn init( _: A, inst: &Option, - handle: &impl raw_window_handle::HasRawWindowHandle, + handle: &(impl raw_window_handle::HasRawWindowHandle + + raw_window_handle::HasRawDisplayHandle), ) -> Option> { inst.as_ref().and_then(|inst| unsafe { match inst.create_surface(handle) { diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 8fe4aef58e..b826e24c4d 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -34,7 +34,7 @@ bitflags = "1.0" # parking_lot 0.12 switches from `winapi` to `windows`; permit either parking_lot = ">=0.11,<0.13" profiling = { version = "1", default-features = false } -raw-window-handle = "0.4" +raw-window-handle = "0.5" thiserror = "1" # backends common @@ -109,7 +109,7 @@ features = ["wgsl-in"] [dev-dependencies] env_logger = "0.9" -winit = "0.26" # for "halmark" example +winit = "0.27" # for "halmark" example [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] -glutin = "0.28" # for "gles" example +glutin = "0.28.0" # for "gles" example diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index f52c05ed34..fcaf03946f 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -178,7 +178,7 @@ pub trait Instance: Sized + Send + Sync { unsafe fn init(desc: &InstanceDescriptor) -> Result; unsafe fn create_surface( &self, - rwh: &impl raw_window_handle::HasRawWindowHandle, + rwh: &(impl raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle), ) -> Result; unsafe fn destroy_surface(&self, surface: A::Surface); unsafe fn enumerate_adapters(&self) -> Vec>; diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index 2da4288b4a..c490038d48 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -591,8 +591,10 @@ impl crate::Instance for super::Instance { unsafe fn create_surface( &self, - has_handle: &impl raw_window_handle::HasRawWindowHandle, + has_handle: &(impl raw_window_handle::HasRawWindowHandle + + raw_window_handle::HasRawDisplayHandle), ) -> Result { + use raw_window_handle::RawDisplayHandle; use raw_window_handle::RawWindowHandle; match has_handle.raw_window_handle() { @@ -602,17 +604,29 @@ impl crate::Instance for super::Instance { .extensions .contains(&khr::WaylandSurface::name()) => { - Ok(self.create_surface_from_wayland(handle.display, handle.surface)) + if let RawDisplayHandle::Wayland(v) = has_handle.raw_display_handle() { + Ok(self.create_surface_from_wayland(v.display, handle.surface)) + } else { + Err(crate::InstanceError) + } } RawWindowHandle::Xlib(handle) if self.shared.extensions.contains(&khr::XlibSurface::name()) => { - Ok(self.create_surface_from_xlib(handle.display as *mut _, handle.window)) + if let RawDisplayHandle::Xlib(v) = has_handle.raw_display_handle() { + Ok(self.create_surface_from_xlib(v.display as *mut _, handle.window)) + } else { + Err(crate::InstanceError) + } } RawWindowHandle::Xcb(handle) if self.shared.extensions.contains(&khr::XcbSurface::name()) => { - Ok(self.create_surface_from_xcb(handle.connection, handle.window)) + if let RawDisplayHandle::Xlib(v) = has_handle.raw_display_handle() { + Ok(self.create_surface_from_xcb(v.display, handle.window)) + } else { + Err(crate::InstanceError) + } } RawWindowHandle::AndroidNdk(handle) => { Ok(self.create_surface_android(handle.a_native_window)) diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 0e52132f7b..4168264577 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -114,7 +114,7 @@ arrayvec = "0.7" log = "0.4" # parking_lot 0.12 switches from `winapi` to `windows`; permit either parking_lot = ">=0.11,<0.13" -raw-window-handle = "0.4" +raw-window-handle = "0.5" serde = { version = "1", features = ["derive"], optional = true } smallvec = "1" @@ -131,7 +131,7 @@ noise = { version = "0.7", default-features = false } obj = "0.10" png = "0.17" nanorand = { version = "0.7", default-features = false, features = ["wyrand"] } -winit = "0.26" +winit = "0.27" [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] async-executor = "1.0" diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index cb5ca21b92..870d03d106 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -850,7 +850,7 @@ impl crate::Context for Context { fn instance_create_surface( &self, - handle: &impl raw_window_handle::HasRawWindowHandle, + handle: &(impl raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle), ) -> Self::SurfaceId { Surface { id: self.0.instance_create_surface(handle, PhantomData), diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 1e56f1572f..3b243d35d2 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -197,7 +197,7 @@ trait Context: Debug + Send + Sized + Sync { fn init(backends: Backends) -> Self; fn instance_create_surface( &self, - handle: &impl raw_window_handle::HasRawWindowHandle, + handle: &(impl raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle), ) -> Self::SurfaceId; fn instance_request_adapter( &self, @@ -1754,7 +1754,9 @@ impl Instance { /// - Raw Window Handle must be a valid object to create a surface upon and /// must remain valid for the lifetime of the returned surface. /// - If not called on the main thread, metal backend will panic. - pub unsafe fn create_surface( + pub unsafe fn create_surface< + W: raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle, + >( &self, window: &W, ) -> Surface { From 17f856a460d65b7335ff45cec6900c04710cc86c Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Tue, 26 Jul 2022 19:55:58 -0400 Subject: [PATCH 02/13] egl fix --- wgpu-hal/src/gles/egl.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 50abd273ca..6accb2b7d5 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -1,6 +1,6 @@ use glow::HasContext; use parking_lot::{Mutex, MutexGuard}; -use raw_window_handle::{HasRawWindowHandle, RawWindowHandle}; +use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawWindowHandle}; use std::{ffi, os::raw, ptr, sync::Arc, time::Duration}; @@ -770,9 +770,10 @@ impl crate::Instance for Instance { #[cfg_attr(target_os = "macos", allow(unused, unused_mut, unreachable_code))] unsafe fn create_surface( &self, - has_handle: &impl HasRawWindowHandle, + has_handle: &(impl HasRawWindowHandle + HasRawDisplayHandle), ) -> Result { use raw_window_handle::RawWindowHandle as Rwh; + use raw_window_handle::RawDisplayHandle as Rdh; let raw_window_handle = has_handle.raw_window_handle(); @@ -800,21 +801,27 @@ impl crate::Instance for Instance { } } #[cfg(not(feature = "emscripten"))] - Rwh::Wayland(handle) => { + Rwh::Wayland(_) => { /* Wayland displays are not sharable between surfaces so if the * surface we receive from this handle is from a different * display, we must re-initialize the context. * * See gfx-rs/gfx#3545 */ + let wayland_raw= if let Rdh::Wayland(display) = has_handle.raw_display_handle() { + display.display + }else{ + return Err(crate::InstanceError); + } ; log::warn!("Re-initializing Gles context due to Wayland window"); if inner .wl_display - .map(|ptr| ptr != handle.display) + .map(|ptr| ptr != wayland_raw) .unwrap_or(true) { use std::ops::DerefMut; let display_attributes = [egl::ATTRIB_NONE]; + let display = inner .egl .instance @@ -822,7 +829,7 @@ impl crate::Instance for Instance { .unwrap() .get_platform_display( EGL_PLATFORM_WAYLAND_KHR, - handle.display, + wayland_raw, &display_attributes, ) .unwrap(); @@ -832,7 +839,8 @@ impl crate::Instance for Instance { .map_err(|_| crate::InstanceError)?; let old_inner = std::mem::replace(inner.deref_mut(), new_inner); - inner.wl_display = Some(handle.display); + inner.wl_display = Some(wayland_raw); + drop(old_inner); } } From 3c3313f0fb170fd0fc5b9bac8c45d97a329fd9c2 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Tue, 26 Jul 2022 20:03:29 -0400 Subject: [PATCH 03/13] egl fix --- wgpu-hal/src/gles/egl.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 6accb2b7d5..197d9ea5b9 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -773,7 +773,6 @@ impl crate::Instance for Instance { has_handle: &(impl HasRawWindowHandle + HasRawDisplayHandle), ) -> Result { use raw_window_handle::RawWindowHandle as Rwh; - use raw_window_handle::RawDisplayHandle as Rdh; let raw_window_handle = has_handle.raw_window_handle(); @@ -808,11 +807,13 @@ impl crate::Instance for Instance { * * See gfx-rs/gfx#3545 */ - let wayland_raw= if let Rdh::Wayland(display) = has_handle.raw_display_handle() { + let wayland_raw = if let raw_window_handle::RawDisplayHandle::Wayland(display) = + has_handle.raw_display_handle() + { display.display - }else{ + } else { return Err(crate::InstanceError); - } ; + }; log::warn!("Re-initializing Gles context due to Wayland window"); if inner .wl_display From ab4df8bcbfd937a9fb527f797590d559c13076bb Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Tue, 26 Jul 2022 20:11:01 -0400 Subject: [PATCH 04/13] Updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f91d440ad5..88f0b1c45b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ the same every time it is rendered, we now warn if it is missing. #### General - Add warning when using CompareFunction::*Equal with vertex shader that is missing @invariant tag by @cwfitzgerald in [#2887](https://github.com/gfx-rs/wgpu/pull/2887) +- Update Winit to version 0.27 and raw-window-handle to 0.5 by @wyatt-herkamp in [#2918](https://github.com/gfx-rs/wgpu/pull/2918) #### Metal - Extract the generic code into `get_metal_layer` by @jinleili in [#2826](https://github.com/gfx-rs/wgpu/pull/2826) From 40d91e9ecc8cc8f476d95f864859d010186660bc Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Sun, 31 Jul 2022 17:59:40 -0400 Subject: [PATCH 05/13] Bump the MSRV --- .github/workflows/ci.yml | 2 +- wgpu-hal/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5278c8afce..9bb32531d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: env: RUST_BACKTRACE: 1 - RUST_VERSION: 1.59 + RUST_VERSION: 1.63 # We distinguish the following kinds of builds: # - local: build for the same target as we compile on, and do local tests diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index b826e24c4d..190eec5ff7 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -8,7 +8,7 @@ homepage = "https://github.com/gfx-rs/wgpu" repository = "https://github.com/gfx-rs/wgpu" keywords = ["graphics"] license = "MIT OR Apache-2.0" -rust-version = "1.59" +rust-version = "1.63" [lib] From 06d37389f00e5d8ab2a535cf501d7fbd2382906a Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Mon, 1 Aug 2022 06:57:17 -0400 Subject: [PATCH 06/13] Revert "Bump the MSRV" This reverts commit 40d91e9ecc8cc8f476d95f864859d010186660bc. --- .github/workflows/ci.yml | 2 +- wgpu-hal/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9bb32531d9..5278c8afce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: env: RUST_BACKTRACE: 1 - RUST_VERSION: 1.63 + RUST_VERSION: 1.59 # We distinguish the following kinds of builds: # - local: build for the same target as we compile on, and do local tests diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 190eec5ff7..b826e24c4d 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -8,7 +8,7 @@ homepage = "https://github.com/gfx-rs/wgpu" repository = "https://github.com/gfx-rs/wgpu" keywords = ["graphics"] license = "MIT OR Apache-2.0" -rust-version = "1.63" +rust-version = "1.59" [lib] From e95d36e1b15af7121f6b9dcd88292ccd05c5d2c9 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Mon, 1 Aug 2022 07:01:32 -0400 Subject: [PATCH 07/13] Change Minimum Winit Version to 0.27.1 --- Cargo.lock | 10 +++++----- wgpu-hal/Cargo.toml | 2 +- wgpu/Cargo.toml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a33e63ad5c..c7cdae0049 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1535,7 +1535,7 @@ dependencies = [ "serde", "wgpu-core", "wgpu-types", - "winit 0.27.0", + "winit 0.27.1", ] [[package]] @@ -2378,7 +2378,7 @@ dependencies = [ "wgpu-core", "wgpu-hal", "wgpu-types", - "winit 0.27.0", + "winit 0.27.1", ] [[package]] @@ -2443,7 +2443,7 @@ dependencies = [ "web-sys", "wgpu-types", "winapi", - "winit 0.27.0", + "winit 0.27.1", ] [[package]] @@ -2572,9 +2572,9 @@ dependencies = [ [[package]] name = "winit" -version = "0.27.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3464a81db85deec66bc170b5a4ca6413d4a5f43df460ff80b550c9207031ea7e" +checksum = "b9b91360f15eb89d0bfee05d3c5981408320fe709f84953d3d90b276fc5962c7" dependencies = [ "bitflags", "cocoa", diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index b826e24c4d..424cf809dc 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -109,7 +109,7 @@ features = ["wgsl-in"] [dev-dependencies] env_logger = "0.9" -winit = "0.27" # for "halmark" example +winit = "~0.27.1" # for "halmark" example [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] glutin = "0.28.0" # for "gles" example diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 4168264577..20f7faf358 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -131,7 +131,7 @@ noise = { version = "0.7", default-features = false } obj = "0.10" png = "0.17" nanorand = { version = "0.7", default-features = false, features = ["wyrand"] } -winit = "0.27" +winit = "~0.27.1" # for "halmark" example [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] async-executor = "1.0" From 772762cdd2b9d60944776115c0ea4a5855f5f76c Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Mon, 1 Aug 2022 10:07:31 -0400 Subject: [PATCH 08/13] Get Xcb Display Handle inside Xcb Window --- wgpu-hal/src/vulkan/instance.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index c490038d48..448f243d19 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -622,8 +622,8 @@ impl crate::Instance for super::Instance { RawWindowHandle::Xcb(handle) if self.shared.extensions.contains(&khr::XcbSurface::name()) => { - if let RawDisplayHandle::Xlib(v) = has_handle.raw_display_handle() { - Ok(self.create_surface_from_xcb(v.display, handle.window)) + if let RawDisplayHandle::Xcb(v) = has_handle.raw_display_handle() { + Ok(self.create_surface_from_xcb(v.connection, handle.window)) } else { Err(crate::InstanceError) } From 3fb64e8340e7f78350722311a1b01fd54679335a Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Mon, 1 Aug 2022 14:51:08 -0400 Subject: [PATCH 09/13] Match both arms for handle and set the winit depend to 0.27.1 --- wgpu-hal/Cargo.toml | 2 +- wgpu-hal/src/gles/egl.rs | 29 +++++++++------------- wgpu-hal/src/vulkan/instance.rs | 44 +++++++++++---------------------- wgpu/Cargo.toml | 2 +- 4 files changed, 28 insertions(+), 49 deletions(-) diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 424cf809dc..92f4632128 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -109,7 +109,7 @@ features = ["wgsl-in"] [dev-dependencies] env_logger = "0.9" -winit = "~0.27.1" # for "halmark" example +winit = "0.27.1" # for "halmark" example [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] glutin = "0.28.0" # for "gles" example diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 197d9ea5b9..bf11afe87d 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -779,13 +779,13 @@ impl crate::Instance for Instance { #[cfg_attr(any(target_os = "android", feature = "emscripten"), allow(unused_mut))] let mut inner = self.inner.lock(); - match raw_window_handle { - Rwh::Xlib(_) => {} - Rwh::Xcb(_) => {} - Rwh::Win32(_) => {} - Rwh::AppKit(_) => {} + match (raw_window_handle, has_handle.raw_display_handle()) { + (Rwh::Xlib(_), _) => {} + (Rwh::Xcb(_), _) => {} + (Rwh::Win32(_), _) => {} + (Rwh::AppKit(_), _) => {} #[cfg(target_os = "android")] - Rwh::AndroidNdk(handle) => { + (Rwh::AndroidNdk(handle), _) => { let format = inner .egl .instance @@ -800,24 +800,17 @@ impl crate::Instance for Instance { } } #[cfg(not(feature = "emscripten"))] - Rwh::Wayland(_) => { + (Rwh::Wayland(_), raw_window_handle::RawDisplayHandle::Wayland(display_handle)) => { /* Wayland displays are not sharable between surfaces so if the * surface we receive from this handle is from a different * display, we must re-initialize the context. * * See gfx-rs/gfx#3545 */ - let wayland_raw = if let raw_window_handle::RawDisplayHandle::Wayland(display) = - has_handle.raw_display_handle() - { - display.display - } else { - return Err(crate::InstanceError); - }; log::warn!("Re-initializing Gles context due to Wayland window"); if inner .wl_display - .map(|ptr| ptr != wayland_raw) + .map(|ptr| ptr != display_handle.display) .unwrap_or(true) { use std::ops::DerefMut; @@ -830,7 +823,7 @@ impl crate::Instance for Instance { .unwrap() .get_platform_display( EGL_PLATFORM_WAYLAND_KHR, - wayland_raw, + display_handle.display, &display_attributes, ) .unwrap(); @@ -840,13 +833,13 @@ impl crate::Instance for Instance { .map_err(|_| crate::InstanceError)?; let old_inner = std::mem::replace(inner.deref_mut(), new_inner); - inner.wl_display = Some(wayland_raw); + inner.wl_display = Some(display_handle.display); drop(old_inner); } } #[cfg(feature = "emscripten")] - Rwh::Web(_) => {} + (Rwh::Web(_), _) => {} other => { log::error!("Unsupported window: {:?}", other); return Err(crate::InstanceError); diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index 448f243d19..f54c0eddae 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -597,60 +597,46 @@ impl crate::Instance for super::Instance { use raw_window_handle::RawDisplayHandle; use raw_window_handle::RawWindowHandle; - match has_handle.raw_window_handle() { - RawWindowHandle::Wayland(handle) - if self - .shared - .extensions - .contains(&khr::WaylandSurface::name()) => - { - if let RawDisplayHandle::Wayland(v) = has_handle.raw_display_handle() { - Ok(self.create_surface_from_wayland(v.display, handle.surface)) - } else { - Err(crate::InstanceError) - } + match ( + has_handle.raw_window_handle(), + has_handle.raw_display_handle(), + ) { + (RawWindowHandle::Wayland(handle), RawDisplayHandle::Wayland(display)) => { + Ok(self.create_surface_from_wayland(display.display, handle.surface)) } - RawWindowHandle::Xlib(handle) + (RawWindowHandle::Xlib(handle), RawDisplayHandle::Xlib(display)) if self.shared.extensions.contains(&khr::XlibSurface::name()) => { - if let RawDisplayHandle::Xlib(v) = has_handle.raw_display_handle() { - Ok(self.create_surface_from_xlib(v.display as *mut _, handle.window)) - } else { - Err(crate::InstanceError) - } + Ok(self.create_surface_from_xlib(display.display as *mut _, handle.window)) } - RawWindowHandle::Xcb(handle) + (RawWindowHandle::Xcb(handle), RawDisplayHandle::Xcb(display)) if self.shared.extensions.contains(&khr::XcbSurface::name()) => { - if let RawDisplayHandle::Xcb(v) = has_handle.raw_display_handle() { - Ok(self.create_surface_from_xcb(v.connection, handle.window)) - } else { - Err(crate::InstanceError) - } + Ok(self.create_surface_from_xcb(display.connection, handle.window)) } - RawWindowHandle::AndroidNdk(handle) => { + (RawWindowHandle::AndroidNdk(handle), _) => { Ok(self.create_surface_android(handle.a_native_window)) } #[cfg(windows)] - RawWindowHandle::Win32(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::AppKit(handle) + (RawWindowHandle::AppKit(handle), _) if self.shared.extensions.contains(&ext::MetalSurface::name()) => { Ok(self.create_surface_from_view(handle.ns_view)) } #[cfg(target_os = "ios")] - RawWindowHandle::UiKit(handle) + (RawWindowHandle::UiKit(handle), _) if self.shared.extensions.contains(&ext::MetalSurface::name()) => { Ok(self.create_surface_from_view(handle.ui_view)) } - _ => Err(crate::InstanceError), + (_, _) => Err(crate::InstanceError), } } diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 20f7faf358..520eb7319a 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -131,7 +131,7 @@ noise = { version = "0.7", default-features = false } obj = "0.10" png = "0.17" nanorand = { version = "0.7", default-features = false, features = ["wyrand"] } -winit = "~0.27.1" # for "halmark" example +winit = "0.27.1" # for "halmark" example [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] async-executor = "1.0" From cae11a081b59424b0ec6e31891eca88c2f6e30b3 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Mon, 1 Aug 2022 15:07:49 -0400 Subject: [PATCH 10/13] Import RawDisplayHandle as Rdh inside egl.rs --- wgpu-hal/src/gles/egl.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index bf11afe87d..8e9a0819d8 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -772,7 +772,7 @@ impl crate::Instance for Instance { &self, has_handle: &(impl HasRawWindowHandle + HasRawDisplayHandle), ) -> Result { - use raw_window_handle::RawWindowHandle as Rwh; + use raw_window_handle::{RawDisplayHandle as Rdh, RawWindowHandle as Rwh}; let raw_window_handle = has_handle.raw_window_handle(); @@ -800,7 +800,7 @@ impl crate::Instance for Instance { } } #[cfg(not(feature = "emscripten"))] - (Rwh::Wayland(_), raw_window_handle::RawDisplayHandle::Wayland(display_handle)) => { + (Rwh::Wayland(_), Rdh::Wayland(display_handle)) => { /* Wayland displays are not sharable between surfaces so if the * surface we receive from this handle is from a different * display, we must re-initialize the context. From 39e7dc8a631e96c131795421f44ab3a120c7ee69 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Mon, 1 Aug 2022 15:14:39 -0400 Subject: [PATCH 11/13] Rdw and Rhw imports --- wgpu-hal/src/vulkan/instance.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index f54c0eddae..bd3a884879 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -594,44 +594,41 @@ impl crate::Instance for super::Instance { has_handle: &(impl raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle), ) -> Result { - use raw_window_handle::RawDisplayHandle; - use raw_window_handle::RawWindowHandle; + use raw_window_handle::{RawDisplayHandle as Rdh, RawWindowHandle as Rwh}; match ( has_handle.raw_window_handle(), has_handle.raw_display_handle(), ) { - (RawWindowHandle::Wayland(handle), RawDisplayHandle::Wayland(display)) => { + (Rwh::Wayland(handle), Rdh::Wayland(display)) => { Ok(self.create_surface_from_wayland(display.display, handle.surface)) } - (RawWindowHandle::Xlib(handle), RawDisplayHandle::Xlib(display)) + (Rwh::Xlib(handle), Rdh::Xlib(display)) if self.shared.extensions.contains(&khr::XlibSurface::name()) => { Ok(self.create_surface_from_xlib(display.display as *mut _, handle.window)) } - (RawWindowHandle::Xcb(handle), RawDisplayHandle::Xcb(display)) + (Rwh::Xcb(handle), Rdh::Xcb(display)) if self.shared.extensions.contains(&khr::XcbSurface::name()) => { Ok(self.create_surface_from_xcb(display.connection, handle.window)) } - (RawWindowHandle::AndroidNdk(handle), _) => { - Ok(self.create_surface_android(handle.a_native_window)) - } + (Rwh::AndroidNdk(handle), _) => Ok(self.create_surface_android(handle.a_native_window)), #[cfg(windows)] - (RawWindowHandle::Win32(handle), _) => { + (Rwh::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::AppKit(handle), _) + (Rwh::AppKit(handle), _) if self.shared.extensions.contains(&ext::MetalSurface::name()) => { Ok(self.create_surface_from_view(handle.ns_view)) } #[cfg(target_os = "ios")] - (RawWindowHandle::UiKit(handle), _) + (Rwh::UiKit(handle), _) if self.shared.extensions.contains(&ext::MetalSurface::name()) => { Ok(self.create_surface_from_view(handle.ui_view)) From 84d4db112f47f8004b1b2c07d2aebbab7729eb6d Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Wed, 3 Aug 2022 11:01:23 -0400 Subject: [PATCH 12/13] Remove raw_window_handle import for the Enscripten CI --- wgpu-hal/src/gles/egl.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 8e9a0819d8..d4ad223f63 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -772,7 +772,7 @@ impl crate::Instance for Instance { &self, has_handle: &(impl HasRawWindowHandle + HasRawDisplayHandle), ) -> Result { - use raw_window_handle::{RawDisplayHandle as Rdh, RawWindowHandle as Rwh}; + use raw_window_handle::{RawWindowHandle as Rwh}; let raw_window_handle = has_handle.raw_window_handle(); @@ -800,7 +800,7 @@ impl crate::Instance for Instance { } } #[cfg(not(feature = "emscripten"))] - (Rwh::Wayland(_), Rdh::Wayland(display_handle)) => { + (Rwh::Wayland(_), raw_window_handle::RawDisplayHandle::Wayland(display_handle)) => { /* Wayland displays are not sharable between surfaces so if the * surface we receive from this handle is from a different * display, we must re-initialize the context. From 35b19feb3c355f59f7e79808c7f9a0d4cec78b78 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Wed, 3 Aug 2022 11:04:27 -0400 Subject: [PATCH 13/13] Formatting Fix --- wgpu-hal/src/gles/egl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index d4ad223f63..bf11afe87d 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -772,7 +772,7 @@ impl crate::Instance for Instance { &self, has_handle: &(impl HasRawWindowHandle + HasRawDisplayHandle), ) -> Result { - use raw_window_handle::{RawWindowHandle as Rwh}; + use raw_window_handle::RawWindowHandle as Rwh; let raw_window_handle = has_handle.raw_window_handle();