Class OnceCommandBuffer

Class Documentation

class inexor::vulkan_renderer::wrapper::OnceCommandBuffer

RAII wrapper class for VkCommandBuffers which will be used only once. These types of command buffers are often used for copy operations. We’re only going to use the command buffer once and wait with returning from the function until the copy operation has finished executing. It’s good practice to tell the driver about our intent using VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT.

Public Functions

OnceCommandBuffer(const Device &device, VkQueue queue, std::uint32_t queue_family_index)

Default constructor.

Parameters
  • device – The const reference to a device RAII wrapper instance.

  • queue – The Vulkan queue to use.

  • queue_family_index – The Vulkan queue family index to use. We can’t determine the queue and queue family index to use automatically using the device wrapper reference because we might choose a queue which is unsuitable for the requested purpose! This is the reason we must specify the queue and queue family index in the constructor.

OnceCommandBuffer(const OnceCommandBuffer&) = delete
OnceCommandBuffer(OnceCommandBuffer&&) noexcept
~OnceCommandBuffer()
OnceCommandBuffer &operator=(const OnceCommandBuffer&) = delete
OnceCommandBuffer &operator=(OnceCommandBuffer&&) = delete
void create_command_buffer()

Create the command buffer.

Note

We are not merging this into the constructor because we need to be able to call this function separately.

void start_recording()

Call vkBeginCommandBuffer.

void end_recording_and_submit_command()

Call vkEndCommandBuffer and vkFreeCommandBuffers.

inline VkCommandBuffer command_buffer() const

Private Members

const Device &m_device
VkQueue m_queue = {VK_NULL_HANDLE}
CommandPool m_command_pool
std::unique_ptr<CommandBuffer> m_command_buffer
bool m_recording_started = {false}