This commit is contained in:
parent
c0367144a6
commit
dd8a5a97ea
9 changed files with 83 additions and 13 deletions
|
@ -17,6 +17,7 @@ pub struct VkSwapchain {
|
|||
pub(super) desired_image_count: u32,
|
||||
pub(super) surface_format: vk::SurfaceFormatKHR,
|
||||
pub(super) surface_resolution: vk::Extent2D,
|
||||
pub(super) new_requested_surface_resolution: Option<vk::Extent2D>,
|
||||
pub(super) present_mode: vk::PresentModeKHR,
|
||||
pub(super) pre_transform: vk::SurfaceTransformFlagsKHR,
|
||||
|
||||
|
@ -64,6 +65,7 @@ impl VkSwapchain {
|
|||
device: device.clone(),
|
||||
|
||||
swapchain: None,
|
||||
new_requested_surface_resolution: None,
|
||||
swapchain_support_details,
|
||||
desired_image_count,
|
||||
surface_format,
|
||||
|
@ -80,6 +82,11 @@ impl VkSwapchain {
|
|||
}
|
||||
|
||||
pub(super) fn create_swapchain(&mut self) -> VkResult<()> {
|
||||
if let Some(new_requested_surface_resolution) = self.new_requested_surface_resolution {
|
||||
self.surface_resolution = new_requested_surface_resolution;
|
||||
self.new_requested_surface_resolution = None;
|
||||
}
|
||||
|
||||
let mut swapchain_create_info = self.create_swapchain_info(&self.surface);
|
||||
|
||||
if let Some(old_swapchain) = self.swapchain {
|
||||
|
@ -154,14 +161,12 @@ impl VkSwapchain {
|
|||
if chosen_extent.width != self.surface_resolution.width
|
||||
|| chosen_extent.height != self.surface_resolution.height
|
||||
{
|
||||
self.surface_resolution = chosen_extent;
|
||||
self.new_requested_surface_resolution = Some(chosen_extent);
|
||||
log::debug!(
|
||||
"New resolution applied ({}x{})",
|
||||
"New resolution submitted ({}x{})",
|
||||
chosen_extent.width,
|
||||
chosen_extent.height
|
||||
);
|
||||
|
||||
self.create_swapchain()?;
|
||||
} else {
|
||||
log::debug!("New resolution skipped ({width}x{height}) : Same resolution");
|
||||
}
|
||||
|
@ -180,6 +185,10 @@ impl VkSwapchain {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn is_dirty(&self) -> bool {
|
||||
self.new_requested_surface_resolution.is_some()
|
||||
}
|
||||
|
||||
fn create_swapchain_info(&self, surface: &VkSurface) -> vk::SwapchainCreateInfoKHR {
|
||||
vk::SwapchainCreateInfoKHR::default()
|
||||
.surface(surface.surface)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue