Thanks to visit codestin.com
Credit goes to lib.rs

Cargo Features

[dependencies]
wgpu = { version = "26.0.1", default-features = false, features = ["dx12", "metal", "vulkan", "gles", "webgpu", "angle", "vulkan-portability", "webgl", "noop", "custom", "spirv", "glsl", "wgsl", "naga-ir", "strict_asserts", "serde", "static-dxc", "counters", "fragile-send-sync-non-atomic-wasm", "web", "std", "parking_lot"] }
default = dx12, gles, metal, parking_lot, std, vulkan, webgpu, wgsl

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

dx12 default

Backends


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

vulkan default

Enables the Vulkan backend on Windows, Linux, and Android.

Enables vulkan of optional wgpu-core

gles default

Enables the OpenGL/GLES backend on Windows, Linux, Android, and Emscripten.

Enables gles of optional wgpu-core

webgpu default = web

Enables the WebGPU backend on WebAssembly.

Enables wasm-bindgen-futures, Document, Event, Navigator, NodeList, Window, WorkerGlobalScope and WorkerNavigator of web-sys, wgsl-out of optional naga

angle

Conditional Backends

Enables the GLES backend on macOS only for use with ANGLE.

Enables angle of optional wgpu-core

vulkan-portability

Enables the Vulkan backend on macOS & iOS only for use with MoltenVK.

Enables vulkan-portability of optional wgpu-core

webgl = web

Enables the GLES backend on WebAssembly only.

Enables smallvec, wgpu-hal, webgl of wgpu-core

noop

Enables the noop backend for testing.

This backend allows creating resources such as buffers and textures, but performs no computation. Because it lacks basic functionality, it is only actually used if explicitly enabled through NoopBackendOptions.

Enables smallvec, wgpu-hal, noop of wgpu-core

custom

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.

spirv

Shading language support


These features enable support for that input language on all platforms. We will translate the input language to whatever the backend requires.

Enable accepting SPIR-V shaders as input.

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

Affects util::make_spirv

glsl

Enable accepting GLSL shaders as input.

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

wgsl default

Enable accepting WGSL shaders as input.

Enables wgsl of optional wgpu-core

Affects dispatch::InstanceInterface.wgsl_language_features

naga-ir

Enable accepting naga IR shaders as input.

Enables naga

strict_asserts

Assertions and Serialization


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

Enables serialization via serde on common wgpu types.

Enables serde of optional wgpu-core and wgpu-types

static-dxc

External libraries


The following features facilitate integration with third-party supporting libraries.

Enables statically linking DXC.

Normally, to use the modern DXC shader compiler with WGPU, the final application must be shipped alongside dxcompiler.dll (min v1.8.2502) (which can be downloaded from Microsoft's GitHub). This feature statically links a version of DXC so that no external binaries are required to compile DX12 shaders.

Enables static-dxc of optional 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 optional 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 is a definitionally single-threaded environment.

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

web webgl? webgpu

Use web-specific libraries on WASM

Those libraties (wasm-bindgen, web-sys, js-sys) can only be used when there is a JavaScript context around the WASM VM, e.g., when the WASM binary is used in a browser.

Enables js-sys, wasm-bindgen, and web-sys, web of wgpu-types

std default

Enables use of the standard library within wgpu and its dependencies.

This can allow for better error reporting and for improved multithreading support.

Enables std of raw-window-handle, optional wgpu-core, and wgpu-types

parking_lot default

Uses parking_lot as the implementation for locking primitives.

This is a recommended feature for most users and should only be disabled when required, e.g., for no_std support. If disabled, either std::sync::Mutex or core::cell::RefCell will be used, based on whether std is enabled or not.

Enables parking_lot

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.

Standard Dependencies

wgpu-core noop? webgl?