Commit Graph

748 Commits

Author SHA1 Message Date
Jonathan Behrens
7a02bfca78 [rs] Implement read_buffer utility function 2021-02-06 11:22:37 -05:00
Dzmitry Malyshau
f9eb133370 [rs] Experimental ReadBuffer structure 2021-02-05 12:59:49 -05:00
bors[bot]
75cbc46d6e [rs] Merge #738
738: Update version and dependencies to gfx-9 r=kvark a=kvark



Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-01 07:17:07 +00:00
Dzmitry Malyshau
9755a464ae [rs] Update version and dependencies to gfx-9 2021-02-01 02:16:31 -05:00
bors[bot]
1e3eac2352 [rs] Merge #679
679: WGSL shader conversion for the examples r=grovesNL a=kvark

Blocked on:
  - ~~https://github.com/gfx-rs/naga/issues/335~~
  - ~~https://github.com/gfx-rs/naga/issues/336~~
  - ~~https://github.com/gfx-rs/wgpu/issues/1095~~
  - ~~https://github.com/gfx-rs/naga/pull/360~~
  - https://github.com/gfx-rs/gfx/pull/3622
  - ~~GL backend doing the program link check earlier~~

Converted:
- [x] boids
- [x] cube
- [x] mipmap
- [x] msaa-line
- [x] shadow
- [x] skybox
- [ ] texture-array
- [ ] water

Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
2021-01-30 06:05:49 +00:00
Dzmitry Malyshau
41a1c0e46f [rs] Convert cube, skybox, msaa-line, and mipmap, to WGSL
Validate example shaders in tests

Support WGSL on the Web via Naga

Port the shadow WGSL partially

Convert hello-compute and boids to WGSL

Conver the shadow's fragment shader to WGSL

Shader entry point refactor
2021-01-30 01:02:04 -05:00
bors[bot]
89284e07a4 [rs] Merge #734
734: Update wgpu to the new render pipeline descriptor API r=grovesNL a=kvark

MAJOR API BREAKING CHANGE
Gets us https://github.com/gfx-rs/wgpu/pull/1176

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-01-30 02:44:01 +00:00
Dzmitry Malyshau
edb342cffe [rs] Update wgpu to the new render pipeline descriptor API 2021-01-29 00:51:44 -05:00
bors[bot]
ba3595b8ab [rs] Merge #730
730: Fix the web backend in code and CI r=grovesNL a=kvark

Fixes #729

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2021-01-27 01:58:43 +00:00
Dzmitry Malyshau
8f6804caa1 [rs] Fix the web backend in code and CI 2021-01-26 20:58:13 -05:00
bors[bot]
2f3d6bce6f [rs] Merge #717
717: Fixup WebGL Building Docs r=kvark a=cwfitzgerald

Improved the docs for building wgpu for targeting webgl. This would have prevented https://github.com/gfx-rs/gfx/issues/3594.

