From 7841fa75344844e08dda06bece39de7ae651457c Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Wed, 8 Jan 2025 12:03:15 +0100 Subject: [PATCH] [d3d12 wgl] Upgrade to `windows 0.59` crates https://github.com/microsoft/windows-rs/releases/tag/0.61.0 The latest `windows 0.59` and `windows-core 0.59` crates were just released (strangely tagged `0.61`), including some minor code improvements for us. The MSRV has been bumped to `1.74`, but `wgpu` is already on `1.76` anyway. --- Cargo.lock | 152 ++++++++++++++++++++++++++++++++--- Cargo.toml | 7 +- wgpu-hal/src/dx12/command.rs | 15 +--- wgpu-hal/src/dx12/mod.rs | 2 +- wgpu-hal/src/gles/wgl.rs | 12 +-- 5 files changed, 153 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 226cdae506..84a33b2d49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1388,7 +1388,7 @@ dependencies = [ "libc", "log", "rustversion", - "windows", + "windows 0.58.0", ] [[package]] @@ -1543,13 +1543,12 @@ dependencies = [ [[package]] name = "gpu-allocator" version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c151a2a5ef800297b4e79efa4f4bec035c5f51d5ae587287c9b952bdf734cacd" +source = "git+https://github.com/Traverse-Research/gpu-allocator?rev=dd4ad67#dd4ad675192450667ba5b2a40cf830c7fb8d0126" dependencies = [ "log", "presser", "thiserror 1.0.69", - "windows", + "windows 0.59.0", ] [[package]] @@ -4120,8 +4119,8 @@ dependencies = [ "wasm-bindgen", "web-sys", "wgpu-types", - "windows", - "windows-core", + "windows 0.59.0", + "windows-core 0.59.0", "winit", ] @@ -4256,23 +4255,46 @@ version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" dependencies = [ - "windows-core", + "windows-core 0.58.0", "windows-targets 0.52.6", ] +[[package]] +name = "windows" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f919aee0a93304be7f62e8e5027811bbba96bcb1de84d6618be56e43f8a32a1" +dependencies = [ + "windows-core 0.59.0", + "windows-targets 0.53.0", +] + [[package]] name = "windows-core" version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" dependencies = [ - "windows-implement", - "windows-interface", - "windows-result", - "windows-strings", + "windows-implement 0.58.0", + "windows-interface 0.58.0", + "windows-result 0.2.0", + "windows-strings 0.1.0", "windows-targets 0.52.6", ] +[[package]] +name = "windows-core" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "810ce18ed2112484b0d4e15d022e5f598113e220c53e373fb31e67e21670c1ce" +dependencies = [ + "windows-implement 0.59.0", + "windows-interface 0.59.0", + "windows-result 0.3.0", + "windows-strings 0.3.0", + "windows-targets 0.53.0", +] + [[package]] name = "windows-implement" version = "0.58.0" @@ -4284,6 +4306,17 @@ dependencies = [ "syn", ] +[[package]] +name = "windows-implement" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83577b051e2f49a058c308f17f273b570a6a758386fc291b5f6a934dd84e48c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "windows-interface" version = "0.58.0" @@ -4295,6 +4328,17 @@ dependencies = [ "syn", ] +[[package]] +name = "windows-interface" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb26fd936d991781ea39e87c3a27285081e3c0da5ca0fcbc02d368cc6f52ff01" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "windows-result" version = "0.2.0" @@ -4304,16 +4348,34 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-result" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d08106ce80268c4067c0571ca55a9b4e9516518eaa1a1fe9b37ca403ae1d1a34" +dependencies = [ + "windows-targets 0.53.0", +] + [[package]] name = "windows-strings" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ - "windows-result", + "windows-result 0.2.0", "windows-targets 0.52.6", ] +[[package]] +name = "windows-strings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b888f919960b42ea4e11c2f408fadb55f78a9f236d5eef084103c8ce52893491" +dependencies = [ + "windows-targets 0.53.0", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -4389,13 +4451,29 @@ dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", + "windows_i686_gnullvm 0.52.6", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows-targets" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -4414,6 +4492,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -4432,6 +4516,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -4450,12 +4540,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -4474,6 +4576,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -4492,6 +4600,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -4510,6 +4624,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -4528,6 +4648,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "winit" version = "0.29.15" diff --git a/Cargo.toml b/Cargo.toml index d693596e99..0deb3c952f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,7 +158,7 @@ bit-set = "0.8" gpu-allocator = { version = "0.27", default-features = false } range-alloc = "0.1" mach-dxcompiler-rs = { version = "0.1.4", default-features = false } -windows-core = { version = "0.58", default-features = false } +windows-core = { version = "0.59", default-features = false } # Gles dependencies khronos-egl = "6" @@ -168,7 +168,7 @@ glutin-winit = { version = "0.4", default-features = false } glutin_wgl_sys = "0.6" # DX and GLES dependencies -windows = { version = "0.58", default-features = false } +windows = { version = "0.59", default-features = false } # wasm32 dependencies console_error_panic_hook = "0.1.7" @@ -207,6 +207,9 @@ ndk-sys = "0.5.0" #js-sys = { path = "../wasm-bindgen/crates/js-sys" } #wasm-bindgen = { path = "../wasm-bindgen" } +# https://github.com/Traverse-Research/gpu-allocator/pull/258 +gpu-allocator = { git = "https://github.com/Traverse-Research/gpu-allocator", rev = "dd4ad67" } + [profile.release] lto = "thin" debug = true diff --git a/wgpu-hal/src/dx12/command.rs b/wgpu-hal/src/dx12/command.rs index 9296a20393..5fc9f56f68 100644 --- a/wgpu-hal/src/dx12/command.rs +++ b/wgpu-hal/src/dx12/command.rs @@ -768,23 +768,12 @@ impl crate::CommandEncoder for super::CommandEncoder { if let Some(ds_view) = ds_view { if flags != Direct3D12::D3D12_CLEAR_FLAGS::default() { unsafe { - // list.ClearDepthStencilView( - // ds_view, - // flags, - // ds.clear_value.0, - // ds.clear_value.1 as u8, - // None, - // ) - // TODO: Replace with the above in the next breaking windows-rs release, - // when https://github.com/microsoft/win32metadata/pull/1971 is in. - (windows_core::Interface::vtable(list).ClearDepthStencilView)( - windows_core::Interface::as_raw(list), + list.ClearDepthStencilView( ds_view, flags, ds.clear_value.0, ds.clear_value.1 as u8, - 0, - std::ptr::null(), + None, ) } } diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index d58d79300a..4fb75c49b2 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -1154,7 +1154,7 @@ impl crate::Surface for Surface { .ok_or(crate::SurfaceError::Other("IDXGIFactoryMedia not found"))? .CreateSwapChainForCompositionSurfaceHandle( &device.present_queue, - handle, + Some(handle), &desc, None, ) diff --git a/wgpu-hal/src/gles/wgl.rs b/wgpu-hal/src/gles/wgl.rs index 2d6c91aee0..3cc7627c66 100644 --- a/wgpu-hal/src/gles/wgl.rs +++ b/wgpu-hal/src/gles/wgl.rs @@ -127,7 +127,7 @@ impl WglContext { if unsafe { OpenGL::wglGetCurrentContext() }.is_invalid() { return Ok(()); } - unsafe { OpenGL::wglMakeCurrent(None, None) } + unsafe { OpenGL::wglMakeCurrent(Default::default(), Default::default()) } } } @@ -380,7 +380,7 @@ fn create_instance_device() -> Result { 1, None, None, - instance, + Some(instance.into()), None, ) } @@ -392,7 +392,7 @@ fn create_instance_device() -> Result { })?; let window = Window { window }; - let dc = unsafe { Gdi::GetDC(window.window) }; + let dc = unsafe { Gdi::GetDC(Some(window.window)) }; if dc.is_invalid() { return Err(crate::InstanceError::with_source( String::from("unable to create memory device"), @@ -627,7 +627,7 @@ struct DeviceContextHandle { impl Drop for DeviceContextHandle { fn drop(&mut self) { unsafe { - Gdi::ReleaseDC(self.window, self.device); + Gdi::ReleaseDC(Some(self.window), self.device); }; } } @@ -663,7 +663,7 @@ impl Surface { ) -> Result<(), crate::SurfaceError> { let swapchain = self.swapchain.read(); let sc = swapchain.as_ref().unwrap(); - let dc = unsafe { Gdi::GetDC(self.window) }; + let dc = unsafe { Gdi::GetDC(Some(self.window)) }; if dc.is_invalid() { log::error!( "unable to get the device context from window: {}", @@ -741,7 +741,7 @@ impl crate::Surface for Surface { // Remove the old configuration. unsafe { self.unconfigure(device) }; - let dc = unsafe { Gdi::GetDC(self.window) }; + let dc = unsafe { Gdi::GetDC(Some(self.window)) }; if dc.is_invalid() { log::error!( "unable to get the device context from window: {}",