28 releases (6 breaking)

new 0.11.2 Oct 22, 2021
0.10.4 Sep 23, 2021
0.9.2 Jul 17, 2021
0.7.1 Feb 25, 2021
0.5.6 Jul 9, 2020

#191 in Graphics APIs

Download history 10270/week @ 2021-07-06 10784/week @ 2021-07-13 10963/week @ 2021-07-20 12095/week @ 2021-07-27 10218/week @ 2021-08-03 11484/week @ 2021-08-10 11592/week @ 2021-08-17 12843/week @ 2021-08-24 10901/week @ 2021-08-31 11164/week @ 2021-09-07 11067/week @ 2021-09-14 11626/week @ 2021-09-21 11199/week @ 2021-09-28 13841/week @ 2021-10-05 10545/week @ 2021-10-12 11833/week @ 2021-10-19

49,213 downloads per month
Used in 190 crates (3 directly)

MIT/Apache

2MB
41K SLoC

wgpu

Matrix Matrix Build Status codecov.io

This is an implementation of WebGPU API in Rust, targeting both native and the Web. See the upstream WebGPU specification (work in progress).

The repository hosts the following parts:

  • Crates.io docs.rs - public Rust API for users
  • Crates.io docs.rs - internal Rust API for WebGPU implementations to use
  • Crates.io docs.rs - internal unsafe GPU abstraction API
  • Crates.io - program that prints out information about all the adapters on the system or invokes a command for every adapter.
  • Crates.io docs.rs - Rust types shared between wgpu-core and wgpu-rs
  • player - standalone application for replaying the API traces, uses winit

Rust examples can be found at wgpu/examples. wgpu is a default member, so you can run the examples directly from the root, e.g. cargo run --example boids.

If you are looking for the native implementation or bindings to the API in other languages, you need wgpu-native.

Supported Platforms

API Windows 7/10 Linux & Android macOS & iOS
DX11 🚧
DX12 🆗
Vulkan
Metal
GLes3 🆗

✅ = Primary support — 🆗 = Secondary support — 🚧 = Unsupported, but support in progress

Testing Infrastructure

wgpu features a set of unit, integration, and example based tests. All framework based examples are automatically reftested against the screenshot in the example directory. The wgpu-info example contains the logic which can automatically run the tests multiple times for all the adapters present on the system. These tests are also run on CI on windows and linux over Vulkan/DX12/DX11/GL on software adapters.

To run the test suite, run the following command:

cargo run --bin wgpu-info -- cargo test --no-fail-fast

To run any individual test on a specific adapter, populate the following environment variables:

  • WGPU_ADAPTER_NAME with a substring of the name of the adapter you want to use (ex. "1080" will match "NVIDIA GeForce 1080ti").
  • WGPU_BACKEND with the name of the backend you want to use (vulkan, metal, dx12, dx11, or gl).

Then to run an example's reftests, run:

cargo test --example <example-name> --no-fail-fast

Or run a part of the integration test suite:

cargo test -p wgpu -- <name-of-test>

If you are a user and want a way to help contribute to wgpu, we always need more help writing test cases.

Coordinate Systems

wgpu uses the coordinate systems of DX and Metal:

Render Depth Texture
render_coordinates depth_coordinates texture_coordinates

Dependencies

~5.5–8.5MB
~149K SLoC