1525: Add Naga bypass to allow feeding raw SPIR-V shader data to the backend. r=kvark a=ElectronicRU
**Connections**
Fixes#1520 .
**Description**
While Naga checking is undoubtedly very useful, it currently lags behind
what is possible in SPIR-V and even what is promised by WGPU (ie binding
arrays). This adds an unsafe method to wgpu::Device to allow feeding
raw SPIR-V data into the backend, and adds a feature flag to request a
backend supporting this operation.
**Testing**
`texture_arrays` example is runnable now, which uncovers an additional bug in Vulkan backend - binding arrays are instead treated like sole bindings, and indices shift, too. Lots of errors from validation layer ensue.
Co-authored-by: Alex S <alex0player@gmail.com>
- rename ShaderInput variants
- rename feature flag
- hard error on Metal backend trying to compile SPIR-V
- fix test failing because of feature flag bits changing
* Add command buffer fill buffer method
* Added test for buffer fill
* Added image clear + test
* image/buffer clear methods are now pure clear to zero
* fix cargo clippy & int type issues
* clear buffer alignment is now given by COPY_BUFFER_ALIGNMENT
* joined buffer/image clear player tests
* ImageSubresourceRange is now used in TextureViewDescriptor
- Rename `ColorAttachmentDescriptor` to `RenderPassColorAttachment`
- Rename `DepthStencilAttachmentDescriptor` to `RenderPassDepthStencilAttachment`
- Rename `attachment` fields on both attachments to `view`
* 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
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>
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>
1076: Fix player warnings r=kvark a=kvark
```
warning: unused `std::result::Result` that must be used
--> player/src/bin/play.rs:142:29
|
142 | ... gfx_select!(device => global.device_create_swap_chain(device, surface, &desc));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_must_use)]` on by default
= note: this `Result` may be an `Err` variant, which should be handled
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
warning: unused `std::result::Result` that must be used
--> player/src/bin/play.rs:147:29
|
147 | ... gfx_select!(device => global.swap_chain_present(id));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this `Result` may be an `Err` variant, which should be handled
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
warning: unused `std::result::Result` that must be used
--> player/src/bin/play.rs:173:21
|
173 | gfx_select!(device => global.device_poll(device, true));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this `Result` may be an `Err` variant, which should be handled
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
warning: 3 warnings emitted
```
Co-authored-by: Dzmitry Malyshau <kvarkus@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.
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>
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>
* Replace &[T] in descriptor structs with Cow<[T]>
* Changed label fields to use Cow<'a, str>
* Deduplicate types across the tracing API
Introduce the ToStatic trait
* Deduplicate trace::RenderBundleDescriptor
* Remove ugly ToOwned bounds
* Simplifiy Action variants
* Make Clone bounds on type defs less verbose
* Fix a error in play.rs
* Remove ToStatic, and Make Action<'a> borrow descriptors instead
813: Add buffer creation error type r=kvark a=GabrielMajeri
**Connections**
Part of #638
**Description**
Adds an error type for the buffer creation functions.
**Testing**
Checked with core and ran test on player.
Co-authored-by: Gabriel Majeri <gabriel.majeri6@gmail.com>
812: Error type for `WaitIdle` r=kvark a=GabrielMajeri
**Connections**
Part of #638
**Description**
Adds an error type for the `wait_idle` function.
**Testing**
Checked with core.
Co-authored-by: Gabriel Majeri <gabriel.majeri6@gmail.com>
773: Error handling for data transfer API r=kvark a=GabrielMajeri
**Connections**
Work on the error model described in #376
**Description**
Removes assertions from the transfer functions, instead returning a custom error type.
**Testing**
Checked with `player` and `wgpu-rs`: https://github.com/gfx-rs/wgpu-rs/pull/430
Co-authored-by: Gabriel Majeri <gabriel.majeri6@gmail.com>
763: Remove raw pointers from the render pipelines API r=kvark a=GabrielMajeri
**Connections**
Rust-ification of API, as part of #689
**Description**
The objective is to get rid of raw pointers in the render pipeline descriptor and associated structures.
**Testing**
Checked with `player` and the `trace` feature, and with `wgpu-rs` with the changes in https://github.com/gfx-rs/wgpu-rs/pull/425
Co-authored-by: Gabriel Majeri <gabriel.majeri6@gmail.com>
739: Remove Peek-Poke r=cwfitzgerald a=kvark
**Connections**
Related to https://github.com/gfx-rs/wgpu/issues/738
Related to https://github.com/djg/peek-poke/issues/10
**Description**
As of #726 , the buffers have a minimum binding size that has to include the shader struct size. It, therefore, can't be zero.
We can remove the hacks we had previously and switch fully to the idiomatic `Option<NonZeroU64>`.
Peek-poke doesn't `NonZeroU64` and friends, so this made me reconsider the user of it entirely. Today, render bundles as well as the Player already represent command streams using a much rustier method. I tried to move everything to this method now, and I think this is going to work much better, and safer.
**Testing**
wgpu-rs works - https://github.com/gfx-rs/wgpu-rs/pull/396
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
There was a lot of highly unsafe use of serialization based on peek-poke that we
weren't entirely happy with. It's replaced by just serializing the passes now.
Also, switch BufferSize to Option<NonZero>.
This is a major change in how the bundles are implemented. Instead of
transparently injecting them into the pass command stream, we are now
treating bundles as first-class API objects and API tracing them
accordingly. The bundle contains a normalized command stream that is
very easy to inject into a native command buffer multiple times.
704: Pipeline layout validation r=cwfitzgerald a=kvark
**Connections**
Implements a solid part of #269
Starts converting the function to return results, related to #638
cc @GabrielMajeri
**Description**
This change matches shader bindings against the pipeline layout. It's *mostly* complete, minus some bugs and not handling the `storage_texture_format` properly.
The risk here is that Naga reflection may have bugs, or our validation may have bugs, and we don't want to break the user content while this is in flux. So the PR introduces an internal `WGPU_SHADER_VALIDATION` environment variable. Switching it to "0" skips Naga shader parsing completely and allows the users to unsafely use the API.
Another aspect of the PR is that some of the functions now return `Result`. The way I see us proceeding is that any errors that we don't expect users to handle should result in panics when `wgpu` is used natively (i.e. not from a browser). These panics would happen in the "direct" backend of wgpu-rs (as well as in wgpu-native), but the `Result` would not be exposed to wgpu-rs, so that it matches the Web behavior.
At the same time, browser implementations (Gecko and Servo) will check the result on their GPU process and implement the WebGPU error model accordingly. This means `wgpu-core` can be super Rusty and safe.
**Testing**
Running on wgpu-rs examples. Most of them fail to get parsed by Naga, but `boids` succeeds and passes validation 🎉
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
668: Return failures to the user in swap_chain_get_next_texture, rather than transparently reconfiguring. r=kvark a=AlphaModder
TODO:
- [x] Change `Global::swap_chain_get_next_texture` in `wgpu-core`.
- [x] Update `wgpu_swap_chain_get_next_texture` in `wgpu-native`. (https://github.com/gfx-rs/wgpu-native/pull/32)
- [x] Wrap `SwapChainOutput`/`SwapChainStatus` in a nice enum in `wgpu-rs`. (https://github.com/gfx-rs/wgpu-rs/pull/323)
- [ ] Update `wgpu_bindings` (?)
Co-authored-by: AlphaModder <quasiflux@gmail.com>
- Clean up after the pending writes on destroy.
- Fix temporary buffer creation.
- Fix internal thread initialization by the command allocator.
- Clean up player event_loop usage.