Cargo Features

[dependencies]
wgpu = { version = "23.0.0", default-features = false, features = ["dx12", "metal", "webgpu", "angle", "vulkan-portability", "webgl", "spirv", "glsl", "wgsl", "naga-ir", "strict_asserts", "serde", "replay", "counters", "fragile-send-sync-non-atomic-wasm"] }
default = dx12, metal, webgpu, wgsl

These default features are set whenever wgpu is added without default-features = false somewhere in the dependency tree.

dx12 default

Backends


⚠️ WIP: Not all backends can be manually configured today. On Windows, Linux & Android the Vulkan & GLES backends are always enabled. See #3514 for more details.

Enables the DX12 backend on Windows.

Enables dx12 of optional wgpu-core

metal default

Enables the Metal backend on macOS & iOS.

Enables metal of optional wgpu-core

webgpu default

Enables the WebGPU backend on Wasm. Disabled when targeting emscripten.

Enables wgsl-out of optional naga

angle

Enables the GLES backend via ANGLE on macOS using.

Enables gles of optional wgpu-core

vulkan-portability

Enables the Vulkan backend on macOS & iOS.

Enables vulkan of optional wgpu-core

webgl

Enables the GLES backend on Wasm

* ⚠️ WIP: Currently will also enable GLES dependencies on any other targets.

Enables wgpu-hal, gles of wgpu-core

spirv

Note: In the documentation, if you see that an item depends on a backend, it means that the item is only available when that backend is enabled and the backend is supported on the current platform.

Shading language support


Enable accepting SPIR-V shaders as input.

Enables spv-in of naga, spirv of wgpu-core

Affects util::make_spirv

glsl

Enable accepting GLSL shaders as input.

Enables glsl-in of naga, glsl of wgpu-core

wgsl default

Enable accepting WGSL shaders as input.

Enables wgsl of optional wgpu-core

naga-ir

Enable accepting naga IR shaders as input.

Enables naga

strict_asserts

Logging & Tracing


The following features do not have any effect on the WebGPU backend.

Apply run-time checks, even in release builds. These are in addition to the validation carried out at public APIs in all builds.

Enables strict_asserts of optional wgpu-core and wgpu-types

serde replay?

Enables serialization via serde on common wgpu types.

Enables serde, serde of wgpu-core

replay = serde

Allow deserializing of trace capture files that were written with the trace feature. To replay a trace file use the wgpu player.

Enables replay of wgpu-core

counters

Other


Internally count resources and events for debugging purposes. If the counters feature is disabled, the counting infrastructure is removed from the build and the exposed counters always return 0.

Enables counters of wgpu-core

fragile-send-sync-non-atomic-wasm

Implement Send and Sync on Wasm, but only if atomics are not enabled.

WebGL/WebGPU objects can not be shared between threads. However, it can be useful to artificially mark them as Send and Sync anyways to make it easier to write cross-platform code. This is technically very unsafe in a multithreaded environment, but on a wasm binary compiled without atomics we know we are definitely not in a multithreaded environment.

Enables fragile-send-sync-non-atomic-wasm of wgpu-hal, wgpu-core, and wgpu-types

Features from optional dependencies

In crates that don't use the dep: syntax, optional dependencies automatically become Cargo features. These features may have been created by mistake, and this functionality may be removed in the future.

wgc counters? fragile-send-sync-non-atomic-wasm? glsl? replay? serde? spirv? webgl?

Enables wgpu-core