559: Update wgpu with the polygon modes support, use in the cube example r=cwfitzgerald a=kvark
Uses https://github.com/gfx-rs/wgpu/pull/921, cc @manuel-woelker
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
557: Pin web-sys version r=grovesNL a=rukai
As mentioned in https://github.com/gfx-rs/wgpu-rs/pull/553 this will prevent the wasm build from breaking.
@grovesNL Is pinning just web-sys and wasm-bindgen sufficient?
Co-authored-by: Rukai <rubickent@gmail.com>
555: Update to latest web-sys r=kvark a=grovesNL
Cherry-pick #497 into `master` now that new versions of web-sys/wasm-bindgen/js-sys/wasm-bindgen-futures are published.
We could also do this for `v0.6` too if we want CI to succeed there, or alternatively consider disabling CI for wasm builds on `v0.6`.
Co-authored-by: Joshua Groves <josh@joshgroves.com>
551: Replace unsafe impl Pod with safe derive r=kvark a=rukai
bytemuck now includes derives that will implement the Pod trait, failing to compile if the struct cannot safely be a Pod.
Lets use it to remove most of the unsafe usage from the examples.
closes https://github.com/gfx-rs/wgpu-rs/issues/190
Co-authored-by: Rukai <rubickent@gmail.com>
547: Implement on_uncaptured_error r=kvark,cwfitzgerald a=scoopr
This is very crude at the moment, I'm mostly just checking if the directions is at all viable.
So I set out to implement `on_caught_error`, focusing solely on the direct backend. It just accepts a `Fn(GPUError)` (and I named it GPUError because I didn't yet want to rename the import of `std::error::Error`).
I store the handler in a `ErrorSinkRaw` struct, which is then wrapped in Arc+Mutex, with the idea that other resources can point to the same Arc, so when `Device::on_uncaught_error` is called mid application, all resources will point to the right place. Otherwise I think something like `Buffer::unmap` would have to find the `Device` it was created with, to find the uncaught handler.
Now I store the `ErrorSink` in the `Device` struct, because it is a convenient place to hold it. But I guess it is a bit nonsensical with the web backend, so either it would need to be `cfg(not(wasm32))`, or move the whole thing in the backend side, but in the direct backend, I don't see a convenient place to store the closure. But the unwrapping is done in direct backend, so it can't really be moved up in to wgpu-core either, unless the error handling overall is moved there.
Also related, I'm now passing the `error_sink` argument to the few methods where I implemented the error handling, which I think is a bit ugly, but it works.
Co-authored-by: Mikko Lehtonen <scoopr@iki.fi>
540: Improve and fix examples/texture-arrays r=cwfitzgerald a=im-0
Original examples/texture-arrays produces following output on my machine (Linux, Mesa/RADV 20.2-rc3, Radeon VII):

Quick investigation showed that only shaders with non-uniform indexing are problematic (first commit helped with this). Then, after searching on the web, I figured out that the problem is in missing `nonuniformEXT`. Second commit fixes this.
I am new to graphics programming, and `nonuniformEXT` may work just by accident. So please confirm my finding before merging.
Co-authored-by: Ivan Mironov <mironov.ivan@gmail.com>
545: Remove bake.frag from shadow example r=kvark a=yutannihilation
Now that `fragment_stage` is a `Option`, I guess this is the case when we don't need fragment shader.
Co-authored-by: Hiroaki Yutani <yutani.ini@gmail.com>
* The conditional at the start of resize() already tests for and exits on the zero width and height condition.
The conditional removed here was then getting run on every other call to resize(), which doesn't seem logical, doesn't correspond to the comment, and seemed to be causing at least one issue with rendered viewport going black during resize.
Fixes#532
(probably) Fixes#519
* Defensive coding to prevent various issues when window size goes to zero, e.g. NaN being passed in cgmath::perspective() aspect ratio parameter.
Fixes#531
523: Change buffer binding to not take a slice r=cwfitzgerald,grovesNL a=kvark
This has been a constant source of confusion w.r.t dynamic offsets.
What it looks like it's doing: user provides a slice of buffer visible to the shader. Just like they provide slices to vertex and index buffer bindings.
What it's actually doing: it takes the offset and size separately, modifying the offset later on based on the dynamic offset.
We don't need this confusion. Semantics is different from `BufferSlice` and so we should have a different API here.
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
517: Added some explanatory comments to hello-compute example r=kvark a=JonathanWoollett-Light
Simply added some more comments explaing the basic compute example.
Also moved the lines:
```rust
let slice_size = numbers.len() * std::mem::size_of::<u32>();
let size = slice_size as wgpu::BufferAddress;
```
To be just before where they are used.
Co-authored-by: Jonathan Woollett-Light <jonathanwoollettlight@gmai.com>
512: Convert to using independent subscriber implementation r=kvark a=cwfitzgerald
https://github.com/gfx-rs/wgpu/pull/881 but for wgpu-rs.
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>