Skip to main content

wgpu/api/
mod.rs

1//! Types and functions which define our public api and their
2//! helper functionality.
3//!
4//! # Conventions
5//!
6//! Each major type gets its own module. The module is laid out as follows:
7//!
8//! - The type itself
9//! - `impl` block for the type
10//! - `Drop` implementation for the type (if needed)
11//! - Descriptor types and their subtypes.
12//! - Any non-public helper types or functions.
13//!
14//! # Imports
15//!
16//! Because our public api is "flat" (i.e. all types are directly under the `wgpu` module),
17//! we use a single `crate::*` import at the top of each module to bring in all the types in
18//! the public api. This is done to:
19//! - Avoid having to write out a long list of imports for each module.
20//! - Allow docs to be written naturally, without needing to worry about needing dedicated doc imports.
21//! - Treat wgpu-types types and wgpu-core types as a single set.
22
23mod adapter;
24mod bind_group;
25mod bind_group_layout;
26mod blas;
27mod buffer;
28mod command_buffer;
29/// Not a root type, but common types for command buffer deferral actions.
30mod command_buffer_actions;
31mod command_encoder;
32// Not a root type, but common descriptor types for pipelines.
33mod common_pipeline;
34mod compute_pass;
35mod compute_pipeline;
36mod device;
37mod external_texture;
38mod instance;
39mod pipeline_cache;
40mod pipeline_layout;
41mod query_set;
42mod queue;
43mod ray_tracing_pass;
44mod ray_tracing_pipeline;
45mod render_bundle;
46mod render_bundle_encoder;
47mod render_pass;
48mod render_pipeline;
49mod sampler;
50mod shader_module;
51mod surface;
52mod surface_texture;
53mod texture;
54mod texture_view;
55mod tlas;
56
57pub use adapter::*;
58pub use bind_group::*;
59pub use bind_group_layout::*;
60pub use blas::*;
61pub use buffer::*;
62pub use command_buffer::*;
63use command_buffer_actions::*;
64pub use command_encoder::*;
65pub use common_pipeline::*;
66pub use compute_pass::*;
67pub use compute_pipeline::*;
68pub use device::*;
69pub use external_texture::*;
70pub use instance::*;
71pub use pipeline_cache::*;
72pub use pipeline_layout::*;
73pub use query_set::*;
74pub use queue::*;
75pub use ray_tracing_pass::*;
76pub use ray_tracing_pipeline::*;
77pub use render_bundle::*;
78pub use render_bundle_encoder::*;
79pub use render_pass::*;
80pub use render_pipeline::*;
81pub use sampler::*;
82pub use shader_module::*;
83pub use surface::*;
84pub use surface_texture::*;
85pub use texture::*;
86pub use texture_view::*;
87pub use tlas::*;
88
89/// Object debugging label.
90pub type Label<'a> = Option<&'a str>;
91
92/// A cute utility type that works just like `PhantomData`, but also
93/// implements `Drop`. This forces any lifetimes that are associated
94/// with the type to be used until the `Drop` impl is ran. This prevents
95/// lifetimes from being shortened.
96#[derive(Debug)]
97pub(crate) struct PhantomDrop<T>(core::marker::PhantomData<T>);
98
99impl<T> Default for PhantomDrop<T> {
100    fn default() -> Self {
101        Self(core::marker::PhantomData)
102    }
103}
104
105impl<T> Drop for PhantomDrop<T> {
106    fn drop(&mut self) {}
107}