Commit Graph

2761 Commits

Author SHA1 Message Date
Andrew Kilroy
08fd37b429 [rs] Fix compilation on aarch64-apple-darwin
wgpu-rs couldn't compile on the Apple M1 (arm64) macs due to a compilation
problem in winit.  winit 0.24.0 has the fix so upgrade the dependency.

Link to the fix's pull request in winit:
   https://github.com/rust-windowing/winit/pull/1752
2021-01-10 11:16:04 +00:00
bors[bot]
ee0d0cb2c5 [rs] Merge #706
706: Update to latest wgpu r=grovesNL a=ElArtista



Co-authored-by: TheArtist <agorglouk@gmail.com>
2021-01-10 10:43:20 +00:00
TheArtist
f5dc0f91f7 [rs] Update to latest wgpu 2021-01-10 10:54:38 +02:00
bors[bot]
5b9cfeb941 Merge #1136
1136: Changed Arc<B::Memory> to Arc<Mutex<B::Memory>> in GpuAllocator r=kvark a=ElArtista

Work around for blocker https://github.com/zakarumych/gpu-alloc/issues/33, makes wgpu compatible with latest gfx

Co-authored-by: TheArtist <agorglouk@gmail.com>
2021-01-09 23:17:03 +00:00
TheArtist
ce908c5f57 Changed Arc<B::Memory> to Arc<Mutex<B::Memory>> in GpuAllocator 2021-01-09 19:53:13 +02:00
bors[bot]
a6a5cbbd3c [rs] Merge #685
685: Replace futures crate with pollster. r=grovesNL a=parasyte

This PR removes all of the `futures` dependencies. `std::future` does not contain a lot of useful helpers available in `futures`. The obvious ones are `join_all`, `FutureExt::map`, and `block_on`.

- `join_all` is replaced with a `Vec<T>` and an `async` block.
- `FuturesExt::map` in the web backend is replaced by rolling the `map` function into the `MakeSendFuture` type.
- `block_on` is provided by `pollster`.

The original code using `join_all` ignored the result type yielded by the Future from `map_async`. This code does the same, but makes dropping the result a little more obvious.

These should not be troublesome. Figured I would call them out anyway.

The last big change is replacing `futures-executor` in the examples with `async-executor`. A new concrete `Spawner` type is used in the example framework instead of an implementation of `futures_task::LocalSpawn`.

Fixes #628

Co-authored-by: Jay Oster <jay@kodewerx.org>
2021-01-07 19:08:55 +00:00
Jay Oster
78f33bcf67 [rs] Replace futures with pollster
This PR removes all of the `futures` dependencies. `std::future` does not contain a lot of useful helpers available in futures. The obvious ones are `join_all`, `FutureExt::map`, and `block_on`.

* `join_all` is replaced with a `Vec<T>` and async blocks.
* `FuturesExt::map` in the web backend is replaced by rolling the `map` function into the `MakeSendFuture` type.
* `block_on` is provided by `pollster`.

The original code using `join_all` ignored the result type yielded by the Future from `map_async`. This code does the same, but makes dropping the result a little more obvious.

These should not be troublesome. Figured I would call them out anyway.

The last big change is replacing `futures-executor` in the examples with `async-executor`. A new concrete `Spawner` type is used in the example framework instead of an implementation of `futures_task::LocalSpawn`.
2021-01-07 10:10:18 -08:00
bors[bot]
8c00cbcc8e Merge #1112
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>
2021-01-06 18:56:30 +00:00
bors[bot]
b83f520605 [rs] Merge #701
701: Fix cargo doc warnings due to unresolved links r=kvark a=manugildev

This PR fixes 13 warnings caused by unresolved internal and external(wgt) links in `cargo doc`.

> <img width="800" alt="Screenshot 2021-01-06 at 18 33 00" src="https://user-images.githubusercontent.com/13288771/103807298-809b4100-5056-11eb-8667-752f4bdd7902.png">


