diff --git a/Cargo.lock b/Cargo.lock index 8a67c3562eb..a9ed91ae459 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1688,7 +1688,7 @@ dependencies = [ "libc", "log", "rustversion", - "windows 0.61.3", + "windows", ] [[package]] @@ -1855,13 +1855,13 @@ 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=673e4ecb503af4188e0ca576acd0dad681f22413#673e4ecb503af4188e0ca576acd0dad681f22413" dependencies = [ + "hashbrown", "log", "presser", - "thiserror 1.0.69", - "windows 0.58.0", + "thiserror 2.0.12", + "windows", ] [[package]] @@ -3925,12 +3925,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.10" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4213,9 +4213,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.46.1" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17" +checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35" dependencies = [ "backtrace", "bytes", @@ -4228,7 +4228,7 @@ dependencies = [ "slab", "socket2", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -5111,8 +5111,8 @@ dependencies = [ "wasm-bindgen", "web-sys", "wgpu-types", - "windows 0.58.0", - "windows-core 0.58.0", + "windows", + "windows-core", "winit 0.29.15", ] @@ -5260,16 +5260,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" -dependencies = [ - "windows-core 0.58.0", - "windows-targets 0.52.6", -] - [[package]] name = "windows" version = "0.61.3" @@ -5277,7 +5267,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ "windows-collections", - "windows-core 0.61.2", + "windows-core", "windows-future", "windows-link", "windows-numerics", @@ -5289,20 +5279,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ - "windows-core 0.61.2", -] - -[[package]] -name = "windows-core" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" -dependencies = [ - "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", + "windows-core", ] [[package]] @@ -5311,11 +5288,11 @@ version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "windows-implement 0.60.0", - "windows-interface 0.59.1", + "windows-implement", + "windows-interface", "windows-link", - "windows-result 0.3.4", - "windows-strings 0.4.2", + "windows-result", + "windows-strings", ] [[package]] @@ -5324,22 +5301,11 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ - "windows-core 0.61.2", + "windows-core", "windows-link", "windows-threading", ] -[[package]] -name = "windows-implement" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "windows-implement" version = "0.60.0" @@ -5351,17 +5317,6 @@ dependencies = [ "syn", ] -[[package]] -name = "windows-interface" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "windows-interface" version = "0.59.1" @@ -5385,19 +5340,10 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ - "windows-core 0.61.2", + "windows-core", "windows-link", ] -[[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-result" version = "0.3.4" @@ -5407,16 +5353,6 @@ dependencies = [ "windows-link", ] -[[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]] name = "windows-strings" version = "0.4.2" diff --git a/Cargo.toml b/Cargo.toml index e8af139f6fd..9f16202ac02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -165,7 +165,7 @@ pp-rs = "0.2.1" profiling = { version = "1.0.1", default-features = false } quote = "1.0.38" raw-window-handle = { version = "0.6.2", default-features = false } -rwh_05 = { version = "0.5.2", package = "raw-window-handle" } # temporary compatibility for glutin-winit +rwh_05 = { version = "0.5.2", package = "raw-window-handle" } # temporary compatibility for glutin-winit rayon = "1.3" regex-lite = "0.1" renderdoc-sys = "1" @@ -206,10 +206,10 @@ gpu-alloc = "0.6" gpu-descriptor = "0.3.2" # DX12 dependencies -gpu-allocator = { version = "0.27", default-features = false } +gpu-allocator = { version = "0.27", default-features = false, features = ["hashbrown"] } range-alloc = "0.1" mach-dxcompiler-rs = { version = "0.1.4", default-features = false } # remember to increase max_shader_model if applicable -windows-core = { version = "0.58", default-features = false } +windows-core = { version = "0.61", default-features = false } # Gles dependencies khronos-egl = "6" @@ -219,7 +219,7 @@ glutin-winit = { version = "0.4", default-features = false } glutin_wgl_sys = "0.6" # DX12 and GLES dependencies -windows = { version = "0.58", default-features = false } +windows = { version = "0.61", default-features = false } # wasm32 dependencies console_error_panic_hook = "0.1.5" @@ -240,7 +240,7 @@ deno_webidl = "0.192.0" deno_webgpu = { version = "0.157.0", path = "./deno_webgpu" } deno_unsync = "0.4.2" deno_error = "0.5.5" -tokio = "1.39" +tokio = "1.47" termcolor = "1.1.3" # android dependencies @@ -250,6 +250,10 @@ ndk-sys = "0.6" [patch.crates-io] wgpu = { path = "./wgpu" } +# https://github.com/Traverse-Research/gpu-allocator/pull/258 +# https://github.com/Traverse-Research/gpu-allocator/pull/269 +gpu-allocator = { git = "https://github.com/Traverse-Research/gpu-allocator", rev = "673e4ecb503af4188e0ca576acd0dad681f22413" } + [profile.release] lto = "thin" debug = true diff --git a/wgpu-hal/src/dx12/command.rs b/wgpu-hal/src/dx12/command.rs index edfea952ed2..a0afff36588 100644 --- a/wgpu-hal/src/dx12/command.rs +++ b/wgpu-hal/src/dx12/command.rs @@ -5,13 +5,13 @@ use windows::Win32::{ Foundation, Graphics::{Direct3D12, Dxgi}, }; -use windows_core::Interface; +use windows_core::Interface as _; use super::conv; use crate::{ auxil::{ self, - dxgi::{name::ObjectExt, result::HResult as _}, + dxgi::{name::ObjectExt as _, result::HResult as _}, }, dx12::borrow_interface_temporarily, AccelerationStructureEntries, @@ -864,23 +864,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. - (Interface::vtable(list).ClearDepthStencilView)( - Interface::as_raw(list), + list.ClearDepthStencilView( ds_view, flags, ds.clear_value.0, ds.clear_value.1 as u8, - 0, - core::ptr::null(), + None, ) } } diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index 5d3a6ac8d45..e02b74d9849 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -23,7 +23,7 @@ use super::{conv, descriptor, D3D12Lib}; use crate::{ auxil::{ self, - dxgi::{name::ObjectExt, result::HResult}, + dxgi::{name::ObjectExt as _, result::HResult as _}, }, dx12::{ borrow_optional_interface_temporarily, shader_compilation, suballocation, @@ -1826,8 +1826,8 @@ impl crate::Device for super::Device { DepthBias: bias.constant, DepthBiasClamp: bias.clamp, SlopeScaledDepthBias: bias.slope_scale, - DepthClipEnable: Foundation::BOOL::from(!desc.primitive.unclipped_depth), - MultisampleEnable: Foundation::BOOL::from(desc.multisample.count > 1), + DepthClipEnable: windows_core::BOOL::from(!desc.primitive.unclipped_depth), + MultisampleEnable: windows_core::BOOL::from(desc.multisample.count > 1), ForcedSampleCount: 0, AntialiasedLineEnable: false.into(), ConservativeRaster: if desc.primitive.conservative { @@ -1857,7 +1857,7 @@ impl crate::Device for super::Device { RasterizedStream: 0, }, BlendState: Direct3D12::D3D12_BLEND_DESC { - AlphaToCoverageEnable: Foundation::BOOL::from( + AlphaToCoverageEnable: windows_core::BOOL::from( desc.multisample.alpha_to_coverage_enabled, ), IndependentBlendEnable: true.into(), diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index a102006acb0..a0e5f1e0f35 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -1295,7 +1295,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/dx12/suballocation.rs b/wgpu-hal/src/dx12/suballocation.rs index 8cee4102303..9d6c988b4d7 100644 --- a/wgpu-hal/src/dx12/suballocation.rs +++ b/wgpu-hal/src/dx12/suballocation.rs @@ -1,10 +1,11 @@ use alloc::sync::Arc; + use gpu_allocator::{d3d12::AllocationCreateDesc, MemoryLocation}; use parking_lot::Mutex; use windows::Win32::Graphics::{Direct3D12, Dxgi}; use crate::{ - auxil::dxgi::{name::ObjectExt, result::HResult as _}, + auxil::dxgi::{name::ObjectExt as _, result::HResult as _}, dx12::conv, }; @@ -143,7 +144,7 @@ impl Allocator { allocations, blocks, total_allocated_bytes: upstream.total_allocated_bytes, - total_reserved_bytes: upstream.total_reserved_bytes, + total_reserved_bytes: upstream.total_capacity_bytes, } } } diff --git a/wgpu-hal/src/gles/wgl.rs b/wgpu-hal/src/gles/wgl.rs index 6a4c3863bb8..bc8c38f12a8 100644 --- a/wgpu-hal/src/gles/wgl.rs +++ b/wgpu-hal/src/gles/wgl.rs @@ -128,7 +128,7 @@ impl WglContext { if unsafe { OpenGL::wglGetCurrentContext() }.is_invalid() { return Ok(()); } - unsafe { OpenGL::wglMakeCurrent(None, None) } + unsafe { OpenGL::wglMakeCurrent(Default::default(), Default::default()) } } } @@ -382,7 +382,7 @@ fn create_instance_device() -> Result { 1, None, None, - instance, + Some(instance.into()), None, ) } @@ -394,7 +394,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"), @@ -636,7 +636,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); }; } } @@ -672,7 +672,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: {}", @@ -750,7 +750,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: {}", diff --git a/wgpu-types/src/counters.rs b/wgpu-types/src/counters.rs index 644cbac7de5..a0ee6a45848 100644 --- a/wgpu-types/src/counters.rs +++ b/wgpu-types/src/counters.rs @@ -181,6 +181,7 @@ pub struct AllocatorReport { /// Sum of the memory used by all allocations, in bytes. pub total_allocated_bytes: u64, /// Sum of the memory reserved by all memory blocks including unallocated regions, in bytes. + // XXX: Rename to total_capacity_bytes following the rename at https://github.com/Traverse-Research/gpu-allocator/pull/266? pub total_reserved_bytes: u64, }