VPP  0.8
A high-level modern C++ API for Vulkan
vpp::UniformFld< TAG, HostT, OFFSET > Struct Template Reference

Template for defining uniform data fields. More...

#include <vppLangIntUniform.hpp>

Public Member Functions

 UniformFld ()
 Constructs uninitialized or GPU-side data field.
 
 UniformFld (const HostT &value)
 Constructs initialized CPU-side data field.
 
 operator HostT & ()
 Allows CPU-side access to the field.
 
 operator const HostT & () const
 Allows CPU-side read-only access to the field.
 

Detailed Description

template<ETag TAG, class HostT, int OFFSET = -1>
struct vpp::UniformFld< TAG, HostT, OFFSET >

Template for defining uniform data fields.

Place UniformFld inside UniformStruct to define a data field. This field can have scalar, vector or matrix type. You must specify one type in the template argument list: the host type (CPU-side). The shader (GPU-side) type is automatically inferred.

Example:

template< ETag TAG >
struct TFramePar : public UniformStruct< TAG, TFramePar >
{
// This defines a field which will be represented by glm::mat4
// matrix type on CPU side and vpp::Mat4 on GPU side. The second one
// is automatically determined from vpp::StructMemberTraits specialization.
UniformFld< TAG, glm::mat4 > m_world2projected;
UniformFld< TAG, glm::mat4 > m_world2view;
// ...
};

The first argument should be the tag passed from UniformStruct.

The second argument describes the CPU type. That allows to create CPU version of the structure that is compatible with GPU version. This argument can be one of the following:

  • Scalar type (int, float, etc.).
  • An instantiation of vpp::format< ... > template specifying some structure consisting of several fields. VPP treats these specially, so that in CPU version of the structure you get access to data_type defined with the format.
  • GLM vector or matrix type. You must include vppSupportGLM.hpp for that to work.
  • Any custom vector or matrix type that has corresponding specialization of vpp::StructMemberTraits template. You can define your own specializations in order to support your types.

[ caution! document also alignment issues with uniform buffers! ]


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