VPP  0.8
A high-level modern C++ API for Vulkan
vpp::VVec4 Class Reference

Shader (GPU-side) data type for mutable variables of 4-element 32-bit float vector type. More...

#include <vppLangVectorTypes.hpp>

Public Member Functions

 VVec4 ()
 Constructs uninitialized vector variable.
 
 VVec4 (const Vec4 &rhs)
 Constructs vector variable and initializes it with given value.
 
 VVec4 (const VVec4 &rhs)
 Constructs vector variable and initializes it with given value.
 
 VVec4 (const std::initializer_list< float > &initValue)
 Constructs vector variable and initializes it with given constant (curly braces syntax).
 
template<class Arg1T , class Arg2T >
 VVec4 (const Arg1T &arg1, const Arg2T &arg2)
 Constructs vector variable and initializes it from two GPU-side values. More...
 
template<class Arg1T , class Arg2T , class Arg3T >
 VVec4 (const Arg1T &arg1, const Arg2T &arg2, const Arg3T &arg3)
 Constructs vector variable and initializes it from three GPU-side values. More...
 
template<class Arg1T , class Arg2T , class Arg3T , class Arg4T >
 VVec4 (const Arg1T &arg1, const Arg2T &arg2, const Arg3T &arg3, const Arg4T &arg4)
 Constructs vector variable and initializes it from four GPU-side values. More...
 
const VVec4operator= (const Vec4 &rhs)
 Assigns new value to vector variable.
 
const VVec4operator= (const VVec4 &rhs)
 Assigns new value to vector variable.
 
 operator Vec4 () const
 Retrieves the r-value from vector variable.
 
Vec4 operator+= (const Vec4 &rhs)
 Performs addition and assigns result to vector variable.
 
Vec4 operator-= (const Vec4 &rhs)
 Performs subtraction and assigns result to vector variable.
 
Vec4 operator*= (const Vec4 &rhs)
 Performs multiplication and assigns result to vector variable.
 
Vec4 operator/= (const Vec4 &rhs)
 Performs division and assigns result to vector variable.
 
Vec4 operator%= (const Vec4 &rhs)
 Computes remainder and assigns result to vector variable.
 
Vec4 operator<<= (const Vec4 &rhs)
 Performs shift to the left and assigns result to vector variable.
 
Vec4 operator>>= (const Vec4 &rhs)
 Performs shift to the right and assigns result to vector variable.
 
Vec4 operator &= (const Vec4 &rhs)
 Performs bitwise AND and assigns result to vector variable.
 
Vec4 operator|= (const Vec4 &rhs)
 Performs bitwise OR and assigns result to vector variable.
 
Vec4 operator^= (const Vec4 &rhs)
 Performs bitwise XOR and assigns result to vector variable.
 
template<typename IndexT >
auto operator[] (IndexT index) const
 Component selection operation.
 

Static Public Attributes

static const size_t item_count = 4
 Number of elements in this vector.
 

Detailed Description

Shader (GPU-side) data type for mutable variables of 4-element 32-bit float vector type.

Use this type inside shader code as a counterpart of CPU-side float[4] type, when it is required to change value of the vector.

This is a l-value type. It can be initialized and changed any time.

Beware that mutable variables can degrade performance on GPU, therefore Vec4 is preferable, unless you really want a mutable variable.

The lifetime of all local mutable variables (including VVec4) spans from the declaration to the end of current C++ block. This is the same as for ordinary C++ variable. However, each mutable variable allocates a variable slot (GPU register) which exists for entire time of shader execution (or shader-level function execution). VPP tries to optimize variable slot usage by reusing slots that were freed because their variables went out of scope. For that reuse to take place, the type of new variable must be identical to the type of some free slot.

Therefore you can safely create a lot of mutable variables as long as they are in separate C++ blocks and have the same type.

The VVec4 type has also a workgroup-scoped counterpart called WVec4. Caution: the reusing semantics does not apply to workgroup-scoped variables (they are permanent).

Constructor & Destructor Documentation

◆ VVec4() [1/3]

template<class Arg1T , class Arg2T >
vpp::VVec4::VVec4 ( const Arg1T &  arg1,
const Arg2T &  arg2 
)

Constructs vector variable and initializes it from two GPU-side values.

These values can be scalars or vectors. They will be concatenated to form the resulting vector.

◆ VVec4() [2/3]

template<class Arg1T , class Arg2T , class Arg3T >
vpp::VVec4::VVec4 ( const Arg1T &  arg1,
const Arg2T &  arg2,
const Arg3T &  arg3 
)

Constructs vector variable and initializes it from three GPU-side values.

These values can be scalars or vectors. They will be concatenated to form the resulting vector.

◆ VVec4() [3/3]

template<class Arg1T , class Arg2T , class Arg3T , class Arg4T >
vpp::VVec4::VVec4 ( const Arg1T &  arg1,
const Arg2T &  arg2,
const Arg3T &  arg3,
const Arg4T &  arg4 
)

Constructs vector variable and initializes it from four GPU-side values.

These values can be scalars or vectors. They will be concatenated to form the resulting vector.


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