// ================================================================================
//  Instance Creation
// ================================================================================
/// Creates an instance of the Vulkan client side driver given the raw handle.
/// Currently Sarekt doesn't support drawing to anything but a presentable
/// window surface.
Instance Creation
Creates an instance of the Vulkan client side driver given the raw handle.
Currently Sarekt doesn't support drawing to anything but a presentable
window surface.
Instance Creation Creates an instance of the Vulkan client side driver given the raw handle . Currently Sarekt doesn ' t support drawing to anything but a presentable window surface .
fn create_instance<W: HasRawWindowHandle>(
    entry: &Entry, window: &W, application_name: &str, application_version: u32, engine_name: &str,
    engine_version: u32,
  ) -> SarektResult<Arc<Instance>> {
    let app_info = vk::ApplicationInfo::builder()
      .application_name(CString::new(application_name)?.as_c_str())
      .application_version(application_version)
      .engine_name(CString::new(engine_name)?.as_c_str())
      .engine_version(engine_version)
      .api_version(ash::vk::make_version(1, 2, 131))
      .build();
    let mut layer_names: Vec<_> = Vec::new(); // Will not alloc until stuff put in, so no problem.
    unsafe {
      if ENABLE_VALIDATION_LAYERS {
        assert!(
          Self::check_validation_layer_support(entry),
          "The requested validation layers were not available!"
        );
        layer_names = VALIDATION_LAYERS.iter().map(|name| name.as_ptr()).collect();
      }
    }
    let extension_names = Self::get_required_extensions(window)?;
    unsafe {
      if IS_DEBUG_MODE {
        Self::log_extensions_dialog(entry, &extension_names);
      }
    }
    let extension_names: Vec<_> = extension_names
      .iter()
      .map(|&ext| ext.as_ptr() as *const i8)
      .collect();
    let mut debug_create_info = vk::DebugUtilsMessengerCreateInfoEXT::builder()
      .message_severity(vk::DebugUtilsMessageSeverityFlagsEXT::all())
      .message_type(vk::DebugUtilsMessageTypeFlagsEXT::all())
      .pfn_user_callback(Some(DebugUtilsAndMessenger::debug_callback))
      .build();
    let instance_create_info = vk::InstanceCreateInfo::builder()
      .application_info(&app_info)
      .enabled_layer_names(&layer_names)
      .enabled_extension_names(&extension_names)
      .push_next(&mut debug_create_info)
      .build();
    let instance = unsafe { entry.create_instance(&instance_create_info, None) }?;
    Ok(Arc::new(instance))
  }
fn create_instance < W : HasRawWindowHandle > ( entry : & Entry , window : & W , application_name : & str , application_version : u32 , engine_name : & str , engine_version : u32 , ) -> SarektResult < Arc < Instance > > { let app_info = vk :: ApplicationInfo :: builder ( ) . application_name ( CString :: new ( application_name ) ? . as_c_str ( ) ) . application_version ( application_version ) . engine_name ( CString :: new ( engine_name ) ? . as_c_str ( ) ) . engine_version ( engine_version ) . api_version ( ash :: vk :: make_version ( 1 , 2 , 131 ) ) . build ( ) ; let mut layer_names : Vec < _ > = Vec :: new ( ) ; // Will not alloc until stuff put in, so no problem. unsafe { if ENABLE_VALIDATION_LAYERS { assert ! ( Self check_validation_layer_support ( entry ) " " ) ; layer_names = VALIDATION_LAYERS . iter ( ) . map ( | name | name . as_ptr ( ) ) . collect ( ) ; } } let extension_names = Self :: get_required_extensions ( window ) ? ; unsafe { if IS_DEBUG_MODE { Self :: log_extensions_dialog ( entry , & extension_names ) ; } } let extension_names : Vec < _ > = extension_names . iter ( ) . map ( | & ext | ext . as_ptr ( ) as * const i8 ) . collect ( ) ; let mut debug_create_info = vk :: DebugUtilsMessengerCreateInfoEXT :: builder ( ) . message_severity ( vk :: DebugUtilsMessageSeverityFlagsEXT :: all ( ) ) . message_type ( vk :: DebugUtilsMessageTypeFlagsEXT :: all ( ) ) . pfn_user_callback ( Some ( DebugUtilsAndMessenger :: debug_callback ) ) . build ( ) ; let instance_create_info = vk :: InstanceCreateInfo :: builder ( ) . application_info ( & app_info ) . enabled_layer_names ( & layer_names ) . enabled_extension_names ( & extension_names ) . push_next ( & mut debug_create_info ) . build ( ) ; let instance = unsafe { entry . create_instance ( & instance_create_info , None ) } ? ; Ok ( Arc :: new ( instance ) ) }
Instance Creation
Creates an instance of the Vulkan client side driver given the raw handle.
Instance Creation Creates an instance of the Vulkan client side driver given the raw handle .
entry
&Entry
window
&W
application_name
&str
application_version
u32
engine_name
&str
engine_version
u32