Commit Graph

713 Commits

Author SHA1 Message Date
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
Dzmitry Malyshau
7a8c6cefe1 [rs] Expose adapter.get_info() everywhere 2020-12-18 21:18:07 -05:00
bors[bot]
6489a1190d [rs] Merge #681
681: Move DeviceExt into a separate module r=cwfitzgerald a=kvark



Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-12-18 01:06:56 +00:00
Dzmitry Malyshau
92c7cdbaba [rs] Move DeviceExt into a separate module 2020-12-17 17:55:11 -05:00
bors[bot]
5bbe5eb4f3 [rs] Merge #680
680: Update wgpu with Naga fixes and OpenGL backend r=cwfitzgerald a=kvark

This PR makes it easier to build wgpu-rs on Linux, since it doesn't require pkg-config into EGL.
Fixes #607
Fixes https://github.com/gfx-rs/wgpu/issues/1063

Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
2020-12-17 21:57:25 +00:00
Dzmitry Malyshau
09e589e5a6 [rs] Simplify the CI check script 2020-12-17 16:34:01 -05:00
Dzmitry Malyshau
bafcc5ace5 [rs] Update wgpu with Naga fixes and OpenGL backend 2020-12-17 13:03:27 -05:00
bors[bot]
9090076253 [rs] Merge #678
678: Require labels for ComputePass and RenderPass  r=kvark a=infinitesnow

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

https://github.com/gfx-rs/wgpu/pull/1088/ improved labelling, update `wgpu-rs` and examples to match.

Change-Id: I1acc45a3023dfc78b6694bd4a28a0131f07b7ba7

Co-authored-by: Emanuele Dalla Longa <3xplosive.g@gmail.com>
2020-12-15 23:27:10 +00:00
Emanuele Dalla Longa
0b718aea93 [rs] Require labels to match gfx-rs/wgpu#1088
Change-Id: I1acc45a3023dfc78b6694bd4a28a0131f07b7ba7
2020-12-16 00:15:05 +01:00
bors[bot]
b369dd3954 [rs] Merge #677
677: Update to latest wgpu master r=kvark a=yzsolt

- Update to latest `wgpu` master
- Fix build error caused by https://github.com/gfx-rs/wgpu/pull/1077

Co-authored-by: Zsolt Bölöny <bolony.zsolt@gmail.com>
2020-12-14 19:12:27 +00:00
Zsolt Bölöny
acf94e9321 [rs] Update to latest wgpu master 2020-12-14 17:57:27 +01:00
bors[bot]
cdda85e7c3 [rs] Merge #672
672: Add write_whole_texture_mips Helper r=kvark a=cwfitzgerald

Adds a helper in QueueExt for uploading an entire texture with all of its mips. Name very bikeshedable.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-12-13 05:45:03 +00:00
Connor Fitzgerald
7e05bba6c4 [rs] Add create_texture_with_data helper 2020-12-12 01:50:49 -05:00
bors[bot]
99c9b253cf [rs] Merge #671
671: Add label to create_shader_module r=cwfitzgerald a=scoopr



Co-authored-by: Mikko Lehtonen <scoopr@iki.fi>
2020-12-09 00:23:25 +00:00
Mikko Lehtonen
88a6d957c7 [rs] Add label to create_shader_module 2020-12-08 22:56:17 +02:00
bors[bot]
d10cf8e198 [rs] Merge #669
669: Update wgpu with Naga changes, replace hello-triangle shaders with WGSL r=cwfitzgerald a=kvark



Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-12-07 15:15:16 +00:00
Dzmitry Malyshau
95dcacd1ad [rs] Update wgpu with Naga changes, replace hello-triangle shaders with WGSL 2020-12-07 09:45:24 -05:00
bors[bot]
19e5c748ad [rs] Merge #664
664: Integrate ETC and ASTC textures in Skybox example r=kvark a=cwfitzgerald

Depends on https://github.com/gfx-rs/wgpu/pull/1074

Converts skybox example to mip-mapped files in:
 - Bgra8
 - Bc1
 - ETC2
 - ASTC4x4

