* Allow dropping of error resources
* Unregister error resources without panic
Panic when removing Vacant element or when index is out of range
* address review comments
562: More errorsinkifying r=kvark a=scoopr
Continuing on with errorsinkifying more places, these wrap Buffer, Texture and CommandEncoder with a struct that includes the `error_sink`, and uses it for the error handling.
I think most of the apis are errorsinkified with this. The remaining ones may need some more thinking.
Queue would be wrapped mostly for the submit, the write_ stuff could in theory piggyback on the texture/buffer error-sink.
Others like swapchain, some mapping stuff, etc. needs some discussion or other implementation work.
Co-authored-by: Mikko Lehtonen <scoopr@iki.fi>
563: Document bind buffer alignment r=kvark a=kvark
Fixes #561
Also updates wgpu dependency to latest, and our exampels are now fully validated for the shader interface 🎉 .
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>
921: add `polygon_mode: PolyonMode` to `RasterizationStateDescriptor` to allow drawing wireframes r=kvark a=manuel-woelker
**Description**
This adds `polygon_mode: PolyonMode` to `RasterizationStateDescriptor` to allow drawing in wireframes and point mode
I added `hal::Features::NON_FILL_POLYGON_MODE` to the `wishful_features` in `instance.rs`. I don't know what side effects this might have.
**Testing**
Tested locally on my Windows machine with Vulkan backend.
Co-authored-by: Manuel Woelker <github@manuel.woelker.org>
922: Add LabeledContextError r=kvark a=scoopr
Purpose for this is to add more context to an error.
create_render_pipeline error is improved, by showing the action
(creating render pipeline) and the user provided label, to aid with
the investigation.
Example error
before:
```
wgpu error: Validation error
Caused by:
error in stage VERTEX: unable to find an entry point matching the Vertex execution model
thread 'main' panicked at 'Handling wgpu errors as fatal by default', src/backend/direct.rs:1457:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
after:
```
wgpu error: Validation error
Caused by:
Creating render pipeline (label: Some("hello-triangle pipeline"))
error in stage VERTEX
unable to find an entry point matching the Vertex execution model
thread 'main' panicked at 'Handling wgpu errors as fatal by default', src/backend/direct.rs:1457:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
Co-authored-by: Mikko Lehtonen <scoopr@iki.fi>
Purpose for this is to add more context to an error.
create_render_pipeline error is improved, by showing the action
(creating render pipeline) and the user provided label, to aid with
the investigation.
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>
923: Fix invalid mip level count check r=kvark a=benfrankel
**Connections**
Fixes https://github.com/gfx-rs/wgpu/issues/894
Continues from https://github.com/gfx-rs/wgpu/pull/893
**Description**
Invalid mip level counts are allowed through `Device::create_texture`, triggering Vulkan validation errors. A fix was applied in https://github.com/gfx-rs/wgpu/pull/893, but the fix needs a minor correction to work properly.
Also added back the `MAX_MIP_LEVELS` check, because it's technically possible for `MAX_MIP_LEVELS` to be less than `kind.compute_num_levels()`, e.g. if one of the given dimensions is very big (2^16).
Error message is updated to reflect the change in behavior: there are now three ways for a mip level count to be invalid: it's equal to zero; it's greater than `MAX_MIP_LEVELS`; or it's greater than the largest mip level count allowed for the given size.
**Testing**
Tested by manually modifying the `mipmap` example in `wgpu-rs` to pass various edge case values for `size` and `mip_level_count`.
Co-authored-by: Ben Frankel <ben.frankel7@gmail.com>
920: Don't bind groups that aren't expected by the layout r=grovesNL a=kvark
**Connections**
Sibling of #919 for master.
**Description**
**Testing**
In addition to the fix itself, this comes with a new regression playtest!
Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.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>
908: Clarify usage of SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING r=cwfitzgerald a=im-0
**Connections**
https://github.com/gfx-rs/wgpu-rs/pull/540
**Description**
This clarifies usage of SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING with GLSL.
**Testing**
This commit only changes documentation.
Co-authored-by: Ivan Mironov <mironov.ivan@gmail.com>
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>
916: Flush staging init buffers r=cwfitzgerald a=kvark
**Connections**
Related to https://github.com/gfx-rs/gfx/pull/3362
With the new use of `write_buffer`/`write_texture`, the results on D3D11 regressed.
**Description**
It just happened to be the case that all the backends returned coherent staging buffers, used internally for `write_*` and `mapped_at_creation == true`. However, D3D11 backend currently doesn't have the coherent memory at all, and it helped me to see that we were missing a flush() on the staging buffer.
**Testing**
Untested, but should work (tm).
Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
909: Add Quad play test r=kvark a=DevOrc
**Connections**
#807
**Description**
Adds a play test that renders a white quad to a texture. The texture is then copied to a buffer and checked for accuracy with a file of expected bytes (All 0xFF).
**Testing**
Cargo test succeeds
Co-authored-by: Noah Charlton <ncharlton002@gmail.com>