![]() |
VPP
0.7
A high-level modern C++ API for Vulkan
|
Base class for custom rendering pipelines. More...
#include <vppPipelineConfig.hpp>
Public Member Functions | |
VkPrimitiveTopology | getPrimitiveTopology () const |
Retrieves selected primitive topology. | |
bool | getEnablePrimitiveRestart () const |
Checks if the primitive restart feature is enabled. | |
std::uint32_t | getTessPatchControlPoints () const |
RenderGraph & | getRenderGraph () const |
Retrieves a reference to the parent render graph of this pipeline. | |
std::uint32_t | getProcessIndex () const |
Retrieves an index of associated Process node in the render graph. | |
template<class AssignmentListT > | |
void | cmdBindVertexInput (const AssignmentListT &list, CommandBuffer hCmdBuffer=CommandBuffer()) |
Issues a command which binds some data buffer containing vertex information to a binding point declared within the pipeline. More... | |
void | cmdBindIndexInput (const VertexIndexBufferView &hVertexIndexBufferView, CommandBuffer hCmdBuffer=CommandBuffer()) |
Issues a command which binds some data buffer containing indices for indexed draw to the pipeline. More... | |
Protected Member Functions | |
PipelineConfig (const Process &boundProcess) | |
Constructor, called only from subclass constructor. More... | |
void | setBlendingMode (const BaseAttachment &dataNode, const VkPipelineColorBlendAttachmentState &blendConfig) |
Sets blending mode for specified color attachment. More... | |
void | enableLogicOperation (bool bEnable, VkLogicOp logicOp) |
Sets logical operation mode for the rasterizer. More... | |
void | setPrimitiveTopology (VkPrimitiveTopology v) |
Specifies what kind of geometric primitives are supplied to the pipeline as input. More... | |
void | setEnablePrimitiveRestart (bool v) |
Enables primitive restart feature for indexed draws. More... | |
void | setTessPatchControlPoints (std::uint32_t v) |
Base class for custom rendering pipelines.
Creating a custom rendering pipeline is one of the most basic tasks when using Vulkan. The pipeline consists of the following building blocks:
You define the pipeline by creating a class derived from PipelineConfig. Inside the class, place fields of types corresponding to the building blocks. By convention, names of those types starts from lowercase letters, as they logically belong to CPU side. You will be able to use these fields to bind data buffers to them.
On the other hand, you also place shader code in the pipeline class, as plain C++ methods. In these methods, you have C++ access to the binding points mentioned above. With help of some special accessor objects, you can actually read data from them on GPU side, perform processing and write results. Entire paradigm here is exactly the same as with plain C++, with only difference that you need these accessor objects sometimes.
Pipeline classes can be subject to all object oriented or generic programming techniques allowed by C++ like inheritance or templating. You can also call external functions from shader code and these functions will be treated also like shader code, executable on GPU. This facilitates creating reusable libraries of GPU code. Even generic libraries in spirit of STL or boost can be created.
PipelineConfig also provides some configuration methods for parameters belonging to fixed function hardware, like blending mode or rasterizer logical operations. These methods should be called only from the constructor of your subclass.
You do not instantiate objects of PipelineConfig directly. Instead, supply them to the PipelineLayout template, which creates actual Vulkan objects related to the pipeline (layout and descriptors).
Rendering pipelines are associated with rendering processes in a render graph (Process nodes). An instance of PipelineConfig object is always bound to some render graph and some Process node within it. Single render graph can have multiple processes, each with its own pipeline or several pipelines.
|
protected |
Constructor, called only from subclass constructor.
Do not construct PipelineConfig objects yourself. Use it only as a base class for your custom pipeline class. Instantiate the custom pipeline through PipelineLayout.
The derived class constructor will be called by PipelineLayout template. You must place two mandatory arguments in the constructor: references to Process object and Device object. You get these values from PipelineLayout. Pass the Process reference to PipelineConfig constructor.
Optionally, you can also pass any number of arbitrary arguments to your PipelineConfig subclass. Put them after two mandatory process and device arguments.
Example:
void vpp::PipelineConfig::cmdBindIndexInput | ( | const VertexIndexBufferView & | hVertexIndexBufferView, |
CommandBuffer | hCmdBuffer = CommandBuffer() |
||
) |
Issues a command which binds some data buffer containing indices for indexed draw to the pipeline.
Indices do not require declaring a binding point, because there is only one index buffer per pipeline and the format is always the same.
Index buffers are provided by using VertexIndexBufferView wrapper object.
The command will be generated into specified command buffer, or the default command buffer if omitted.
For example, see the cmdBindVertexInput() documentation.
void vpp::PipelineConfig::cmdBindVertexInput | ( | const AssignmentListT & | list, |
CommandBuffer | hCmdBuffer = CommandBuffer() |
||
) |
Issues a command which binds some data buffer containing vertex information to a binding point declared within the pipeline.
The buffer will be bound at command execution time. This method accepts assignment list, in the following form:
( bindingPoint_1 = buffer_1, bindingPoint_2 = buffer_2, ... bindingPoint_n = buffer_n )
Where:
If you need to bind only one buffer, specify single item list by using the following syntax:
( bindingPoint_1 = buffer_1 )
In any case, the list should be surrounded by parentheses. Otherwise C++ will not recognize overloaded comma operator and confuse list elements with method arguments.
The command will be generated into specified command buffer, or the default command buffer if omitted.
Example:
|
protected |
Sets logical operation mode for the rasterizer.
Call only from your pipeline class constructor. This function configures logical operation mode for the rasterizer hardware.
The first pareametrer enables or disables logical operation mode. When disabled, the rasterizer will simply write color value to destination. When enabled, the rasterizer will perform the operation selected by the second argument:
For detailed description of these operations, see chapter 26.2 of Vulkan official specification.
|
protected |
Sets blending mode for specified color attachment.
The first argument should be a reference to output color attachment node of the render graph.
The second argument is a structure describing the configuration of blending units on the GPU for that attachment. See chapter 26.1 in the official Vulkan specification for details.
|
protected |
Enables primitive restart feature for indexed draws.
This mode allows to use special index value equal to 0xFFFFFFFF in order to start a new series of primitives in certain topologies, like line or triangle strips, triangle fans. It is not applicable to list topologies.
See chapter 19 of the official Vulkan specification for more details.
|
protected |
Specifies what kind of geometric primitives are supplied to the pipeline as input.
The parameter can be one of the following:
These values are convenience aliases for Vulkan-defined enumeration. See chapter 19.1 of Vulkan official specification for description of each topology.