Cargo Features
[dependencies]
wgpu = { version = "23.0.1", 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
somewhere in the dependency tree.default-features = false - 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.
- metal default
-
Enables the Metal backend on macOS & iOS.
- webgpu default
-
Enables the WebGPU backend on Wasm. Disabled when targeting
emscripten
. - angle
-
Enables the GLES backend via ANGLE on macOS using.
- vulkan-portability
-
Enables the Vulkan backend on macOS & iOS.
- webgl
-
Enables the GLES backend on Wasm
* ⚠️ WIP: Currently will also enable GLES dependencies on any other targets. - 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.
- wgsl default
-
Enable accepting WGSL shaders as input.
- 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. - replay = serde
-
Allow deserializing of trace capture files that were written with the
trace
feature. To replay a trace file use the wgpu player. - 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.
- fragile-send-sync-non-atomic-wasm
-
Implement
Send
andSync
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
andSync
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.