Commit Graph

331 Commits

Author SHA1 Message Date
Dzmitry Malyshau
bc07717f77 Enable X11 in Vulkan (#335)
* Enable X11 in Vulkan

* Fix Cargo comments
2020-05-31 11:40:33 -04:00
bors[bot]
0c69bdd850 Merge #323
323: Rename SwapChain::get_next_texture to SwapChain::get_next_frame, and return errors to the user. r=kvark a=AlphaModder

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

This creates a new type `SwapChainResult` just for the method. 
It also alters the signature of `Context::swap_chain_get_next_texture` to return 
```rust
(Option<Self::TextureViewId>, wgt::SwapChainStatus, Self::SwapChainOutputDetail)
```
which is a little ugly but I couldn't think of anything better. 

Co-authored-by: AlphaModder <quasiflux@gmail.com>
2020-05-31 05:19:03 +00:00
AlphaModder
91d46ecc2b Rename SwapChain::get_next_texture to SwapChain::get_next_frame, and have it return errors to the user. 2020-05-30 18:41:31 -07:00
bors[bot]
e371a2e1b7 Merge #330
330: Add equality derives to `BindGroupLayoutEntry` r=kvark a=Kimundi



Co-authored-by: Marvin Löbel <loebel.marvin@gmail.com>
2020-05-29 21:03:01 +00:00
Marvin Löbel
dd087b810e Add equality derives to BindGroupLayoutEntry 2020-05-29 22:55:21 +02:00
bors[bot]
d12d1422a7 Merge #321
321: Update wgpu and use write_texture r=grovesNL a=kvark

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

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-05-26 14:15:51 +00:00
Dzmitry Malyshau
686b4f71a6 Update wgpu and use write_texture 2020-05-26 10:10:32 -04:00
bors[bot]
4b16959e3e Merge #320
320: Fix typo in Friends section of README r=kvark a=jakbyte



Co-authored-by: jakbyte <jakbyte@protonmail.com>
2020-05-23 15:01:49 +00:00
jakbyte
b04f8ef3ac Fix typo in Friends section of README 2020-05-22 17:24:39 -04:00
bors[bot]
143861d361 Merge #315
315: Update wgpu-core rev r=urgent a=kvark

Fixes #314 

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-05-18 16:11:53 +00:00
Dzmitry Malyshau
2b9beebd3e Update wgpu-core rev 2020-05-18 12:11:02 -04:00
bors[bot]
c830faa06b Merge #311
311: Read WGPU_TRACE environment in the examples r=kvark a=kvark



Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2020-05-15 21:50:15 +00:00
Dzmitry Malyshau
1e722a557e Read WGPU_TRACE environment in the examples 2020-05-15 17:49:16 -04:00
Dzmitry Malyshau
4cc94fe58e Disable GHA deploy temporarily 2020-05-14 10:12:47 -04:00
Dzmitry Malyshau
28c826182f Update wgpu and use write_buffer in the examples 2020-05-14 10:12:47 -04:00
bors[bot]
c14c8e0830 Merge #306
306: Improve example friendliness: Don't busy-redraw in examples r=kvark a=khoek

Looking around for solid Rust graphics libraries, I was a bit shocked when the `wgpu-rs` examples made my whole X desktop environment in Ubuntu laggy---maximizing/minimizing other windows or moving any of them had very noticeable latency when an example was running.

This almost turned me off, but after playing around I found that this was just because of the
```rust
match event {
            event::Event::MainEventsCleared => window.request_redraw(),
            ...
```
in all of the examples. Trying to add the least code possible I've replaced a `ControlFlow::Poll` with `ControlFlow::WaitUntil(...)` in the event loops and capped the redraws-per-second below 50, which completely solves this problem for me (plus the window resize response on the examples themselves are much improved, etc.).

I was just going for an unintrusive fix---this is by no means a perfect solution, but I think in the worst case it won't be any worse that what was there originally. Plus, I think it will make people like me who try to start by copying an example more likely to stick around in the short term.

Co-authored-by: Keeley Hoek <keeley@hoek.io>
2020-05-11 21:35:47 +00:00
Keeley Hoek
ab2f1c7d03 Don't busy-redraw in examples 2020-05-12 03:20:19 +10:00
bors[bot]
9c1e6b8611 Merge #302
302: Add BufferRange struct for #199 r=kvark a=paulkernfeld

- Use in set_index_buffer
- Use in set_vertex_buffer
- Use in BindingResource

Co-authored-by: Paul Kernfeld <paulkernfeld@gmail.com>
2020-05-10 21:50:06 +00:00
Paul Kernfeld
1172a186b1 Add Buffer.slice fn for #199
This fn is used for set_index_buffer, set_vertex_buffer, and
BindingResource
2020-05-10 17:37:19 -04:00
bors[bot]
9f19533462 Merge #272
272: Force the wasm32 types to match Send / Sync with the native types r=kvark a=kyren

This is potentially a controversial change so this is just a draft to discuss it.

Currently, when building wgpu on wasm32, none of the interface types are Send or Sync, whereas on any other platform they are generally Send and Sync and this can cause a lot of pain, especially in the presence of async.

This PR is the nuclear option: lie and forcibly declare nearly all interface types to be Send or Send + Sync.

I think I understand the situation with proposed wasm32 threading a bit better now, and as of right now at least with my current understanding, it seems to me unlikely that javascript values held by rust could *ever* be sent transparently to another worker.  The mechanism that rust apparently will use to implement transparent threading will be to use `SharedArrayBuffer` to share memory between multiple workers.  Javascript provides a way for certain (serializable) objects to be shared with with other workers through `worker.postMessage()`, so Javascript has *some* story for sending javascript values to other threads, but only plain rust values that exist solely in the `SharedArrayBuffer` memory are send-able under this scheme.  I've looked briefly through some of the wasm proposals like the interface types proposal, but I don't have a good sense if there's any proposed mechanism at all for interface types and threads to interact at all.

If that's true that's really unfortunate because it seems like any thread safe API shared by native and web is doomed to mismatch.  This is even more unfortunate because many of the webgpu types in the draft standard are marked as 'Serializable', meaning that they *are* actually safe to send to another worker via `postMessage`, but there does not appear to be a planned way for rust to do this transparently.

I definitely could be misunderstanding the situation though and even if I am understanding it, the situation may have since changed.  I also don't know the timing here, I don't know what the eventual timing of wasm32 threading support will be vs webgpu support and interface types support.  *Right now* this PR is almost certainly sound, but there's definitely a possible future where it becomes unsound, and even maybe a possible future where it becomes unsound but then could later be made sound again.

Co-authored-by: kyren <kerriganw@gmail.com>
2020-05-07 04:09:14 +00:00
kyren
c37a3233e9 Force the wasm32 types to match Send / Sync with the native types
There are several things in this commit:

1) Add `Send` or `Send + Sync` bounds to most of the associated types in `Context`.
2) Force most of the handle types and future types returned by the web backend to be Send / Sync
3) Make `BufferReadMapping` and `BufferWriteMapping` `Send` again on native by
   making the associated detail types implement `Send`.