Looks quite good now with mipmapping and trilinear filtering even at small resolutions.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-12-06 22:27:35 +00:00
Connor Fitzgerald
20689c32d2 [rs] Integrate ETC and ASTC textures in skybox example 2020-12-06 16:51:57 -05:00
bors[bot]
17b475ae6a [rs] Merge #663
663: Shader module descriptor r=cwfitzgerald,grovesNL a=kvark

Depends on https://github.com/gfx-rs/wgpu/pull/1071
Fixes #665
Based on #662

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-12-06 02:13:54 +00:00
Dzmitry Malyshau
47f471bebb [rs] Introduce ShaderModuleDescriptor 2020-12-05 18:53:37 -05:00
bors[bot]
71a7ffe7b5 [rs] Merge #662
662: API and examples update for index_format r=kvark a=kejor

__Connections__
#608 https://github.com/gfx-rs/wgpu/issues/978 https://github.com/gfx-rs/wgpu/pull/1019

__Description__
Use new API from 4513fb2b83 where `wgpu_render_pass_set_index_buffer` and `wgpu_render_bundle_set_index_buffer` receive an `index_format` and `VertexStateDescriptor`'s `index_format` is an `Option`. The examples were updated accordingly.

Co-authored-by: kejor <kevinoviedorueda@gmail.com>
2020-12-05 02:14:38 +00:00
kejor
fe1a76dee7 [rs] API and examples update for index_format 2020-12-04 20:29:42 -05:00
Dzmitry Malyshau
41c658df7a [rs] Fix map_extent_3d in the Web backend 2020-12-02 17:32:36 -05:00
bors[bot]
4b7a0161a3 [rs] Merge #659
659: Temporarily skip debug labels for web backend r=kvark a=grovesNL

Debug labels aren't currently supported by gecko. We can re-enable these later.

Co-authored-by: Joshua Groves <josh@joshgroves.com>
2020-12-02 04:12:45 +00:00
Joshua Groves
1431e7f9d1 [rs] Temporarily skip debug labels for web backend
Debug labels aren't currently supported by gecko
2020-12-02 00:32:55 -03:30
Joshua Groves
b278dd2c64 [rs] Specify version for wasm-bindgen-cli 2020-12-01 21:41:46 -03:30
bors[bot]
3c401d2468 [rs] Merge #657
657: Add EGL to docs action r=kvark a=grovesNL

Looks like we need to install EGL for the docs action to match the regular CI action, see https://github.com/gfx-rs/wgpu-rs/runs/1478040907

Co-authored-by: Joshua Groves <josh@joshgroves.com>
2020-12-02 00:54:29 +00:00
Joshua Groves
3fd6320df9 [rs] Add EGL to docs action 2020-12-01 21:18:16 -03:30
Joshua Groves
6ec1d27ac6 [rs] Publish examples to subdirectory 2020-12-01 21:09:53 -03:30
Dzmitry Malyshau
265c99c1d7 [rs] Create CHANGELOG.md 2020-12-01 09:25:15 -05:00
bors[bot]
8e0ead1b77 [rs] Merge #655
655: Update to gfx from master r=kvark a=kvark

Depends on https://github.com/gfx-rs/wgpu/pull/1057
Expect the unexpected wrt the gpu-descriptor, which hasn't been tested much!

Also refactors the CI a bit to reduce the number of jobs by moving out `wasm` into a separate job.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-12-01 04:47:39 +00:00
Dzmitry Malyshau
adbf0c719f [rs] Update to gfx from master 2020-11-30 23:45:56 -05:00
bors[bot]
bc9648a44c [rs] Merge #649
649: Adopt the updated bind group entry API r=kvark a=kvark

Depends on https://github.com/gfx-rs/wgpu/pull/1047

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-12-01 03:45:56 +00:00
Dzmitry Malyshau
c9a718d689 [rs] Adopt the updated bind group entry API 2020-11-30 22:31:31 -05:00
bors[bot]
1eaed5e448 [rs] Merge #654
654: Use web-sys release instead of patch r=kvark a=grovesNL

`patch` isn't necessary anymore because there's a new release of web-sys and wasm-bindgen

Fixes #637

Co-authored-by: Joshua Groves <josh@joshgroves.com>
2020-12-01 02:49:48 +00:00