1325: Relax and imporve vertex attribute validation r=cwfitzgerald a=kvark
**Connections**
None
**Description**
Improves our validation of vertex attributes in the following ways:
1. Relaxes the size matching, so that we allow the shaders to default some of the values we don't provide
2. Require interpolation to match
3. Make the error messages more detailed:
> In Device::create_render_pipeline
error in stage VERTEX
error matching the stage input at 1 (Uint32x2 interpolated as None) against the previous stage outputs
input type is not compatible with the provided Float32x2
**Testing**
Tested on wgpu-rs examples.
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
- 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>