Commit Graph

1304 Commits

Author SHA1 Message Date
Dzmitry Malyshau
f18fa7ef9b Derive bind group layout entries in Naga validation 2020-08-08 01:09:41 -04:00
bors[bot]
430b29d781
Merge #866
866: Streghten the multi-ref-count on BGLs r=cwfitzgerald a=kvark

**Connections**
Fixes #834

**Description**
Bind group layouts (BGLs) have to be somewhat uniquely tracked, and there was a synchronization issue with their use of `MultiRefCount`. What would happen in multi-thread environment is that we'd see `bind_group_layout_drop`, which first decreases the refcount, and then adds the ID to the list of suspected resources for deletion. But between these operations, something else may have triggered the triage of suspected resources, and if BGL was already there previously, it would be removed earlier than expected.

The solution I came up with is deferring the "dec()" call until the triage itself. That guarantees no gaps, and in fact it goes in line with the other resources we are tracking. I'm fairly confident that the new method works correctly at all times.

**Testing**
Tested extensively on https://github.com/gfx-rs/wgpu/issues/834#issuecomment-669362572

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-08-05 21:46:20 +00:00
Dzmitry Malyshau
8731da278e Streghten the multi-ref-count on BGLs 2020-08-05 17:39:25 -04:00
bors[bot]
8057acf120
Merge #865
865: Replace u32 with NonZeroU32 in TextureView r=kvark a=kunalmohan

**Connections**
_Link to the issues addressed by this PR, or dependent PRs in other repositories_

**Description**
_Describe what problem this is solving, and how it's solved._
We now expose separate methods under `Global` to register error/invalid resources. So the check for `mip_level_count = 0` and `array_layer_count = 0` can be made on the client-side in Servo, and directly register an error resource instead of trying to create a real one.

