VPP  0.7
A high-level modern C++ API for Vulkan
Public Member Functions | List of all members
vpp::ComputationEngine Class Reference

Base class for computation engines. More...

#include <vppComputationEngine.hpp>

Inheritance diagram for vpp::ComputationEngine:
vpp::ExtendedCommands vpp::NonRenderingCommands vpp::UniversalCommands

Public Member Functions

 ComputationEngine (const Device &hDevice, EQueueType queueType=Q_GRAPHICS)
 Construct a computation engine attached to specified device and default command queue. More...
 
 ComputationEngine (const Queue &hQueue)
 Construct a computation engine attached to specified command queue. More...
 
 ComputationEngine (const Queue &hQueue, const CommandPool &hCommandPool)
 Construct a computation engine attached to specified command queue and command pool. More...
 
 ComputationEngine (const CommandPool &hCommandPool)
 Construct a computation engine attached to specified command pool. More...
 
void compile ()
 Compiles all computations. More...
 
void wait ()
 Waits for all computations to finish. More...
 
const Devicedevice () const
 Retrieves the device.
 

Additional Inherited Members

- Static Public Member Functions inherited from vpp::ExtendedCommands
static void cmdChangeImageLayout (const Img &hImage, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, std::uint32_t levelCount=1, std::uint32_t layerCount=1, std::uint32_t baseMipLevel=0, std::uint32_t baseArrayLayer=0, VkImageAspectFlags aspectMask=VK_IMAGE_ASPECT_COLOR_BIT, CommandBuffer hCmdBuffer=CommandBuffer())
 
- 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, VkImageLayout imageLayout, const VkClearColorValue &color, CommandBuffer hCmdBuffer=CommandBuffer())
 Clears an image with specified color.
 
static void cmdClearColorImage (const Img &hImage, VkImageLayout imageLayout, 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 computation engines.

Derive your own class from ComputationEngine and place one or more Computation derived objects within it.

Call compile() method once in the constructor of your ComputationEngine subclass.

Every Computation field of the subclass can now launch a computation on the GPU and optionally wait for the result. Use one of the operator() overloads for that purpose. Syntactically, a ComputationEngine derived class looks similar to regular C++ class with methods.

Constructor & Destructor Documentation

◆ ComputationEngine() [1/4]

vpp::ComputationEngine::ComputationEngine ( const Device hDevice,
EQueueType  queueType = Q_GRAPHICS 
)

Construct a computation engine attached to specified device and default command queue.

This is the simplest constructor, requiring only a device object. It is recommended to use this one.

You can optionally specify a queue type, however currently only Q_GRAPHICS makes sense, so just leave this parameter as default.

◆ ComputationEngine() [2/4]

vpp::ComputationEngine::ComputationEngine ( const Queue hQueue)

Construct a computation engine attached to specified command queue.

This constructor can be used when you want to schedule the computation to specific command queue. It retrieves the device automatically from the queue.

◆ ComputationEngine() [3/4]

vpp::ComputationEngine::ComputationEngine ( const Queue hQueue,
const CommandPool hCommandPool 
)

Construct a computation engine attached to specified command queue and command pool.

This constructor can be used when you want to schedule the computation to specific command queue and allocate command buffers from specific command pool.

This is more advanced usage. In most cases, default queue and command pool maintained by the device object should be sufficient.

◆ ComputationEngine() [4/4]

vpp::ComputationEngine::ComputationEngine ( const CommandPool hCommandPool)

Construct a computation engine attached to specified command pool.

This constructor can be used when you want to schedule the computation to a command queue created from default family and allocate command buffers from specific command pool. Youi provide only the command pool reference.

This is more advanced usage. In most cases, default queue and command pool maintained by the device object should be sufficient.

Member Function Documentation

◆ compile()

void vpp::ComputationEngine::compile ( )

Compiles all computations.

Call this method as the final operation inside the constructor of your ComputationEngine subclass. It compiles all contained Computation objects and prpares them for execution.

◆ wait()

void vpp::ComputationEngine::wait ( )

Waits for all computations to finish.

This is not the most efficient way to synchronize computations. Better use fences or semaphores.


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