mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
Cross-platform, safe, pure-rust graphics api.
0f592b4443
34: Basic windowing and presentation r=grovesNL a=kvark - [x] native swapchain creation - [x] native use of frames and presentation - [x] native semaphore waits - [x] rust wrapping - [x] working examples ~~I may or may not bite the bullet and update gfx-rs here. Probably not :)~~ ## Architecture There is a bit of complexity here to manage all the synchronization and lifetimes properly. Essentially, presentation is exposed in Vulkan/gfx-rs as a separate hidden queue, so we inevitably run into the territory of using semaphores for synchronization, where previously we could ignore them for workloads on a single queue. A swapchain has a fixed (at creation) number of frames, each represented by a texture plus view pair. When `get_next_texture` is called we acquire the next image index and return this pair. We wait for the associated fence to make sure the frame is no image used. We then associate a semaphore with this index for image availability. The texture has extra information to link back to an image of the swapchain (which is `None` for regular textures). Whenever it's used, the command buffer collects that link to be used on submission, where it's just resolved to a semaphore that we wait on actual submission. Presenting on a swapchain creates a temporary command buffer that we only use for transiting the swapchain image into presentable state. This small submission is useful for establishing a "ready" semaphore as well as a fence (waited in `get_next_image`). The "ready" semaphore is used immediately for native `present` call. Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com> Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com> |
||
---|---|---|
examples | ||
wgpu-bindings | ||
wgpu-native | ||
wgpu-rs | ||
.gitignore | ||
.travis.yml | ||
bors.toml | ||
Cargo.lock | ||
Cargo.toml | ||
LICENSE | ||
Makefile | ||
README.md | ||
rustfmt.toml |
WebGPU
This is an experimental WebGPU implementation as a native static library. It's written in Rust and is based on gfx-hal and satellite libraries. The corresponding WebIDL specification can be found at gpuweb project.
The implementation consists of the following parts:
wgpu-native
- the native implementation of WebGPU as a C API librarywgpu-bindings
- automatic generator of actual C headerswgpu-remote
- remoting layer to work with WebGPU across the process boundarywgpu-rs
- idiomatic Rust wrapper of the native library