Function ash::prelude::read_into_defaulted_vector

source ยท
pub(crate) unsafe fn read_into_defaulted_vector<N: Copy + Default + TryInto<usize>, T: Default + Clone>(
    f: impl Fn(&mut N, *mut T) -> Result,
) -> VkResult<Vec<T>>
where <N as TryInto<usize>>::Error: Debug,
Expand description

Repeatedly calls f until it does not return vk::Result::INCOMPLETE anymore, ensuring all available data has been read into the vector.

Items in the target vector are default()-initialized which is required for vk::BaseOutStructure-like structs where vk::BaseOutStructure::s_type needs to be a valid type and vk::BaseOutStructure::p_next a valid or null pointer.

See for example vkEnumerateInstanceExtensionProperties: the number of available items may change between calls; vk::Result::INCOMPLETE is returned when the count increased (and the vector is not large enough after querying the initial size), requiring Ash to try again.