Update
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 1s

This commit is contained in:
Florian RICHER 2024-11-24 19:24:28 +01:00
parent c0367144a6
commit dd8a5a97ea
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
9 changed files with 83 additions and 13 deletions

View file

@ -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)