use anyhow::Result; use vulkanalia::prelude::v1_0::*; use crate::app::AppData; pub(crate) unsafe fn begin_single_time_commands( device: &Device, data: &AppData, ) -> Result { let info = vk::CommandBufferAllocateInfo::builder() .level(vk::CommandBufferLevel::PRIMARY) .command_pool(data.command_pool) .command_buffer_count(1); let command_buffer = device.allocate_command_buffers(&info)?[0]; let info = vk::CommandBufferBeginInfo::builder().flags(vk::CommandBufferUsageFlags::ONE_TIME_SUBMIT); device.begin_command_buffer(command_buffer, &info)?; Ok(command_buffer) } pub(crate) unsafe fn end_single_time_commands( device: &Device, data: &AppData, command_buffer: vk::CommandBuffer, ) -> Result<()> { device.end_command_buffer(command_buffer)?; let command_buffers = &[command_buffer]; let info = vk::SubmitInfo::builder().command_buffers(command_buffers); device.queue_submit(data.graphics_queue, &[info], vk::Fence::null())?; device.queue_wait_idle(data.graphics_queue)?; device.free_command_buffers(data.command_pool, &[command_buffer]); Ok(()) }