From 1098476cd0ca6503c905c301bc08944d34ec720f Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 18 Aug 2026 11:41:00 +1000 Subject: [PATCH] wgpu-core: use `wgpu-sync` for atomics --- Cargo.lock | 1 - wgpu-core/Cargo.toml | 5 +---- wgpu-core/build.rs | 2 -- wgpu-core/src/device/resource.rs | 7 ++----- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4585d0497..65adcaf70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4795,7 +4795,6 @@ dependencies = [ "naga", "naga-types", "num-traits", - "portable-atomic", "profiling", "proptest", "raw-window-handle", diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 8bf400c7b..08c064692 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -121,7 +121,7 @@ std = ["wgpu-sync/std"] static-dxc = ["wgpu-hal/static-dxc"] ## Enable portable atomics on platforms that do not support 64bit atomics. -portable-atomic = ["dep:portable-atomic", "wgpu-hal/portable-atomic"] +portable-atomic = ["wgpu-sync/portable-atomic", "wgpu-hal/portable-atomic"] #! ### Target Conditional Features # -------------------------------------------------------------------- @@ -208,9 +208,6 @@ serde = { workspace = true, features = ["derive"], default-features = false, opt smallvec.workspace = true thiserror.workspace = true -[target.'cfg(not(target_has_atomic = "64"))'.dependencies] -portable-atomic = { workspace = true, optional = true } - [target.'cfg(not(target_family = "wasm"))'.dev-dependencies] proptest.workspace = true diff --git a/wgpu-core/build.rs b/wgpu-core/build.rs index 849afb835..3266e9a56 100644 --- a/wgpu-core/build.rs +++ b/wgpu-core/build.rs @@ -25,7 +25,5 @@ fn main() { any(target_os = "linux", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd") ) }, metal: { all(target_vendor = "apple", feature = "metal") }, - - supports_64bit_atomics: { target_has_atomic = "64" } } } diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index f984e20be..845755ac4 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -9,13 +9,13 @@ use core::{ fmt, mem::{self, ManuallyDrop}, num::NonZeroU32, - sync::atomic::{AtomicBool, Ordering}, }; use hal::ShouldBeNonZeroExt; use arrayvec::ArrayVec; use bitflags::Flags; use smallvec::SmallVec; +use wgpu_sync::atomic::{AtomicBool, Ordering}; use wgpu_sync::OnceCell; use wgt::{ math::align_to, ColorWrites, DeviceLostReason, TextureFormat, TextureSampleType, @@ -66,10 +66,7 @@ use super::{ ENTRYPOINT_FAILURE_ERROR, ZERO_BUFFER_SIZE, }; -#[cfg(supports_64bit_atomics)] -use core::sync::atomic::AtomicU64; -#[cfg(not(supports_64bit_atomics))] -use portable_atomic::AtomicU64; +use wgpu_sync::atomic::AtomicU64; pub(crate) struct CommandIndices { /// The index of the last command submission that was attempted.