diff --git a/vulkan-rs/src/swapchain.rs b/vulkan-rs/src/swapchain.rs index 4f5c860..ea53095 100644 --- a/vulkan-rs/src/swapchain.rs +++ b/vulkan-rs/src/swapchain.rs @@ -50,11 +50,15 @@ impl Swapchain { image_usage: impl Into, prefered_format: VkFormat, array_layers: u32, + window_size: (u32, u32), ) -> Result> { let surface_caps = surface.capabilities(&device)?; let extent = if surface_caps.currentExtent.width == u32::max_value() { - return Err(anyhow::Error::msg("Surface has no extent")); + VkExtent2D { + width: window_size.0, + height: window_size.1, + } } else { VkExtent2D { width: surface_caps.currentExtent.width, @@ -178,7 +182,7 @@ impl Swapchain { }) } - pub fn recreate(&self) -> Result<()> { + pub fn recreate(&self, window_size: (u32, u32)) -> Result<()> { // wait for the device to get idle self.device.wait_idle()?; @@ -187,7 +191,10 @@ impl Swapchain { let extent = if surface_caps.currentExtent.width == u32::max_value() || surface_caps.currentExtent.height == u32::max_value() { - return Err(anyhow::Error::msg("Surface has no extent")); + VkExtent2D { + width: window_size.0, + height: window_size.1, + } } else if surface_caps.currentExtent.width == 0 || surface_caps.currentExtent.height == 0 { // don't recreate swapchain return Ok(());