- Rename `ColorAttachmentDescriptor` to `RenderPassColorAttachment`
- Rename `DepthStencilAttachmentDescriptor` to `RenderPassDepthStencilAttachment`
- Rename `attachment` fields on both attachments to `view`
1279: Fix some typos r=kvark a=grovesNL
**Description**
Fix a few small typos in doc comments
**Testing**
None
Co-authored-by: Joshua Groves <josh@joshgroves.com>
* chore: validate offset + size in get_mapped_range
This commit introduces out of bounds & offset validation for
buffer_get_mapped_range, like described in the WebGPU spec. See
https://gpuweb.github.io/gpuweb/#dom-gpubuffer-getmappedrange.
Closes#818
* review comments
* fmt
* fix test
* fix tests
* update error message
* review comment
* use wgt::BufferAddress
* clippy
* Add CONSERVATIVE_RASTERIZATION native feature
* update gfx to cd3042d8c02d9dc7fc74ac8c292099c9789f6d43
* error for polygon mode not fill +conservative raster
* wgpu-core: update gfx-hal usage related to sparse resources
* wgpu-core: support naga gfx-13
* Update gfx and naga dependencies to gfx-13 tag
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
1247: Add license to the memory init tracker r=kvark a=kvark
**Connections**
Gecko's code lints complain...
**Description**
Add a license header like all the other files
**Testing**
should work!
Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
1243: Force-drop the token before calling fire_map_callbacks r=kvark a=kvark
**Connections**
Related to WebGPU update in Gecko
**Description**
Since the token was alive, technically, we saw an assertion firing up about concurrent access to the token root.
**Testing**
Tested in Gecko
Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
1237: Move `#[error]` attributes after the corresponding `#[derive]` r=kvark a=Aaron1011
**Connections**
See https://github.com/rust-lang/rust/issues/79202
**Description**
Fixes Nightly future-incompat warnings
**Testing**
There are no behavior changes intended.
Co-authored-by: Aaron Hill <aa1ronham@gmail.com>
1210: Reset the bindings on the push constant change r=wumpf a=kvark
**Connections**
Fixes#1207
(unconfirmed!)
**Description**
I was able to replay the trace in #1207 without validation errors, so I looked deeper into what might have gone wrong.
The code isolated in #1194 looks great. However, the calling code's handling of push constants might have changed a bit.
And I see that the trace uses push constants, so here is what happened, I think:
- layout A was set, expecting bind group layouts X and Z
- bind groups X and Y where bound
- layout B was set, expecting bind group layout X and Y. We see that Y group can now be bound, so we do this. The old logic in this case wasn't considering the push constants in any way, it would only consider them if bind group layouts didn't change, erroneously.
- layout B has different push constant ranges...
So it's a one-line fix now, which I'm hoping is correct.
**Testing**
Not tested
@Wumpf would you be able to check this?
Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
1190: Fix crash on zero init of buffer with no more ref count r=kvark a=Wumpf
**Description**
Previously, if a buffer would no longer have any reference, the zero init step crashed when trying to unwrap its ref_count.
**Testing**
Tested successfully on 54a0f4ff13 where this problem would pop up
Co-authored-by: Andreas Reich <r_andreas2@web.de>
1182: Update all versions r=kvark a=kvark
**Connections**
Picks up https://github.com/gfx-rs/gfx/pull/3620 and a bunch of other fixes in gfx-rs and naga.
**Description**
Updates the dependencies ("gfx-9" naga train) as well as self version to 0.7, to match the v0.7 branch.
**Testing**
Should just work :)
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
1151: Update gfx and naga to gfx-6 tag r=cwfitzgerald a=kvark
**Connections**
Fixes#1149
Regression from https://github.com/gfx-rs/gfx/pull/3573
**Description**
The physical devices held references to `RawInstance` in Vulkan backend, and we weren't cleaning them up.
Note: an alternative fix could be in `gfx-backend-vulkan` - to move the `Entry` into `RawInstance`, thus delaying the shutdown. I didn't go this way because that would be less explicit.
**Testing**
Tested on wgpu-rs examples
Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
1144: Fix and simplify attachment dimension mismatch check r=kvark a=DasEtwas
This also improves error messages with detailed dimension and attachment type name info which developers can hopefully recognize.
**Connections**
None
**Description**
Before this commit, depth/stencil attachments are not considered when evaluating the renderpasses' dimension, which will result in a "NoAttachment" error with a confusing display message.
**Testing**
Tested by running an application making use of color-only and depth/stencil-only attachment renderpasses.
Tested by running boids, hello-triangle and shadow examples.
Co-authored-by: DasEtwas <18222134+DasEtwas@users.noreply.github.com>
1135: Make all textures support usage COPY_SRC and COPY_DST r=kvark a=fintelia
**Connections**
N/A
**Description**
In WebGPU, all textures should be allowed to have usages COPY_SRC and COPY_DST. However, right now when Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES is enabled any features that the backend says can't be blitted to/from will not gain these capabilities. In particular, compressed textures may not support blitting while still allowing access via copies to/from buffers.
You can also see the defaults used when TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES is not requested:
8c00cbcc8e/wgpu-types/src/lib.rs (L1224-L1342)
**Testing**
I ran a [patched version of the wgpu-rs cube example](https://github.com/fintelia/wgpu-rs/tree/cube-bc4/examples/cube).
Co-authored-by: Jonathan Behrens <fintelia@gmail.com>
1112: Expose adapter specific formats features via Extension, support for storage read+write r=kvark a=Wumpf
**Connections**
Draft until https://github.com/gfx-rs/gfx/pull/3559 landed (then update and comment two lines in)
New & improved replacement for #1109
PR for wgpu-rs to be opened once there's some confidence that this is that it should look like. [Preview](https://github.com/gfx-rs/wgpu-rs/compare/master...Wumpf:texture-format-feature-query?expand=1)
**Description**
Adapter exposes now per texture format specific features. Feature struct defined as allowed usages + flags. Flags describe only storage texture usage so far.
Query not used for validation unless `TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES` feature is enabled on a device. Otherwise uses hardcoded feature set guaranteed by webgpu.
Storage read/write binding can then be used as a consequence (storage atomic has no effect yet).
**Testing**
Manual testing with my fluid sim project through wgpu-rs which covers storage r/w for a few different formats and storage in general for formats that don't support this usage by default at all.
Ran tests and a couple of samples to see if anything broke with the feature disabled.
Co-authored-by: Andreas Reich <r_andreas2@web.de>
1124: Fix range tracker merging r=kvark a=kvark
**Connections**
Fixes#1123
**Description**
The merge routine was not properly updating the end pointer in some branches.
**Testing**
A unit test is added with the data extracted from the user case.
Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
1115: Request buffer FAST_DEVICE_ACCESS only with some non MAP or COPY usage r=kvark a=fintelia
**Connections**
Fixes#1113
**Description**
On Linux AMD (and likely elsewhere) buffers with FAST_DEVICE_ACCESS are very slow to access when mapped. This makes sure that upload/download buffers don't request it unless those buffers are leveraging MAPPABLE_PRIMARY_BUFFERS for some non-map/copy usage.
**Testing**
I reran the failing reproduction case in the linked issue.
Co-authored-by: Jonathan Behrens <fintelia@gmail.com>
1103: Fix Assorted Low-Hanging Validation and Error Message Issues r=kvark a=cwfitzgerald
**Connections**
Closes#1085Closes#393Closes#1053
**Description**
These commits are independent and should be reviewed individually. Combined into a single PR to reduce noise.
Overview of what was done:
- Add validation for empty texture and buffer usage flags. (#393)
- Add allowed texture usage flags to `format.describe()` (#1085)
Validate new textures follow the allowed usage flags.
- Properly validates vertex and buffers are bound. (#1053)
Improves error messages when no vertex buffer is bound. (Before it said the limit was 0, now it says something is unbound)
- Improve the vertex buffer overrun messages by keeping track of which slot has the smallest index.
**Testing**
Tested on examples by artificially creating the situation I am trying to validate, as well as running clean examples to make sure they pass validation.
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
1096: Fix build for wasm32 target r=kvark a=VincentFTS
**Connections**
#115
**Description**
Fix Wgpu build for Wasm target
**Testing**
It’s just a first step toward wasm support in Wgpu-rs, a PR in Wgpu-rs will come later.
Co-authored-by: Vincent Jousse <contact@ftsoftware.fr>
1093: Update naga and gfx, move the shader validation into a shader descriptor bit r=cwfitzgerald a=kvark
**Connections**
Includes https://github.com/gfx-rs/gfx/pull/3533 and a bunch of Naga things.
**Description**
Updates Naga with the new WGSL syntax, lots of fixes.
Large update of the GL backend.
**Testing**
Tested on some wgpu-rs examples.
Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
1077: Remove extern "C" from set_index_buffer r=kvark a=DevOrc
**Connections**
Fixes an issue that is blocking gfx-rs/wgpu-native#61
**Description**
Moves the ffi definition of wgpu_render_bundle_set_index_buffer / wgpu_render_pass_set_index_buffer to wgpu-native. This is needed because wgpu-native has its own version of IndexFormat that is different than the wgpu_types version.
**Testing**
My projects with wgpu-native work
Co-authored-by: Noah Charlton <ncharlton002@gmail.com>
1080: Fix the validation of vertex buffer sizes r=kvark a=JCapucho
**Connections**
None that i know of
**Description**
~~The vertex buffer size (in vertices) was being divided by stride causing the limit to be lower than it was supposed to be.~~
This bug wasn't triggered earlier because if the stride was 0 it wouldn't perform any calculation and the stride was only set when a set pipeline command was received and the `VertexState` `inputs` were already created so the following commands would work:
```
SetPipeline with 1 vertex buffer
SetVertexBuffer with only 4 vertices
Draw 6 vertices
```
This would have passed validation while this wouldn't
```
SetPipeline with 1 vertex buffer of stride 8
SetVertexBuffer with 4 vertices
SetPipeline with 1 vertex buffer of stride 8
SetVertexBuffer with 4 vertices
Draw 3 vertices
```
Now all draw calls have proper vertex validation and not only after the `inputs` are populated
**Testing**
This change was tested after debugging an issue with the draw calls failing in a specific order in [veloren](https://gitlab.com/veloren/veloren/-/tree/imbris/wgpu-master-rebased)
Co-authored-by: Capucho <jcapucho7@gmail.com>
The purpose of the PR is to support Naga modules everywhere.
As a requirement, it updates the gfx-rs version used.
Most of the logic is dedicated towards building a shader interface,
where previously we just used naga's IR. Now we have our own mini-IR.
1047: Update bind group layout API to match upstream r=cwfitzgerald a=kvark
**Connections**
Follows https://github.com/gpuweb/gpuweb/pull/1076, https://github.com/gpuweb/gpuweb/pull/1223 (https://github.com/gpuweb/gpuweb/issues/1164), https://github.com/gpuweb/gpuweb/pull/1255, and https://github.com/gpuweb/gpuweb/pull/1256
**Description**
Aligns our API closer to the latest changes in WebGPU upstream. We technically don't have to do this, but I believe in the end it would be best if our API gets close to upstream.
Note: this is a sensitive change for the users, everybody will get their code broken. So please take a look at the API and see if something is missing or needs improvement, so that we don't have to go through the changes again afterwards.
**Testing**
Doesn't really need testing. Partially covered by the existing playtest.
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
1051: Register init-destination buffer in the pending writes r=kvark a=kvark
**Connections**
Fixes#1049
**Description**
At some recent point we introduced the map of destination buffers for copies, and I missed the case where buffers are mapped at creation.
**Testing**
Tested on the test-case in #1049
Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
1023: Drop surfaces and adapters r=cwfitzgerald a=kvark
**Connections**
Not very connected
**Description**
Refactors our destruction paths a bit
**Testing**
tested on wgpu-rs
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
1008: Add helpers to convert passes to serialized forms r=grovesNL a=kvark
**Connections**
Stuff I needed to fix in the upcoming Gecko WebGPU update.
**Description**
It allows us to use the tracing `Command` more aggressively.
**Testing**
Tested in Gecko, doesn't need testing in wgpu
Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
1000: Elide redundant set_pipeline calls. r=kvark a=Kimundi
**Description**
This adds an check in each `set_pipeline()` call for wether the same pipeline id has already been set previously. This should cause free performance wins for suboptimal usage of the wgpu API, while having neglible overhead otherwise.
An example scenario for where this would be useful is a game that just blindly sets all render state for each object, but has few actually different objects:
```rust
for game_obj in game_objs {
rpass.set_pipeline(...);
rpass.set_bind_group(...);
rpass.set_vertex_buffer(...);
rpass.draw(...);
}
```
**Testing**
Ideally we would have tests that check that pipeline changes have been ellided, but I'm not sure how to write them in the current codebase.
**Future work**
- We could extend this kind of redundant state change detection to most `.set_*` methods on `RenderPass`es.
- If we want to guarantee this behavior in the API, we should also document it.
Co-authored-by: Marvin Löbel <loebel.marvin@gmail.com>
982: Fix debug markers in render passes (#981) r=kvark a=kazimuth
Hey, that was easy. Didn't change anything in the debug groups markers / command pass markers, since afaict they work correctly.
I didn't add a test here because I'm not sure how to use the `player` testing apparatus, but I figure since I'm just adding a line of code that's already there for compute passes ([here](https://github.com/gfx-rs/wgpu/blob/master/wgpu-core/src/command/compute.rs#L452)) it should be alright. Let me know if there's anything else I should add.
Co-authored-by: James Gilles <jameshgilles@gmail.com>
966: Immediate resource destruction and freeing r=cwfitzgerald a=kvark
**Connections**
Fixes#964
**Description**
We are making it so a buffer or a texture can have their native resources freed while they are still referenced, so without waiting for GC.
In addition, the PR adds a few missing cases where error IDs should have been handled, like at render pass encoding.
**Testing**
Tested on wgpu-rs examples, see https://github.com/gfx-rs/wgpu-rs/pull/591
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
* Pass [u8] instead of [u32] for push constants
Use 2-instruction aligner
Fixed alignment
Fixed offsets
Added alignment checks and fixed size
Use semantic constants
* Replaced all magic number with constant
* Fixed type cast
963: Add repr(C) on mapping structs r=trivial a=kvark
**Connections**
Required for https://phabricator.services.mozilla.com/D92636
**Description**
Allows C clients to avoid redefining those structs.
**Testing**
No need
Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
938: Remove erroneous extra feature check r=kvark a=cwfitzgerald
**Connections**
None, found during investigation of DI issue.
**Description**
This line of code just shows up twice in a row, checking the same feature and setting the same feature.
**Testing**
Untested, but shouldn't affect anything.
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
* 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
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.
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>
903: fix for mixed STORAGE_STORE and STORAGE_LOAD r=kvark a=kocsis1david
**Connections**
None
**Description**
A buffer that contains dynamic data is used for both uniforms and storage read. This was a problem for wgpu and it gave a `PendingTransition` error.
**Testing**
It's a trivial fix, but I don't know if there's an example for it in wgpu-rs that can be used for testing.
It seems that the PR "Sync changes from mozilla-central" is already solving the same issue.
Co-authored-by: Dávid Kocsis <kocsis1david@windowslive.com>
* Allow copying from depth textures
* Rename TextureFormat::is_depth_format to just is_depth
* Only allow Depth32Float format for copying, and only as source
895: Improve validation in B2B copies and RenderCommands 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._
Validation for the following have been added-
- Validate all parameters in B2B copy even if `copy_size == 0`.
- Check for copy operations issued within same buffer.
- `RenderPass.setViewport()`
- `RenderPass.setScissorRect()`
**Testing**
_Explain how this change is tested._
Tested with CTS in Servo. More tests pass now. Will test on wgpu-rs now.
<!--
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>
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>