Closed coolcatcoder closed 6 months ago
You can look at some of Vulkano's examples that use vulkano-utils. Like this one: https://github.com/vulkano-rs/vulkano/blob/7b17d590a7908ed2ba08d8e64f70b75b528b5d23/examples/multi-window-game-of-life/main.rs#L105-L109
From looking at that specific example (and others), it seems to create a frame buffer every frame, if I understand correctly. How badly does this affect performance, if at all?
I agree that that is a bit of a silly thing to do. We should probably update the examples with something more sensible.
What would be a more sensible course of action, so that I can implement it in my code?
It should be created whenever the swapchain is (re)created, and then kept and reused.
Is it possible to find out when a window renderer recreates its swapchain? I couldn't figure out how to do that, if that is even possible.
Okay by ctrl-f-ing my way through the vulkano window renderer code, I think it only sets recreate_swapchain on .resize() and .set_present_mode(), then it only actually recreates the swapchain on acquisition of the future. So now I just need to somehow access final_views so I can recreate my framebuffers.
This seems like it could be simplified by perhaps storing a closure that gets passed final_views, that gets called on recreation of the swapchain.
Edit: This seems like a fairly simple change, and I've never contributed to anything before, so I'll try to create some code, and then I'll chuck it into a pull request.
How would I create frame buffers when the swapchain images stored as final_views in VulkanoWindowRenderer are private? Usually in my code, when the window size changed, I would recreate my frame buffers by looping through the swapchain images and create a frame buffer for every one. Something like this:
(Fairly certain I stole this code from one of the examples.) How would I adapt the code to work with VulkanoWindowRenderer?
Edit: Thinking about this further, how would I even access the new images at all? Resize() only sets recreate_swapchain. Perhaps we could give some sort of closure for it to call when it recreates the swapchain?