Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove id32 Feature #4913

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
9 changes: 0 additions & 9 deletions wgpu-core/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions wgpu/src/backend/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand All @@ -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)
}
}
Expand Down
8 changes: 8 additions & 0 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {}
Expand Down
Loading