summaryrefslogtreecommitdiffstats
path: root/third_party/rust/wgpu-core/src/id.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/wgpu-core/src/id.rs')
-rw-r--r--third_party/rust/wgpu-core/src/id.rs47
1 files changed, 19 insertions, 28 deletions
diff --git a/third_party/rust/wgpu-core/src/id.rs b/third_party/rust/wgpu-core/src/id.rs
index 72b74218d0..1fa89f2bf0 100644
--- a/third_party/rust/wgpu-core/src/id.rs
+++ b/third_party/rust/wgpu-core/src/id.rs
@@ -91,8 +91,7 @@ pub fn as_option_slice<T: Marker>(ids: &[Id<T>]) -> &[Option<Id<T>>] {
/// An identifier for a wgpu object.
///
-/// An `Id<T>` value identifies a value stored in a [`Global`]'s [`Hub`]'s [`Storage`].
-/// `Storage` implements [`Index`] and [`IndexMut`], accepting `Id` values as indices.
+/// An `Id<T>` value identifies a value stored in a [`Global`]'s [`Hub`].
///
/// ## Note on `Id` typing
///
@@ -112,10 +111,7 @@ pub fn as_option_slice<T: Marker>(ids: &[Id<T>]) -> &[Option<Id<T>>] {
/// [`Global`]: crate::global::Global
/// [`Hub`]: crate::hub::Hub
/// [`Hub<A>`]: crate::hub::Hub
-/// [`Storage`]: crate::storage::Storage
/// [`Texture<A>`]: crate::resource::Texture
-/// [`Index`]: std::ops::Index
-/// [`IndexMut`]: std::ops::IndexMut
/// [`Registry`]: crate::hub::Registry
/// [`Empty`]: hal::api::Empty
#[repr(transparent)]
@@ -182,15 +178,6 @@ where
self.0.backend()
}
- /// Transmute this identifier to one with a different marker trait.
- ///
- /// Legal use is governed through a sealed trait, however it's correctness
- /// depends on the current implementation of `wgpu-core`.
- #[inline]
- pub const fn transmute<U: self::transmute::Transmute<T>>(self) -> Id<U> {
- Id(self.0, PhantomData)
- }
-
#[inline]
pub fn zip(index: Index, epoch: Epoch, backend: Backend) -> Self {
Id(RawId::zip(index, epoch, backend), PhantomData)
@@ -202,20 +189,6 @@ where
}
}
-pub(crate) mod transmute {
- // This trait is effectively sealed to prevent illegal transmutes.
- pub trait Transmute<U>: super::Marker {}
-
- // Self-transmute is always legal.
- impl<T> Transmute<T> for T where T: super::Marker {}
-
- // TODO: Remove these once queues have their own identifiers.
- impl Transmute<super::markers::Queue> for super::markers::Device {}
- impl Transmute<super::markers::Device> for super::markers::Queue {}
- impl Transmute<super::markers::CommandBuffer> for super::markers::CommandEncoder {}
- impl Transmute<super::markers::CommandEncoder> for super::markers::CommandBuffer {}
-}
-
impl<T> Copy for Id<T> where T: Marker {}
impl<T> Clone for Id<T>
@@ -349,6 +322,24 @@ ids! {
pub type QuerySetId QuerySet;
}
+impl CommandEncoderId {
+ pub fn into_command_buffer_id(self) -> CommandBufferId {
+ Id(self.0, PhantomData)
+ }
+}
+
+impl CommandBufferId {
+ pub fn into_command_encoder_id(self) -> CommandEncoderId {
+ Id(self.0, PhantomData)
+ }
+}
+
+impl DeviceId {
+ pub fn into_queue_id(self) -> QueueId {
+ Id(self.0, PhantomData)
+ }
+}
+
#[test]
fn test_id_backend() {
for &b in &[