-
-
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
nannou v0.9 - Vulkan graphics, simpler event API and much more #240
Conversation
Awesome stuff!! |
This switches the windowed-graphics API from OpenGL (via glium) to Vulkan (via vulkano). You can read more about the motivations, thoughts and discussion behind this switch at #208 and #108. There are still a few items left to complete before this PR is ready: - [ ] Fix bug where view seems to be vertically flipped (probably in vertex mapping process). - [ ] Fix bug where clearing an image that is then multisampled does not work. vulkano-rs/vulkano#1123 - [ ] Add depth attachment to draw renderpass. - [ ] Fix bug where alpha channels always seem opaque. - [ ] Update old loop modes for changes in the application loop. - [ ] Merge conrod vulkan backend and switch to it. - [ ] Merge and publish vulkano-rs/vulkano#1117 or related fix so we can switch to crates.io dep. Closes #208. Closes #108.
Also removes the use of `Frame::clear_all` in favour of `Frame::clear` as a `Frame` now only represents the frame for a single window.
In Vulkan, the *y* axis increases in the downwards direction rather than the upwards direction like in OpenGL.
The new `gpu` module contains items related to interfacing with one or more GPUs via Vulkan. The `App` builder now allows for specifying a custom Vulkan instance and also allows for easily setting up a debug callback for receiving messages from validation layers..
Still need to: - Allow for custom depth formats - Validate depth format
This involved refactoring the `RefreshSync` run loop into a set of modular functions for easier re-use between loop modes. Note that while each loop mode is now supported, the `Wait` and `Rate` present modes are not yet optimal. If using the `Wait` or `Rate` we should attempt to use the `Mailbox` present mode with triple-buffering in order to avoid blocking when acquiring an image. This is different to the `RefreshSync` mode as the `RefreshSync` mode is *driven* by the rate at which swapchain images can be retrieved for each window.
This allows for specifying a set of custom swapchain parameters during the window building process. The swapchain will now be recreated each time the `LoopMode` is changed at runtime. It will attempt to use optimal `PresentMode` and image count for the new swapchain unless the user has chosen a specific value for either of these parameters. The `loop_mode` example has been updated with some short docs along with the addition of the new loop mode. The window title now displays the current `LoopMode`.
The `simple_ui.rs` example works! There is an issue on my machine where, once I added MSAA, the `Ui` drawing now clears over the top of the existing window contents. I think this is just another case of vulkano-rs/vulkano#1123 and probably only affects linux machines running the intel mesa drivers.
Previously a unique set of images was created for each framebuffer unnecessarily. Now, a single set of `RenderPassImages` is created only when dimensions have changed and these are shared between each of the swapchain image framebuffers.
This should allow the `draw` renderer to draw on top of existing graphics in the case that a background was not specified.
…g in a new vk_compute_shader example
Now that vulkano 0.12.0 is out we're able to start stabilising dependencies! All that's left is to stabilise the `shade_runner` dev-dependency (used within the `vk_hotload.rs` example) and we'll be able to publish v0.9!
Switch to stable dependencies for vulkano and conrod!
This saves on info duplication and keeps the README a bit cleaner!
Remove most README contents in favour of pointing to the guide
Awesome work here, I'm excited for this to land! Is there any way in which i (or others) could help? |
I've bumped both I'd like to get to the bottom of this slow framerate on @JoshuaBatty laptop. I'm not seeing this unless the application is in the background #307 Can you please confirm josh if you are seeing a slow framerate with the application in the foreground? MoltenVK segfault is fixed and just waiting on the next vulkansdk to be released I'm going to run some profiling on windows and ubuntu. See what I can find. Hey @Walther welcome. I'm excited to we are very close now. The only blockers are the website and the sdk. With a change this big and a team this small we are no doubt going run into some issues initially after release into the wild but the more people playing with it, the quicker we can find and fix them. |
A couple of hours of testing later: nannou v0.9 branch testingSystem details:
Key takeaways:
Let me know if there's something you'd like to get more details on - happy to help! Below, more verbose & individual comments on the test runs, in the order I ran the examples. all_functions
basics/1_nannou_events
basics/2_variables_window_console
basics/3_variable_scope
basics/4_conditionals
basics/5_loops
basics/6_functions
loop_mode
multi_window
osc_receiver && osc_sender
simple_audio
simple_draw
simple_mesh
simple_polygon
simple_polyline
simple_ui
simple_window
template_app
template_sketch
generative_design/p_1_0_01
generative_design/p_1_1_01
generative_design/p_1_2_3_01
generative_design/p_1_2_3_02
laser/laser_frame_stream
laser/laser_frame_stream_gui
laser/laser_raw_stream
vulkan/vk_quad_warp
vulkan/vk_shader_include
vulkan/vk_compute_shader
vulkan/vk_debug
vulkan/vk_hotload
vulkan/vk_image_sequence
vulkan/vk_image
vulkan/vk_images
vulkan/vk_teapot_camera
vulkan/vk_teapot
vulkan/vk_triangle_raw_frame
vulkan/vk_triangle
|
Hey @Walther The load time on the images example is interesting. I'll look into that. I'm not sure about the laser examples perhaps @mitchmindtree or @JoshuaBatty might be of more help as they wrote it. I'm glad you like the hot loader! |
Ok I can confirm all examples are working on Windows in release and debug. Nothing errors printed. |
Also @Walther did you run the |
I ran the examples in default aka debug mode. Running it in release mode launches the window pretty quickly. I still found it interesting how big the difference was compared to the other examples - others launch the window under a second, These were not intended as a complaint or anything severe, just an interesting observation :) |
Ah yep so debug is way slower then release mode for rust. The way you'd handle this in a proper application is to load the images on another thread but this might be adding a bit too much complexity to this example.
No worries at all. All feedback is welcome and valuable. |
Use shade_runner from crates.io with version 0.1.0.
Update CHANGELOG for v0.9 release
Alright, I think it might be finally time to land this behemoth! |
Epic work everyone, amazing to have this merged now! Onwards to 0.10 :) |
cc @JoshuaBatty, @freesig This is mostly just all the text for now! Feel free to make any PRs to this branch to remove or add anything or let me know here and I'll have a look again tomoz :) TODO: - [ ] Add inline links to "post contents" section near top. - [ ] Syntax highlighting for code. - [ ] Add some sweet pics and animations. - [ ] Add the Vulkan-specific post (mostly a copy of [this stuff](nannou-org/nannou#240 (comment)) should be sweet?).
cc @JoshuaBatty, @freesig This is mostly just all the text for now! Feel free to make any PRs to this branch to remove or add anything or let me know here and I'll have a look again tomoz :) TODO: - [ ] Add inline links to "post contents" section near top. - [ ] Syntax highlighting for code. - [ ] Add some sweet pics and animations. - [ ] Add the Vulkan-specific post (mostly a copy of [this stuff](nannou-org/nannou#240 (comment)) should be sweet?).
cc @JoshuaBatty, @freesig This is mostly just all the text for now! Feel free to make any PRs to this branch to remove or add anything or let me know here and I'll have a look again tomoz :) TODO: - [ ] Add inline links to "post contents" section near top. - [ ] Syntax highlighting for code. - [ ] Add some sweet pics and animations. - [ ] Add the Vulkan-specific post (mostly a copy of [this stuff](nannou-org/nannou#240 (comment)) should be sweet?).
cc @JoshuaBatty, @freesig This is mostly just all the text for now! Feel free to make any PRs to this branch to remove or add anything or let me know here and I'll have a look again tomoz :) TODO: - [ ] Add inline links to "post contents" section near top. - [ ] Syntax highlighting for code. - [ ] Add some sweet pics and animations. - [ ] Add the Vulkan-specific post (mostly a copy of [this stuff](nannou-org/nannou#240 (comment)) should be sweet?).
This is easily the biggest update for nannou so far!
OpenGL -> Vulkan
The switch from OpenGL to Vulkan for cross-platform graphics is the main story here. You can find more details at #208 and #216, but the primary reasons for switching to Vulkan are:
Both High-level and Low-level Access
While the existing high-level graphics APIs should behave almost exactly the same (apart from smoother graphics and slightly better performance), this PR also allows for much lower level access to the graphics stack than was previously available. In other words, nannou now allows for fully custom graphics pipeline creation, access to each window's unique swapchain, custom vulkan instance creation, custom device selection and loads more. To demonstrate this low level access, @JoshuaBatty and I have started a new series of
vk_*.rs
examples in theexamples/vulkan/
directory. These demonstrate how to work with basic geometry, images, 3D, first-person cameras, compute shaders and more. We'll continue adding to these over time - requests are very welcome!GLSL
Note that GLSL is still well supported so you can still reach into your existing bag of shader tricks! Note however that currently only the most recent versions of GLSL are supported, so you may need to update older versions. Funnily enough, this might make it easier to run GLSL 450 code on macOS as I believe support for more recent versions of OpenGL and GLSL from Apple have been lacking.
MacOS
For folks wondering about how macOS is supported, nannou uses vulkano under the hood which links to MoltenVK on macOS for translating Vulkan to Apple's Metal API. We're hoping that by the time this is merged, @freesig's work on automating the MoltenVK installation process at build time will have landed. In theory this means that you should be able to run
cargo build
like normal and everything should Just Work™ (you might have to restart your terminal), though don't be surprised if there are hiccups as this is all still very new.Tradeoffs
All that said, this change will mean that nannou may no longer be compatible on some older systems that don't yet have Vulkan support. Nannou aims to foster the next generation of creative coding and with our small team's limited capacity this unfortunately means we must draw a line in the sand at some point. If you're curious about the level of support for Vulkan on your system's GPU you can search for it here to find detailed reports. If you're not sure what GPU you have or it's not listed in that database, the site will allow you to download the tool for generating your own report.
If nannou was working for you in 0.8 but stopped in 0.9 we would love for you to leave an issue and let us know. We'll do our best to address each issue, though keep in mind that our ability will be limited in cases where Vulkan driver support is lacking.
Simpler Event API
One glaring issue with nannou's current event API is the way that user's are expected to handle events via the
event
function. While the event type is thorough and allows for accessing loads of hardware, application and window events, handling theEvent
type itself could be quite verbose and confronting for new users who might be unfamiliar with the fancy pattern matching required.This update allows for using functions to handle events in a way that will be much more familiar to users coming from Processing, OF and Cinder and reduces the amount of language-learning users have to go through before they can start being creative.
For a closer look at these changes check out #221 and in particular the changes to the examples in the diff. The new
all_functions.rs
example demonstrates all of the new event functions that may be registered with apps and windows in one place.For details on the other small tweaks, patches, fixes and features check out the CHANGELOG diff and the commit messages below.
Merging is currently pending:
LoadOp
of swapchain imagecolor
attachment fromDontCare
toLoad
forUi
andDraw
renderpasses #241.