mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Remove id32 feature
This commit is contained in:
committed by
Jim Blandy
parent
d9784aca8e
commit
87ecc089dd
@@ -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"]
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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> {}
|
||||
|
||||
Reference in New Issue
Block a user