Co-authored-by: Manuel Gil <manugildev@gmail.com>
2021-01-06 18:49:52 +00:00
Manuel Gil
291668d124 [rs] Fix cargo doc warnings due to unresolved links 2021-01-06 18:30:24 +00:00
Andreas Reich
30c96bfead Added note on why hal update needed for STORAGE_READ_WRITE is blocked atm 2021-01-06 17:59:53 +01:00
bors[bot]
4c81941989 Merge #1134
1134: Never prefer CPU devices over GPUs r=kvark a=myfreeweb

**Connections**
Rebase of #969 onto master

**Description**
See #969

Co-authored-by: Greg V <greg@unrelenting.technology>
2021-01-06 16:32:54 +00:00
Greg V
072b94c9fd Never prefer CPU devices over GPUs 2021-01-06 19:19:39 +03:00
bors[bot]
788d1c7eda [rs] Merge #699
699: Fixed inconsistent framerate in examples. r=kvark a=Wumpf

Does not affect web builds.

Previously, framerate would float between 30-40 fps depending on how many events would come in. Fast mouse movements over the window lead to higher framerates since request_redraw was called every 20ms (-> 50fps) AND all events were consumed, additionally the event loop would wake up only every 10ms, so actual rate of request_redraw depended on how often we'd wake up.

Fixed this by setting the max sleep time of the event loop to the remaining time until hitting the desired time interval since the last frame.

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2021-01-06 14:22:33 +00:00
Andreas Reich
e29d17a13f wgpu format features are again part of TextureFormatInfo
+ some cleanup/fix indentations
2021-01-05 23:54:50 +01:00
Andreas Reich
070bceda31 [rs] Fixed inconsistent framerate in examples.
Does not affect web builds.
Previously, framerate would float between 30-40 fps depending on how many events would come in. Fast mouse movements over the window lead to higher framerates since request_redraw was called every 20ms (-> 50fps) AND all events were consumed, additionally the event loop would wake up only every 10ms, so actual rate of request_redraw depended on how often we'd wake up.
Fixed this by setting the max sleep time of the event loop to the remaining time until hitting the desired time interval since the last frame.

The difference is most visible on the spinning cubes in the shadow example since the cubes currently spin with a fixed angle per frame (independent of frame timings).
2021-01-05 22:58:28 +01:00
bors[bot]
365cbfa898 [rs] Merge #697
697: Remove wgpu-subscriber -> subscriber alias in examples r=kvark a=manugildev

Fixes #686

> All examples should be able to be copied into their own project and missing crates filled in based on errors alone.

Co-authored-by: Manuel Gil <manugildev@gmail.com>
2021-01-05 19:22:58 +00:00
Manuel Gil
d2844caaf0 [rs] Remove wgpu-subscriber -> subscriber alias in examples 2021-01-05 19:05:52 +00:00
bors[bot]
c691570c60 Merge #1127
1127: Fix API traced dynamic offsets and markers r=critical a=kvark

**Connections**
This was a regression from #1106, discovered while investigating #1123

**Description**
When running a pass, it was mutably used for "convenience". Once we moved the tracing of that pass from the beginning of the function to the end, the "convenience" eliminated our dynamic offsets and markers.
The solution is to stop mutating the passes inside our big functions.

**Testing**
Re-traced Terra

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2021-01-04 22:58:50 +00:00
Dzmitry Malyshau
d70148725b Fix API traced dynamic offsets and object labels 2021-01-04 17:54:56 -05:00
bors[bot]
66c987b226 Merge #1126
1126: Check swapchain frame to still be in use r=harmless a=kvark

**Connections**
Fixes #1123

**Description**
What happened there is - the same command buffer was used to record work into multiple swapchain frames.
The ID management of those is a bit special, so the error wasn't very descriptive, internal logic caught inconsistency.
Now there is a proper error, and the old error is better.
Note that ideally we'd want "present" to work like "destroy" on textures, but essentially the users would have to fix it anyway. It's not going to make their life easier (in fact - only harder), so we can defer this to a follow-up.

