pub fn new(
        app_name: &str,
        extensions: &SVec4<&str>,
        layers: &SVec4<&str>,
        options: &VulkanInitOptions,
    ) -> VulkanInstance {
        unsafe {
            let loader = DynamicVulkanLoader::new();

            let app_name = CString::new(app_name).unwrap();
            let app_info = VkApplicationInfo {
                application_name: ptr::null(),
                application_version: 0,
                engine_name: app_name.as_ptr() as _,
                engine_version: 0,
                api_version: make_version(1, 1, 0),
                ..Default::default()
            };

            // Best Practices Validation
            const ENABLE_BRE: [ValidationEnabledFeature; 1] =
                [ValidationEnabledFeature::BestPracticesExt];
            let bre_feature = VkValidationFeaturesEXT {
                enabled_validation_feature_count: ENABLE_BRE.len() as _,
                enabled_validation_features: ENABLE_BRE.as_ptr() as *const _,
                disabled_validation_feature_count: 0,
                disabled_validation_features: ptr::null(),
                ..Default::default()
            };

            let layers_c = to_cstr_array(layers);
            let layers_c = layers_c
                .iter()
                .map(|s| s.as_ptr())
                .collect::<SVec4<*const i8>>();

            let exts_c = to_cstr_array(extensions);
            let exts_c = exts_c
                .iter()
                .map(|s| s.as_ptr() as _)
                .collect::<SVec4<*const i8>>();

            let creator = VkInstanceCreateInfo {
                next: if options.enable_best_practice_validation {
                    &bre_feature as *const _ as _
                } else {
                    ptr::null()
                },
                flags: 0,
                application_info: &app_info,
                enabled_layer_count: layers_c.len() as _,
                enabled_layer_names: layers_c.as_ptr(),
                enabled_extension_count: exts_c.len() as _,
                enabled_extension_names: exts_c.as_ptr(),
                ..Default::default()
            };

            let vk_create_instance = loader.create_instance();
            let mut instance = MaybeUninit::uninit();
            check_vk_force(vk_create_instance(
                &creator,
                ptr::null(),
                instance.as_mut_ptr(),
            ));

            let instance = instance.assume_init();

            // Load all instance-level functions.
            let getter = loader.get_instance_proc_addr();
            let funcs = InstanceFunctions::new(getter, instance);

            Self {
                instance,
                _loader: loader,
                fns: funcs,
            }
        }
    }
/// Create a VkInstance and load all instance-level functions.
/// Will panic if any function fails to load.
Create a VkInstance and load all instance-level functions.
Will panic if any function fails to load.
Create a VkInstance and load all instance - level functions . Will panic if any function fails to load .
pub fn new(
        app_name: &str,
        extensions: &SVec4<&str>,
        layers: &SVec4<&str>,
        options: &VulkanInitOptions,
    ) -> VulkanInstance {
        unsafe {
            let loader = DynamicVulkanLoader::new();
            let app_name = CString::new(app_name).unwrap();
            let app_info = VkApplicationInfo {
                application_name: ptr::null(),
                application_version: 0,
                engine_name: app_name.as_ptr() as _,
                engine_version: 0,
                api_version: make_version(1, 1, 0),
                ..Default::default()
            };
            // Best Practices Validation
            const ENABLE_BRE: [ValidationEnabledFeature; 1] =
                [ValidationEnabledFeature::BestPracticesExt];
            let bre_feature = VkValidationFeaturesEXT {
                enabled_validation_feature_count: ENABLE_BRE.len() as _,
                enabled_validation_features: ENABLE_BRE.as_ptr() as *const _,
                disabled_validation_feature_count: 0,
                disabled_validation_features: ptr::null(),
                ..Default::default()
            };
            let layers_c = to_cstr_array(layers);
            let layers_c = layers_c
                .iter()
                .map(|s| s.as_ptr())
                .collect::<SVec4<*const i8>>();
            let exts_c = to_cstr_array(extensions);
            let exts_c = exts_c
                .iter()
                .map(|s| s.as_ptr() as _)
                .collect::<SVec4<*const i8>>();
            let creator = VkInstanceCreateInfo {
                next: if options.enable_best_practice_validation {
                    &bre_feature as *const _ as _
                } else {
                    ptr::null()
                },
                flags: 0,
                application_info: &app_info,
                enabled_layer_count: layers_c.len() as _,
                enabled_layer_names: layers_c.as_ptr(),
                enabled_extension_count: exts_c.len() as _,
                enabled_extension_names: exts_c.as_ptr(),
                ..Default::default()
            };
            let vk_create_instance = loader.create_instance();
            let mut instance = MaybeUninit::uninit();
            check_vk_force(vk_create_instance(
                &creator,
                ptr::null(),
                instance.as_mut_ptr(),
            ));
            let instance = instance.assume_init();
            // Load all instance-level functions.
            let getter = loader.get_instance_proc_addr();
            let funcs = InstanceFunctions::new(getter, instance);
            Self {
                instance,
                _loader: loader,
                fns: funcs,
            }
        }
    }
