[d3d12 wgl] Upgrade to windows 0.62 crates (#6876)

* [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.

* [d3d12 wgl] Upgrade to `windows 0.61` crates

https://github.com/microsoft/windows-rs/releases/tag/63

* [d3d12 wgl] Upgrade to windows 0.62 crates

https://github.com/microsoft/windows-rs/releases/tag/69
This commit is contained in:
Marijn Suijten 2025-11-05 17:47:31 +01:00 committed by GitHub
parent cb2edd2915
commit 59a03eaf2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 104 additions and 172 deletions

View File

@ -18,14 +18,6 @@ skip = [
# Winit uses an old version
{ name = "windows-sys", version = "0.52.0" },
# Loom uses a new windows version
{ name = "windows", version = "0.61.1" },
{ name = "windows-core", version = "0.61.2" },
{ name = "windows-implement", version = "0.60.0" },
{ name = "windows-interface", version = "0.59.1" },
{ name = "windows-result", version = "0.3.4" },
{ name = "windows-strings", version = "0.4.2" },
]
wildcards = "deny"
allow-wildcard-paths = true
@ -64,6 +56,9 @@ private = { ignore = true }
[sources]
allow-git = [
# Waiting on releases; used in examples/tests only
# Pending a release for https://github.com/Xudong-Huang/generator-rs/pull/75
"https://github.com/Xudong-Huang/generator-rs",
]
unknown-registry = "deny"
unknown-git = "deny"

169
Cargo.lock generated
View File

@ -55,6 +55,12 @@ dependencies = [
"memchr",
]
[[package]]
name = "allocator-api2"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "android-activity"
version = "0.5.2"
@ -295,7 +301,7 @@ dependencies = [
"miniz_oxide",
"object",
"rustc-demangle",
"windows-link 0.2.1",
"windows-link",
]
[[package]]
@ -1652,15 +1658,14 @@ dependencies = [
[[package]]
name = "generator"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "605183a538e3e2a9c1038635cc5c2d194e2ee8fd0d1b66b8349fad7dbacce5a2"
source = "git+https://github.com/Xudong-Huang/generator-rs?rev=70b89fdabcc0e82fe84ca17f65cc52ff25e8e6de#70b89fdabcc0e82fe84ca17f65cc52ff25e8e6de"
dependencies = [
"cc",
"cfg-if",
"libc",
"log",
"rustversion",
"windows 0.61.3",
"windows",
]
[[package]]
@ -1670,7 +1675,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
dependencies = [
"rustix 1.1.2",
"windows-link 0.2.1",
"windows-link",
]
[[package]]
@ -1829,14 +1834,15 @@ dependencies = [
[[package]]
name = "gpu-allocator"
version = "0.27.0"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c151a2a5ef800297b4e79efa4f4bec035c5f51d5ae587287c9b952bdf734cacd"
checksum = "51255ea7cfaadb6c5f1528d43e92a82acb2b96c43365989a28b2d44ee38f8795"
dependencies = [
"hashbrown 0.16.0",
"log",
"presser",
"thiserror 1.0.69",
"windows 0.58.0",
"thiserror 2.0.17",
"windows",
]
[[package]]
@ -1898,6 +1904,8 @@ version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
dependencies = [
"allocator-api2",
"equivalent",
"foldhash 0.2.0",
"serde",
]
@ -2256,7 +2264,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
dependencies = [
"cfg-if",
"windows-link 0.2.1",
"windows-link",
]
[[package]]
@ -3087,7 +3095,7 @@ dependencies = [
"petgraph 0.6.5",
"redox_syscall 0.5.18",
"smallvec",
"windows-link 0.2.1",
"windows-link",
]
[[package]]
@ -4975,8 +4983,8 @@ dependencies = [
"wasm-bindgen",
"web-sys",
"wgpu-types",
"windows 0.58.0",
"windows-core 0.58.0",
"windows",
"windows-core",
"winit 0.29.15",
]
@ -5126,84 +5134,49 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.58.0"
version = "0.62.2"
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"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"
checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580"
dependencies = [
"windows-collections",
"windows-core 0.61.2",
"windows-core",
"windows-future",
"windows-link 0.1.3",
"windows-numerics",
]
[[package]]
name = "windows-collections"
version = "0.2.0"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"
checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610"
dependencies = [
"windows-core 0.61.2",
"windows-core",
]
[[package]]
name = "windows-core"
version = "0.58.0"
version = "0.62.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
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",
]
[[package]]
name = "windows-core"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
dependencies = [
"windows-implement 0.60.2",
"windows-interface 0.59.3",
"windows-link 0.1.3",
"windows-result 0.3.4",
"windows-strings 0.4.2",
"windows-implement",
"windows-interface",
"windows-link",
"windows-result",
"windows-strings",
]
[[package]]
name = "windows-future"
version = "0.2.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"
checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb"
dependencies = [
"windows-core 0.61.2",
"windows-link 0.1.3",
"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.2"
@ -5215,17 +5188,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.3"
@ -5237,12 +5199,6 @@ dependencies = [
"syn",
]
[[package]]
name = "windows-link"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
[[package]]
name = "windows-link"
version = "0.2.1"
@ -5251,49 +5207,30 @@ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-numerics"
version = "0.2.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"
checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26"
dependencies = [
"windows-core 0.61.2",
"windows-link 0.1.3",
"windows-core",
"windows-link",
]
[[package]]
name = "windows-result"
version = "0.2.0"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-result"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"
dependencies = [
"windows-link 0.1.3",
"windows-link",
]
[[package]]
name = "windows-strings"
version = "0.1.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
dependencies = [
"windows-result 0.2.0",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-strings"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"
dependencies = [
"windows-link 0.1.3",
"windows-link",
]
[[package]]
@ -5347,7 +5284,7 @@ version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link 0.2.1",
"windows-link",
]
[[package]]
@ -5402,7 +5339,7 @@ version = "0.53.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
dependencies = [
"windows-link 0.2.1",
"windows-link",
"windows_aarch64_gnullvm 0.53.1",
"windows_aarch64_msvc 0.53.1",
"windows_i686_gnu 0.53.1",
@ -5415,11 +5352,11 @@ dependencies = [
[[package]]
name = "windows-threading"
version = "0.1.0"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6"
checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37"
dependencies = [
"windows-link 0.1.3",
"windows-link",
]
[[package]]

View File

@ -135,7 +135,7 @@ indicatif = "0.18"
itertools = { version = "0.14" }
jobserver = "0.1"
ktx2 = "0.4"
libc = { version = "0.2.171", default-features = false }
libc = { version = "0.2.172", default-features = false }
# See https://github.com/rust-fuzz/libfuzzer/issues/126
libfuzzer-sys = ">0.4.0,<=0.4.7"
libloading = "0.8"
@ -212,10 +212,12 @@ gpu-alloc = "0.6"
gpu-descriptor = "0.3.2"
# DX12 dependencies
gpu-allocator = { version = "0.27", default-features = false }
gpu-allocator = { version = "0.28", 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.62", default-features = false }
# Gles dependencies
khronos-egl = "6"
@ -225,7 +227,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.62", default-features = false }
# wasm32 dependencies
console_error_panic_hook = "0.1.5"
@ -247,7 +249,7 @@ deno_webidl = "0.214.0"
deno_webgpu = { version = "0.181.0", path = "./deno_webgpu" }
deno_unsync = "0.4.4"
deno_error = "0.7.0"
tokio = "1.45.1"
tokio = "1.47"
termcolor = "1.1.3"
# android dependencies
@ -257,6 +259,9 @@ ndk-sys = "0.6"
[patch.crates-io]
wgpu = { path = "./wgpu" }
# https://github.com/Xudong-Huang/generator-rs/pull/75
generator = { git = "https://github.com/Xudong-Huang/generator-rs", rev = "70b89fdabcc0e82fe84ca17f65cc52ff25e8e6de" }
[profile.release]
lto = "thin"
debug = true

View File

@ -1,17 +1,19 @@
use alloc::vec::Vec;
use core::{mem, ops::Range};
use windows::Win32::{
Foundation,
Graphics::{Direct3D12, Dxgi},
use windows::{
core::Interface as _,
Win32::{
Foundation,
Graphics::{Direct3D12, Dxgi},
},
};
use windows_core::Interface;
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, CommandEncoder as _,
@ -1001,23 +1003,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,
)
}
}

View File

@ -2,8 +2,10 @@ use alloc::sync::Arc;
use core::{ffi, ptr};
use once_cell::sync::Lazy;
use windows::Win32::{Foundation::HWND, Graphics::DirectComposition};
use windows_core::Interface;
use windows::{
core::Interface as _,
Win32::{Foundation::HWND, Graphics::DirectComposition},
};
use super::DynLib;

View File

@ -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, DCompLib,
@ -1896,8 +1896,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 {
@ -1926,7 +1926,7 @@ impl crate::Device for super::Device {
RasterizedStream: 0,
};
let blend_state = Direct3D12::D3D12_BLEND_DESC {
AlphaToCoverageEnable: Foundation::BOOL::from(
AlphaToCoverageEnable: windows_core::BOOL::from(
desc.multisample.alpha_to_coverage_enabled,
),
IndependentBlendEnable: true.into(),

View File

@ -93,7 +93,7 @@ use hashbrown::HashMap;
use parking_lot::{Mutex, RwLock};
use suballocation::Allocator;
use windows::{
core::{Free, Interface},
core::{Free as _, Interface},
Win32::{
Foundation,
Graphics::{
@ -1345,7 +1345,7 @@ impl crate::Surface for Surface {
.ok_or(crate::SurfaceError::Other("IDXGIFactoryMedia not found"))?
.CreateSwapChainForCompositionSurfaceHandle(
&device.present_queue,
handle,
Some(handle),
&desc,
None,
)

View File

@ -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,
}
}
}

View File

@ -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()) }
}
}
@ -226,7 +226,7 @@ unsafe fn setup_pixel_format(dc: Gdi::HDC) -> Result<(), crate::InstanceError> {
if index == 0 {
return Err(crate::InstanceError::with_source(
String::from("unable to choose pixel format"),
Error::from_win32(),
Error::from_thread(),
));
}
@ -244,7 +244,7 @@ unsafe fn setup_pixel_format(dc: Gdi::HDC) -> Result<(), crate::InstanceError> {
if index == 0 {
return Err(crate::InstanceError::with_source(
String::from("unable to get pixel format index"),
Error::from_win32(),
Error::from_thread(),
));
}
let mut format = Default::default();
@ -254,7 +254,7 @@ unsafe fn setup_pixel_format(dc: Gdi::HDC) -> Result<(), crate::InstanceError> {
{
return Err(crate::InstanceError::with_source(
String::from("unable to read pixel format"),
Error::from_win32(),
Error::from_thread(),
));
}
@ -311,7 +311,7 @@ fn create_global_window_class() -> Result<CString, crate::InstanceError> {
if atom == 0 {
return Err(crate::InstanceError::with_source(
String::from("unable to register window class"),
Error::from_win32(),
Error::from_thread(),
));
}
@ -382,7 +382,7 @@ fn create_instance_device() -> Result<InstanceDevice, crate::InstanceError> {
1,
None,
None,
instance,
Some(instance.into()),
None,
)
}
@ -394,11 +394,11 @@ fn create_instance_device() -> Result<InstanceDevice, crate::InstanceError> {
})?;
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"),
Error::from_win32(),
Error::from_thread(),
));
}
let dc = DeviceContextHandle {
@ -484,7 +484,7 @@ impl crate::Instance for Instance {
if context.is_null() {
return Err(crate::InstanceError::with_source(
String::from("unable to create OpenGL context"),
Error::from_win32(),
Error::from_thread(),
));
}
WglContext {
@ -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,11 +672,11 @@ 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: {}",
Error::from_win32()
Error::from_thread()
);
return Err(crate::SurfaceError::Other(
"unable to get the device context from window",
@ -750,11 +750,11 @@ 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: {}",
Error::from_win32()
Error::from_thread()
);
return Err(crate::SurfaceError::Other(
"unable to get the device context from window",
@ -828,7 +828,7 @@ impl crate::Surface for Surface {
};
if unsafe { extra.SwapIntervalEXT(if vsync { 1 } else { 0 }) } == Foundation::FALSE.0 {
log::error!("unable to set swap interval: {}", Error::from_win32());
log::error!("unable to set swap interval: {}", Error::from_thread());
return Err(crate::SurfaceError::Other("unable to set swap interval"));
}

View File

@ -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,
}