VPP  0.7
A high-level modern C++ API for Vulkan
Public Member Functions | Static Public Attributes | List of all members
vpp::Vec4 Class Reference

Shader (GPU-side) data type for 4-element 32-bit float vectors. More...

#include <vppLangVectorTypes.hpp>

Public Member Functions

 Vec4 (const std::initializer_list< float > &init)
 Vector initialization with curly braces syntax. More...
 
 Vec4 (float init)
 Vector initialization to single constant value.
 
 Vec4 (const Vec4 &rhs)
 Vector initialization from another vector.
 
template<class Arg1T >
 Vec4 (const Arg1T &arg1)
 Vector initialization from GPU-side value. More...
 
template<class Arg1T , class Arg2T >
 Vec4 (const Arg1T &arg1, const Arg2T &arg2)
 Vector initialization from two GPU-side values. More...
 
template<class Arg1T , class Arg2T , class Arg3T >
 Vec4 (const Arg1T &arg1, const Arg2T &arg2, const Arg3T &arg3)
 Vector initialization from three GPU-side values. More...
 
template<class Arg1T , class Arg2T , class Arg3T , class Arg4T >
 Vec4 (const Arg1T &arg1, const Arg2T &arg2, const Arg3T &arg3, const Arg4T &arg4)
 Vector initialization from four GPU-side values. More...
 
Vec4 operator+ (const Vec4 &rhs) const
 Addition operation on vector components.
 
Vec4 operator- (const Vec4 &rhs) const
 Subtraction operation on vector components.
 
Vec4 operator* (const Vec4 &rhs) const
 Multiplication operation on vector components.
 
Vec4 operator/ (const Vec4 &rhs) const
 Division operation on vector components.
 
Vec4 operator% (const Vec4 &rhs) const
 Remainder operation on vector components.
 
Vec4 operator- () const
 Negation operation on vector components.
 
BVec4 operator== (const Vec4 &rhs) const
 Comparison (equal) operation on vector components.
 
BVec4 operator!= (const Vec4 &rhs) const
 Comparison (not equal) operation on vector components.
 
BVec4 operator> (const Vec4 &rhs) const
 Comparison (greater) operation on vector components.
 
BVec4 operator>= (const Vec4 &rhs) const
 Comparison (greater or equal) operation on vector components.
 
BVec4 operator< (const Vec4 &rhs) const
 Comparison (less) operation on vector components.
 
BVec4 operator<= (const Vec4 &rhs) const
 Comparison (less or equal) operation on vector components.
 
Vec4 operator* (const Float &rhs) const
 Multiplication operation of vector and scalar.
 
Vec2 operator* (const Mat2x4 &rhs) const
 Multiplication operation of vector and 2-column matrix.
 
Vec3 operator* (const Mat3x4 &rhs) const
 Multiplication operation of vector and 3-column matrix.
 
Vec4 operator* (const Mat4 &rhs) const
 Multiplication operation of vector and 4-column matrix.
 
auto operator[] (ESwizzle sw) 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 4-element 32-bit float vectors.

Use this type inside shader code as a counterpart of CPU-side float[4] type.

This is a r-value type. You must initialize it with value, either CPU-side one (an explicit constant), or an expression computed on GPU side. The value can not be changed.

Constant initialization can be performed using initializer list syntax, i.e.:

float pi = 3.1415926f;
Vec4 v = Vec4 { 1.0f * pi, 2.0f * pi, 3.0f * pi, 4.0f * pi };

Note that from the GPU point of view, CPU-side variables are constants and can be used in initializers.

Initialization with GPU-side values (variable or constant) is performed using the constructor syntax, e.g.:

Float x, y, z;
Vec3 coords ( x, y, z );
Vec4 hcoords = Vec4 ( coords, Float ( 1.0f ) );

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

Constructor & Destructor Documentation

◆ Vec4() [1/5]

vpp::Vec4::Vec4 ( const std::initializer_list< float > &  init)

Vector initialization with curly braces syntax.

For example:

Vec4 { 1.0f, 0.5f, 2.0f, 1.0f }

◆ Vec4() [2/5]

template<class Arg1T >
vpp::Vec4::Vec4 ( const Arg1T &  arg1)
explicit

Vector initialization from GPU-side value.

The value can be a scalar, or another vector.

◆ Vec4() [3/5]

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

Vector initialization from two GPU-side values.

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

◆ Vec4() [4/5]

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

Vector initialization from three GPU-side values.

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

◆ Vec4() [5/5]

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

Vector initialization 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: