Cargo Features
wgpu-hal has no features set by default.
[dependencies]
wgpu-hal = { version = "25.0.1", features = ["metal", "vulkan", "gles", "dx12", "static-dxc", "renderdoc", "fragile-send-sync-non-atomic-wasm", "portable-atomic", "oom_panic", "device_lost_panic", "internal_error_panic", "cargo-clippy", "once_cell", "rustc-hash"] }
- metal
-
Backend Features
The interaction of features between wgpu-core and wgpu-hal is a bit nuanced to get the desired behavior on all platforms.
At the wgpu-hal level the features are defined to enable the backends on all platforms that can compile the backend. Vulkan for example will have an effect on Windows, Mac, Linux, and Android. This is done with target conditional dependencies in wgpu-hal. This allows
--all-features
to compile on all platforms.wgpu-core's features are defined to enable the backends on their "default" platforms. For example we exclude the Vulkan backend on MacOS unless a separate feature
vulkan-portability
is enabled. In response to these features, it enables features of platform specific crates. For example, thevulkan
feature in wgpu-core enables thevulkan
feature inwgpu-core-deps-windows-linux-android
which in turn enables thevulkan
feature inwgpu-hal
only on those platforms. If you enable thevulkan-portability
feature, it will enable thevulkan
feature inwgpu-core-deps-apple
. The only way to do this is unfortunately to have a separate crate for each platform category that participates in the feature unification.This trick doesn't work at the
wgpu
level, because thewgpu
->wgpu-core
dependency is conditional, making the Cargo.toml signifigantly more complicated in all areas.See https://github.com/gfx-rs/wgpu/issues/3514, https://github.com/gfx-rs/wgpu/pull/7076, and https://github.com/rust-lang/cargo/issues/1197 for more information.
Enables the Metal backend when targeting Apple platforms.
Enables objc and profiling, msl-out of naga and arrayvec, block, core-graphics-types ^0.1, hashbrown, libc, log, and metal ^0.31.0
arrayvec:
Target agnostic dependencies used only in backends.
- vulkan
-
Enables ordered-float >=3, <=4.6, profiling, and smallvec, android_system_properties, arrayvec, ash, bytemuck, gpu-alloc, gpu-descriptor, hashbrown, libc, libloading, and log, spv-out of naga, Win32 of windows ^0.58
- gles
-
Enables ndk-sys ^0.5.0, objc, profiling, wasm-bindgen, and web-sys, glsl-out of naga, Win32_Graphics_Gdi, Win32_Graphics_OpenGL, Win32_System_LibraryLoader and Win32_UI_WindowsAndMessaging of windows ^0.58 and arrayvec, bytemuck, cfg-if, glow, glutin_wgl_sys, hashbrown, js-sys, khronos-egl, libloading, and log
glow:
Backend: GLES
- dx12
-
Enables the DX12 backend when targeting Windows.
Enables windows-core ^0.58, arrayvec, bit-set, and bytemuck, hashbrown, libloading, and log, ordered-float >=3, <=4.6, profiling, and range-alloc, d3d12 of gpu-allocator, hlsl-out of naga, Win32_Graphics_Direct3D, Win32_Graphics_Direct3D12, Win32_Graphics_Direct3D_Dxc, Win32_Graphics_Direct3D_Fxc, Win32_Graphics_DirectComposition, Win32_Graphics_Dxgi_Common, Win32_Security, Win32_System_Diagnostics_Debug, Win32_System_Kernel, Win32_System_Performance, Win32_System_Threading and Win32_UI_WindowsAndMessaging of windows ^0.58
- static-dxc
-
Misc Other Features
Enables mach-dxcompiler-rs
- renderdoc
-
Enables libloading, log, and renderdoc-sys
- fragile-send-sync-non-atomic-wasm
-
Enables fragile-send-sync-non-atomic-wasm of wgpu-types
- portable-atomic
-
Enables portable-atomic
- oom_panic
-
Internal Debugging Features
Panic when running into an out-of-memory error (for debugging purposes).
Only affects the d3d12 and vulkan backends. - device_lost_panic
-
Panic when running into a device lost error (for debugging purposes).
Only affects the d3d12 and vulkan backends. - internal_error_panic
-
Panic when running into an internal error other than out-of-memory and device lost (for debugging purposes).
Only affects the d3d12 and vulkan backends. - cargo-clippy
-
Workarounds
objc's
msg_send
macro injects this in our code https://github.com/SSheldon/rust-objc/issues/125 You shouldn't ever enable this feature.
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.
Platform: All
- once_cell implicit feature
-
Enables once_cell
once_cell:
Single assignment cells and lazy values
- rustc-hash implicit feature
-
Enables rustc-hash ^1
rustc-hash:
A speedy, non-cryptographic hashing algorithm used by rustc
- gpu-allocator win dx12?