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

Interface to the automatic command recording framework. More...

#include <vppCommandBufferRecorder.hpp>

Public Member Functions

 CommandBufferRecorder (CommandBuffer buffer, std::uint32_t flags=0)
 Creates and initializes the recorder for given command buffer.
 
 ~CommandBufferRecorder ()
 Finalizes the recorder.
 
void render (const RenderPass &hRenderPass, const FrameBuffer &hFrameBuffer, bool bAutoBindPipeline=true)
 Generates commands for graphics rendering, for specified render pass and framebuffer. More...
 
void compute (const ComputePass &hComputePass, bool bAutoBindPipeline=true)
 Generates commands for computation, for specified compute pass. More...
 
void perform (const Procedure &hProcedure)
 Generates commands for auxiliary processing, for specified compiled procedure. More...
 
void presentImage (VkImage hImage)
 Generates commands for presentation of a SwapChain image on screen. More...
 
void unpresentImage (VkImage hImage)
 Generates commands for releasing a SwapChain image currently presented on screen. More...
 

Detailed Description

Interface to the automatic command recording framework.

This class is the main interface to the framework used by VPP to generate sequences of commands for render and compute passes. This is the recommended way to fill command buffers.

The first step is to create the recorder object. You need only to provide the target CommandBuffer object to the constructor.

Next, call one of the methods depending on what kind of operation you want to do:

  • render: when you have a RenderPass to be rendered into specific FrameBuffer (typical operation for graphics rendering).
  • compute: when you have a ComputePass to execute (typical operation for compute shader execution).
  • presentImage: when you want to create commands to display an image to the swapchain (physically on screen).
  • unpresentImage: when you want to create commands to unlock the image displayed on screen, to overwrite it for the next frame.

In all cases, do not call begin() and end() methods on the CommandBuffer, as the CommandBufferRecorder does it implicitly.

The CommandBufferRecorder should be temporary, created on stack. Do not store it.

You must finalize the recorder (by ensured the destructor is called) before the buffer is submitted to a queue. For example:

// Create the buffer.
CommandBuffer cmdBuffer = m_device.defaultCmdPool().createBuffer();
{
// Initialize the recorder, perform rendering, finalize recorder (by destructor).
CommandBufferRecorder recorder ( cmdBuffer );
recorder.render ( m_pass, m_frameBuffer );
}
// Submit the buffer.
Queue q ( m_device, Q_GRAPHICS );
q.submit ( cmdBuffer );

Member Function Documentation

◆ compute()

void vpp::CommandBufferRecorder::compute ( const ComputePass hComputePass,
bool  bAutoBindPipeline = true 
)

Generates commands for computation, for specified compute pass.

Command sequence for this step is obtained by execution of the corresponding lambda function registered in the ComputePass.

◆ perform()

void vpp::CommandBufferRecorder::perform ( const Procedure hProcedure)

Generates commands for auxiliary processing, for specified compiled procedure.

This usually is not called directly, as the CompiledProcedures class already does it.

Compiled procedure is a sequence of Vulkan commands that are not rendering nor computing anything. For example, copying images and buffers and other tasks not requiring a pipeline.

Compiled procedures do not have render graphs nor pipelines. They have also some extra functions allowing easy calling on CPU side. These functions perform queuing and synchronization automatically.

Command sequence for this step is obtained by execution of the corresponding lambda function registered in the procedure.

◆ presentImage()

void vpp::CommandBufferRecorder::presentImage ( VkImage  hImage)

Generates commands for presentation of a SwapChain image on screen.

This command sequence is fixed. Normally you do not need to call this, because the SwapChain class does it automatically. Call this method only if you use low-level Vulkan rather than SwapChain.

◆ render()

void vpp::CommandBufferRecorder::render ( const RenderPass hRenderPass,
const FrameBuffer hFrameBuffer,
bool  bAutoBindPipeline = true 
)

Generates commands for graphics rendering, for specified render pass and framebuffer.

The CommandBufferRecorder implicitly does all preparation and gathers commands for the render preprocessing step, all subpasses and postprocessing step.

Command sequences for these steps are obtained by execution of the corresponding lambda functions in the RenderGraph, associated with given RenderPass.

◆ unpresentImage()

void vpp::CommandBufferRecorder::unpresentImage ( VkImage  hImage)

Generates commands for releasing a SwapChain image currently presented on screen.

This command sequence is fixed. Normally you do not need to call this, because the SwapChain class does it automatically. Call this method only if you use low-level Vulkan rather than SwapChain.


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