Commit Graph

2761 Commits

Author SHA1 Message Date
Mikko Lehtonen
60af888c74 [rs] Add context to errors
ContextError is just a simple wrapper that contains a string and the original error, and it is used to decorate the error to give it more context.
2020-09-14 22:54:52 +03:00
Mikko Lehtonen
8252758674 Reverts the addition of LabeledContextError
Removed as discussed, moving them to wgpu-rs side
2020-09-14 22:45:10 +03:00
Kunal Mohan
d423d3d5d7 Allow dropping of error resources (#925)
* 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
2020-09-13 21:17:53 -04:00
bors[bot]
3c0634fdec [rs] Merge #562
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>
2020-09-13 04:28:57 +00:00
bors[bot]
f66bc8ff79 [rs] Merge #563
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>
2020-09-13 04:11:39 +00:00
Dzmitry Malyshau
c269703bcf [rs] Document the bind buffer alignment 2020-09-13 00:10:11 -04:00
Dzmitry Malyshau
24ad4af92c [rs] Update wgpu with Naga changes 2020-09-13 00:10:11 -04:00
bors[bot]
43adcbcf68 Merge #926
926: Update naga with new image API r=cwfitzgerald a=kvark

**Connections**
Gets us https://github.com/gfx-rs/naga/pull/187, https://github.com/gfx-rs/naga/pull/185, https://github.com/gfx-rs/naga/pull/182, partially https://github.com/gfx-rs/naga/pull/169, and https://github.com/gfx-rs/naga/pull/167

**Description**
Brings us to a point where all wgpu-rs shaders are successfully validated 🎉 

**Testing**
wgpu-rs examples

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-09-13 03:59:44 +00:00
Mikko Lehtonen
d0db3fc0a0 [rs] Errorsinkify CommandEncoder 2020-09-13 01:11:18 +03:00
Mikko Lehtonen
f5ab931aba [rs] Errorsinkify Texture 2020-09-12 23:26:35 +03:00
Mikko Lehtonen
d93d494582 [rs] Errorsinkify Buffer 2020-09-12 23:26:35 +03:00
bors[bot]
70732bb6ac [rs] Merge #559
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>
2020-09-11 20:04:31 +00:00
Dzmitry Malyshau
6a3c106cc4 Update naga with new image API 2020-09-11 12:34:20 -04:00
Dzmitry Malyshau
dd850b8156 [rs] Use implicit bind group layout in the mipmap example 2020-09-10 23:59:52 -04:00
Dzmitry Malyshau
72ab5f2809 [rs] Update wgpu with the polygon modes support, use in the cube example 2020-09-10 22:02:05 -04:00
bors[bot]
9edf44118e [rs] Merge #557
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>
2020-09-10 22:43:34 +00:00
bors[bot]
f6f7210b63 Merge #924
924: Unlock nightly builds on CI r=kvark a=kvark

See https://github.com/Xudong-Huang/generator-rs/issues/24

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2020-09-10 15:07:13 +00:00
Dzmitry Malyshau
fc27920fde Unlock nightly builds on CI 2020-09-10 11:04:24 -04:00
Rukai
0c213ec85d [rs] Pin web-sys version 2020-09-10 23:10:07 +10:00
bors[bot]
93ac56514a [rs] Merge #553
553: Add hello-windows example r=kvark a=qthree

# `hello-windows`
## Description

This is demonstration of ability to create multiple windows with differently colored backgrounds.

## Screenshot
![screenshot](https://user-images.githubusercontent.com/9898555/92568685-bc411c80-f2a9-11ea-9d4d-84bb236c40f9.png)

# `shared-textures` (old version)
## Description

This is demonstration of ability to create multiple windows and share single texture across all of them.
Available in ad3030ae8f61e3ea3f7b913cd03c366119d058fb commit.

## Screenshot
![screenshot](https://user-images.githubusercontent.com/9898555/92500037-cc63e800-f226-11ea-8f50-bfa02538cce5.png)


Co-authored-by: qthree <qthree3@gmail.com>
2020-09-10 04:34:35 +00:00
bors[bot]
67ee3d6678 [rs] Merge #555
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>
2020-09-10 04:25:18 +00:00
Joshua Groves
9d48bc26c0 [rs] Update to latest web-sys 2020-09-10 01:09:50 -02:30
qthree
5338992913 [rs] Add hello-windows example 2020-09-10 06:55:42 +07:00
bors[bot]
2972212d42 Merge #921
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>
2020-09-09 19:50:33 +00:00
Manuel Woelker
336d070b26 add polygon_mode: PolyonMode to RasterizationStateDescriptor to allow drawing wireframes 2020-09-09 21:34:37 +02:00
bors[bot]
8db3af7286 Merge #922
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>
2020-09-09 17:56:10 +00:00
Mikko Lehtonen
2fb8fc34d2 Add LabeledContextError
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.
2020-09-08 17:44:53 +03:00
bors[bot]
cc33e622cf [rs] Merge #551
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>
2020-09-08 13:40:45 +00:00
Rukai
3cfb3295cb [rs] Replace unsafe impl Pod with safe derive 2020-09-08 23:39:12 +10:00
bors[bot]
730313177e Merge #923
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>
2020-09-08 12:20:50 +00:00
Ben Frankel
2ee07a2a47 Fix invalid mip level count check 2020-09-07 16:49:06 -07:00
Dzmitry Malyshau
c69b03d32f [rs] Update wgpu to the latest DX11 fix 2020-09-06 20:41:24 -04:00
Dzmitry Malyshau
68bf10a3a5 Fix invalidated segment of the staging memory 2020-09-06 20:37:03 -04:00
bors[bot]
5cfdd4a135 Merge #920
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>
2020-09-06 02:22:02 +00:00
bors[bot]
9e81e3d6ef [rs] Merge #547
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>
2020-09-05 16:02:20 +00:00
Dzmitry Malyshau
eed8bf84ef Playtest for binding a group 2020-09-04 23:47:24 -04:00
Dzmitry Malyshau
1886149cae Don't bind groups that aren't expected by the layout 2020-09-04 23:47:24 -04:00
Mikko Lehtonen
e28bc9cbbb [rs] impl std error for Error
Relies more on the source() of error for informative messages
2020-09-05 01:29:03 +03:00
Mikko Lehtonen
4277bcab2c [rs] direct: ErrorSinkify Device methods 2020-09-05 00:21:53 +03:00
Mikko Lehtonen
03fda219e3 [rs] direct: Implement on_uncaptured_error
Currently the sink is used only in Device::create_shader_module and
Device::create_render_pipeline, to be expanded in future commits.
2020-09-05 00:21:47 +03:00
Mikko Lehtonen
506ee7a368 [rs] direct: Move Device to its own struct 2020-09-05 00:21:11 +03:00
Mikko Lehtonen
f987a82503 [rs] Add Device::on_captured_error
The implementation is dummy one
2020-09-03 09:37:09 +03:00
Mikko Lehtonen
117d323f71 [rs] Don't import Error directly 2020-09-03 09:34:10 +03:00
bors[bot]
1e7eec0686 [rs] Merge #548
548: wgpu update with correctness fixes r=kvark a=kvark

Picks up a few important correctness fixes, such as https://github.com/gfx-rs/wgpu/pull/916 and https://github.com/gfx-rs/wgpu/pull/912

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-09-02 20:47:07 +00:00
Dzmitry Malyshau
2ac4876361 [rs] wgpu update with correctness fixes 2020-09-02 16:45:20 -04:00
bors[bot]
3f1abf571e Merge #908
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>
2020-09-02 20:43:32 +00:00
bors[bot]
ad3657aba8 [rs] Merge #540
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):

![texture-arrays-non-uniform-bug](https://user-images.githubusercontent.com/18099621/91645079-8c00af00-ea5b-11ea-854a-ef5ab5a63ce2.png)

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>
2020-09-02 20:38:32 +00:00
bors[bot]
bbb9b84bd2 Merge #916
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>
2020-09-02 20:24:41 +00:00
Dzmitry Malyshau
35d2ed39b5 Flush staging init buffers 2020-09-02 15:58:32 -04:00
bors[bot]
6df8421f22 Merge #909
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>
2020-09-01 20:18:21 +00:00