pub fn new ( app_name : & str , extensions : & SVec4 < & str > , layers : & SVec4 < & str > , options : & VulkanInitOptions , ) -> VulkanInstance { unsafe { let loader = DynamicVulkanLoader :: new ( ) ; let app_name = CString :: new ( app_name ) . unwrap ( ) ; let app_info = VkApplicationInfo { application_name : ptr :: null ( ) , application_version : 0 , engine_name : app_name . as_ptr ( ) as _ , engine_version : 0 , api_version : make_version ( 1 , 1 , 0 ) , .. Default :: default ( ) } ; // Best Practices Validation const ENABLE_BRE : [ ValidationEnabledFeature ; 1 ] = [ ValidationEnabledFeature :: BestPracticesExt ] ; let bre_feature = VkValidationFeaturesEXT { enabled_validation_feature_count : ENABLE_BRE . len ( ) as _ , enabled_validation_features : ENABLE_BRE . as_ptr ( ) as * const _ , disabled_validation_feature_count : 0 , disabled_validation_features : ptr :: null ( ) , .. Default :: default ( ) } ; let layers_c = to_cstr_array ( layers ) ; let layers_c = layers_c . iter ( ) . map ( | s | s . as_ptr ( ) ) . collect :: < SVec4 < * const i8 > > ( ) ; let exts_c = to_cstr_array ( extensions ) ; let exts_c = exts_c . iter ( ) . map ( | s | s . as_ptr ( ) as _ ) . collect :: < SVec4 < * const i8 > > ( ) ; let creator = VkInstanceCreateInfo { next : if options . enable_best_practice_validation { & bre_feature as * const _ as _ } else { ptr :: null ( ) } , flags : 0 , application_info : & app_info , enabled_layer_count : layers_c . len ( ) as _ , enabled_layer_names : layers_c . as_ptr ( ) , enabled_extension_count : exts_c . len ( ) as _ , enabled_extension_names : exts_c . as_ptr ( ) , .. Default :: default ( ) } ; let vk_create_instance = loader . create_instance ( ) ; let mut instance = MaybeUninit :: uninit ( ) ; check_vk_force ( vk_create_instance ( & creator , ptr :: null ( ) , instance . as_mut_ptr ( ) , ) ) ; let instance = instance . assume_init ( ) ; // Load all instance-level functions. let getter = loader . get_instance_proc_addr ( ) ; let funcs = InstanceFunctions :: new ( getter , instance ) ; Self { instance , _loader : loader , fns : funcs , } } }
Create a VkInstance and load all instance-level functions.
Create a VkInstance and load all instance - level functions .
app_name
&str
extensions
&SVec4<&str>
layers
&SVec4<&str>
options
&VulkanInitOptions
app_name
&str
extensions
&SVec4<&str>
layers
&SVec4<&str>
options
&VulkanInitOptions