2020-05-06 23:02:27 -04:00
bors[bot]
89ee5bffd3 Merge #300
300: Properly free pass contents r=kvark a=kvark

Fixes #299

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-05-06 01:56:54 +00:00
Dzmitry Malyshau
17b46687ce Rustfmt pass on examples 2020-05-05 21:55:42 -04:00
Dzmitry Malyshau
7147340595 Free pass contents 2020-05-05 21:55:25 -04:00
bors[bot]
c5b14235d4 Merge #298
298: Added a screenshot for harmony. r=kvark a=StarArawn



Co-authored-by: John Mitchell <john.mitchell@mangolanguages.com>
2020-05-05 16:05:05 +00:00
John Mitchell
c5c9a5ea45 Added a screenshot for harmony. 2020-05-05 11:59:56 -04:00
Dzmitry Malyshau
3d83812760 Add wgpu-pbr to README 2020-05-05 11:20:15 -04:00
bors[bot]
9abff0f235 Merge #297
297: Update wgpu with the BGL fix r=kvark a=kvark



Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
2020-05-05 04:05:22 +00:00
Dzmitry Malyshau
f3ff8d33ae Update wgpu with the BGL fix 2020-05-05 00:04:24 -04:00
bors[bot]
f79ee512eb Merge #295
295: Remove wasm-bindgen patches r=grovesNL a=rukai

A new release occurred with the required fixes, so we no longer need to patch it.

Co-authored-by: Rukai <rubickent@gmail.com>
2020-05-02 12:44:45 +00:00
Rukai
a1ef4c499a Remove wasm-bindgen patches 2020-05-02 22:41:15 +10:00
bors[bot]
449924bb42 Merge #291
291: Update for wgpu-core r=grovesNL a=kvark

Depends on https://github.com/gfx-rs/wgpu/pull/619
Closes #285

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-05-02 03:59:45 +00:00
Dzmitry Malyshau
4413c4648d Update for wgpu-core 2020-04-30 15:52:16 -04:00
bors[bot]
49640d2497 Merge #281
281: The Context trait r=grovesNL a=kvark