**Testing**
_Explain how this change is tested._
Not yet tested. Will be done wgpu-rs examples.
<!--
Non-trivial functional changes would need to be tested through:
  - [wgpu-rs](https://github.com/gfx-rs/wgpu-rs) - test the examples.
  - [wgpu-native](https://github.com/gfx-rs/wgpu-native/) - check the generated C header for sanity.

Ideally, a PR needs to link to the draft PRs in these projects with relevant modifications.
See https://github.com/gfx-rs/wgpu/pull/666 for an example.
If you can add a unit/integration test here in `wgpu`, that would be best.
-->


Co-authored-by: Kunal Mohan <kunalmohan99@gmail.com>
2020-08-05 17:10:47 +00:00
Kunal Mohan
aa44969818 Replace u32 with NonZeroU32 in TextureView 2020-08-05 21:23:25 +05:30
bors[bot]
fc14f3d21d
Merge #864
864: Remove `power` module r=kvark a=GabrielMajeri

**Connections**
Closes #859 

**Description**
Removes the `power.rs` module. If the user wants to detect the battery status and choose between low-power and high-performance, they can do so themselves.

**Testing**
Tested with core.

Co-authored-by: Gabriel Majeri <gabriel.majeri6@gmail.com>
2020-08-05 13:46:34 +00:00
Gabriel Majeri
021251a908 Remove power module 2020-08-05 16:27:41 +03:00
bors[bot]
78546f410d
Merge #857
857: Separate valid internal IDs from external ones r=cwfitzgerald a=kvark

**Connections**
Closes #638 
wgpu-rs update - https://github.com/gfx-rs/wgpu-rs/pull/494

**Description**
The core change here is to allow user-specified IDs to be in the "Error" state that was introduced in #776 .

This is done by defining an internal `Valid<I>` wrapper. Now, the hub storages can be indexed by this valid wrapper only. For regular IDs, we have to go through `storage.get(index)`, which returns a `Result`. It still panics if the ID is totally garbage though, we don't want to handle what can't be expected here.

All the other changes come mostly as a consequence of that:
  - new "Invalid*" error variants are added
  - the error types are undergone sever refactoring
  - new `command/draw.rs` module for stuff shared between render passes and bundles
  - functions to generate error IDs for all the types
  - various renames, e.g. `comb` -> `cmd_buf`

The expected use by wgpu-rs is unchanged. So far, I don't think we'd be generating Error IDs, but we can always reconsider.
For browsers though, if `device_create_xxx` failed, they would generate and error ID. It will occupy the slot up until the corresponding JS object is dropped.

**Testing**
Tested on wgpu-rs examples

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-08-04 20:51:11 +00:00
Dzmitry Malyshau
dbd7e2c579 Separate valid internal IDs from external ones 2020-08-04 11:16:59 -04:00
bors[bot]
5d35936d5c
Merge #856
856: Implementation of the builder pattern r=kvark a=Andful

**Connections**
This pull request addresses the issue #851 

**Description**
Add a builder for wgpu types.

**Testing**
TODO
<!--
Non-trivial functional changes would need to be tested through:
  - [wgpu-rs](https://github.com/gfx-rs/wgpu-rs) - test the examples.
  - [wgpu-native](https://github.com/gfx-rs/wgpu-native/) - check the generated C header for sanity.

Ideally, a PR needs to link to the draft PRs in these projects with relevant modifications.
See https://github.com/gfx-rs/wgpu/pull/666 for an example.
If you can add a unit/integration test here in `wgpu`, that would be best.
-->


Co-authored-by: Andrea Nardi <buongiorno19972@gmail.com>
2020-08-02 03:51:58 +00:00
Andrea Nardi
acfbbb42b5 Implementation of the builder pattern
Signed-off-by: Andrea Nardi <buongiorno19972@gmail.com>
2020-08-02 05:49:10 +02:00
bors[bot]
872a6c4c2b
Merge #860
860: Update naga and fix type widths r=mechanical a=kvark

**Connections**
Related to https://github.com/gfx-rs/naga/pull/98

**Description**
Naga's "width" has type `Bytes`, so we should treat it as such.

**Testing**
How did it use to work? Oh right, it didn't.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-08-01 03:48:19 +00:00
Dzmitry Malyshau
3291b72368 Update naga and fix type widths 2020-07-31 23:46:19 -04:00
bors[bot]
b352093988
Merge #855
855: Fix multi-layer copies r=kvark a=cwfitzgerald

**Description**

When copying multiple layers at the same time, we ignored 

**Testing**

Tested on the skybox example with BC1 textures doing all layer copies.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-07-30 21:07:40 +00:00
Connor Fitzgerald
00a5be7f7b Fix multi-layer copies 2020-07-30 16:58:29 -04:00
bors[bot]
9e4839eb04
Merge #854
854: Replace NonZeroU32 with u32 in TextureViewDescriptor r=kvark a=kunalmohan

**Connections**
_Link to the issues addressed by this PR, or dependent PRs in other repositories_

**Description**
_Describe what problem this is solving, and how it's solved._

**Testing**
_Explain how this change is tested._
Not yet tested
<!--
Non-trivial functional changes would need to be tested through:
  - [wgpu-rs](https://github.com/gfx-rs/wgpu-rs) - test the examples.
  - [wgpu-native](https://github.com/gfx-rs/wgpu-native/) - check the generated C header for sanity.

Ideally, a PR needs to link to the draft PRs in these projects with relevant modifications.
See https://github.com/gfx-rs/wgpu/pull/666 for an example.
If you can add a unit/integration test here in `wgpu`, that would be best.
-->

r?@kvark


Co-authored-by: Kunal Mohan <kunalmohan99@gmail.com>
2020-07-30 16:10:29 +00:00
Kunal Mohan
c8360152cd Replace NonZeroU32 with u32 in TextureViewDescriptor 2020-07-30 21:35:07 +05:30
bors[bot]
0e27959404
Merge #853
853: Implement TEXTURE_COMPRESSION_BC extension r=kvark a=cwfitzgerald

**Connections**

Closes #852.

**Description**

Adds support for BCn textures as specified in the upstream issue. This also shores up the validation and copy logic to work well with the block oriented nature of compressed textures. ETC2 and ASTC should fall out of this easily.

**Testing**

No wgpu-rs changes were needed, however I tested it with the following changes in wgpu-rs: 96c05ef4bf.


Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-07-30 02:57:12 +00:00
Connor Fitzgerald
e5c647745e Implement TEXTURE_COMPRESSION_BC extension 2020-07-29 18:43:50 -04:00
bors[bot]
43aa8b11b2
Merge #840
840: Add builder for TextureDescriptor r=kvark a=cwfitzgerald

**Connections**

https://github.com/gfx-rs/wgpu-rs/issues/478 https://github.com/gfx-rs/wgpu-rs/issues/470

**Description**

Adds a mut based builder pattern to TextureDescriptor as a test.

**Testing**

Will test in wgpu-rs...


Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-07-29 18:28:46 +00:00
Connor Fitzgerald
d5f23f9323 Add builder for TextureDescriptor 2020-07-29 14:28:03 -04:00
bors[bot]
f6ba5b8298
Merge #845
845: Finish error model refactor r=kvark a=GabrielMajeri

**Connections**
I think this is the last part of #638. I've reviewed all the remaining `unwrap`s and `assert`s in the code, and these should be the last ones left which ought to return errors (the remaining ones seem to uphold internal invariants).

**Description**
Implements error handling for various conditions, which are then returned to the caller. Including, but not limited to:
- running out of memory when creating a command pool
- running out of memory when creating a frame buffer for a render pass
- invalid dimensions when creating a texture

**Testing**
Tested with core and player.

Co-authored-by: Gabriel Majeri <gabriel.majeri6@gmail.com>
2020-07-29 18:10:33 +00:00
bors[bot]
75292f3f56
Merge #844
844: Add mip level count and array layer count validation to texture_create_view r=kvark a=kunalmohan

**Connections**
_Link to the issues addressed by this PR, or dependent PRs in other repositories_

**Description**
_Describe what problem this is solving, and how it's solved._
Catches the error when `mip_level_count = 0` and `base_mip_level > texture.mip_level_count` (same with `array_layer_count`)

**Testing**
_Explain how this change is tested._
Haven't been tested yet
<!--
Non-trivial functional changes would need to be tested through:
  - [wgpu-rs](https://github.com/gfx-rs/wgpu-rs) - test the examples.
  - [wgpu-native](https://github.com/gfx-rs/wgpu-native/) - check the generated C header for sanity.

Ideally, a PR needs to link to the draft PRs in these projects with relevant modifications.
See https://github.com/gfx-rs/wgpu/pull/666 for an example.
If you can add a unit/integration test here in `wgpu`, that would be best.
-->


Co-authored-by: Kunal Mohan <kunalmohan99@gmail.com>
2020-07-29 17:35:40 +00:00
Gabriel Majeri
a5f72d26d3 Handle DeviceLost in triage_submissions 2020-07-29 20:17:48 +03:00
Gabriel Majeri
62f1f9c438 Error types for conv module 2020-07-29 20:17:46 +03:00
Kunal Mohan
0ef76a7643 Add mip level count and array layer count validation to texture_create_view 2020-07-29 21:47:28 +05:30
Gabriel Majeri
2f06d3e4f9 Return out of memory condition from render pass 2020-07-29 09:58:46 +03:00
Gabriel Majeri
e860dd995f Handle command pool creation error 2020-07-29 09:56:42 +03:00
bors[bot]
9929b8719f
Merge #846
846: Make level and layer count for texture view optional r=cwfitzgerald a=kvark

**Connections**
implements https://github.com/gpuweb/gpuweb/pull/945

**Description**
`NonZeroU32` is more idiomatic here

**Testing**
untested, but should work

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2020-07-29 03:04:18 +00:00
Dzmitry Malyshau
d2c1e725db Make level and layer count for texture view optional 2020-07-28 22:55:39 -04:00
bors[bot]
0dcd1e1204
Merge #847
847: Gecko-requested refactor r=cwfitzgerald a=kvark



Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2020-07-28 21:01:27 +00:00
Dzmitry Malyshau
bf862b7907 Clarity renames according to the Gecko review 2020-07-28 16:58:28 -04:00
bors[bot]
5bd24d5085
Merge #843
843: Reformat the alignment errors, add a stride check r=GabrielMajeri a=kvark

**Connections**
Addresses [one of the things](https://community-tc.services.mozilla.com/tasks/JQlmdXSiSK2ufM7mX8F1Tg/runs/0/logs/https%3A%2F%2Fcommunity-tc.services.mozilla.com%2Fapi%2Fqueue%2Fv1%2Ftask%2FJQlmdXSiSK2ufM7mX8F1Tg%2Fruns%2F0%2Fartifacts%2Fpublic%2Flogs%2Flive.log#L1999) Servo hit on the CTS

**Description**
This change affects the unaligned* error messages: instead of printing the exact value, they now refer to the constant in the code. On one hand, this involves an extra redirection for anyone who hits this. But on the other hand, it makes them aware of the actual constants they should be respecting. I think it's better in the long term, especially if we change any of these.

**Testing**
Not tested, but should work!

r? @GabrielMajeri 

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2020-07-28 17:56:05 +00:00
Dzmitry Malyshau
b16640cdc4 Refactor pipeline creation to check the resource counts earlier 2020-07-28 13:55:07 -04:00
Dzmitry Malyshau
6e10518f12 Reformat the alignment errors, add a stride check 2020-07-28 11:48:49 -04:00
bors[bot]
c77f4de5a6
Merge #841
841: Safe error handling for queue module r=kvark a=GabrielMajeri

**Connections**
Part of #638 

**Description**
Adds error types for the `queue.rs` module. The out-of-memory conditions are reported upwards, other internal `gfx-hal` errors are unwrapped.

**Testing**
Tested with core and player.


Co-authored-by: Gabriel Majeri <gabriel.majeri6@gmail.com>
2020-07-27 16:34:32 +00:00
Gabriel Majeri
8316e9e678 Safe error handling for queue module 2020-07-26 17:49:53 +03:00
bors[bot]
11b3a95671
Merge #835
835: Convert all logging to tracing and add fmt logger r=kvark a=cwfitzgerald

**Connections**

#289 ish.

**Description**

This converts us fully to tracing, allowing traces to show up in logs.

https://github.com/gfx-rs/wgpu-rs/pull/476 should be considered at the same time as this PR.

**Testing**

Ran examples in wgpu-rs.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-07-26 04:00:54 +00:00
Connor Fitzgerald
cb485f3798 Convert all logging to tracing and add fmt logger 2020-07-25 19:33:21 -04:00
bors[bot]
6182495102
Merge #838
838: wait for buffer to be done in the player r=cwfitzgerald a=kvark

**Connections**
Fixes our code enough to replay #834 without issues. Doesn't help to solve the original problem though.

**Description**
There are two things in here:
  1. don't deduplicate the BGLs if we are not generating new IDs at this layer. This helps Servo/Gecko/player. cc @kunalmohan 
  2. have an option in `buffer_destroy` to *actually* kill it, at the cost of blocking on GPU sometimes. This is required for the player, since the very next command may try to reuse the ID.

**Testing**
Tested on the trace in #834 

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-07-24 22:57:04 +00:00
bors[bot]
645b43b0c7
Merge #839
839: Fix push constant pipeline invalidation r=kvark a=cwfitzgerald

**Connections**

Fixes #821

**Description**

We need to invalidate everything if push constants change. This code is kinda ugly but this is try three and it's the least terrible I got.

**Testing**

Pinging @Wumpf :)

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-07-24 22:26:30 +00:00
Connor Fitzgerald
b9498952a1 Fix push constant pipeline invalidation 2020-07-24 18:19:36 -04:00
bors[bot]
102d69eb58
Merge #832
832: Return errors from device functions r=kvark a=GabrielMajeri

**Connections**
Part of #638 

**Description**
Lots of changes, but they should be easily reviewable commit-by-commit.

- Error types for most of the fallible resource creation errors in `device/mod.rs`

- Removed assertions and replaced them with error types

- All of the `BufferMap`, `BufferNotMapped` etc. errors were united in a single `BufferAccessError`, since it was pretty weird to have so many overlapping error types.

- Removed all `unwrap`s of `gfx-hal` errors - they are now returned to the caller.

**Testing**
Checked with core and tested with `wgpu-rs` (see https://github.com/gfx-rs/wgpu-rs/pull/469)

Co-authored-by: Gabriel Majeri <gabriel.majeri6@gmail.com>
2020-07-24 20:43:56 +00:00
Gabriel Majeri
7cf9970121 Error handling for device functions 2020-07-24 22:56:51 +03:00
Dzmitry Malyshau
7e4ce4a4fe wait for buffer to be done in the player 2020-07-24 14:34:18 -04:00
bors[bot]
0591c48fd2
Merge #833
833: Switch pipeline flag to mutation of depth/stencil r=startoaster a=kvark

**Connections**
Reported on the matrix

**Description**
If the pass mutates depth/stencil, but the pipeline doesn't, it's not a bug!

**Testing**
on it...

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-07-24 02:26:50 +00:00
Dzmitry Malyshau
33d6eff6c9 Switch pipeline flag to mutation of depth/stencil 2020-07-23 22:24:21 -04:00
bors[bot]
8a2ee26fff
Merge #831
831: Carry RefCount in future suspects in order to prevent early removal r=cwfitzgerald a=kvark

**Connections**
Fixes  #830

**Description**
see https://github.com/gfx-rs/wgpu/issues/830#issuecomment-662825775

**Testing**
Tested on harmony + Sponza

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-07-23 16:09:02 +00:00
Dzmitry Malyshau
da34c918d3 Carry RefCount in future suspects in order to prevent early removal 2020-07-23 01:38:32 -04:00
bors[bot]
487e378653
Merge #829
829: Fix typo in BufferUsage docs r=kvark a=cwfitzgerald

**Connections**

A couple people have bugged me about this in the past.

**Description**

Docs were wrong, they are now right.

**Testing**

Read it again :)


Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-07-23 02:38:23 +00:00