From b83b21427f97a5c34fe5bf9a4908c86ace96457b Mon Sep 17 00:00:00 2001 From: hakolao Date: Tue, 12 Jul 2022 10:47:48 +0300 Subject: [PATCH 1/3] Allow swapchain recreation with new present mode in utils --- vulkano-util/src/renderer.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vulkano-util/src/renderer.rs b/vulkano-util/src/renderer.rs index 343b806b65..84342d249b 100644 --- a/vulkano-util/src/renderer.rs +++ b/vulkano-util/src/renderer.rs @@ -53,6 +53,7 @@ pub struct VulkanoWindowRenderer { recreate_swapchain: bool, previous_frame_end: Option>, image_index: usize, + present_mode: vulkano::swapchain::PresentMode, } impl VulkanoWindowRenderer { @@ -87,6 +88,7 @@ impl VulkanoWindowRenderer { recreate_swapchain: false, previous_frame_end, image_index: 0, + present_mode: descriptor.present_mode, } } @@ -136,6 +138,13 @@ impl VulkanoWindowRenderer { (swapchain, images) } + pub fn set_present_mode(&mut self, present_mode: vulkano::swapchain::PresentMode) { + if self.present_mode != present_mode { + self.present_mode = present_mode; + self.recreate_swapchain = true; + } + } + /// Return swapchain image format pub fn swapchain_format(&self) -> Format { self.final_views[self.image_index].format().unwrap() @@ -197,7 +206,7 @@ impl VulkanoWindowRenderer { dims[0] / dims[1] } - /// Resize swapchain and camera view images at the beginning of next frame + /// Resize swapchain and camera view images at the beginning of next frame based on window dimensions pub fn resize(&mut self) { self.recreate_swapchain = true; } @@ -301,6 +310,8 @@ impl VulkanoWindowRenderer { let dimensions: [u32; 2] = self.window().inner_size().into(); let (new_swapchain, new_images) = match self.swap_chain.recreate(SwapchainCreateInfo { image_extent: dimensions, + // Use present mode from current state + present_mode: self.present_mode, ..self.swap_chain.create_info() }) { Ok(r) => r, From c2e8795ba4a57cc76e30fa7e9228b908bbc59e36 Mon Sep 17 00:00:00 2001 From: hakolao Date: Tue, 12 Jul 2022 11:23:35 +0300 Subject: [PATCH 2/3] Add doc text --- vulkano-util/src/renderer.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/vulkano-util/src/renderer.rs b/vulkano-util/src/renderer.rs index 84342d249b..db4b2774b1 100644 --- a/vulkano-util/src/renderer.rs +++ b/vulkano-util/src/renderer.rs @@ -138,6 +138,7 @@ impl VulkanoWindowRenderer { (swapchain, images) } + /// Set window renderer present mode. This triggers a swapchain recreation. pub fn set_present_mode(&mut self, present_mode: vulkano::swapchain::PresentMode) { if self.present_mode != present_mode { self.present_mode = present_mode; From 456677476316a95265d0ba9137d3d135d6fb4125 Mon Sep 17 00:00:00 2001 From: hakolao Date: Tue, 12 Jul 2022 11:27:07 +0300 Subject: [PATCH 3/3] Add to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cc246f6eb..3a2e396e8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ - Added an `is_signaled` method to `FenceSignalFuture`. - Add a simple `general_purpose_image_view` method to `StorageImage` for less verbose image view creation for e.g. intermediary render targets. - Add a `vulkano_util` crate to help reduce boilerplate in many use cases. `VulkanoContext` to hold access to device & instances, `VulkanoWindows` to organize windows and their renderers. `VulkanoRenderer` to hold the window and methods to `acquire` (swapchain) and `present` between which you are intended to execute your pipelines. +- Add option to change `PresentMode` at runtime in `vulkano_util` with `set_present_mode` # Version 0.29.0 (2022-03-11)