diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index d7eceb3dff..987e9d0420 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -56,8 +56,6 @@ replay = ["serde", "wgt/replay", "arrayvec/serde", "naga/deserialize"] ## Enable serializable compute/render passes, and bundle encoders. serial-pass = ["serde", "wgt/serde", "arrayvec/serde"] -id32 = [] - ## Enable `ShaderModuleSource::Wgsl` wgsl = ["naga/wgsl-in"] diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index 1782172c2a..739beb7180 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -8,17 +8,8 @@ use std::{ }; use wgt::{Backend, WasmNotSendSync}; -#[cfg(feature = "id32")] -type IdType = u32; -#[cfg(not(feature = "id32"))] type IdType = u64; -#[cfg(feature = "id32")] -type NonZeroId = std::num::NonZeroU32; -#[cfg(not(feature = "id32"))] type NonZeroId = std::num::NonZeroU64; -#[cfg(feature = "id32")] -type ZippedIndex = u16; -#[cfg(not(feature = "id32"))] type ZippedIndex = Index; const INDEX_BITS: usize = std::mem::size_of::() * 8; diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 75643dc792..5dede69f3f 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -3064,9 +3064,7 @@ where T: 'static + WasmNotSendSync, { fn from(id: ObjectId) -> Self { - // If the id32 feature is enabled in wgpu-core, this will make sure that the id fits in a NonZeroU32. - #[allow(clippy::useless_conversion)] - let id = id.id().try_into().expect("Id exceeded 32-bits"); + let id = id.id(); // SAFETY: The id was created via the impl below unsafe { Self::from_raw(id) } } @@ -3077,9 +3075,7 @@ where T: 'static + WasmNotSendSync, { fn from(id: wgc::id::Id) -> Self { - // If the id32 feature is enabled in wgpu-core, the conversion is not useless - #[allow(clippy::useless_conversion)] - let id = id.into_raw().into(); + let id = id.into_raw(); Self::from_global_id(id) } } diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 66aa8c681c..7dd0dc6c10 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -5170,6 +5170,14 @@ impl Surface<'_> { #[repr(transparent)] pub struct Id(NonZeroU64, PhantomData<*mut T>); +impl Id { + /// For testing use only. We provide no guarentees about the actual value of the ids. + #[doc(hidden)] + pub fn inner(&self) -> u64 { + self.0.get() + } +} + // SAFETY: `Id` is a bare `NonZeroU64`, the type parameter is a marker purely to avoid confusing Ids // returned for different types , so `Id` can safely implement Send and Sync. unsafe impl Send for Id {}