wgpu/
lib.rs

1//! A cross-platform graphics and compute library based on [WebGPU](https://gpuweb.github.io/gpuweb/).
2//!
3//! To start using the API, create an [`Instance`].
4//!
5//! ## Feature flags
6#![doc = document_features::document_features!()]
7//!
8//! ### Feature Aliases
9//!
10//! These features aren't actually features on the crate itself, but a convenient shorthand for
11//! complicated cases.
12//!
13//! - **`wgpu_core`** --- Enabled when there is any non-webgpu backend enabled on the platform.
14//! - **`naga`** ---- Enabled when any non-wgsl shader input is enabled.
15//!
16
17#![no_std]
18#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
19#![doc(html_logo_url = "https://raw.githubusercontent.com/gfx-rs/wgpu/trunk/logo.png")]
20#![warn(
21    clippy::alloc_instead_of_core,
22    clippy::allow_attributes,
23    clippy::std_instead_of_alloc,
24    clippy::std_instead_of_core,
25    missing_docs,
26    rust_2018_idioms,
27    unsafe_op_in_unsafe_fn
28)]
29// NOTE: Keep this in sync with `wgpu-core`.
30#![cfg_attr(not(send_sync), allow(clippy::arc_with_non_send_sync))]
31#![cfg_attr(not(any(wgpu_core, webgpu)), allow(unused))]
32
33extern crate alloc;
34extern crate std;
35#[cfg(wgpu_core)]
36pub extern crate wgpu_core as wgc;
37#[cfg(wgpu_core)]
38pub extern crate wgpu_hal as hal;
39pub extern crate wgpu_types as wgt;
40
41//
42//
43// Modules
44//
45//
46
47mod api;
48mod backend;
49mod cmp;
50mod dispatch;
51mod macros;
52pub mod util;
53
54//
55//
56// Private re-exports
57//
58//
59
60//
61//
62// Public re-exports
63//
64//
65
66#[cfg(custom)]
67pub use backend::custom;
68
69pub use api::*;
70pub use wgt::{
71    AdapterInfo, AddressMode, AllocatorReport, AstcBlock, AstcChannel, Backend, BackendOptions,
72    Backends, BindGroupLayoutEntry, BindingType, BlendComponent, BlendFactor, BlendOperation,
73    BlendState, BufferAddress, BufferBindingType, BufferSize, BufferTransition, BufferUsages,
74    BufferUses, Color, ColorTargetState, ColorWrites, CommandBufferDescriptor, CompareFunction,
75    CompositeAlphaMode, CopyExternalImageDestInfo, CoreCounters, DepthBiasState, DepthStencilState,
76    DeviceLostReason, DeviceType, DownlevelCapabilities, DownlevelFlags, DownlevelLimits,
77    Dx12BackendOptions, Dx12Compiler, DxcShaderModel, DynamicOffset, Extent3d, Face, Features,
78    FeaturesWGPU, FeaturesWebGPU, FilterMode, FrontFace, GlBackendOptions, GlFenceBehavior,
79    Gles3MinorVersion, HalCounters, ImageSubresourceRange, IndexFormat, InstanceDescriptor,
80    InstanceFlags, InternalCounters, Limits, MemoryHints, MultisampleState, NoopBackendOptions,
81    Origin2d, Origin3d, PipelineStatisticsTypes, PollError, PollStatus, PolygonMode,
82    PowerPreference, PredefinedColorSpace, PresentMode, PresentationTimestamp, PrimitiveState,
83    PrimitiveTopology, PushConstantRange, QueryType, RenderBundleDepthStencil, RequestAdapterError,
84    SamplerBindingType, SamplerBorderColor, ShaderLocation, ShaderModel, ShaderRuntimeChecks,
85    ShaderStages, StencilFaceState, StencilOperation, StencilState, StorageTextureAccess,
86    SurfaceCapabilities, SurfaceStatus, TexelCopyBufferLayout, TextureAspect, TextureDimension,
87    TextureFormat, TextureFormatFeatureFlags, TextureFormatFeatures, TextureSampleType,
88    TextureTransition, TextureUsages, TextureUses, TextureViewDimension, Trace, VertexAttribute,
89    VertexFormat, VertexStepMode, WasmNotSend, WasmNotSendSync, WasmNotSync, COPY_BUFFER_ALIGNMENT,
90    COPY_BYTES_PER_ROW_ALIGNMENT, MAP_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT,
91    QUERY_RESOLVE_BUFFER_ALIGNMENT, QUERY_SET_MAX_QUERIES, QUERY_SIZE, VERTEX_STRIDE_ALIGNMENT,
92};
93#[expect(deprecated)]
94pub use wgt::{ImageCopyBuffer, ImageCopyTexture, ImageCopyTextureTagged, ImageDataLayout};
95// wasm-only types, we try to keep as many types non-platform
96// specific, but these need to depend on web-sys.
97#[cfg(any(webgpu, webgl))]
98#[expect(deprecated)]
99pub use wgt::ImageCopyExternalImage;
100#[cfg(any(webgpu, webgl))]
101pub use wgt::{CopyExternalImageSourceInfo, ExternalImageSource};
102
103/// Re-export of our `naga` dependency.
104///
105#[cfg(wgpu_core)]
106#[cfg_attr(docsrs, doc(cfg(any(wgpu_core, naga))))]
107// We re-export wgpu-core's re-export of naga, as we may not have direct access to it.
108pub use ::wgc::naga;
109/// Re-export of our `naga` dependency.
110///
111#[cfg(all(not(wgpu_core), naga))]
112#[cfg_attr(docsrs, doc(cfg(any(wgpu_core, naga))))]
113// If that's not available, we re-export our own.
114pub use naga;
115
116/// Re-export of our `raw-window-handle` dependency.
117///
118pub use raw_window_handle as rwh;
119
120/// Re-export of our `web-sys` dependency.
121///
122#[cfg(any(webgl, webgpu))]
123pub use web_sys;
124
125#[doc(hidden)]
126pub use macros::helpers as __macro_helpers;