mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-26 00:33:51 +00:00
Cross-platform, safe, pure-rust graphics api.
ba0acc94a1
427: Rewrite of the resource lifetime tracking r=crossed-fingers a=kvark Addresses this TODO item in `triage_referenced()`: > //TODO: lock less, if possible Now, also fixes #428 Pros: - only locking the storages that need to be, and only for the duration of their cleanup - less run-time branching, more predefined code paths, which may lead to better cache utilization (thinking of both instruction and data cache here) - more consistent use of `Stored` type Cons: - a bit of verbosity / code duplication in `triage_referenced()`. In particular, the code that finds where to register an unreferenced resource, it used to be unified for all resources. --- @grovesNL this should be reviewable on a commit basis. The high-level breakdown of changes is: 1. Switch from enum of resource types to structure of arrays for the matter of lifetime tracker 2. Rename the involved structures to better reflect what they do (the old `PendingResources` was bad) 3. Separate lifetime tracking into a sub-module 4. Make `RefCount` in objects optional, getting the semantics of "user needs it" when `Some`. 5. Rewrite the first stage of lifetime tracking: instead of permanently staging resources that the user doesn't need, and adding strong refcounts to them, we only populate it temporarily with anything that gets the refcount reduced. This means less overhead for `maintain()` at an increased risk of leaking some stuff (depends on our code quality). 6. Consequently, device tracker becomes the main (and last) owner of all the resources. Overall, it's a major change and risk. I tested on `vange-rs` (which I consider to be the most complex wgpu-rs app) with Vulkan validation enabled, and it seems all to be working good now. Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com> |
||
---|---|---|
examples | ||
ffi | ||
wgpu-core | ||
wgpu-native | ||
wgpu-remote | ||
.clang-format | ||
.gitignore | ||
.travis.yml | ||
bors.toml | ||
Cargo.lock | ||
Cargo.toml | ||
CHANGELOG.md | ||
LICENSE | ||
Makefile | ||
README.md | ||
rustfmt.toml |
This is an active GitHub mirror of the WebGPU native implementation in Rust, which now lives in Mozilla-central. Issues and pull requests are accepted, but we merge them in m-c manually and then sync to GitHub instead of landing directly here.
WebGPU
This is an experimental WebGPU implementation as a native static library. It's written in Rust and is based on gfx-hal and Rendy libraries. The corresponding WebIDL specification can be found at gpuweb project.
The implementation consists of the following parts:
wgpu-core
- internal Rust API for WebGPU implementations to usewgpu-native
- the native implementation of WebGPU as a C API librarywgpu-remote
- remoting layer to work with WebGPU across the process boundaryffi
- the C headers generated by cbindgen for both of the libraries
Supported Platforms
API | Windows | Linux | macOS & iOS |
---|---|---|---|
DX11 | ✔️ | ||
DX12 | ✔️ | ||
Vulkan | ✔️ | ✔️ | |
Metal | ✔️ | ||
OpenGL |
Usage
This repository contains C-language examples that link to the native library targets and perform basic rendering and computation. Please refer to our Getting Started page at the wiki for more information.
Bindings:
- https://github.com/gfx-rs/wgpu-rs - idiomatic Rust wrapper with a few more examples to get a feel of the API
- https://github.com/almarklein/wgpu-py - experimental Python wrapper
- https://nest.pijul.com/porky11/wgpu - experimental Scopes wrapper