I also think (but haven't changed yet) that all the examples should use `wgpu::BackendBit::all()` as that is really what people should be defaulting to.

(Rendered: https://github.com/cwfitzgerald/wgpu-rs/blob/webgl-docs/README.md#run-examples-on-the-web-wasm32-unknown-unknown)

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2021-01-23 23:53:30 +00:00
Connor Fitzgerald
316bd4f959 [rs] Fixup webgl docs 2021-01-23 18:20:41 -05:00
bors[bot]
7ea65e8f9f [rs] Merge #726
726: Bump wgpu-core and update texture_view_drop call r=kvark a=mkeeter

This PR updates to the latest `wgpu-core` commit ([wgpu #1163](https://github.com/gfx-rs/wgpu/pull/1163)), and is the counterpart to [wgpu-native #66](https://github.com/gfx-rs/wgpu-native/pull/66).

I'm using `wait = false` in the `texture_view_drop` call to match `buffer_drop` and `texture_drop` elsewhere `backend/direct.rs`, though I don't quite understand the implications 😅

Co-authored-by: Matt Keeter <matt.j.keeter@gmail.com>
2021-01-23 21:40:06 +00:00
Matt Keeter
3ca0b0cf9c [rs] Bump wgpu-core and update texture_view_drop call 2021-01-23 12:12:42 -05:00
bors[bot]
fe0644b040 [rs] Merge #720
720: Remove typed-arena dependency r=cwfitzgerald a=kvark

Also bumps the wgpu dependency to include https://github.com/gfx-rs/wgpu/pull/1160

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-01-20 06:03:01 +00:00
Dzmitry Malyshau
ea16651793 [rs] Remove typed-arena dependency 2021-01-19 22:01:54 -05:00
bors[bot]
f8bb6482ac [rs] Merge #716
716: Update Wgpu-Core r=trivial a=cwfitzgerald

This rollup fixes a pretty bad segfault that always occurs.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2021-01-16 07:59:22 +00:00
Connor Fitzgerald
eb2d591d59 [rs] Update wgpu-core etc 2021-01-16 02:58:07 -05:00
bors[bot]
e71cb4c964 [rs] Merge #715
715: Add pipeline statistics and timeline queries r=kvark a=cwfitzgerald

Blocked on https://github.com/gfx-rs/wgpu/pull/1128.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2021-01-16 06:06:18 +00:00
Connor Fitzgerald
af61d9c917 [rs] Add pipeline statistics and timeline queries 2021-01-16 01:05:03 -05:00
bors[bot]
cb2f9e45df [rs] Merge #713
713: Expose texture format feature query (and update to latest wgpu) r=kvark a=Wumpf

Exposes texture format feature query from https://github.com/gfx-rs/wgpu/pull/1112
Updating wgpu-core led to breaking change of moving get_swap_chain_preferred_format from device to adapter.

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2021-01-13 23:51:48 +00:00
Andreas Reich
1974b2a344 [rs] Exposed get_texture_format_features on adapter 2021-01-13 23:23:44 +01:00
bors[bot]
5c9b6704c0 [rs] Merge #698
698: Format PassErrorScope pipelines r=kvark a=scoopr

Pairing for gfx-rs/wgpu#1132, formats the pipeline ids

Co-authored-by: Mikko Lehtonen <scoopr@iki.fi>
2021-01-12 21:34:35 +00:00
Mikko Lehtonen
9ab5cdbd1f [rs] Format PassErrorScope pipelines 2021-01-12 23:32:10 +02:00
bors[bot]
76bfba0969 [rs] Merge #709
709: Move get_swap_chain_preferred_format from device to adapter r=kvark a=niklaskorz

See https://github.com/gfx-rs/wgpu/pull/1142. This PR applies the necessary changes for the move of `get_swap_chain_preferred_format` from device to adapter.

Co-authored-by: Niklas Korz <niklas@niklaskorz.de>
2021-01-11 21:43:51 +00:00
Niklas Korz
4d2bec6cab [rs] Move get_swap_chain_preferred_format from device to adapter
Squashed commit of the following:

commit 260976b10e3a54b253768d71e5e47c51b976c25c
Author: Niklas Korz <niklas@niklaskorz.de>
Date:   Mon Jan 11 20:23:31 2021 +0100

    Formatting

commit e3f837e1b6a81c8c7a9566ba6a2c6dd8adfbbde7
Author: Niklas Korz <niklas@niklaskorz.de>
Date:   Mon Jan 11 20:20:37 2021 +0100

    Update examples

commit b0774c0aa56fbdfe741dd6c0e86d55b8c6b42de3
Author: Niklas Korz <niklas@niklaskorz.de>
Date:   Mon Jan 11 19:31:29 2021 +0100

    Use adapter.get_swap_chain_preferred_format
2021-01-11 20:32:03 +01:00
bors[bot]
1e3a93a632 [rs] Merge #707
707: Fix compilation on aarch64-apple-darwin r=kvark a=andykilroy

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

Co-authored-by: Andrew Kilroy <7545475+andykilroy@users.noreply.github.com>
2021-01-10 16:11:43 +00:00
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]
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]
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
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
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]
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
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
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
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]
f1604cdc57 [rs] Merge #684
684: First step for WebGL support. r=grovesNL a=VincentFTS

This permits to test WebGL backend in Wgpu-rs.
Next step is to test examples to make them work with WebGL backend !

Co-authored-by: Vincent Jousse <contact@ftsoftware.fr>
2020-12-22 17:48:23 +00:00
Vincent Jousse
9f3a050fc4 [rs] First step for WebGL support. 2020-12-22 18:41:07 +01:00
bors[bot]
46d9c19390 [rs] Merge #688
688: Use only 1 and 4 samples for msaa-line example r=kvark a=cwfitzgerald

As 1 and 4 samples are the only universally supported values, switch the msaa-line example to only using them. In the future where users can determine the supported sample counts. See https://github.com/gfx-rs/wgpu/issues/804

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-12-22 03:29:30 +00:00
Connor Fitzgerald
5fac4835f6 [rs] Use only 1 and 4 samples for msaa-line example 2020-12-21 15:34:19 -05:00
bors[bot]
860265e5e9 [rs] Merge #682
682: Expose adapter.get_info() everywhere r=grovesNL a=kvark



Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
2020-12-19 04:51:29 +00:00