VPP  0.7
A high-level modern C++ API for Vulkan
Public Types | Public Member Functions | List of all members
vpp::inPushConstant< DefinitionT > Class Template Reference

Binding point class for push constant data input to shaders. Place in your pipeline configuration class to declare a push constant. More...

#include <vppLangIntUniform.hpp>

Public Types

typedef DefinitionT< CPUDataBlock
 A typedef to CPU version of the data structure.
 

Public Member Functions

 inPushConstant ()
 Constructor. Does not take any arguments.
 
void cmdPush (CommandBuffer currentBuffer)
 Emits push command to specified command buffer. More...
 
template<typename ValueT >
void cmdPush (CommandBuffer currentBuffer, const ValueT &field)
 Emits push command to specified command buffer. More...
 
void cmdPush ()
 Emits push command to default command buffer. More...
 
template<typename ValueT >
void cmdPush (const ValueT &field)
 Emits push command to default command buffer. More...
 
DataBlockdata ()
 Allows to access the fields of the data structure. More...
 

Detailed Description

template<template< vpp::ETag TAG > class DefinitionT>
class vpp::inPushConstant< DefinitionT >

Binding point class for push constant data input to shaders. Place in your pipeline configuration class to declare a push constant.

Specify the name of your uniform data structure template as the argument. Accepts templates derived from UniformStruct.

This class should be used only to define a binding point inside your custom pipeline configuration (a PipelineConfig or ComputePipelineConfig subclass).

Push constants in VPP are used in pretty much the same way as uniform buffers, with some differences. There are the following steps to consider when using push constants within pipeline config:

Example:

// define data structure for the buffer
template< ETag TAG >
struct TMyBufferStructure : public UniformStruct< TAG, TMyBufferStructure >
{
UniformFld< TAG, glm::mat4 > m_matrixField;
UniformFld< TAG, glm::vec4 > m_vectorField;
// ...
};
// it is convenient to make these typedefs
typedef TMyBufferStructure< vpp::CPU > CMyBufferStructure;
typedef TMyBufferStructure< vpp::GPU > GMyBufferStructure;
class MyPipelineConfig : public vpp::PipelineConfig
{
// defines the binding point - assume it contains TMyBufferStructure entry
void fVertexShader ( vpp::VertexShader* pShader )
{
using namespace vpp;
// Accessing a buffer containing single structure.
varBuffer ( m_inPushConstant );
Mat4 m1 = varBuffer [ & GMyBufferStructure::m_matrixField ];
}
};
// [jeszcze example na cmdPush]

Member Function Documentation

◆ cmdPush() [1/4]

template<template< vpp::ETag TAG > class DefinitionT>
void vpp::inPushConstant< DefinitionT >::cmdPush ( CommandBuffer  currentBuffer)

Emits push command to specified command buffer.

The command will be executed when the command buffer is executed by the queue. It will transfer entire push constant structure to the GPU.

◆ cmdPush() [2/4]

template<template< vpp::ETag TAG > class DefinitionT>
template<typename ValueT >
void vpp::inPushConstant< DefinitionT >::cmdPush ( CommandBuffer  currentBuffer,
const ValueT &  field 
)

Emits push command to specified command buffer.

The command will be executed when the command buffer is executed by the queue. It will transfer only specified field contents to the GPU. As the field reference, supply a reference to a field inside CPU version of the data structure.

◆ cmdPush() [3/4]

template<template< vpp::ETag TAG > class DefinitionT>
void vpp::inPushConstant< DefinitionT >::cmdPush ( )

Emits push command to default command buffer.

The command will be executed when the command buffer is executed by the queue. It will transfer entire push constant structure to the GPU. This overload is meant to be used inside rendering command sequence (Process, Preprocess or Postprocess).

◆ cmdPush() [4/4]

template<template< vpp::ETag TAG > class DefinitionT>
template<typename ValueT >
void vpp::inPushConstant< DefinitionT >::cmdPush ( const ValueT &  field)

Emits push command to default command buffer.

The command will be executed when the command buffer is executed by the queue. It will transfer only specified field contents to the GPU. As the field reference, supply a reference to a field inside CPU version of the data structure.

This overload is meant to be used inside rendering command sequence (Process, Preprocess or Postprocess).

◆ data()

template<template< vpp::ETag TAG > class DefinitionT>
DataBlock& vpp::inPushConstant< DefinitionT >::data ( )

Allows to access the fields of the data structure.

Fields are being written directly. However, they are synchronized (sent to GPU) at the moment when cmdPush() command is being executed by the queue.

It is a common practice to issue cmdPush() inside rendering command sequence (Process, Preprocess or Postprocess). However, do NOT write push constant fields there. Fields should be written before issuing the command buffer to the queue – not when constructing the buffer what the command sequence actually does.


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