Skip to content

Instantly share code, notes, and snippets.

@cwfitzgerald
Last active March 28, 2025 00:05
Show Gist options
  • Save cwfitzgerald/2cbc9d318b7eea94999f0c139403fcb7 to your computer and use it in GitHub Desktop.
Save cwfitzgerald/2cbc9d318b7eea94999f0c139403fcb7 to your computer and use it in GitHub Desktop.
unsafe trait VulkanInstanceInitializationCallbacks {
/// Given the list of available instance extensions, you can extend the list of extensions
/// that are requested.
///
/// # SAFETY
///
/// - All extensions in `requested_extensions` must be in `available_extensions`.
fn extend_instance_extensions<'a>(
&'a mut self,
available_extensions: &[alloc::string::String],
requested_extensions: &mut Vec<alloc::string::String>,
);
}
unsafe trait VulkanDeviceInitializationCallbacks {
/// Create the storage for any additional structures that need to be stored in the
/// `pnext` chain of `vk::PhysicalDeviceProperties2`
fn create_physical_device_properties_storage(&mut self) -> Box<dyn Any> {
Box::new(())
}
/// Given the list of available device extensions, you may extend the pnext chain
/// of the vk::PhysicalDeviceProperties to contain additional structures. These values
/// should be zeroed.
///
/// In order to store the additional structures, you may store them inside
/// the `storage` parameter which is created by `create_physical_device_properties_storage`.
fn extend_physical_device_properties<'chain>(
&mut self,
storage: &'chain mut dyn Any,
available_extensions: &[alloc::string::String],
properties: &mut vk::PhysicalDeviceProperties2<'chain>,
);
/// All the structures that were in the `pnext` chain of `vk::PhysicalDeviceProperties2`
/// were filled out, and now you can process them.
fn process_physical_device_properties<'chain>(
&mut self,
properties: &vk::PhysicalDeviceProperties2<'chain>,
);
/// Create the storage for any additional structures that need to be stored in the
/// `pnext` chain of `vk::DeviceCreateInfo`
fn create_device_create_info_storage(&mut self) -> Box<dyn Any> {
Box::new(())
}
/// Given the list of available device extensions, you may extend the pnext chain
/// of the vk::DeviceCreateInfo to contain additional structures with the correct
/// values. If a given feature is available in both a core and an extension form,
/// check if the core form is already on the chain and skip the extension form.
///
/// In order to store the additional structures, you may store them inside
/// the `storage` parameter which is created by `create_device_create_info_storage`.
fn extend_device_create_info<'chain>(
&mut self,
storage: &'chain mut dyn Any,
create_info: &mut vk::DeviceCreateInfo<'chain>,
requested_extensions: &mut Vec<alloc::string::String>,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment