VPP  0.8
A high-level modern C++ API for Vulkan
vpp::Output< BindingPointT > Class Template Reference

Provides output access to communication variable binding point from shader code. More...

#include <vppLangIntInOut.hpp>

Public Member Functions

 Output (const BindingPointT &var)
 Constructs the output point associated with specified binding point (ioVariable or ioStructure).
 
template<typename MemberT >
auto operator[] (MemberT struct_type::*pMember) const
 Provides access to structure members for ioStructure binding points. Provide a pointer to member of your structure (a subclass of LocalStruct). More...
 
auto operator[] (const Int &index)
 Provides access to an item in case if the variable is an array. More...
 
auto operator[] (const UInt &index)
 
auto operator[] (int index)
 
auto operator[] (unsigned int index)
 
template<typename RightT >
void operator= (const RightT &rhs)
 
Int Size () const
 Returns GPU-side value equal to the array size (number of vertices).
 
int size () const
 Returns CPU-side value equal to the array size (number of vertices).
 

Detailed Description

template<class BindingPointT>
class vpp::Output< BindingPointT >

Provides output access to communication variable binding point from shader code.

Place Output inside your shader code to write data to a communication variable.

The argument should be decltype of the binding point field. It accepts ioVariable and ioStructure binding points. Also provide the binding point reference to the constructor.

You must pay attention yo use Output only in the shader which has been declared as source shader in the binding point.

Example of usage:

struct GStdPipelineData : public LocalStruct< GStdPipelineData >
{
Member< Vec4 > m_worldVertex;
Member< Vec4 > m_worldNormal;
Member< Vec4 > m_worldTangent;
Member< Vec4 > m_textureUV01;
Member< Vec4 > m_textureUV23;
};
class MyPipelineConfig : public PipelineConfig
{
void fVertexShader ( VertexShader* pShader );
void fFragmentShader ( FragmentShader* pShader );
// ...
typedef ioStructure< GStdPipelineData, vertexShader, fragmentShader > ShaderIO;
ShaderIO m_shaderIO;
fragmentShader m_fragmentShader;
};
void MyPipelineConfig :: fVertexShader ( VertexShader* pShader )
{
// GPU code
Output< decltype ( m_shaderIO ) > output ( m_shaderIO );
const Vec4 worldVtx = ...; // compute world vertex position
output [ & GStdPipelineData::m_worldVertex ] = worldVtx;
// ...
}

Member Function Documentation

◆ operator[]() [1/5]

template<class BindingPointT>
template<typename MemberT >
auto vpp::Output< BindingPointT >::operator[] ( MemberT struct_type::*  pMember) const

Provides access to structure members for ioStructure binding points. Provide a pointer to member of your structure (a subclass of LocalStruct).

Not applicable for ioVariable binding points.

◆ operator[]() [2/5]

template<class BindingPointT>
auto vpp::Output< BindingPointT >::operator[] ( const Int index)

Provides access to an item in case if the variable is an array.

Communication variables are automatically converted to arrays in certain types of shaders, i.e.:

  • geometry shaders,
  • tessellation control shaders,
  • tessellation evaluation shaders.

This is because these shaders operate on multiple vertices at once, forming a geometric primitive or patch. You can access values for individual vertices, by using one of indexing operators.

◆ operator[]() [3/5]

template<class BindingPointT>
auto vpp::Output< BindingPointT >::operator[] ( const UInt index)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator[]() [4/5]

template<class BindingPointT>
auto vpp::Output< BindingPointT >::operator[] ( int  index)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator[]() [5/5]

template<class BindingPointT>
auto vpp::Output< BindingPointT >::operator[] ( unsigned int  index)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.


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