**Testing**
Tested on wgpu-rs examples as well as on Terra.

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2021-01-04 22:12:19 +00:00
Dzmitry Malyshau
922f2c0977 Check swapchain frame to still be in use 2021-01-04 17:03:16 -05:00
bors[bot]
35a2c8c474 Merge #1125
1125: Fix UB in populating dynamic offsets r=kvark a=kvark

**Connections**
Related to the traces in #1123

**Description**
The dynamic offsets arrays appear to be empty in the traces, which makes no sense. We are populating them unconditionally, and I double-checked on the `shadow` example that the traces we record contain the offsets. So my only guess is that the reported traces are taken from a release build, and our code that does `slice::from_raw_parts()` on the offsets is UB because the pointer can be garbage (if length is 0). This is what the PR fixes.

**Testing**
Untested

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2021-01-04 19:49:21 +00:00
Dzmitry Malyshau
f328995950 Fix UB in populating dynamic offsets 2021-01-04 14:46:04 -05:00
bors[bot]
29cb9e687d Merge #1124
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>
2021-01-04 18:42:02 +00:00
Dzmitry Malyshau
a7e573d612 Fix range tracker merging 2021-01-04 13:41:25 -05:00
bors[bot]
b82482f31c Merge #1121
1121: Implement render bundle freeing r=straightforward a=kvark

**Connections**
Fixes #1120

**Description**
Since render bundles were added the relevant bits of logic to free them were just missing.

**Testing**
Untested

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-01-04 14:32:45 +00:00
Dzmitry Malyshau
5953098461 Implement render bundle freeing 2021-01-04 09:30:10 -05:00
bors[bot]
7f0b8f3e34 [rs] Merge #693
693: Expose get_swap_chain_preferred_format r=kvark a=manugildev

Fixes #691

This functionality was committed in gfx-rs/wgpu@6f1d614 but never exposed to `wgpu-rs`.

Problem: Examples made use of `wgpu::TextureFormat::Bgra8UnormSrgb` but that's unreliable and according to the [API](https://gpuweb.github.io/gpuweb/#dom-gpucanvascontext-getswapchainpreferredformat) this method is the way of properly obtaining an optimal texture format for the `SwapChain` based on the platform.

- [x]  Expose `get_swap_chain_preferred_format()` on Device
- [x]  Use `TextureFormat::Bgra8Unorm` for [web.rs](e00ef5d584/src/backend/web.rs (L970))
- [x]  Update [framework.rs](e00ef5d584/examples/framework.rs (L227)) and examples to call this new method

Co-authored-by: Manuel Gil <manugildev@gmail.com>
2021-01-04 14:12:35 +00:00
bors[bot]
d09b149f6d Merge #1119
1119: Lock device tracker after the resources r=kvark a=kvark

**Connections**
Fixes  #1118

**Description**
Added a comment above `struct Device` explaining the problem and constraints.
We may have a few other cases that need to be handled gracefully by the type system.
For this fix we at least ensure that the device tracker is always locked temporarily.

**Testing**
Untested.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-01-04 14:10:11 +00:00
Manuel Gil
81bcc72651 [rs] Expose get_swap_chain_preferred_format on Device
- Update examples to make use of the new method
2021-01-03 17:35:04 +00:00
Dzmitry Malyshau
2b02b7c8e4 Lock device tracker after the resources 2021-01-03 11:29:18 -05:00
bors[bot]
36d274bc5a Merge #1115
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>
2021-01-03 03:32:08 +00:00
bors[bot]
b67c2b0299 Merge #1117
1117: Free associated staging buffers r=cwfitzgerald a=kvark

**Connections**
Reported on the Matrix. Having a loop that creates mapped buffers and drops them results in OOM.

**Description**
We are now checking for the map state when destroying buffers.

**Testing**
Ran through an ad-hoc example.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-01-02 23:55:05 +00:00
Dzmitry Malyshau
d095dd39b7 Free associated staging buffers 2021-01-02 18:52:07 -05:00
Jonathan Behrens
0e84c29691 Limit when buffer FAST_DEVICE_ACCESS is requested 2021-01-02 14:18:14 -05:00
bors[bot]
e9232127f0 Merge #1114
1114: Fixed error message for BindingTypeMaxCountError r=cwfitzgerald a=Wumpf

Previously, `BindingTypeMaxCountError` would incorrectly report the binding count as the violated limit. Now it reports both the limit and the count that violated it.

Example error message before:
```
wgpu error: Validation Error

Caused by:
    In Device::create_bind_group_layout
      note: label = `BindGroupLayout write scalar`
    too many bindings of type StorageTextures in stage COMPUTE, limit is 5
```


Example error message after:
```
wgpu error: Validation Error

Caused by:
    In Device::create_bind_group_layout
      note: label = `BindGroupLayout write scalar`
    too many bindings of type StorageTextures in stage COMPUTE, limit is 4, count was 5
```

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2021-01-02 15:08:09 +00:00
Andreas Reich
9770959577 Fixed error message for BindingTypeMaxCountError
Previously, it would incorrectly report the binding count as the violated limit. Now it reports both the limit and the count that violated it.
2021-01-02 15:13:52 +01:00
Andreas Reich
757d12aca3 map depth/stencil feature to RENDER_ATTACHMENT 2020-12-30 12:23:13 +01:00
Andreas Reich
c17b2dc6a0 Expose adapter_get_texture_format_features 2020-12-30 12:00:00 +01:00
Andreas Reich
4207e57c02 validation against adapter specific format features
TextureFormatFeatures is now a struct of two u32 flags. Query happens only at texture creation time
2020-12-30 10:38:55 +01:00
Andreas Reich
0ccad9a466 wip adapter specific format features & rw storage 2020-12-29 17:14:22 +01:00
bors[bot]
ee3ca89105 [rs] Merge #690
690: Add `RenderEncoder` r=kvark a=0x182d4454fb211940

It seems like `RenderPass` and `RenderBundleEncoder` share many methods in common (`set_pipeline`, `draw_indexed`, etc). By creating a shared trait, it allows more reusable code. For instance:

```rust
impl RedCircle {
    fn new(...) -> Self { .. }
    fn draw<'a>(&'a self, encoder: &mut impl RenderEncoder<'a>) { .. }
}
```

This code would then work for both structs.

Moving the previous methods from their `impl`s to the trait's would break previous code, as to use these methods code would now have to import `RenderEncoder`. To avoid this, it is implemented by calling the direct methods.

It may be worth considering moving this to `wgpu::util`.

Co-authored-by: 0x182d4454fb211940 <nathanwoodformal@gmail.com>
2020-12-28 01:19:59 +00:00
bors[bot]
a90d2fcf8a Merge #1101
1101: Bump gfx-hal and gpu-alloc r=kvark a=cwfitzgerald

**Connections**

Absorbs https://github.com/zakarumych/gpu-alloc/pull/31 and https://github.com/gfx-rs/gfx/pull/3548#issuecomment-749158016

**Description**

This fixes the last of the DX11 issues listed in #1059.

**Testing**

Various examples ran.


Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-12-27 06:11:06 +00:00
Connor Fitzgerald
79973aaaff Bump gfx-hal and gpu-alloc 2020-12-27 01:10:24 -05:00
0x182d4454fb211940
cbbf25c6f8 [rs] Add set_push_constants to RenderEncoder 2020-12-25 14:01:04 +00:00
0x182d4454fb211940
a2ff43f989 [rs] Remove unneeded cast from encoder.rs 2020-12-25 13:50:36 +00:00
0x182d4454fb211940
8dc1c0896b [rs] Move RenderEncoder to util 2020-12-25 13:47:38 +00:00
0x182d4454fb211940
6ee00ab401 [rs] Add RenderEncoder 2020-12-24 17:37:06 +00:00
bors[bot]
aded405479 Merge #1106
1106: Encode render passes while command buffer is only read-locked r=cwfitzgerald a=kvark

**Connections**
Could fix #1104 to some extent

**Description**
The heaviest part of the render pass encoding doesn't need a write lock. Only in the end we need it.

**Testing**
Untested.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-12-23 16:21:03 +00:00