pub fn new(
        context: &VkContext,
        window: &dyn Window,
        event_listener: Option<&mut dyn VkSurfaceSwapchainLifetimeListener>,
    ) -> VkResult<VkSurface> {
        let swapchain = ManuallyDrop::new(VkSwapchain::new(
            &context.device().device_context,
            window,
            None,
            context.present_mode_priority(),
        )?);

        if let Some(event_listener) = event_listener {
            event_listener.swapchain_created(&context.device().device_context, &swapchain)?;
        }

        let sync_frame_index = AtomicUsize::new(0);

        let previous_inner_size = window.physical_size();

        let (result_tx, result_rx) = crossbeam_channel::bounded(1);

        Ok(VkSurface {
            device_context: context.device().device_context.clone(),
            swapchain,
            sync_frame_index: Arc::new(sync_frame_index),
            previous_inner_size,
            present_mode_priority: context.present_mode_priority().clone(),
            frame_is_in_flight: AtomicBool::new(false),
            result_tx,
            result_rx,
            torn_down: false,
        })
    }
/// Create the surface - a per-window object that maintains the swapchain
Create the surface - a per-window object that maintains the swapchain
Create the surface - a per - window object that maintains the swapchain
pub fn new(
        context: &VkContext,
        window: &dyn Window,
        event_listener: Option<&mut dyn VkSurfaceSwapchainLifetimeListener>,
    ) -> VkResult<VkSurface> {
        let swapchain = ManuallyDrop::new(VkSwapchain::new(
            &context.device().device_context,
            window,
            None,
            context.present_mode_priority(),
        )?);
        if let Some(event_listener) = event_listener {
            event_listener.swapchain_created(&context.device().device_context, &swapchain)?;
        }
        let sync_frame_index = AtomicUsize::new(0);
        let previous_inner_size = window.physical_size();
        let (result_tx, result_rx) = crossbeam_channel::bounded(1);
        Ok(VkSurface {
            device_context: context.device().device_context.clone(),
            swapchain,
            sync_frame_index: Arc::new(sync_frame_index),
            previous_inner_size,
            present_mode_priority: context.present_mode_priority().clone(),
            frame_is_in_flight: AtomicBool::new(false),
            result_tx,
            result_rx,
            torn_down: false,
        })
    }
pub fn new ( context : & VkContext , window : & dyn Window , event_listener : Option < & mut dyn VkSurfaceSwapchainLifetimeListener > , ) -> VkResult < VkSurface > { let swapchain = ManuallyDrop :: new ( VkSwapchain :: new ( & context . device ( ) . device_context , window , None , context . present_mode_priority ( ) , ) ? ) ; if let Some ( event_listener ) = event_listener { event_listener . swapchain_created ( & context . device ( ) . device_context , & swapchain ) ? ; } let sync_frame_index = AtomicUsize :: new ( 0 ) ; let previous_inner_size = window . physical_size ( ) ; let ( result_tx , result_rx ) = crossbeam_channel :: bounded ( 1 ) ; Ok ( VkSurface { device_context : context . device ( ) . device_context . clone ( ) , swapchain , sync_frame_index : Arc :: new ( sync_frame_index ) , previous_inner_size , present_mode_priority : context . present_mode_priority ( ) . clone ( ) , frame_is_in_flight : AtomicBool :: new ( false ) , result_tx , result_rx , torn_down : false , } ) }
Create the surface - a per-window object that maintains the swapchain
Create the surface - a per - window object that maintains the swapchain
context
&VkContext
window
&dyn Window
event_listener
Option<&mut dyn VkSurfaceSwapchainLifetimeListener>
context
&VkContext
window
&dyn Window
event_listener
Option<&mut dyn VkSurfaceSwapchainLifetimeListener>