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;
34#[cfg(std)]
35extern crate std;
36#[cfg(wgpu_core)]
37pub extern crate wgpu_core as wgc;
38#[cfg(wgpu_core)]
39pub extern crate wgpu_hal as hal;
40pub extern crate wgpu_types as wgt;
41
42//
43//
44// Modules
45//
46//
47
48mod api;
49mod backend;
50mod cmp;
51mod dispatch;
52mod macros;
53pub mod util;
54
55//
56//
57// Private re-exports
58//
59//
60
61//
62//
63// Public re-exports
64//
65//
66
67#[cfg(custom)]
68pub use backend::custom;
69
70pub use api::*;
71pub use wgt::{
72    AdapterInfo, AddressMode, AllocatorReport, AstcBlock, AstcChannel, Backend, BackendOptions,
73    Backends, BindGroupLayoutEntry, BindingType, BlendComponent, BlendFactor, BlendOperation,
74    BlendState, BufferAddress, BufferBindingType, BufferSize, BufferTextureCopyInfo,
75    BufferTransition, BufferUsages, BufferUses, Color, ColorTargetState, ColorWrites,
76    CommandBufferDescriptor, CompareFunction, CompositeAlphaMode, CopyExternalImageDestInfo,
77    CoreCounters, DepthBiasState, DepthStencilState, DeviceLostReason, DeviceType,
78    DownlevelCapabilities, DownlevelFlags, DownlevelLimits, Dx12BackendOptions, Dx12Compiler,
79    DxcShaderModel, DynamicOffset, Extent3d, Face, Features, FeaturesWGPU, FeaturesWebGPU,
80    FilterMode, FrontFace, GlBackendOptions, GlFenceBehavior, Gles3MinorVersion, HalCounters,
81    ImageSubresourceRange, IndexFormat, InstanceDescriptor, InstanceFlags, InternalCounters,
82    Limits, MemoryBudgetThresholds, MemoryHints, MultisampleState, NoopBackendOptions, Origin2d,
83    Origin3d, PipelineStatisticsTypes, PollError, PollStatus, PolygonMode, PowerPreference,
84    PredefinedColorSpace, PresentMode, PresentationTimestamp, PrimitiveState, PrimitiveTopology,
85    PushConstantRange, QueryType, RenderBundleDepthStencil, RequestAdapterError,
86    SamplerBindingType, SamplerBorderColor, ShaderLocation, ShaderModel, ShaderRuntimeChecks,
87    ShaderStages, StencilFaceState, StencilOperation, StencilState, StorageTextureAccess,
88    SurfaceCapabilities, SurfaceStatus, TexelCopyBufferLayout, TextureAspect, TextureDimension,
89    TextureFormat, TextureFormatFeatureFlags, TextureFormatFeatures, TextureSampleType,
90    TextureTransition, TextureUsages, TextureUses, TextureViewDimension, Trace, VertexAttribute,
91    VertexFormat, VertexStepMode, WasmNotSend, WasmNotSendSync, WasmNotSync, COPY_BUFFER_ALIGNMENT,
92    COPY_BYTES_PER_ROW_ALIGNMENT, MAP_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT,
93    QUERY_RESOLVE_BUFFER_ALIGNMENT, QUERY_SET_MAX_QUERIES, QUERY_SIZE, VERTEX_STRIDE_ALIGNMENT,
94};
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(web)]
98pub use wgt::{CopyExternalImageSourceInfo, ExternalImageSource};
99
100/// Re-export of our `naga` dependency.
101///
102#[cfg(wgpu_core)]
103#[cfg_attr(docsrs, doc(cfg(any(wgpu_core, naga))))]
104// We re-export wgpu-core's re-export of naga, as we may not have direct access to it.
105pub use ::wgc::naga;
106/// Re-export of our `naga` dependency.
107///
108#[cfg(all(not(wgpu_core), naga))]
109#[cfg_attr(docsrs, doc(cfg(any(wgpu_core, naga))))]
110// If that's not available, we re-export our own.
111pub use naga;
112
113/// Re-export of our `raw-window-handle` dependency.
114///
115pub use raw_window_handle as rwh;
116
117/// Re-export of our `web-sys` dependency.
118///
119#[cfg(web)]
120pub use web_sys;
121
122#[doc(hidden)]
123pub use macros::helpers as __macro_helpers;