-
-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - Transition graphics backend from vulkano to wgpu #452
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Feb 16, 2020
This PR is an overhaul of the graphics backend used throughout nannou. See nannou-org#446, nannou-org#374, nannou-org#408 for related issues and motivation.
The `simple_ui.rs` and `named_color_reference.rs` examples have been tweaked slightly to allow for testing. They will be changed to their original state once wgpu support for draw is implemented.
Fixes drawing behaviour when the window is resized.
Still need to enable the depth buffer and test with 3D.
Also re-exports the `wgpu` crate's `Texture` type as `TextureHandle`. The new `Texture` type acts as a much more convenient handle around the `wgpu::Texture`, providing access to the descriptor from which it was created along with all the info it provides. The new `TextureBuilder` type wraps the `TextureDescriptor` with a set of reasonable defaults, allowing for more convenient texture construction.
mitchmindtree
changed the title
WIP - Transition graphics backend from vulkano to winit
WIP - Transition graphics backend from vulkano to wgpu
Feb 22, 2020
This restructures management of wgpu adapters, devices and queues so that devices and their queues can be automatically shared between windows. This allows for easy sharing of GPU resources like textures and buffers between multiple windows - very useful for multi-display installations, projection mapping, etc.
Currently I'm getting some "GPU got stuck" errors which cause the window to lock-up for a few seconds before causing the process to crash. Going to enable logging to see if validation layers show any issues before going further with this.
This fixes a crash I was running into in on Linux with Intel HD620.
Also adds methods for accessing the primary and available monitors to the **App**.
Also implements the scale factor changed event.
Defaulting the `wpgu::PowerPreference` to `HighPerformance` makes things fly on the macbook pro I have for testing. Simplified the loop modes as much as possible based on what is currently possible with wgpu - also seems to improve behaviour a bit on macOS.
This is useful for copying the swap chain texture for example.
This allows the user to ensure that the command buffer responsible for drawing to the swap chain texture is submitted prior to the end of their `view` function. This is necessary to allow the user to read back buffers and textures involved in drawing to the texture at the end of the `view` function. Without this change, it is not possible to do so in nannou's current API. The most significant user-impacting change is that the `view` functions now take the `Frame` by value, rather than by reference.
This adds a suite of functionality for efficiently mapping texture data and reading it from the CPU. Highlights include: - `TextureCapturer` to simplify the reading of textures into image file compatible formats. A `capture_hi_res.rs` example has been added to demonstrate. - `window.capture_frame(path)` for writing the next frame to a file at the given path. A `simple_capture.rs` example has been added demonstrating this. `TextureFormatConverter` has been renamed to `TextureReshaper` and support has been added for converting both texture size and sample count.
Also removes the remaining vulkan examples. We can always refer to these from previous commits when we are ready to port them to the new wgpu graphics backend.
This should avoid some confusion where users might wonder why their aync reads/writes aren't happening when unaware that `device.poll` must be called.
Previously a validation error was occurring due to passing a sampled texture to the bind group without declaring that the texture was multisampled in the fragment shader. This adds some new multisampled shaders that correctly declare the texture and do the multisampling resolve manually. Dedicated shaders have been added for common sample counts with unrolled loops to avoid having the shader deal with conditions based on uniform data. A fallback shader is provided for all other sample counts. Closes nannou-org#462.
This allows for specifying the window size of a sketch without having to set the size within the `view` function every frame. Closes nannou-org#461. Note that as a result of `nannou::sketch(view)` producing a builder type, you now must call `.run()` to make the sketch do anything. The `app::Builder` now also supports a `.size(w, h)` builder method for specifying the default window width and height in points.
This makes the capture examples synchronous with the main thread in order to avoid users' machines running out of RAM as was reported during testing. Both examples now display a comment on how to get a speed up via threading and mentions the potential memory usage caveats. Specifically, this adds a `capture_frame_threaded` method to accompany the `capture_frame` method. This also changes the `TextureCapturer` to use all available CPUs by default when `read_threaded` is called, rather than just 1.
mitchmindtree
added a commit
to mitchmindtree/guide
that referenced
this pull request
Mar 3, 2020
The main change is the removal of a lot of vulkan related build instructions on macOS and windows. Hopefully these platforms have been simplified a lot now, though I imagine we might have to add a thing or two following this big overhaul. Code example updates are minor - mostly just changing `view` functions to take `Frame` by value rather than by reference. This commit requires nannou-org/nannou#452 is merged into main before the book tests will pass for travis.
Okydoky I think we're ready! |
Epic work @mitchmindtree |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a WIP overhaul of the graphics backend used throughout nannou! 🎂 🎉 🎈
See #446, #374, #408 for related issues and motivation.
Progress:
wgpu
branch.winit
dependency to version 0.21.wgpu.rs
module. Re-exportwgpu
and extend with helper items as we go.vk
related state fromApp
. Comment out loop functions for now.draw::backend::wgpu
with placeholder types.window.rs
swapchain and surface code to switch from vk to wgpu items.frame.rs
module.vk.rs
module.run_loop
for changes towinit::EventLoop
. We should no longer usepoll_events
, but instead useMainEventsCleared
andRedrawRequested
. This will likely require a full re-write. May be easiest to introduce oneLoopMode
at a time.ui.rs
module to useconrod_wgpu
rather thanconrod_vulkano
.draw.rs
module. Update draw.rs module #440.wgpu::SamplerBuilder
.wgpu::TextureBuilder
.wgpu::Device
s toApp
. Allows for use of a single device across multiple windows. This is necessary to support sharing resources between windows.Draw
Renderer
and test with 3D vertices.log
, so users can add a logger likeenv_logger
if they want to receive output for now.vk
examples directory towgpu
and update all examples.screenshot.rs
example.screenshot_hi_res.rs
example - drawing to a larger image independent of window size.wgpu
module.nannou
.Improve application loop update timing. Find more info onWill address this in a follow-up PR - see Improve loop timing and revisitget_next_texture()
delays and wgpu swap chain behaviour. Consider semantic differences betweenRefreshSync
andRate
now thatPresentMode
toggle is exposed in window builder.LoopMode
s #456.Add GL support feature to match wgpu examples. Test GL backend.This can wait - should keep track of Wgpu gl support gfx-rs/wgpu-rs#182.Closes #187
Closes #197
Closes #261
Closes #293
Closes #306
Closes #307
Closes #312
Closes #314
Closes #319
Closes #336
Closes #348
Closes #350
Closes #352
Closes #354
Closes #356
Closes #357
Closes #365
Closes #372
Closes #373
Closes #374
Closes #392
Closes #408
Closes #412
Closes #422
Closes #433
Closes #438
Closes #440
Closes #446
Currently nannou compiles! That said, only a handful of the examples are working. The
frame
,app
,window
,event
andvk
(nowwgpu
) modules have been updated forwgpu
and the latest version ofwinit
. Thedraw
andui
modules are yet to be updated, but shouldn't be too tricky considering we have theconrod_wgpu
implementation as a reference.cc @DavidPartouche @freesig
Update:
ui
anddraw
modules now updated!