pub fn choose_swap_extent(
    window_surface: &dyn WindowSurface,
    physical_device: &vk::PhysicalDevice,
) -> Result<vk::Extent2D> {
    //! Getting surface capabilities is safe because suppport for the swapchain
    //! extenstion is verified when picking a physical device
    let capabilities =
        unsafe { window_surface.surface_capabilities(physical_device)? };

    if capabilities.current_extent.width != u32::MAX {
        log::debug!("use current extent {:?}", capabilities.current_extent);
        Ok(capabilities.current_extent)
    } else {
        let (width, height) = window_surface.framebuffer_size();
        let extent = vk::Extent2D {
            width: clamp(
                width,
                capabilities.min_image_extent.width,
                capabilities.max_image_extent.width,
            ),
            height: clamp(
                height,
                capabilities.min_image_extent.height,
                capabilities.max_image_extent.height,
            ),
        };
        log::debug!("use computed extent {:?}", extent);
        Ok(extent)
    }
}
/// Choose the swap extent for the swapchain based on the window's framebuffer
/// size.
Choose the swap extent for the swapchain based on the window's framebuffer
size.
Choose the swap extent for the swapchain based on the window ' s framebuffer size .
pub fn choose_swap_extent(
    window_surface: &dyn WindowSurface,
    physical_device: &vk::PhysicalDevice,
) -> Result<vk::Extent2D> {
    //! Getting surface capabilities is safe because suppport for the swapchain
    //! extenstion is verified when picking a physical device
    let capabilities =
        unsafe { window_surface.surface_capabilities(physical_device)? };
    if capabilities.current_extent.width != u32::MAX {
        log::debug!("use current extent {:?}", capabilities.current_extent);
        Ok(capabilities.current_extent)
    } else {
        let (width, height) = window_surface.framebuffer_size();
        let extent = vk::Extent2D {
            width: clamp(
                width,
                capabilities.min_image_extent.width,
                capabilities.max_image_extent.width,
            ),
            height: clamp(
                height,
                capabilities.min_image_extent.height,
                capabilities.max_image_extent.height,
            ),
        };
        log::debug!("use computed extent {:?}", extent);
        Ok(extent)
    }
}
pub fn choose_swap_extent ( window_surface : & dyn WindowSurface , physical_device : & vk :: PhysicalDevice , ) -> Result < vk :: Extent2D > { //! Getting surface capabilities is safe because suppport for the swapchain //! extenstion is verified when picking a physical device let capabilities = unsafe { window_surface . surface_capabilities ( physical_device ) ? } ; if capabilities . current_extent . width != u32 :: MAX { log :: debug ! ( " " capabilities current_extent ) ; Ok ( capabilities . current_extent ) } else { let ( width , height ) = window_surface . framebuffer_size ( ) ; let extent = vk :: Extent2D { width : clamp ( width , capabilities . min_image_extent . width , capabilities . max_image_extent . width , ) , height : clamp ( height , capabilities . min_image_extent . height , capabilities . max_image_extent . height , ) , } ; log :: debug ! ( " " extent ) ; Ok ( extent ) } }
Choose the swap extent for the swapchain based on the window's framebuffer
size.
Choose the swap extent for the swapchain based on the window ' s framebuffer size .
window_surface
&dyn WindowSurface
physical_device
&vk::PhysicalDevice