The main motivation here is to avoid blocking the wgpu-core updates by `wgpu-native`. Instead, `wgpu-native` becomes a branch, and the dependency of `wgpu-rs` -> `wgpu-native` starts adhering to the contract/API of the standard webgpu-native headers.

The biggest change is the introduction of the Context trait. I recall us discussing 2 downsides to having this trait:
  1. inconvenient for the users to include. This is a non-issue here, since it's private.
  2. more code to maintain. This is less of an issue if we aim to have 3 backends.

What this gives in return is a well established contract with the backends. Unlike gfx-rs, the backend code is right here, a part of the crate, so the contract is only for internal use.

Fixes #156 : the "direct" implementation of it goes straight to wgpu-core. What this gives us is less overhead for command recording, since there is no longer an extra indirection on every command, and no heap allocation at the end of a render pass.

The downside of this PR is one extra `Arc` (with addref) per object.

This commit also has small improvements:
- consuming command buffers on submit (Fixes #267)
- Instance type
- proper call to destructors
- fallible `request_device`

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-04-27 04:12:38 +00:00
Dzmitry Malyshau
b7883e485c Small comment on WebGPU backend bit, readme update 2020-04-27 00:11:22 -04:00
Dzmitry Malyshau
e30a428190 Port the Web backend to the Context trait 2020-04-26 19:18:24 -04:00
Dzmitry Malyshau
0d85635008 Move everything into Context trait, remove async 2020-04-26 19:18:24 -04:00
Dzmitry Malyshau
ba95354734 Rewire the backend system to remove wgpu-native step
Main change here is the introduction of the Context trait.
The "direct" implementation of it goes straight to wgpu-core.

This commit also has small improvements:
- consuming command buffers on submit
- Instance type
- proper call to destructors
2020-04-26 19:18:24 -04:00
Chinedu Francis Nwafili
309cc1cedd Add screenshots of examples
When looking into wgpu-rs as a replacement for WebGL I went to the
examples directory on GitHub to browse for a bit.

I wanted to see some of the examples at a glance without needing to
clone the repository.

This commit enables that by adding a README to each example with a
description of the example and screenshots / example output.

In a few cases the description is a bit redundant - but my hope is that
in the future we can improve all the READMEs.

Being a web API and thus very accessible, WebGPU could end up being many
people's first introduction to graphics programming so the lower we make
the barrier the better.
2020-04-26 18:59:48 -02:30
bors[bot]
c0b09bebad Merge #280
280: Add required wasm-bindgen patches to readme r=grovesNL a=rukai

Fixes https://github.com/gfx-rs/wgpu-rs/issues/279

Co-authored-by: Rukai <rubickent@gmail.com>
2020-04-25 03:03:56 +00:00
Rukai
c7895732a4 Add required wasm-bindgen patches to readme 2020-04-25 12:09:13 +10:00
Gabriel Majeri
aa8f5d7267 Build and deploy examples in CI 2020-04-24 22:32:26 -02:30
Igor Shaposhnik
36289ea720 Disable fail fast on CI 2020-04-24 22:31:21 -02:30
Christophe Massolin
0fb47262ea Update README.md for running examples on the web (#275)
* [readme] add details for running on wasm32 target

* [readme] update

* [readme] [web] Running instruction on webgpu.io
2020-04-24 09:42:15 -04:00
bors[bot]
242a596e2c Merge #271
271: Improve docs for BindingType r=kvark a=HalfVoxel

I think everything should be correct.

The readonly flags seem obvious at face value, but I couldn't find anything in the specifications about them (other than some unrelated validation), so I didn't add any documentation for those fields.

Co-authored-by: Aron Granberg <aron.granberg@gmail.com>
2020-04-22 13:08:31 +00:00
Aron Granberg
567cb16f7c Improve docs for BindingType 2020-04-22 15:07:11 +02:00
bors[bot]
5f885ed3cc Merge #268
268: Fix hello-triangle example format and bind group r=kvark a=kvark



Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-04-21 23:10:18 +00:00
Dzmitry Malyshau
b612d9c8ef Fix hello-triangle example format and bind group 2020-04-21 19:08:42 -04:00
bors[bot]
1e3b1a38fe Merge #262
262: Reverse srgb in hello-triangle r=kvark a=grovesNL

Reverse srgb support in hello-triangle (these were backwards by mistake)

Co-authored-by: Joshua Groves <josh@joshgroves.com>
2020-04-20 02:18:30 +00:00
bors[bot]
fe565e7cef Merge #264
264: Use opaque texels in mipmap example r=kvark a=grovesNL

This fixes rendering for the mipmap example in Nightly

Co-authored-by: Joshua Groves <josh@joshgroves.com>
2020-04-20 02:13:07 +00:00