pub unsafe fn allocate_memory(
        &self,
        memory_requirements: vk::MemoryRequirements,
        property_flags: vk::MemoryPropertyFlags,
    ) -> Result<Allocation> {
        use anyhow::Context;
        use ash::version::InstanceV1_0;

        let memory_properties = self
            .instance
            .ash
            .get_physical_device_memory_properties(self.physical_device);

        let memory_type_index = memory_properties
            .memory_types
            .iter()
            .enumerate()
            .find(|(i, memory_type)| {
                let type_supported =
                    memory_requirements.memory_type_bits & (1 << i) != 0;
                let properties_supported =
                    memory_type.property_flags.contains(property_flags);
                type_supported & properties_supported
            })
            .map(|(i, _memory_type)| i as u32)
            .with_context(|| {
                "unable to find a suitable memory type for this allocation!"
            })?;

        self.allocator
            .lock()
            .unwrap()
            .allocate(vk::MemoryAllocateInfo {
                memory_type_index,
                allocation_size: memory_requirements.size,
                ..Default::default()
            })
    }
/// Allocate a a chunk of memory for use in a buffer or texture.
///
/// # unsafe because
///
/// - the caller is responsible for eventually calling 'free memory' before
///   the application quits
///
Allocate a a chunk of memory for use in a buffer or texture.
Allocate a a chunk of memory for use in a buffer or texture .
pub unsafe fn allocate_memory(
        &self,
        memory_requirements: vk::MemoryRequirements,
        property_flags: vk::MemoryPropertyFlags,
    ) -> Result<Allocation> {
        use anyhow::Context;
        use ash::version::InstanceV1_0;
        let memory_properties = self
            .instance
            .ash
            .get_physical_device_memory_properties(self.physical_device);
        let memory_type_index = memory_properties
            .memory_types
            .iter()
            .enumerate()
            .find(|(i, memory_type)| {
                let type_supported =
                    memory_requirements.memory_type_bits & (1 << i) != 0;
                let properties_supported =
                    memory_type.property_flags.contains(property_flags);
                type_supported & properties_supported
            })
            .map(|(i, _memory_type)| i as u32)
            .with_context(|| {
                "unable to find a suitable memory type for this allocation!"
            })?;
        self.allocator
            .lock()
            .unwrap()
            .allocate(vk::MemoryAllocateInfo {
                memory_type_index,
                allocation_size: memory_requirements.size,
                ..Default::default()
            })
    }
pub unsafe fn allocate_memory ( & self , memory_requirements : vk :: MemoryRequirements , property_flags : vk :: MemoryPropertyFlags , ) -> Result < Allocation > { use anyhow :: Context ; use ash :: version :: InstanceV1_0 ; let memory_properties = self . instance . ash . get_physical_device_memory_properties ( self . physical_device ) ; let memory_type_index = memory_properties . memory_types . iter ( ) . enumerate ( ) . find ( | ( i , memory_type ) | { let type_supported = memory_requirements . memory_type_bits & ( 1 << i ) != 0 ; let properties_supported = memory_type . property_flags . contains ( property_flags ) ; type_supported & properties_supported } ) . map ( | ( i , _memory_type ) | i as u32 ) . with_context ( | | { " " } ) ? ; self . allocator . lock ( ) . unwrap ( ) . allocate ( vk :: MemoryAllocateInfo { memory_type_index , allocation_size : memory_requirements . size , .. Default :: default ( ) } ) }
Allocate a a chunk of memory for use in a buffer or texture.
Allocate a a chunk of memory for use in a buffer or texture .
&self
memory_requirements
vk::MemoryRequirements
property_flags
vk::MemoryPropertyFlags
unsafe because
the caller is responsible for eventually calling 'free memory' before
the application quits
the caller is responsible for eventually calling ' free memory ' before the application quits