pub fn create_command_buffer(device: &VkDevice, pool: vk::CommandPool, is_begin: bool) -> VkResult<vk::CommandBuffer> {

    let command_buffer_ci = vk::CommandBufferAllocateInfo {
        s_type: vk::StructureType::COMMAND_BUFFER_ALLOCATE_INFO,
        p_next: ptr::null(),
        command_pool: pool,
        level: vk::CommandBufferLevel::PRIMARY,
        command_buffer_count: 1,
    };

    let mut buffers = unsafe {
        device.logic.handle.allocate_command_buffers(&command_buffer_ci)
            .map_err(|_| VkError::create("Command Buffers"))?
    };
    let cmd_buffer = buffers.pop().unwrap();

    // If requested, also start the new command buffer
    if is_begin {
        let begin_info = vk::CommandBufferBeginInfo {
            s_type: vk::StructureType::COMMAND_BUFFER_BEGIN_INFO,
            p_next: ptr::null(),
            flags: vk::CommandBufferUsageFlags::empty(),
            p_inheritance_info: ptr::null(),
        };

        unsafe {
            device.logic.handle.begin_command_buffer(cmd_buffer, &begin_info)
                .map_err(|_| VkError::device("Begin Command Buffer"))?
        }
    }

    Ok(cmd_buffer)
}
/// Get a new command buffer from the command pool.
///
/// If begin is true, the command buffer is also started so we can start adding commands.
Get a new command buffer from the command pool.
If begin is true, the command buffer is also started so we can start adding commands.
Get a new command buffer from the command pool . If begin is true the command buffer is also started so we can start adding commands .
pub fn create_command_buffer(device: &VkDevice, pool: vk::CommandPool, is_begin: bool) -> VkResult<vk::CommandBuffer> {
    let command_buffer_ci = vk::CommandBufferAllocateInfo {
        s_type: vk::StructureType::COMMAND_BUFFER_ALLOCATE_INFO,
        p_next: ptr::null(),
        command_pool: pool,
        level: vk::CommandBufferLevel::PRIMARY,
        command_buffer_count: 1,
    };
    let mut buffers = unsafe {
        device.logic.handle.allocate_command_buffers(&command_buffer_ci)
            .map_err(|_| VkError::create("Command Buffers"))?
    };
    let cmd_buffer = buffers.pop().unwrap();
    // If requested, also start the new command buffer
    if is_begin {
        let begin_info = vk::CommandBufferBeginInfo {
            s_type: vk::StructureType::COMMAND_BUFFER_BEGIN_INFO,
            p_next: ptr::null(),
            flags: vk::CommandBufferUsageFlags::empty(),
            p_inheritance_info: ptr::null(),
        };
        unsafe {
            device.logic.handle.begin_command_buffer(cmd_buffer, &begin_info)
                .map_err(|_| VkError::device("Begin Command Buffer"))?
        }
    }
    Ok(cmd_buffer)
}
pub fn create_command_buffer ( device : & VkDevice , pool : vk :: CommandPool , is_begin : bool ) -> VkResult < vk :: CommandBuffer > { let command_buffer_ci = vk :: CommandBufferAllocateInfo { s_type : vk :: StructureType :: COMMAND_BUFFER_ALLOCATE_INFO , p_next : ptr :: null ( ) , command_pool : pool , level : vk :: CommandBufferLevel :: PRIMARY , command_buffer_count : 1 , } ; let mut buffers = unsafe { device . logic . handle . allocate_command_buffers ( & command_buffer_ci ) . map_err ( | _ | VkError :: create ( " " ) ) ? } ; let cmd_buffer = buffers . pop ( ) . unwrap ( ) ; // If requested, also start the new command buffer if is_begin { let begin_info = vk :: CommandBufferBeginInfo { s_type : vk :: StructureType :: COMMAND_BUFFER_BEGIN_INFO , p_next : ptr :: null ( ) , flags : vk :: CommandBufferUsageFlags :: empty ( ) , p_inheritance_info : ptr :: null ( ) , } ; unsafe { device . logic . handle . begin_command_buffer ( cmd_buffer , & begin_info ) . map_err ( | _ | VkError :: device ( " " ) ) ? } } Ok ( cmd_buffer ) }
Get a new command buffer from the command pool.
Get a new command buffer from the command pool .
device
&VkDevice
pool
vk::CommandPool
is_begin
bool
device
&VkDevice
pool
vk::CommandPool
is_begin
bool