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