Commit Graph
83 Commits
Author SHA1 Message Date
Oleg Andreev c9a7fe75d4 Return None from get_swap_chain_preferred_format if the adapter does not support the surface. 2021-03-01 18:15:01 +03:00
Tnze 6e6816e938 Use the "max" function to ensure that the swapchain size is not less than 1. For better readability. 2021-02-09 14:20:22 +08:00
Connor Fitzgerald 6d52bc5535 Add pipeline statistics and timeline queries 2021-01-16 01:05:03 -05:00
Niklas Korz 0578cda7a6 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
Jay Oster dae801baa0 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
Andreas Reich 2b2aed3a46 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
Manuel Gil a5f44f2759 Remove wgpu-subscriber -> subscriber alias in examples 2021-01-05 19:05:52 +00:00
Manuel Gil e00ef5d584 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 f3d6d242d7 Update wgpu with Naga fixes and OpenGL backend 2020-12-17 13:03:27 -05:00
Connor Fitzgerald a4202a4ff0 Add create_texture_with_data helper 2020-12-12 01:50:49 -05:00
Diggory Blake bed49ac654 Print chosen adapter when running examples 2020-11-30 18:33:51 +00:00
Dzmitry Malyshau 2dc59ba2d9 Port to the updated wgpu error model 2020-11-23 17:59:21 -05:00
Zsolt Bölöny 16427aed19 Rename TextureUsage::OUTPUT_ATTACHMENT to RENDER_ATTACHMENT 2020-11-09 10:35:55 +01:00
Dzmitry Malyshau 503b61dc6c Update wgpu with another bind group fix, updated power preference 2020-10-13 16:57:52 -04:00
Dzmitry Malyshau 30fb46a999 Really fix the environment to WGPU_BACKEND this time 2020-10-11 23:43:39 -04:00
Dzmitry Malyshau d8fe188305 Support WGPU_BACKEND environment in the examples 2020-10-11 23:17:38 -04:00
Joshua Groves 0fb8a436e5 Reorder framework window creation for web 2020-09-16 01:04:49 -02:30
crispweed 1935cfa28a Removed erroneous zero size check related conditional in water example resize() (#534)
* The conditional at the start of resize() already tests for and exits on the zero width and height condition.
The conditional removed here was then getting run on every other call to resize(), which doesn't seem logical, doesn't correspond to the comment, and seemed to be causing at least one issue with rendered viewport going black during resize.

Fixes #532
(probably) Fixes #519

* Defensive coding to prevent various issues when window size goes to zero, e.g. NaN being passed in cgmath::perspective() aspect ratio parameter.

Fixes #531
2020-08-25 13:25:50 -04:00
Dzmitry Malyshau ed9a2ca6df Update for the wgpu grand refactor 2020-08-13 00:26:40 -04:00
Connor Fitzgerald ccfe3ed285 Enable features in CI to prevent compiler errors 2020-07-29 12:58:08 -04:00
Connor Fitzgerald 7871d100c8 Convert to tracing for logging and add fmt logger 2020-07-26 00:44:39 -04:00
Connor Fitzgerald 7e17789987 Split framework limit situation into requested/required, enforcing correctness in the framework 2020-07-24 17:37:04 -04:00
Rukai be388200dc Update to latest wgpu 2020-07-21 01:51:55 +10:00
Zsolt Bölöny 10538f8a9f Move logger init earlier in the example framework 2020-07-19 22:41:27 +02:00
Connor Fitzgerald a67047297c Implement PUSH_CONSTANTS feature 2020-07-13 15:43:46 -04:00
m4b 68754e6ca9 recreate swapchain on framework.rs examples on resize, ref #352 2020-07-10 21:30:39 -07:00
Gabriel Majeri eb91482d0b Update to new wgpu-core render pipeline API 2020-07-07 21:02:11 +03:00
Connor Fitzgerald 5529b60da4 Convert Extensions + Capabilities into Features 2020-06-26 01:27:57 -04:00
kyren e6ec327689 A different attempt at the example framework 2020-06-25 13:13:13 -04:00
kyren f05496fa59 Get event loop + futures working on native, untested on web 2020-06-25 13:13:13 -04:00
Dzmitry Malyshau aef72d7fd7 Refactor examples API, improve belt documentation and logic 2020-06-23 23:51:47 -04:00
Dzmitry Malyshau 4aa7abdff8 Staging belt, use LocalSpawner for the framework 2020-06-23 23:15:47 -04:00
Connor Fitzgerald 741644d252 Add Tracing 2020-06-22 23:14:29 -04:00
Marvin Löbel 693abce446 Move backends: BackendBit paramter to Instance::new() 2020-06-19 01:25:38 +02:00
Connor Fitzgerald f8be38cc01 Implement TEXTURE_BINDING_ARRAY extension 2020-06-11 16:36:53 -04:00
Dzmitry Malyshau 9259d2e51d Update to wgpu with shader validation 2020-06-08 20:54:39 -04:00
Connor Fitzgerald b71c420f7a Implement extensions interface as described in wgpu#691 2020-06-08 01:20:00 -04:00
Connor Fitzgerald cf9d9d6656 Rustify the example's use of Extensions and SamplerDescriptor 2020-06-02 21:44:07 -04: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
Dzmitry Malyshau 686b4f71a6 Update wgpu and use write_texture 2020-05-26 10:10:32 -04:00
Dzmitry Malyshau 1e722a557e Read WGPU_TRACE environment in the examples 2020-05-15 17:49:16 -04:00
Dzmitry Malyshau 28c826182f Update wgpu and use write_buffer in the examples 2020-05-14 10:12:47 -04:00
Keeley Hoek ab2f1c7d03 Don't busy-redraw in examples 2020-05-12 03:20:19 +10:00
Dzmitry Malyshau 17b46687ce Rustfmt pass on examples 2020-05-05 21:55:42 -04:00
Dzmitry Malyshau 4413c4648d Update for wgpu-core 2020-04-30 15:52:16 -04:00
Dzmitry Malyshau e30a428190 Port the Web backend to the Context trait 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
Joshua Groves 423f576d8e Use srgb for swapchain when possible 2020-04-18 01:04:28 -02:30
Joshua Groves f0ab842d6e Combine wasm_main/main and add console_log 2020-04-18 01:04:28 -02:30
Joshua Groves 349f992a7a Switch event loop back to ControlFlow::Poll 2020-04-18 01:04:28 -02:30