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;
29mod command_encoder;
30// Not a root type, but common descriptor types for pipelines.
31mod common_pipeline;
32mod compute_pass;
33mod compute_pipeline;
34mod device;
35mod instance;
36mod pipeline_cache;
37mod pipeline_layout;
38mod query_set;
39mod queue;
40mod render_bundle;
41mod render_bundle_encoder;
42mod render_pass;
43mod render_pipeline;
44mod sampler;
45mod shader_module;
46mod surface;
47mod surface_texture;
48mod texture;
49mod texture_view;
50mod tlas;
51
52pub use adapter::*;
53pub use bind_group::*;
54pub use bind_group_layout::*;
55pub use blas::*;
56pub use buffer::*;
57pub use command_buffer::*;
58pub use command_encoder::*;
59pub use common_pipeline::*;
60pub use compute_pass::*;
61pub use compute_pipeline::*;
62pub use device::*;
63pub use instance::*;
64pub use pipeline_cache::*;
65pub use pipeline_layout::*;
66pub use query_set::*;
67pub use queue::*;
68pub use render_bundle::*;
69pub use render_bundle_encoder::*;
70pub use render_pass::*;
71pub use render_pipeline::*;
72pub use sampler::*;
73pub use shader_module::*;
74pub use surface::*;
75pub use surface_texture::*;
76pub use texture::*;
77pub use texture_view::*;
78pub use tlas::*;
79
80/// Object debugging label.
81pub type Label<'a> = Option<&'a str>;
82
83/// A cute utility type that works just like PhantomData, but also
84/// implements Drop. This forces any lifetimes that are associated
85/// with the type to be used until the Drop impl is ran. This prevents
86/// lifetimes from being shortened.
87#[derive(Debug)]
88pub(crate) struct PhantomDrop<T>(std::marker::PhantomData<T>);
89
90impl<T> Default for PhantomDrop<T> {
91    fn default() -> Self {
92        Self(std::marker::PhantomData)
93    }
94}
95
96impl<T> Drop for PhantomDrop<T> {
97    fn drop(&mut self) {}
98}