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

Base class for render graphs. More...

#include <vppRenderGraph.hpp>

Inheritance diagram for vpp::RenderGraph:
vpp::NonRenderingCommands vpp::UniversalCommands

Public Member Functions

 RenderGraph ()
 Constructs null reference.
 
 ~RenderGraph ()
 Decreases reference count.
 

Static Public Member Functions

static void cmdDraw (unsigned int vertexCount, unsigned int instanceCount, unsigned int firstVertex, unsigned int firstInstance, CommandBuffer hCmdBuffer=CommandBuffer())
 Generates a command to draw specified region of vertex/instance buffers. More...
 
static void cmdDrawIndexed (unsigned int indexCount, unsigned int instanceCount, unsigned int firstIndex, int vertexOffset, unsigned int firstInstance, CommandBuffer hCmdBuffer=CommandBuffer())
 Generates a command to draw specified region of vertex/instance buffers, using additional index buffer to address vertices. More...
 
static void cmdDrawIndirect (const IndirectBufferView &data, VkDeviceSize offset, unsigned int drawCount, CommandBuffer hCmdBuffer=CommandBuffer())
 Generates a command to draw specified region of indirect drawing buffer. More...
 
static void cmdDrawIndexedIndirect (const IndirectBufferView &data, VkDeviceSize offset, unsigned int drawCount, CommandBuffer hCmdBuffer=CommandBuffer())
 Generates a command to draw specified region of indirect drawing buffer, also using an index buffer to address vertices. More...
 
static void cmdClearImages (unsigned int attachmentCount, const VkClearAttachment *pAttachments, unsigned int rectCount, const VkClearRect *pRects, CommandBuffer hCmdBuffer=CommandBuffer())
 Generates a command to clear specified attachment images. More...
 
- Static Public Member Functions inherited from vpp::NonRenderingCommands
static void cmdFillBuffer (const Buf &hDstBuffer, size_t offset, size_t size, std::uint32_t value, CommandBuffer hCmdBuffer=CommandBuffer())
 Fills specified buffer (or a region of it) with constant value.
 
static void cmdCopyBuffer (const Buf &hSrcBuffer, const Buf &hDstBuffer, CommandBuffer hCmdBuffer=CommandBuffer())
 Copies entire contents from one buffer to another.
 
static void cmdCopyBuffer (const Buf &hSrcBuffer, const Buf &hDstBuffer, const std::vector< VkBufferCopy > &regions, CommandBuffer hCmdBuffer=CommandBuffer())
 Copies a list of regions from one buffer to another.
 
static void cmdUpdateBuffer (const Buf &hDstBuffer, size_t offset, size_t size, const std::uint32_t *pData, CommandBuffer hCmdBuffer=CommandBuffer())
 Modifies a buffer region with specified data. More...
 
static void cmdCopyImage (const Img &hSrcImage, VkImageLayout srcImageLayout, const Img &hDstImage, VkImageLayout dstImageLayout, CommandBuffer hCmdBuffer=CommandBuffer())
 Copies entire contents from one image to another.
 
static void cmdCopyImage (const Img &hSrcImage, VkImageLayout srcImageLayout, const Img &hDstImage, VkImageLayout dstImageLayout, const std::vector< VkImageCopy > &regions, CommandBuffer hCmdBuffer=CommandBuffer())
 Copies a list of regions from one image to another.
 
static void cmdCopyBufferToImage (const Buf &hSrcBuffer, const Img &hDstImage, VkImageLayout dstImageLayout, CommandBuffer hCmdBuffer=CommandBuffer())
 Copies entire contents from a buffer to an image.
 
static void cmdCopyBufferToImage (const Buf &hSrcBuffer, const Img &hDstImage, VkImageLayout dstImageLayout, const std::vector< VkBufferImageCopy > &regions, CommandBuffer hCmdBuffer=CommandBuffer())
 Copies a list of regions from a buffer to an image.
 
static void cmdCopyImageToBuffer (const Img &hSrcImage, VkImageLayout srcImageLayout, const Buf &hDstBuffer, CommandBuffer hCmdBuffer=CommandBuffer())
 Copies entire contents from an image to a buffer.
 
