Remove id32 feature

This commit is contained in:
Connor Fitzgerald
2023-12-20 23:43:10 -05:00
committed by Jim Blandy
parent d9784aca8e
commit 87ecc089dd
4 changed files with 10 additions and 17 deletions

View File

@@ -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"]

View File

@@ -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::<ZippedIndex>() * 8;

View File

@@ -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<T>) -> 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)
}
}

View File

@@ -5170,6 +5170,14 @@ impl Surface<'_> {
#[repr(transparent)]
pub struct Id<T>(NonZeroU64, PhantomData<*mut T>);
impl<T> Id<T> {
/// 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<T> Send for Id<T> {}