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

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

#include <vppLangIntInOut.hpp>

Public Member Functions

 Input (const BindingPointT &var)
 Constructs the input point associated with specified binding point (ioVariable or ioStructure).
 
 Input (const BindingPointT &var, std::uint32_t interpFlags)
 Constructs the input point associated with specified binding point (ioVariable or ioStructure). Additionally sets interpolation mode. The mode is a bitwise OR of the following flags: More...
 
template<typename MemberT >
auto operator[] (MemberT StructT::*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)
 
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).
 
ValueT InterpolateAtCentroid ()
 
ValueT InterpolateAtSample (const Int &sample)
 
ValueT InterpolateAtOffset (const Vec2 &offset)
 

Detailed Description

template<class BindingPointT>
class vpp::Input< BindingPointT >

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

Place Input inside your shader code to read data from 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 Input only in the shader which has been declared as destination 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 :: fFragmentShader ( FragmentShader* pShader )
{
// GPU code
Input< decltype ( m_shaderIO ) > input ( m_shaderIO );
// Caution: as this is fragment shader, worldVertex will be interpolated
const Vec4 worldVertex = input [ & GStdPipelineData::m_worldVertex ];
// ...
}

Constructor & Destructor Documentation

◆ Input()

template<class BindingPointT>
vpp::Input< BindingPointT >::Input ( const BindingPointT &  var,
std::uint32_t  interpFlags 
)

Constructs the input point associated with specified binding point (ioVariable or ioStructure). Additionally sets interpolation mode. The mode is a bitwise OR of the following flags:

  • IN_FLAT: no interpolation will be done.
  • IN_NOPERSPECTIVE: linear, non-perspective correct, interpolation will be used.
  • IN_CENTROID: when used with multi-sampling rasterization, allows a single interpolation location for an entire pixel.
  • IN_SAMPLE: when used with multi-sampling rasterization, requires per-sample interpolation.

This constructor is allowed only for ioVariable binding points and only in fragment shaders.

Member Function Documentation

◆ operator[]() [1/5]

template<class BindingPointT>
template<typename MemberT >
auto vpp::Input< BindingPointT >::operator[] ( MemberT StructT::*  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::Input< 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::Input< 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::Input< 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::Input< 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: