![]() |
VPP
0.8
A high-level modern C++ API for Vulkan
|
Represents a group of resources bound to rendering or compute pipeline. More...
#include <vppShaderDataBlock.hpp>
Public Member Functions | |
ShaderDataBlock () | |
Constructs null reference. | |
ShaderDataBlock (const PipelineLayoutBase &hLayout) | |
Constructs data block for specified PipelineLayout object. More... | |
VkDescriptorSet | getDescriptorSet (std::uint32_t iSet) const |
Retrieves Vulkan handle of the descriptor set. | |
const Device & | device () const |
Retrieves the device. | |
template<class AssignmentListT > | |
void | update (const AssignmentListT &list) |
Updates resources specified in the assignment list. More... | |
void | cmdBind (CommandBuffer hCmdBuffer=CommandBuffer()) const |
Generates a command that binds the data block to the pipeline. More... | |
Represents a group of resources bound to rendering or compute pipeline.
Resources can be bound to a pipeline by means of binding points inside the pipeline. However, these binding points do not hold the actual data objects (images, buffers) directly. Binding points only represent metadata defining the resources. Actual references to data objects are grouped and stored inside ShaderDataBlock instances.
A ShaderDataBlock is a special kind of vector, holding the references to buffer and image views. First, you fill that vector by calling the update() method, then you bind entire vector at once by means of cmdBind() method.
Filling up the ShaderDataBlock happens instantly and should be done in frame preparation phase. Binding is a command, which should be placed in Process command sequence or recorded explicitly to a command buffer. Execution of the command happens during rendering phase and bound resources are used for subsequent drawing commands, until next binding happens or rendering phase ends.
A ShaderDataBlock instance is associated with particular pipeline, represented by a PipelineLayout<> object. It holds references to all relevant resources defined inside the pipeline, particularly all images and buffers (but not push constants, those are updated in different way). You can create multiple shader data blocks, holding different sets of resources.
ShaderDataBlock is a high-level counterpart of a descriptor set, low-level Vulkan object.
Updating a shader data block involves calling the update template method. You specify an assignment list as the argument. This is a list of assignments separated by the comma operator and enclosed in extra parentheses. On the left hand side of each assignment you place a binding point name. On the right hand side there should be appropriate view object, denoting a buffer or image. You can bind any number of resources at once.
A good practice is to create a special method inside your PipelineConfig subclass. This method takes a ShaderDataBlock pointer (or reference), as well as references to resource views to be bound to that data block. This way you have easy access to binding points and may make the private in the class. Now, in order to initialize a ShaderDataBlock, you only need to call this method from the outside.
An example of updating (for graphics pipelines it is the same):
ShaderDataBlock objects are reference-counted and may be passed by value.
vpp::ShaderDataBlock::ShaderDataBlock | ( | const PipelineLayoutBase & | hLayout | ) |
Constructs data block for specified PipelineLayout object.
The reference to opaque vpp::PipelineLayoutBase type represents any PipelineLayout< ... > object (it is a base class). You can use this type to pass layout references into your own functions while delegating ShaderDataBlock construction.
void vpp::ShaderDataBlock::cmdBind | ( | CommandBuffer | hCmdBuffer = CommandBuffer() | ) | const |
Generates a command that binds the data block to the pipeline.
Subsequent draw commands will use resources stored in this data block.
The command will be generated into specified command buffer, or the default command buffer if omitted.
void vpp::ShaderDataBlock::update | ( | const AssignmentListT & | list | ) |
Updates resources specified in the assignment list.
See the description of the class ShaderDataBlock for more details on the assignment list syntax.