From 2f119a0464631f18da43cbd00512f1b4239222cf Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 18 Jul 2024 22:23:27 +0200 Subject: [PATCH] windows-rs 0.58 --- Cargo.lock | 108 +++++++++++++++++------------ wgpu-core/src/instance.rs | 4 +- wgpu-hal/Cargo.toml | 6 +- wgpu-hal/src/auxil/dxgi/factory.rs | 5 +- wgpu-hal/src/dx12/adapter.rs | 3 +- wgpu-hal/src/dx12/command.rs | 2 +- wgpu-hal/src/dx12/descriptor.rs | 4 +- wgpu-hal/src/dx12/device.rs | 2 +- wgpu-hal/src/dx12/instance.rs | 3 +- wgpu-hal/src/dx12/mod.rs | 19 ++--- 10 files changed, 88 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b16e55cd887..d7ec9845dd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1676,7 +1676,7 @@ dependencies = [ "log", "presser", "thiserror", - "windows 0.57.0", + "windows 0.58.0", ] [[package]] @@ -2598,7 +2598,7 @@ dependencies = [ "redox_syscall 0.5.1", "smallvec", "thread-id", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -4335,8 +4335,8 @@ dependencies = [ "web-sys", "wgpu-types", "winapi", - "windows 0.57.0", - "windows-core 0.57.0", + "windows 0.58.0", + "windows-core 0.58.0", "winit 0.29.15", ] @@ -4465,17 +4465,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" dependencies = [ "windows-core 0.54.0", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] name = "windows" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" dependencies = [ - "windows-core 0.57.0", - "windows-targets 0.52.5", + "windows-core 0.58.0", + "windows-targets 0.52.6", ] [[package]] @@ -4484,27 +4484,28 @@ version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" dependencies = [ - "windows-result", - "windows-targets 0.52.5", + "windows-result 0.1.2", + "windows-targets 0.52.6", ] [[package]] name = "windows-core" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" dependencies = [ "windows-implement", "windows-interface", - "windows-result", - "windows-targets 0.52.5", + "windows-result 0.2.0", + "windows-strings", + "windows-targets 0.52.6", ] [[package]] name = "windows-implement" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", @@ -4513,9 +4514,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", @@ -4528,7 +4529,26 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result 0.2.0", + "windows-targets 0.52.6", ] [[package]] @@ -4568,7 +4588,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -4603,18 +4623,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "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]] @@ -4631,9 +4651,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -4655,9 +4675,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -4679,9 +4699,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" @@ -4709,9 +4729,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -4733,9 +4753,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -4751,9 +4771,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -4775,9 +4795,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winit" diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 98f155f6dd6..ff709106e65 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -650,7 +650,7 @@ impl Global { ) -> Result { profiling::scope!("Instance::instance_create_surface_from_surface_handle"); self.instance_create_surface_dx12(id_in, |inst| unsafe { - inst.create_surface_from_surface_handle(surface_handle as _) + inst.create_surface_from_surface_handle(surface_handle) }) } @@ -665,7 +665,7 @@ impl Global { ) -> Result { profiling::scope!("Instance::instance_create_surface_from_swap_chain_panel"); self.instance_create_surface_dx12(id_in, |inst| unsafe { - inst.create_surface_from_swap_chain_panel(swap_chain_panel as _) + inst.create_surface_from_swap_chain_panel(swap_chain_panel) }) } diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 5809dabff5e..9b12b14e89a 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -140,7 +140,7 @@ libloading = { version = "0.8", optional = true } # backend: Dx12 bit-set = { version = "0.6", optional = true } range-alloc = { version = "0.1", optional = true } -gpu-allocator = {version = "0.27", default-features = false, optional = true } +gpu-allocator = { version = "0.27", default-features = false, optional = true } hassle-rs = { version = "0.11", optional = true } # backend: Gles glutin_wgl_sys = { version = "0.6", optional = true } @@ -153,8 +153,8 @@ winapi = { version = "0.3", features = [ "dcomp", ] } # For core macros. This crate is also reexported as windows::core. -windows-core = { version = "0.57.0", optional = true } -windows = { version = "0.57.0", optional = true, features = [ +windows-core = { version = "0.58.0", optional = true } +windows = { version = "0.58.0", optional = true, features = [ "Win32_Graphics_Direct3D_Fxc", "Win32_Graphics_Direct3D", "Win32_Graphics_Direct3D12", diff --git a/wgpu-hal/src/auxil/dxgi/factory.rs b/wgpu-hal/src/auxil/dxgi/factory.rs index 0fd8a4793cf..92e6063f7fc 100644 --- a/wgpu-hal/src/auxil/dxgi/factory.rs +++ b/wgpu-hal/src/auxil/dxgi/factory.rs @@ -12,8 +12,7 @@ pub enum DxgiFactoryType { } fn should_keep_adapter(adapter: &Dxgi::IDXGIAdapter1) -> bool { - let mut desc = unsafe { std::mem::zeroed() }; - unsafe { adapter.GetDesc1(&mut desc) }.unwrap(); + let desc = unsafe { adapter.GetDesc1() }.unwrap(); // The Intel Haswell family of iGPUs had support for the D3D12 API but it was later // removed due to a security vulnerability. @@ -227,7 +226,7 @@ pub fn create_factory( crate::InstanceError::with_source(String::from("failed to load dxgi.dll"), e) })?; - let mut factory_flags = 0; + let mut factory_flags = Dxgi::DXGI_CREATE_FACTORY_FLAGS::default(); if instance_flags.contains(wgt::InstanceFlags::VALIDATION) { // The `DXGI_CREATE_FACTORY_DEBUG` flag is only allowed to be passed to diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index 26aa8175f26..1883f56f068 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -100,8 +100,7 @@ impl super::Adapter { // We have found a possible adapter. // Acquire the device information. - let mut desc: Dxgi::DXGI_ADAPTER_DESC2 = unsafe { mem::zeroed() }; - unsafe { adapter.unwrap_adapter2().GetDesc2(&mut desc) }.unwrap(); + let desc = unsafe { adapter.unwrap_adapter2().GetDesc2() }.unwrap(); let device_name = auxil::dxgi::conv::map_adapter_name(desc.Description); diff --git a/wgpu-hal/src/dx12/command.rs b/wgpu-hal/src/dx12/command.rs index 9aec00e14a3..aaec9579a86 100644 --- a/wgpu-hal/src/dx12/command.rs +++ b/wgpu-hal/src/dx12/command.rs @@ -726,7 +726,7 @@ impl crate::CommandEncoder for super::CommandEncoder { desc.color_attachments.len() as u32, Some(color_views.as_ptr()), false, - ds_view.as_ref().map(|v| v as _), + ds_view.as_ref().map(|v| v as *const _), ) }; diff --git a/wgpu-hal/src/dx12/descriptor.rs b/wgpu-hal/src/dx12/descriptor.rs index 3d6697c123e..ebb42ddcd13 100644 --- a/wgpu-hal/src/dx12/descriptor.rs +++ b/wgpu-hal/src/dx12/descriptor.rs @@ -126,7 +126,7 @@ impl FixedSizeHeap { ) -> Result { let desc = Direct3D12::D3D12_DESCRIPTOR_HEAP_DESC { Type: ty, - NumDescriptors: HEAP_SIZE_FIXED as _, + NumDescriptors: HEAP_SIZE_FIXED as u32, Flags: Direct3D12::D3D12_DESCRIPTOR_HEAP_FLAG_NONE, NodeMask: 0, }; @@ -135,7 +135,7 @@ impl FixedSizeHeap { .into_device_result("Descriptor heap creation")?; Ok(Self { - handle_size: unsafe { device.GetDescriptorHandleIncrementSize(ty) } as _, + handle_size: unsafe { device.GetDescriptorHandleIncrementSize(ty) } as usize, availability: !0, // all free! start: unsafe { heap.GetCPUDescriptorHandleForHeapStart() }, _raw: heap, diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index 71bf2f6c455..3b95c4a576a 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -1029,7 +1029,7 @@ impl crate::Device for super::Device { ParameterType: Direct3D12::D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, Anonymous: Direct3D12::D3D12_ROOT_PARAMETER_0 { DescriptorTable: Direct3D12::D3D12_ROOT_DESCRIPTOR_TABLE { - NumDescriptorRanges: range.len() as _, + NumDescriptorRanges: range.len() as u32, pDescriptorRanges: range.as_ptr(), }, }, diff --git a/wgpu-hal/src/dx12/instance.rs b/wgpu-hal/src/dx12/instance.rs index 24be9c07137..3acdc5134f2 100644 --- a/wgpu-hal/src/dx12/instance.rs +++ b/wgpu-hal/src/dx12/instance.rs @@ -147,7 +147,8 @@ impl crate::Instance for super::Instance { raw_window_handle::RawWindowHandle::Win32(handle) => Ok(super::Surface { factory: self.factory.clone(), factory_media: self.factory_media.clone(), - target: SurfaceTarget::WndHandle(Foundation::HWND(handle.hwnd.get())), + // https://github.com/rust-windowing/raw-window-handle/issues/171 + target: SurfaceTarget::WndHandle(Foundation::HWND(handle.hwnd.get() as *mut _)), supports_allow_tearing: self.supports_allow_tearing, swap_chain: RwLock::new(None), }), diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index e8e5baaa6f9..81c5bc3f34b 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -220,11 +220,11 @@ impl DxgiLib { pub fn create_factory2( &self, - factory_flags: u32, + factory_flags: Dxgi::DXGI_CREATE_FACTORY_FLAGS, ) -> Result, libloading::Error> { // Calls windows::Win32::Graphics::Dxgi::CreateDXGIFactory2 on dxgi.dll type Fun = extern "system" fn( - flags: u32, + flags: Dxgi::DXGI_CREATE_FACTORY_FLAGS, riid: *const windows_core::GUID, ppfactory: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; @@ -356,7 +356,10 @@ impl Instance { } } - pub unsafe fn create_surface_from_surface_handle(&self, surface_handle: isize) -> Surface { + pub unsafe fn create_surface_from_surface_handle( + &self, + surface_handle: *mut std::ffi::c_void, + ) -> Surface { // TODO: Should we assume ownership and call HANDLE::free() on Drop? let surface_handle = Foundation::HANDLE(surface_handle); Surface { @@ -956,7 +959,7 @@ impl crate::Surface for Surface { config.extent.width, config.extent.height, non_srgb_format, - flags.0 as u32, + flags, ) }; if let Err(err) = result.into_result() { @@ -1063,12 +1066,10 @@ impl crate::Surface for Surface { match self.target { SurfaceTarget::WndHandle(wnd_handle) => { // Disable automatic Alt+Enter handling by DXGI. - const DXGI_MWA_NO_WINDOW_CHANGES: u32 = 1; - const DXGI_MWA_NO_ALT_ENTER: u32 = 2; unsafe { self.factory.MakeWindowAssociation( wnd_handle, - DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER, + Dxgi::DXGI_MWA_NO_WINDOW_CHANGES | Dxgi::DXGI_MWA_NO_ALT_ENTER, ) } .into_device_result("MakeWindowAssociation")?; @@ -1197,8 +1198,8 @@ impl crate::Queue for Queue { let (interval, flags) = match sc.present_mode { // We only allow immediate if ALLOW_TEARING is valid. wgt::PresentMode::Immediate => (0, Dxgi::DXGI_PRESENT_ALLOW_TEARING), - wgt::PresentMode::Mailbox => (0, 0), - wgt::PresentMode::Fifo => (1, 0), + wgt::PresentMode::Mailbox => (0, Dxgi::DXGI_PRESENT::default()), + wgt::PresentMode::Fifo => (1, Dxgi::DXGI_PRESENT::default()), m => unreachable!("Cannot make surface with present mode {m:?}"), };