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>
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>
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>
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>
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>
495: Update a documentation to refer to create_buffer_init() instead of create_buffer_with_data() r=kvark a=yutannihilation
A followup of #482
Co-authored-by: Hiroaki Yutani <yutani.ini@gmail.com>
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>
493: Use BCn textures if possible in skybox example r=kvark a=cwfitzgerald
This converts the skybox to using compressed textures if available. I have designed the code to be extensible to other compressed formats as they are added.
Additionally I added srgb to the texture types, as we were using a srgb framebuffer without properly converting into linear on the texture reads.
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
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>
492: Replace NonZeroU32 with u32 in TextureViewDescriptor r=kvark a=kunalmohan
Includes https://github.com/gfx-rs/wgpu/pull/854
(rustfmt seems to have introduced a number of other changes. I can revert them if they are undesired)
r?@kvark
Co-authored-by: Kunal Mohan <kunalmohan99@gmail.com>
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>
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>
482: Add label parameter to `create_buffer_with_data` r=kvark a=OptimisticPeach
Improves QOL by allowing you to attach a label to a buffer when created with predetermined data:
```
let uniform_buf = device.create_buffer_with_data(
bytemuck::cast_slice(my_data),
wgpu::BufferUsage::UNIFORM,
Some(Cow::Borrowed("My Uniforms")),
);
```
Co-authored-by: OptimisticPeach <patrikbuhring@yahoo.com>
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>
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>
484: Enable features in CI to prevent compiler errors r=kvark a=cwfitzgerald
Simple change, this also builds features in CI.
I added trace and replay features to wasm, even though wasm doesn't support tracing as is, because people may enable them to get serde support for wgpu-types stuff.
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
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>