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#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
18#![doc(html_logo_url = "https://raw.githubusercontent.com/gfx-rs/wgpu/trunk/logo.png")]
19#![warn(missing_docs, rust_2018_idioms, unsafe_op_in_unsafe_fn)]
20
21//
22//
23// Modules
24//
25//
26
27mod api;
28mod backend;
29mod context;
30mod macros;
31mod send_sync;
32pub mod util;
33
34//
35//
36// Private re-exports
37//
38//
39
40#[allow(unused_imports)] // WebGPU needs this
41use context::Context;
42use send_sync::*;
43
44type C = dyn context::DynContext;
45#[cfg(send_sync)]
46type Data = dyn std::any::Any + Send + Sync;
47#[cfg(not(send_sync))]
48type Data = dyn std::any::Any;
49
50//
51//
52// Public re-exports
53//
54//
55
56pub use api::*;
57pub use wgt::{
58    AdapterInfo, AddressMode, AstcBlock, AstcChannel, Backend, Backends, BindGroupLayoutEntry,
59    BindingType, BlendComponent, BlendFactor, BlendOperation, BlendState, BufferAddress,
60    BufferBindingType, BufferSize, BufferUsages, Color, ColorTargetState, ColorWrites,
61    CommandBufferDescriptor, CompareFunction, CompositeAlphaMode, CoreCounters, DepthBiasState,
62    DepthStencilState, DeviceLostReason, DeviceType, DownlevelCapabilities, DownlevelFlags,
63    Dx12Compiler, DynamicOffset, Extent3d, Face, Features, FilterMode, FrontFace,
64    Gles3MinorVersion, HalCounters, ImageDataLayout, ImageSubresourceRange, IndexFormat,
65    InstanceDescriptor, InstanceFlags, InternalCounters, Limits, MaintainResult, MemoryHints,
66    MultisampleState, Origin2d, Origin3d, PipelineStatisticsTypes, PolygonMode, PowerPreference,
67    PredefinedColorSpace, PresentMode, PresentationTimestamp, PrimitiveState, PrimitiveTopology,
68    PushConstantRange, QueryType, RenderBundleDepthStencil, SamplerBindingType, SamplerBorderColor,
69    ShaderLocation, ShaderModel, ShaderStages, StencilFaceState, StencilOperation, StencilState,
70    StorageTextureAccess, SurfaceCapabilities, SurfaceStatus, TextureAspect, TextureDimension,
71    TextureFormat, TextureFormatFeatureFlags, TextureFormatFeatures, TextureSampleType,
72    TextureUsages, TextureViewDimension, VertexAttribute, VertexFormat, VertexStepMode,
73    WasmNotSend, WasmNotSendSync, WasmNotSync, COPY_BUFFER_ALIGNMENT, COPY_BYTES_PER_ROW_ALIGNMENT,
74    MAP_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT, QUERY_RESOLVE_BUFFER_ALIGNMENT, QUERY_SET_MAX_QUERIES,
75    QUERY_SIZE, VERTEX_STRIDE_ALIGNMENT,
76};
77// wasm-only types, we try to keep as many types non-platform
78// specific, but these need to depend on web-sys.
79#[cfg(any(webgpu, webgl))]
80pub use wgt::{ExternalImageSource, ImageCopyExternalImage};
81
82//
83//
84// Re-exports of dependencies
85//
86//
87
88/// Re-export of our `wgpu-core` dependency.
89///
90#[cfg(wgpu_core)]
91pub use ::wgc as core;
92
93/// Re-export of our `wgpu-hal` dependency.
94///
95///
96#[cfg(wgpu_core)]
97pub use ::hal;
98
99/// Re-export of our `naga` dependency.
100///
101#[cfg(wgpu_core)]
102#[cfg_attr(docsrs, doc(cfg(any(wgpu_core, naga))))]
103// We re-export wgpu-core's re-export of naga, as we may not have direct access to it.
104pub use ::wgc::naga;
105/// Re-export of our `naga` dependency.
106///
107#[cfg(all(not(wgpu_core), naga))]
108#[cfg_attr(docsrs, doc(cfg(any(wgpu_core, naga))))]
109// If that's not available, we re-export our own.
110pub use naga;
111
112/// Re-export of our `raw-window-handle` dependency.
113///
114pub use raw_window_handle as rwh;
115
116/// Re-export of our `web-sys` dependency.
117///
118#[cfg(any(webgl, webgpu))]
119pub use web_sys;