diff --git a/CHANGELOG.md b/CHANGELOG.md index 96b17ed25..c3a797356 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,7 @@ the same every time it is rendered, we now warn if it is missing. #### General - Added downlevel restriction error message for `InvalidFormatUsages` error by @Seamooo in [#2886](https://github.com/gfx-rs/wgpu/pull/2886) - 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) diff --git a/Cargo.lock b/Cargo.lock index e16d6af4d..c7cdae004 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.1", ] [[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", - "nix", + "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 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.1", ] [[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.1", ] [[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9b91360f15eb89d0bfee05d3c5981408320fe709f84953d3d90b276fc5962c7" +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 d5e712f4f..c2915ab8d 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 61bb72f6c..55b4f9aa3 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 03ec97192..8ad4774c6 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 b2d675100..e52fe26ec 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.1" # 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/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 50abd273c..bf11afe87 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,7 +770,7 @@ 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; @@ -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,7 +800,7 @@ impl crate::Instance for Instance { } } #[cfg(not(feature = "emscripten"))] - Rwh::Wayland(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. @@ -810,11 +810,12 @@ impl crate::Instance for Instance { log::warn!("Re-initializing Gles context due to Wayland window"); if inner .wl_display - .map(|ptr| ptr != handle.display) + .map(|ptr| ptr != display_handle.display) .unwrap_or(true) { use std::ops::DerefMut; let display_attributes = [egl::ATTRIB_NONE]; + let display = inner .egl .instance @@ -822,7 +823,7 @@ impl crate::Instance for Instance { .unwrap() .get_platform_display( EGL_PLATFORM_WAYLAND_KHR, - handle.display, + display_handle.display, &display_attributes, ) .unwrap(); @@ -832,12 +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(handle.display); + 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/lib.rs b/wgpu-hal/src/lib.rs index f52c05ed3..fcaf03946 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 2da4288b4..bd3a88487 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -591,52 +591,49 @@ 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::RawWindowHandle; + use raw_window_handle::{RawDisplayHandle as Rdh, RawWindowHandle as Rwh}; - match has_handle.raw_window_handle() { - RawWindowHandle::Wayland(handle) - if self - .shared - .extensions - .contains(&khr::WaylandSurface::name()) => - { - Ok(self.create_surface_from_wayland(handle.display, handle.surface)) + match ( + has_handle.raw_window_handle(), + has_handle.raw_display_handle(), + ) { + (Rwh::Wayland(handle), Rdh::Wayland(display)) => { + Ok(self.create_surface_from_wayland(display.display, handle.surface)) } - RawWindowHandle::Xlib(handle) + (Rwh::Xlib(handle), Rdh::Xlib(display)) if self.shared.extensions.contains(&khr::XlibSurface::name()) => { - Ok(self.create_surface_from_xlib(handle.display as *mut _, handle.window)) + Ok(self.create_surface_from_xlib(display.display as *mut _, handle.window)) } - RawWindowHandle::Xcb(handle) + (Rwh::Xcb(handle), Rdh::Xcb(display)) if self.shared.extensions.contains(&khr::XcbSurface::name()) => { - Ok(self.create_surface_from_xcb(handle.connection, handle.window)) - } - RawWindowHandle::AndroidNdk(handle) => { - Ok(self.create_surface_android(handle.a_native_window)) + Ok(self.create_surface_from_xcb(display.connection, handle.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)) } - _ => Err(crate::InstanceError), + (_, _) => Err(crate::InstanceError), } } diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 0e52132f7..520eb7319 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.1" # for "halmark" example [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 cb5ca21b9..870d03d10 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 d5fb4e067..14a93731e 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, @@ -1755,7 +1755,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 {