VPP  0.8
A high-level modern C++ API for Vulkan
vpp::CommandBuffer Class Reference

Represents a sequence of Vulkan commands. More...

#include <vppCommandBuffer.hpp>

Public Types

enum  EBeginFlags { ONE_TIME_SUBMIT = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, RENDER_PASS_CONTINUE = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, SIMULTANEOUS_USE = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT }
 

Public Member Functions

 CommandBuffer ()
 Constructs a null, invalid command buffer.
 
 CommandBuffer (VkCommandBuffer hBuffer)
 Constructs a command buffer from given Vulkan handle.
 
VkCommandBuffer handle () const
 Retrieves the Vulkan handle.
 
 operator bool () const
 Checks whether this command buffer object is valid (non-null).
 
VkResult reset ()
 Resets the state of individual command buffer for reusing.
 
VkResult release ()
 Frees individual command buffer. More...
 
VkResult begin (std::uint32_t flags=0)
 Sets the buffer in the recording state. More...
 
VkResult end ()
 Ends command recording for this buffer. More...
 

Detailed Description

Represents a sequence of Vulkan commands.

Rendering and computation in Vulkan is performed by means of commands. Sequences of these commands are first recorded into CommandBuffer objects. Next, these CommandBuffer objects are submitted for execution to command queues exposed by the rendering device.

In order to create a command buffer, you need to have access to a CommandPool object first. The CommandPool object manages resources and lifetime for command buffers. One possibility is to use the default command pool provided by each Device instance. Use the Device::defaultCmdPool() method to retrieve the reference.

Next, call the CommandPool::createBuffer() method to obtain a CommandBuffer instance.

Having a CommandBuffer object, you can proceed in two ways:

  • Use the CommandBufferRecorder object to utilise the VPP framework to generate commands to be recorded. These commands are taken from Process, Preprocess and Postprocess commands sequences of the render graph, or the compute pass sequence.
  • Specify commands directly, using overloads which take the CommandBuffer object or VkCommandBuffer handle.

The first way is the more standard (and recommended) usage.

After execution of the command buffer has finished, the buffer can be freed or reset for reusing. Reusing is typical method. You can free or reuse entire bunch of command buffers created by common CommandPool object. Using the CommandPool to manage command buffers in bulk is recommended.

CommandBuffer objects are lightweight, do not manage resources implicitly and can be passed by value.

Member Function Documentation

◆ begin()

VkResult vpp::CommandBuffer::begin ( std::uint32_t  flags = 0)

Sets the buffer in the recording state.

Call only in manual recording mode (not using CommandBufferRecorder).

◆ end()

VkResult vpp::CommandBuffer::end ( )

Ends command recording for this buffer.

Call only in manual recording mode (not using CommandBufferRecorder).

◆ release()

VkResult vpp::CommandBuffer::release ( )

Frees individual command buffer.

You usually do not need to call this, as the parent CommandPool will free all its buffers when being destroyed.


The documentation for this class was generated from the following file: