[package] name = "wgpu" version.workspace = true authors.workspace = true edition.workspace = true description = "Rusty WebGPU API wrapper" homepage.workspace = true repository.workspace = true keywords.workspace = true license.workspace = true readme = "../README.md" exclude = ["Cargo.lock"] [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] targets = [ "x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "wasm32-unknown-unknown", ] [package.metadata.cargo-machete] # Cargo machete can't check build.rs dependencies. See https://github.com/bnjbvr/cargo-machete/issues/100 ignored = ["cfg_aliases"] [lib] [features] default = ["wgsl", "dx12", "metal", "webgpu"] #! ### Backends # -------------------------------------------------------------------- #! ⚠️ WIP: Not all backends can be manually configured today. #! On Windows, Linux & Android the Vulkan & GLES backends are always enabled. #! See [#3514](https://github.com/gfx-rs/wgpu/issues/3514) for more details. ## Enables the DX12 backend on Windows. dx12 = ["wgc?/dx12"] ## Enables the Metal backend on macOS & iOS. metal = ["wgc?/metal"] ## Enables the WebGPU backend on Wasm. Disabled when targeting `emscripten`. webgpu = ["naga?/wgsl-out"] ## Enables the GLES backend via [ANGLE](https://github.com/google/angle) on macOS using. angle = ["wgc?/gles"] ## Enables the Vulkan backend on macOS & iOS. vulkan-portability = ["wgc?/vulkan"] ## Enables the GLES backend on Wasm ## ## * ⚠️ WIP: Currently will also enable GLES dependencies on any other targets. webgl = ["dep:hal", "wgc/gles"] #! **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. spirv = ["naga/spv-in", "wgc/spirv"] ## Enable accepting GLSL shaders as input. glsl = ["naga/glsl-in", "wgc/glsl"] ## Enable accepting WGSL shaders as input. wgsl = ["wgc?/wgsl"] ## Enable accepting naga IR shaders as input. naga-ir = ["dep:naga"] #! ### 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. strict_asserts = ["wgc?/strict_asserts", "wgt/strict_asserts"] ## Enables serialization via `serde` on common wgpu types. serde = ["dep:serde", "wgc/serde"] # Uncomment once we get to https://github.com/gfx-rs/wgpu/issues/5974 # ## Allow writing of trace capture files. See [`Adapter::request_device`]. # trace = ["serde", "wgc/trace"] ## Allow deserializing of trace capture files that were written with the `trace` feature. ## To replay a trace file use the [wgpu player](https://github.com/gfx-rs/wgpu/tree/trunk/player). replay = ["serde", "wgc/replay"] #! ### 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. counters = ["wgc/counters"] ## 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. fragile-send-sync-non-atomic-wasm = [ "hal/fragile-send-sync-non-atomic-wasm", "wgc/fragile-send-sync-non-atomic-wasm", "wgt/fragile-send-sync-non-atomic-wasm", ] # wgpu-core is always available as an optional dependency, "wgc". # Whenever wgpu-core is selected, we want raw window handle support. [dependencies.wgc] optional = true workspace = true features = ["raw-window-handle"] # wgpu-core is required whenever not targeting web APIs directly. # Whenever wgpu-core is selected, we want raw window handle support. [target.'cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))'.dependencies.wgc] workspace = true features = ["raw-window-handle"] # If we are not targeting WebGL, enable indirect-validation. # WebGL doesn't support indirect execution so this is not needed. [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc] workspace = true features = ["indirect-validation"] # Enable `wgc` by default on macOS and iOS to allow the `metal` crate feature to # enable the Metal backend while being no-op on other targets. [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc] workspace = true # We want the wgpu-core Direct3D backend and OpenGL (via WGL) on Windows. [target.'cfg(windows)'.dependencies.wgc] workspace = true features = ["gles"] # We want the wgpu-core Vulkan backend on Unix (but not emscripten, macOS, iOS) and Windows. [target.'cfg(any(windows, all(unix, not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc] workspace = true features = ["vulkan"] # We want the wgpu-core GLES backend on Unix (but not macOS, iOS). [target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies.wgc] workspace = true features = ["gles"] [dependencies.wgt] workspace = true # We need wgpu-hal unless we're targeting the web APIs. [target.'cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))'.dependencies] hal = { workspace = true } [target.'cfg(all(not(target_arch = "wasm32"), unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies] hal = { workspace = true, features = ["renderdoc"] } [target.'cfg(windows)'.dependencies] hal = { workspace = true, features = ["renderdoc"] } [target.'cfg(target_arch = "wasm32")'.dependencies.hal] workspace = true optional = true [dependencies] arrayvec.workspace = true document-features.workspace = true log.workspace = true parking_lot.workspace = true profiling.workspace = true raw-window-handle = { workspace = true, features = ["std"] } serde = { workspace = true, features = ["derive"], optional = true } smallvec.workspace = true static_assertions.workspace = true [dependencies.naga] workspace = true optional = true [build-dependencies] cfg_aliases.workspace = true # used to test all the example shaders [dev-dependencies.naga] workspace = true features = ["wgsl-in"] [target.'cfg(target_arch = "wasm32")'.dependencies] web-sys = { workspace = true, features = [ "Document", "Navigator", "Node", "NodeList", "HtmlCanvasElement", "OffscreenCanvas", "ImageBitmap", "ImageBitmapRenderingContext", "Window", "WorkerGlobalScope", "WorkerNavigator", # Needed by webgpu_sys "Event", "EventTarget", ] } wasm-bindgen.workspace = true js-sys.workspace = true wasm-bindgen-futures.workspace = true parking_lot.workspace = true