356: Add generic ranges to buffer mapping api and make it safe. r=kvark a=lachlansneff
[Rendered](https://charted.space/notes/wgpu-rs/wgpu/struct.Buffer.html)
The safety issues with the current api (being able to unmap while still holding a slice to mapped data) are fixed by having `get_mapped_range` and `get_mapped_range_mut` return `BufferView` and `BufferViewMut`, which notify the buffer that those ranges are no longer being used when they're dropped. `Buffer.unmap` asserts that the list of mapped ranges is empty, therefore it is safe.
Co-authored-by: Lachlan Sneff <lachlan.sneff@gmail.com>
Main change here is the introduction of the Context trait.
The "direct" implementation of it goes straight to wgpu-core.
This commit also has small improvements:
- consuming command buffers on submit
- Instance type
- proper call to destructors
When looking into wgpu-rs as a replacement for WebGL I went to the
examples directory on GitHub to browse for a bit.
I wanted to see some of the examples at a glance without needing to
clone the repository.
This commit enables that by adding a README to each example with a
description of the example and screenshots / example output.
In a few cases the description is a bit redundant - but my hope is that
in the future we can improve all the READMEs.
Being a web API and thus very accessible, WebGPU could end up being many
people's first introduction to graphics programming so the lower we make
the barrier the better.
262: Reverse srgb in hello-triangle r=kvark a=grovesNL
Reverse srgb support in hello-triangle (these were backwards by mistake)
Co-authored-by: Joshua Groves <josh@joshgroves.com>
`File::create` isn't available on wasm, so we can't actually write the
output image anywhere unless we target something else as the file
system (e.g. local storage)
Remove odd patching matching
Replace std::sync::Mutex with spin::Mutex in GpuFuture
Reduce GpuFuture usage to one explicit allocation instead of two
Fix examples to poll the device in the background when using map_read or map_write
Remove device.poll from GpuFuture::poll and document future invariants
Massively simplify examples
Use Arc::clone(...) instead of arc.clone()
Switch println to log::info
210: Update WGPU deps to rev 08e8d406c1 r=kvark a=aloucks
I also moved the `path` chunks in `Cargo.toml` to a single `[patch]` section so that it's one block to commment/uncomment for local development.
Co-authored-by: Aaron Loucks <aloucks@cofront.net>