static void cmdCopyImageToBuffer (const Img &hSrcImage, VkImageLayout srcImageLayout, const Buf &hDstBuffer, const std::vector< VkBufferImageCopy > &regions, CommandBuffer hCmdBuffer=CommandBuffer())
 Copies a list of regions from an image to a buffer.
 
static void cmdBlitImage (const Img &hSrcImage, VkImageLayout srcImageLayout, const Img &hDstImage, VkImageLayout dstImageLayout, const VkOffset3D &srcBegin, const VkOffset3D &srcEnd, const VkOffset3D &dstBegin, const VkOffset3D &dstEnd, CommandBuffer hCmdBuffer=CommandBuffer())
 Copies source image region into destination image, potentially performing format conversion, arbitrary scaling and filtering.
 
static void cmdBlitImage (const Img &hSrcImage, VkImageLayout srcImageLayout, const Img &hDstImage, VkImageLayout dstImageLayout, const VkOffset3D &srcBegin, const VkOffset3D &srcEnd, const VkOffset3D &dstBegin, CommandBuffer hCmdBuffer=CommandBuffer())
 Copies source image region into destination image, potentially performing format conversion, but no scaling.
 
static void cmdBlitImage (const Img &hSrcImage, VkImageLayout srcImageLayout, const Img &hDstImage, VkImageLayout dstImageLayout, const std::vector< VkImageBlit > &regions, CommandBuffer hCmdBuffer=CommandBuffer())
 Copies source image regions into destination image, potentially performing format conversion, arbitrary scaling and filtering.
 
static void cmdResolveImage (const Img &hSrcImage, VkImageLayout srcImageLayout, const Img &hDstImage, VkImageLayout dstImageLayout, const VkOffset3D &srcOffset, const VkOffset3D &dstOffset, const VkExtent3D &size, CommandBuffer hCmdBuffer=CommandBuffer())
 Resolves source multisampled image region into destination regular image. More...
 
static void cmdResolveImage (const Img &hSrcImage, VkImageLayout srcImageLayout, const Img &hDstImage, VkImageLayout dstImageLayout, CommandBuffer hCmdBuffer=CommandBuffer())
 Resolves source multisampled image into destination regular image. More...
 
static void cmdResolveImage (const Img &hSrcImage, VkImageLayout srcImageLayout, const Img &hDstImage, VkImageLayout dstImageLayout, const std::vector< VkImageResolve > &regions, CommandBuffer hCmdBuffer=CommandBuffer())
 Resolves a list of source multisampled image regions into destination regular image regions. More...
 
static void cmdClearColorImage (const Img &hImage, const VkClearColorValue &color, CommandBuffer hCmdBuffer=CommandBuffer())
 Clears an image with specified color.
 
static void cmdClearColorImage (const Img &hImage, const VkClearColorValue &color, const std::vector< VkImageSubresourceRange > &regions, CommandBuffer hCmdBuffer=CommandBuffer())
 Clears a list of regions in specified image with specified color.
 
static void cmdClearDepthStencilImage (const Img &hImage, VkImageLayout imageLayout, float depth, std::uint32_t stencil, CommandBuffer hCmdBuffer=CommandBuffer())
 Clears a depth or stencil image with specified value.
 
static void cmdClearDepthStencilImage (const Img &hImage, VkImageLayout imageLayout, float depth, std::uint32_t stencil, const std::vector< VkImageSubresourceRange > &regions, CommandBuffer hCmdBuffer=CommandBuffer())
 Clears a list of regions in depth or stencil image with specified value.
 
static void cmdResetQueryPool (const QueryPool &hPool, std::uint32_t first, std::uint32_t count, CommandBuffer hCmdBuffer=CommandBuffer())
 Resets a range of queries in a query pool.
 
static void cmdResetQueryPool (const QueryPool &hPool, CommandBuffer hCmdBuffer=CommandBuffer())
 Resets all queries in a query pool.
 
static void cmdCopyQueryPoolResults (const Buf &hDstBuffer, const QueryPool &hPool, VkQueryResultFlags flags, std::uint32_t count, std::uint32_t first, VkDeviceSize dstOffset, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdCopyQueryPoolResults (const Buf &hDstBuffer, const QueryPool &hPool, VkQueryResultFlags flags, CommandBuffer hCmdBuffer=CommandBuffer())
 
- Static Public Member Functions inherited from vpp::UniversalCommands
static void cmdExecuteCommands (const VkCommandBuffer *pBuffers, size_t size, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdExecuteCommands (const CommandBuffer *pBuffers, size_t size, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdExecuteCommands (const std::vector< CommandBuffer > &buffers, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdWaitEvents (const std::vector< Event > &events, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, const Barriers &barriers=Barriers(), CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdPipelineBarrier (VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const Barriers &barriers, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdImagePipelineBarrier (const Img &image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, bool bByRegion, VkImageLayout oldLayout=VK_IMAGE_LAYOUT_GENERAL, VkImageLayout newLayout=VK_IMAGE_LAYOUT_GENERAL, int mipLevel=-1, int arrayLayer=-1, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdBufferPipelineBarrier (const Buf &hBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdSetViewport (const VkViewport &viewport, std::uint32_t index=0, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdSetViewport (const std::vector< VkViewport > &viewports, std::uint32_t first=0, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdSetLineWidth (float lineWidth, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdSetDepthBias (float constantFactor, float clamp, float slopeFactor, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdSetDepthBounds (float minDepthBounds, float maxDepthBounds, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdSetScissor (const VkRect2D &scissor, std::uint32_t index=0, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdSetScissor (const std::vector< VkRect2D > &scissors, std::uint32_t first=0, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdSetStencilCompareMask (VkStencilFaceFlags faceMask, std::uint32_t compareMask, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdSetStencilWriteMask (VkStencilFaceFlags faceMask, std::uint32_t writeMask, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdSetStencilReference (VkStencilFaceFlags faceMask, std::uint32_t reference, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdSetBlendConstants (const float blendConstants [4], CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdBeginQuery (const QueryPool &hPool, std::uint32_t query, VkQueryControlFlags flags, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdEndQuery (const QueryPool &hPool, std::uint32_t query, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdWriteTimestamp (const QueryPool &hPool, std::uint32_t query, VkPipelineStageFlagBits pipelineStage, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdBindPipeline (const Pipeline &hPipeline, VkPipelineBindPoint pipelineBindPoint, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdBindDescriptorSets (const ShaderDataBlock &hDataBlock, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdBindIndexInput (const Buf &hBuffer, VkIndexType indexType, VkDeviceSize offset, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdBindVertexBuffers (const std::vector< Buf > &buffers, const std::vector< VkDeviceSize > &offsets, std::uint32_t first=0, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdBindVertexBuffers (const std::vector< Buf > &buffers, std::uint32_t first=0, CommandBuffer hCmdBuffer=CommandBuffer())
 
static void cmdPushConstants (const PipelineLayoutBase &hPipelineLayout, VkShaderStageFlags stageFlags, const void *pValues, std::uint32_t size, std::uint32_t offset=0, CommandBuffer hCmdBuffer=CommandBuffer())
 

Detailed Description

Base class for render graphs.

Inherit from this class to make your custom render graph class. Additionally RenderGraph defines some convenience wrappers for Vulkan drawing commands, including those meant for operation on the implicit context.

Since this class serves as a counted reference to internal representation, you can pass RenderGraph by value. In order to do be able to that, keep your custom render graph class lightweight. Store only graph nodes (e.g. Process, Attachment, Preprocess and Postprocess) in the object.

An example of renderer using a simple render graph:

// Define formats you use.
typedef vpp::format< float, vpp::DT > DepthFormat;
// The render graph itself.
class DepthBufferRenderGraph : public vpp::RenderGraph
{
public:
DepthBufferRenderGraph (
unsigned int width, unsigned int height, vpp::Device hDevice );
public:
vpp::Device m_hDevice;
// Single subpass, as well as initializing/finalizing steps.
vpp::Process m_renderDepthAttachment;
vpp::Preprocess m_preprocess;
vpp::Postprocess m_postprocess;
// Single output image (attachment).
vpp::Attachment< DepthFormat > m_depthAttachmentBuffer;
};
DepthBufferRenderGraph :: DepthBufferRenderGraph (
unsigned int width, unsigned int height, vpp::Device hDevice ) :
m_hDevice ( hDevice ),
m_depthAttachmentBuffer ( width, height )
{
// Register the output image in the process node.
m_renderDepthAttachment.setDepthOutput (
m_depthAttachmentBuffer, 1.0f,
VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
);
}
// The renderer. Not all details are shown.
class DepthBufferRenderer
{
public:
DepthBufferRenderer (
DepthBufferView* pBufferView, vpp::Device hDevice );
// This will create rendering command sequence.
void createRenderPlan ( vpp::CommandBuffer hCmdBuffer );
private:
vpp::Device m_hDevice;
DepthBufferView* m_pBufferView;
VkExtent3D m_imageSize;
// The render graph object.
std::shared_ptr< DepthBufferRenderGraph > m_renderGraph;
// The pipeline - not shown in this example for brevity.
// The data for the pipeline - not shown in this example for brevity.
vpp::ShaderDataBlock m_renderShaderDataBlock;
// The render pass object.
vpp::RenderPass m_renderPass;
// Options - not shown in this example for brevity.
vpp::RenderingOptions m_renderOptions;
// The frame buffer object.
vpp::FrameBuffer m_frameBuffer;
// ...
};
DepthBufferRenderer :: DepthBufferRenderer (
DepthBufferView* pBufferView, vpp::Device hDevice ) :
m_hDevice ( hDevice ),
m_pBufferView ( pBufferView ),
m_imageSize ( pBufferView->image().info().extent ),
m_renderGraph ( new DepthBufferRenderGraph (
m_imageSize.width, m_imageSize.height, hDevice ) ),
m_renderPipeline ( m_renderGraph->m_renderDepthAttachment, hDevice ),
m_renderShaderDataBlock ( m_renderPipeline ),
m_renderPass ( *m_renderGraph, hDevice ),
m_frameBuffer (
std::vector< vpp::FrameImageView > {
vpp::FrameImageView ( pBufferView->image() )
},
m_renderPass ),
...
{
using namespace vpp;
// Register the pipeline within render pass.
m_renderPass.addPipeline (
m_renderGraph->m_renderDepthAttachment,
m_renderPipeline, m_renderOptions );
// Register the command sequence for the rendering process.
// Note the lambda function - it wil be executed later!
m_renderGraph->m_renderDepthAttachment << [ this ]()
{
// Select current pipeline.
m_renderPass.pipeline ( 0, 0 ).cmdBind();
// Select current data set.
m_renderShaderDataBlock.cmdBind();
// Bind the buffer with vertices (details not shown).
m_renderPipeline->cmdBindVertexInput ( ... );
// Draw (details not shown).
m_renderGraph->cmdDraw ( ... );
};
// Register the command sequence for the initializing process.
// Note the lambda function - it will be executed later!
m_renderGraph->m_preprocess << [ this ]()
{
// Insert here any commands to be run before the render pass begins.
// ...
};
// Register the command sequence for the finalizing process.
// Note the lambda function - it will be executed later!
m_renderGraph->m_postprocess << [ this ]()
{
// Insert here any commands to be run after the render pass ends.
// ...
};
}
// Convenience method.
void DepthBufferRenderer :: createRenderPlan ( vpp::CommandBuffer hCmdBuffer )
{
vpp::CommandBufferRecorder recorder ( hCmdBuffer );
// This will generate commands into the command buffer.
// Execution of the lambdas above will be triggered by this call.
recorder.render ( m_renderPass, m_frameBuffer, false );
}

Member Function Documentation

◆ cmdClearImages()

static void vpp::RenderGraph::cmdClearImages ( unsigned int  attachmentCount,
const VkClearAttachment *  pAttachments,
unsigned int  rectCount,
const VkClearRect *  pRects,
CommandBuffer  hCmdBuffer = CommandBuffer() 
)
static

Generates a command to clear specified attachment images.

The command will be generated into specified command buffer, or the default command buffer if omitted.

◆ cmdDraw()

static void vpp::RenderGraph::cmdDraw ( unsigned int  vertexCount,
unsigned int  instanceCount,
unsigned int  firstVertex,
unsigned int  firstInstance,
CommandBuffer  hCmdBuffer = CommandBuffer() 
)
static

Generates a command to draw specified region of vertex/instance buffers.

Vertex and instance buffers (when applicable) must be bound in currently recorded command sequence by calling PipelineConfig::cmdBindVertexInput() prior to issuing cmdDraw(). This should be done for all binding points used in the vertex shader.

The command will be generated into specified command buffer, or the default command buffer if omitted.

Usually this command is called from the lambda routine registered for the Process node. Do not specify command buffer in such case.

◆ cmdDrawIndexed()

static void vpp::RenderGraph::cmdDrawIndexed ( unsigned int  indexCount,
unsigned int  instanceCount,
unsigned int  firstIndex,
int  vertexOffset,
unsigned int  firstInstance,
CommandBuffer  hCmdBuffer = CommandBuffer() 
)
static

Generates a command to draw specified region of vertex/instance buffers, using additional index buffer to address vertices.

Vertex and instance buffers (when applicable) must be bound in currently recorded command sequence by calling PipelineConfig::cmdBindVertexInput() and prior to issuing cmdDrawIndexed(). This should be done for all binding points used in the vertex shader.

Also bind the index buffer by calling PipelineConfig::cmdBindIndexInput(). The index buffer should contain an array of 32-bit integers. One of possibilities is to use Indices container class for it.

The command will be generated into specified command buffer, or the default command buffer if omitted.

Usually this command is called from the lambda routine registered for the Process node. Do not specify command buffer in such case.

◆ cmdDrawIndexedIndirect()

static void vpp::RenderGraph::cmdDrawIndexedIndirect ( const IndirectBufferView data,
VkDeviceSize  offset,
unsigned int  drawCount,
CommandBuffer  hCmdBuffer = CommandBuffer() 
)
static

Generates a command to draw specified region of indirect drawing buffer, also using an index buffer to address vertices.

The indirect drawing buffer contains parameters for implicit draw commands which are automatically generated. This allows to draw multiple regions of index/instance buffers using single draw call. The buffer should contain an array of VkDrawIndexedIndirectCommand structures. One of possibilities is to use the IndexedIndirectCommands container class for it.

Vertex and instance buffers (when applicable) must be bound in currently recorded command sequence by calling PipelineConfig::cmdBindVertexInput() and prior to issuing cmdDrawIndexedIndirect(). This should be done for all binding points used in the vertex shader.

Also bind the index buffer by calling PipelineConfig::cmdBindIndexInput(). The index buffer should contain an array of 32-bit integers. One of possibilities is to use Indices container class for it.

The command will be generated into specified command buffer, or the default command buffer if omitted.

Usually this command is called from the lambda routine registered for the Process node. Do not specify command buffer in such case.

◆ cmdDrawIndirect()

static void vpp::RenderGraph::cmdDrawIndirect ( const IndirectBufferView data,
VkDeviceSize  offset,
unsigned int  drawCount,
CommandBuffer  hCmdBuffer = CommandBuffer() 
)
static

Generates a command to draw specified region of indirect drawing buffer.

The indirect drawing buffer contains parameters for implicit draw commands which are automatically generated. This allows to draw multiple regions of vertex/instance buffers using single draw call. The buffer should contain an array of VkDrawIndirectCommand structures. One of possibilities is to use the IndirectCommands container class for it.

Vertex and instance buffers (when applicable) must be bound in currently recorded command sequence by calling PipelineConfig::cmdBindVertexInput() and prior to issuing cmdDrawIndirect(). This should be done for all binding points used in the vertex shader.

The command will be generated into specified command buffer, or the default command buffer if omitted.

Usually this command is called from the lambda routine registered for the Process node. Do not specify command buffer in such case.


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