VPP  0.8
A high-level modern C++ API for Vulkan
vpp::UniformVar< TDef, BufferT > Class Template Reference

Provides access to scalar or arrayed buffer binding point from shader code. More...

#include <vppLangIntUniform.hpp>

Public Member Functions

 UniformVar (BufferT &buf)
 Constructs the accessor for provided binding point.
 
template<typename MemberT >
auto operator[] (MemberT Definition::*pMember) const
 Provides read and write access to specified field. Single buffers only. More...
 
auto operator[] (const Int &index) const
 Provides read and write access to specified item. Arrayed buffers only. More...
 
auto operator[] (const UInt &index) const
 
auto operator[] (int index) const
 
auto operator[] (unsigned int index) const
 
Int Size () const
 Returns GPU-side value equal to the size of the array. Arrayed buffers only.
 
int size () const
 Returns CPU-side value equal to the size of the array. Arrayed buffers only.
 

Detailed Description

template<template< vpp::ETag TAG > class TDef, class BufferT>
class vpp::UniformVar< TDef, BufferT >

Provides access to scalar or arrayed buffer binding point from shader code.

Place UniformVar inside your shader code to access the data in uniform, storage or push constant buffer.

The first argument should be the structure template (derived from UniformStruct).

The second argument should be the decltype of accessed binding point.

It accepts the following binding points: inUniformBuffer, ioBuffer, inUniformBufferDyn, ioBufferDyn, inPushConstant and arrayOf based on those.

Also specify the binding point in the constructor of UniformVar. The binding point should be an object inside PipelineConfig subclass and the shader should be a method in the same subclass - or some code called from it.

UniformVar gives access to single structure in single or arrayed buffer. To access an array embedded inside single buffer, see UniformArray and UniformSimpleArray.

Example of single buffer:

template< ETag TAG >
struct TFramePar : public UniformStruct< TAG, TFramePar >
{
UniformFld< TAG, glm::mat4 > m_world2projected;
UniformFld< TAG, glm::mat4 > m_world2view;
// ...
};
typedef TFramePar< vpp::CPU > CFramePar;
typedef TFramePar< vpp::GPU > GFramePar;
class MyPipelineConfig : public vpp::PipelineConfig
{
// ...
vpp::inUniformBuffer m_inUniformBuffer;
void fVertexShader ( vpp::VertexShader* pShader )
{
using namespace vpp;
varUniformBuffer ( m_inUniformBuffer );
Mat4 w2p = varUniformBuffer [ & GFramePar::m_world2projected ];
// ...
}
};

Example of arrayed buffer:

template< ETag TAG >
struct TFramePar : public UniformStruct< TAG, TFramePar >
{
UniformFld< TAG, glm::mat4 > m_world2projected;
UniformFld< TAG, glm::mat4 > m_world2view;
// ...
};
typedef TFramePar< vpp::CPU > CFramePar;
typedef TFramePar< vpp::GPU > GFramePar;
class MyPipelineConfig : public vpp::PipelineConfig
{
// ...
void fVertexShader ( vpp::VertexShader* pShader )
{
using namespace vpp;
varUniformBufferArr ( m_inUniformBufferArr );
Int arrayIndex = ...; // compute array index
Mat4 w2p = varUniformBufferArr [ arrayIndex ][ & GFramePar::m_world2projected ];
// ...
}
};

Member Function Documentation

◆ operator[]() [1/5]

template<template< vpp::ETag TAG > class TDef, class BufferT>
template<typename MemberT >
auto vpp::UniformVar< TDef, BufferT >::operator[] ( MemberT Definition::*  pMember) const

Provides read and write access to specified field. Single buffers only.

Some buffers are read-only. It is an error to attempt to write them.

◆ operator[]() [2/5]

template<template< vpp::ETag TAG > class TDef, class BufferT>
auto vpp::UniformVar< TDef, BufferT >::operator[] ( const Int index) const

Provides read and write access to specified item. Arrayed buffers only.

Some buffers are read-only. It is an error to attempt to write them.

◆ operator[]() [3/5]

template<template< vpp::ETag TAG > class TDef, class BufferT>
auto vpp::UniformVar< TDef, BufferT >::operator[] ( const UInt index) const

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<template< vpp::ETag TAG > class TDef, class BufferT>
auto vpp::UniformVar< TDef, BufferT >::operator[] ( int  index) const

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<template< vpp::ETag TAG > class TDef, class BufferT>
auto vpp::UniformVar< TDef, BufferT >::operator[] ( unsigned int  index) const

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: