From df4947cf4712e9104a733dd54a0eb3ca2bf4c318 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Sat, 15 Aug 2026 08:17:34 +0200 Subject: [PATCH] Move markers to types we keep them undocumented because they are impl detail Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- wgpu-core/src/id.rs | 67 +-------------------------------------- wgpu-types/src/lib.rs | 2 ++ wgpu-types/src/markers.rs | 64 +++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 66 deletions(-) create mode 100644 wgpu-types/src/markers.rs diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index b9876781b..bc76f43e6 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -1,4 +1,4 @@ -use wgt::WasmNotSendSync; +pub use wgt::markers::*; /// Identify an object by the pointer returned by `Arc::as_ptr`. /// @@ -69,68 +69,3 @@ impl From<&alloc::sync::Arc> for PointerId` will have the same type of identifier as -/// `Device` because `Device` for any `T` defines the same maker type. -pub trait Marker: 'static + WasmNotSendSync { - const TYPE: &'static str; -} - -// This allows `()` to be used as a marker type for tests. -// -// We don't want these in production code, since they essentially remove type -// safety, like how identifiers across different types can be compared. -#[cfg(test)] -impl Marker for () { - const TYPE: &'static str = "Untyped"; -} - -/// Define markers for each resource. -macro_rules! ids { - ($( - $(#[$($meta:meta)*])* - pub type $marker:ident; - )*) => { - /// Marker types for each resource. - pub mod markers { - $( - #[derive(Debug)] - pub enum $marker {} - impl super::Marker for $marker { - const TYPE: &'static str = stringify!($marker); - } - )* - } - } -} - -ids! { - pub type Adapter; - pub type Surface; - pub type Device; - pub type Queue; - pub type Buffer; - pub type StagingBuffer; - pub type TextureView; - pub type Texture; - pub type ExternalTexture; - pub type Sampler; - pub type BindGroupLayout; - pub type PipelineLayout; - pub type BindGroup; - pub type ShaderModule; - pub type RenderPipeline; - pub type ComputePipeline; - pub type PipelineCache; - pub type CommandEncoder; - pub type CommandBuffer; - pub type RenderPassEncoder; - pub type ComputePassEncoder; - pub type RenderBundleEncoder; - pub type RenderBundle; - pub type QuerySet; - pub type Blas; - pub type Tlas; -} diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 1c47f9dd5..6ab56c7fe 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -40,6 +40,8 @@ mod features; pub mod instance; mod limits; mod macros; +#[doc(hidden)] // for use in wgpu-core,wgpu-core-remote-types +pub mod markers; pub mod math; mod origin_extent; mod ray_tracing; diff --git a/wgpu-types/src/markers.rs b/wgpu-types/src/markers.rs new file mode 100644 index 000000000..1b217e0b6 --- /dev/null +++ b/wgpu-types/src/markers.rs @@ -0,0 +1,64 @@ +/// Marker trait used to determine which types uniquely identify a resource. +/// +/// For example, `Device` will have the same type of identifier as +/// `Device` because `Device` for any `T` defines the same maker type. +pub trait Marker: 'static + crate::WasmNotSendSync { + const TYPE: &'static str; +} + +// This allows `()` to be used as a marker type for tests. +// +// We don't want these in production code, since they essentially remove type +// safety, like how identifiers across different types can be compared. +#[cfg(test)] +impl Marker for () { + const TYPE: &'static str = "Untyped"; +} + +/// Define markers for each resource. +macro_rules! ids { + ($( + $(#[$($meta:meta)*])* + pub type $marker:ident; + )*) => { + /// Marker types for each resource. + pub mod markers { + $( + #[derive(Debug)] + pub enum $marker {} + impl super::Marker for $marker { + const TYPE: &'static str = stringify!($marker); + } + )* + } + } +} + +ids! { + pub type Adapter; + pub type Surface; + pub type Device; + pub type Queue; + pub type Buffer; + pub type StagingBuffer; + pub type TextureView; + pub type Texture; + pub type ExternalTexture; + pub type Sampler; + pub type BindGroupLayout; + pub type PipelineLayout; + pub type BindGroup; + pub type ShaderModule; + pub type RenderPipeline; + pub type ComputePipeline; + pub type PipelineCache; + pub type CommandEncoder; + pub type CommandBuffer; + pub type RenderPassEncoder; + pub type ComputePassEncoder; + pub type RenderBundleEncoder; + pub type RenderBundle; + pub type QuerySet; + pub type Blas; + pub type Tlas; +}