VPP  0.7
A high-level modern C++ API for Vulkan
vppLangVectorTypes.hpp
1 /*
2  Copyright 2016-2018 SOFT-ERG, Przemek Kuczmierczyk (www.softerg.com)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:
7 
8  1. Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10 
11  2. Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 // -----------------------------------------------------------------------------
28 namespace vpp {
29 // -----------------------------------------------------------------------------
30 
45 class BVec4
46 {
47 public:
58  BVec4 ( const std::initializer_list< bool >& init );
59 
64  BVec4 ( bool init );
65 
70  BVec4 ( const BVec4& rhs );
71 
78  template< class Arg1T >
79  explicit BVec4 ( const Arg1T& arg1 );
80 
87  template< class Arg1T, class Arg2T >
88  BVec4 ( const Arg1T& arg1, const Arg2T& arg2 );
89 
96  template< class Arg1T, class Arg2T, class Arg3T >
97  BVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
98 
105  template< class Arg1T, class Arg2T, class Arg3T, class Arg4T >
106  BVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
107 
109  BVec4 operator&& ( const BVec4& rhs ) const;
110 
112  BVec4 operator|| ( const BVec4& rhs ) const;
113 
115  BVec4 operator!() const;
116 
118  BVec4 operator== ( const BVec4& rhs ) const;
119 
121  BVec4 operator!= ( const BVec4& rhs ) const;
122 
124  BVec4 operator> ( const BVec4& rhs ) const;
125 
127  BVec4 operator>= ( const BVec4& rhs ) const;
128 
130  BVec4 operator< ( const BVec4& rhs ) const;
131 
133  BVec4 operator<= ( const BVec4& rhs ) const;
134 
136  auto operator[]( ESwizzle sw ) const;
137 
139  static const size_t item_count = 4;
140 };
141 
142 // -----------------------------------------------------------------------------
156 class VBVec4
157 {
159  VBVec4();
160 
162  VBVec4 ( const BVec4& rhs );
163 
165  VBVec4 ( const VBVec4& rhs );
166 
170  VBVec4 ( const std::initializer_list< bool >& initValue );
171 
178  template< class Arg1T, class Arg2T >
179  VBVec4 ( const Arg1T& arg1, const Arg2T& arg2 );
180 
187  template< class Arg1T, class Arg2T, class Arg3T >
188  VBVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
189 
196  template< class Arg1T, class Arg2T, class Arg3T, class Arg4T >
197  VBVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
198 
202  const VBVec4& operator= ( const BVec4& rhs );
203 
207  const VBVec4& operator= ( const VBVec4& rhs );
208 
212  operator BVec4() const;
213 
215  template< typename IndexT >
216  auto operator[]( IndexT index ) const;
217 
219  static const size_t item_count = 4;
220 };
221 
222 // -----------------------------------------------------------------------------
230 class BVec3 {};
231 
232 // -----------------------------------------------------------------------------
241 class VBVec3 {};
242 
243 // -----------------------------------------------------------------------------
251 class BVec2 {};
252 
253 // -----------------------------------------------------------------------------
262 class VBVec2 {};
263 
264 // -----------------------------------------------------------------------------
298 class Vec4
299 {
300 public:
311  Vec4 ( const std::initializer_list< float >& init );
312 
317  Vec4 ( float init );
318 
323  Vec4 ( const Vec4& rhs );
324 
331  template< class Arg1T >
332  explicit Vec4 ( const Arg1T& arg1 );
333 
341  template< class Arg1T, class Arg2T >
342  Vec4 ( const Arg1T& arg1, const Arg2T& arg2 );
343 
351  template< class Arg1T, class Arg2T, class Arg3T >
352  Vec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
353 
361  template< class Arg1T, class Arg2T, class Arg3T, class Arg4T >
362  Vec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
363 
365  Vec4 operator+ ( const Vec4& rhs ) const;
366 
368  Vec4 operator- ( const Vec4& rhs ) const;
369 
371  Vec4 operator* ( const Vec4& rhs ) const;
372 
374  Vec4 operator/ ( const Vec4& rhs ) const;
375 
377  Vec4 operator% ( const Vec4& rhs ) const;
378 
380  Vec4 operator-() const;
381 
383  BVec4 operator== ( const Vec4& rhs ) const;
384 
386  BVec4 operator!= ( const Vec4& rhs ) const;
387 
389  BVec4 operator> ( const Vec4& rhs ) const;
390 
392  BVec4 operator>= ( const Vec4& rhs ) const;
393 
395  BVec4 operator< ( const Vec4& rhs ) const;
396 
398  BVec4 operator<= ( const Vec4& rhs ) const;
399 
401  Vec4 operator* ( const Float& rhs ) const;
402 
404  Vec2 operator* ( const Mat2x4& rhs ) const;
405 
407  Vec3 operator* ( const Mat3x4& rhs ) const;
408 
410  Vec4 operator* ( const Mat4& rhs ) const;
411 
413  auto operator[]( ESwizzle sw ) const;
414 
416  static const size_t item_count = 4;
417 };
418 
419 // -----------------------------------------------------------------------------
420 // -----------------------------------------------------------------------------
421 
435 class VVec4
436 {
437 public:
439  VVec4();
440 
442  VVec4 ( const Vec4& rhs );
443 
445  VVec4 ( const VVec4& rhs );
446 
450  VVec4 ( const std::initializer_list< float >& initValue );
451 
458  template< class Arg1T, class Arg2T >
459  VVec4 ( const Arg1T& arg1, const Arg2T& arg2 );
460 
467  template< class Arg1T, class Arg2T, class Arg3T >
468  VVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
469 
476  template< class Arg1T, class Arg2T, class Arg3T, class Arg4T >
477  VVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
478 
482  const VVec4& operator= ( const Vec4& rhs );
483 
487  const VVec4& operator= ( const VVec4& rhs );
488 
492  operator Vec4() const;
493 
495  inline Vec4 operator+= ( const Vec4& rhs );
496 
498  inline Vec4 operator-= ( const Vec4& rhs );
499 
501  inline Vec4 operator*= ( const Vec4& rhs );
502 
504  inline Vec4 operator/= ( const Vec4& rhs );
505 
507  inline Vec4 operator%= ( const Vec4& rhs );
508 
510  inline Vec4 operator<<= ( const Vec4& rhs );
511 
513  inline Vec4 operator>>= ( const Vec4& rhs );
514 
516  inline Vec4 operator&= ( const Vec4& rhs );
517 
519  inline Vec4 operator|= ( const Vec4& rhs );
520 
522  inline Vec4 operator^= ( const Vec4& rhs );
523 
525  template< typename IndexT >
526  auto operator[]( IndexT index ) const;
527 
529  static const size_t item_count = 4;
530 };
531 
532 // -----------------------------------------------------------------------------
540 class Vec3 {};
541 
542 // -----------------------------------------------------------------------------
551 class VVec3 {};
552 
553 // -----------------------------------------------------------------------------
561 class Vec2 {};
562 
563 // -----------------------------------------------------------------------------
572 class VVec2 {};
573 
574 // -----------------------------------------------------------------------------
608 class IVec4
609 {
610 public:
621  IVec4 ( const std::initializer_list< int >& init );
622 
627  IVec4 ( int init );
628 
633  IVec4 ( const IVec4& rhs );
634 
641  template< class Arg1T >
642  explicit IVec4 ( const Arg1T& arg1 );
643 
651  template< class Arg1T, class Arg2T >
652  IVec4 ( const Arg1T& arg1, const Arg2T& arg2 );
653 
661  template< class Arg1T, class Arg2T, class Arg3T >
662  IVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
663 
671  template< class Arg1T, class Arg2T, class Arg3T, class Arg4T >
672  IVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
673 
675  IVec4 operator+ ( const IVec4& rhs ) const;
676 
678  IVec4 operator- ( const IVec4& rhs ) const;
679 
681  IVec4 operator* ( const IVec4& rhs ) const;
682 
684  IVec4 operator/ ( const IVec4& rhs ) const;
685 
687  IVec4 operator% ( const IVec4& rhs ) const;
688 
690  IVec4 operator<< ( const IVec4& rhs ) const;
691 
693  IVec4 operator>> ( const IVec4& rhs ) const;
694 
696  IVec4 operator| ( const IVec4& rhs ) const;
697 
699  IVec4 operator^ ( const IVec4& rhs ) const;
700 
702  IVec4 operator& ( const IVec4& rhs ) const;
703 
705  IVec4 operator-() const;
706 
708  IVec4 operator~() const;
709 
711  BVec4 operator== ( const IVec4& rhs ) const;
712 
714  BVec4 operator!= ( const IVec4& rhs ) const;
715 
717  BVec4 operator> ( const IVec4& rhs ) const;
718 
720  BVec4 operator>= ( const IVec4& rhs ) const;
721 
723  BVec4 operator< ( const IVec4& rhs ) const;
724 
726  BVec4 operator<= ( const IVec4& rhs ) const;
727 
729  auto operator[]( ESwizzle sw ) const;
730 
732  static const size_t item_count = 4;
733 };
734 
735 // -----------------------------------------------------------------------------
736 // -----------------------------------------------------------------------------
737 
754 class VIVec4 {};
755 
756 // -----------------------------------------------------------------------------
764 class IVec3 {};
765 
766 // -----------------------------------------------------------------------------
775 class VIVec3 {};
776 
777 // -----------------------------------------------------------------------------
785 class IVec2 {};
786 
787 // -----------------------------------------------------------------------------
796 class VIVec2 {};
797 
798 // -----------------------------------------------------------------------------
806 class UVec4 {};
807 
808 // -----------------------------------------------------------------------------
816 class VUVec4 {};
817 
818 // -----------------------------------------------------------------------------
826 class UVec3 {};
827 
828 // -----------------------------------------------------------------------------
836 class VUVec3 {};
837 
838 // -----------------------------------------------------------------------------
846 class UVec2 {};
847 
848 // -----------------------------------------------------------------------------
856 class VUVec2 {};
857 
858 // -----------------------------------------------------------------------------
866 class DVec4 {};
867 
868 // -----------------------------------------------------------------------------
876 class VDVec4 {};
877 
878 // -----------------------------------------------------------------------------
886 class DVec3 {};
887 
888 // -----------------------------------------------------------------------------
897 class VDVec3 {};
898 
899 // -----------------------------------------------------------------------------
907 class DVec2 {};
908 
909 // -----------------------------------------------------------------------------
918 class VDVec2 {};
919 
920 // -----------------------------------------------------------------------------
921 // -----------------------------------------------------------------------------
922 
923 class PHVec4
924 {
925 public:
926  PHVec4 ( const PHVec4& rhs );
927  operator Vec4() const;
928 };
929 
930 // -----------------------------------------------------------------------------
931 } // namespace vpp
932 // -----------------------------------------------------------------------------
IVec4 operator<<(const IVec4 &rhs) const
Shift to the left operation on vector components.
Shader (GPU-side) data type for mutable variables of 3-element 64-bit float vector type...
Definition: vppLangVectorTypes.hpp:897
auto operator[](ESwizzle sw) const
Computes a permutation of vector components.
IVec4 operator/(const IVec4 &rhs) const
Division operation on vector components.
BVec4 operator>=(const BVec4 &rhs) const
Comparison (greater or equal) operation on vector components.
static const size_t item_count
Number of elements in this vector.
Definition: vppLangVectorTypes.hpp:529
IVec4 operator|(const IVec4 &rhs) const
Bitwise or operation on vector components.
Vec4 operator-() const
Negation operation on vector components.
static const size_t item_count
Number of elements in this vector.
Definition: vppLangVectorTypes.hpp:416
BVec4 operator==(const IVec4 &rhs) const
Comparison (equal) operation on vector components.
Vec4 operator>>=(const Vec4 &rhs)
Performs shift to the right and assigns result to vector variable.
BVec4 operator<=(const Vec4 &rhs) const
Comparison (less or equal) operation on vector components.
Vec4 operator<<=(const Vec4 &rhs)
Performs shift to the left and assigns result to vector variable.
BVec4 operator!=(const IVec4 &rhs) const
Comparison (not equal) operation on vector components.
Vec4 operator-=(const Vec4 &rhs)
Performs subtraction and assigns result to vector variable.
BVec4 operator>=(const Vec4 &rhs) const
Comparison (greater or equal) operation on vector components.
static const size_t item_count
Number of elements in this vector.
Definition: vppLangVectorTypes.hpp:139
The VPP namespace.
Definition: main.hpp:1
Shader (GPU-side) data type for mutable variables of 4-element 64-bit float vector type...
Definition: vppLangVectorTypes.hpp:876
Shader (GPU-side) data type for 3-element boolean vectors.
Definition: vppLangVectorTypes.hpp:230
BVec4 operator<=(const BVec4 &rhs) const
Comparison (less or equal) operation on vector components.
BVec4 operator>=(const IVec4 &rhs) const
Comparison (greater or equal) operation on vector components.
BVec4 operator>(const Vec4 &rhs) const
Comparison (greater) operation on vector components.
Shader (GPU-side) data type for mutable variables of 2-element 32-bit unsigned integer vector type...
Definition: vppLangVectorTypes.hpp:856
Vec4 operator+(const Vec4 &rhs) const
Addition operation on vector components.
Shader (GPU-side) data type for 2-element 64-bit floating point vectors.
Definition: vppLangVectorTypes.hpp:907
const VVec4 & operator=(const Vec4 &rhs)
Assigns new value to vector variable.
IVec4 operator>>(const IVec4 &rhs) const
Shift to the right operation on vector components.
IVec4 operator*(const IVec4 &rhs) const
Multiplication operation on vector components.
Shader (GPU-side) data type for 4-element 64-bit floating point vectors.
Definition: vppLangVectorTypes.hpp:866
Vec4 operator/(const Vec4 &rhs) const
Division operation on vector components.
Shader (GPU-side) data type for mutable variables of 2-element 32-bit integer vector type...
Definition: vppLangVectorTypes.hpp:796
Shader (GPU-side) data type for 3-element 32-bit unsigned integer vectors.
Definition: vppLangVectorTypes.hpp:826
VVec4()
Constructs uninitialized vector variable.
Shader (GPU-side) data type for 2-element 32-bit unsigned integer vectors.
Definition: vppLangVectorTypes.hpp:846
Shader (GPU-side) data type for 2-element boolean vectors.
Definition: vppLangVectorTypes.hpp:251
BVec4 operator==(const Vec4 &rhs) const
Comparison (equal) operation on vector components.
Shader (GPU-side) data type for 4-element boolean vectors.
Definition: vppLangVectorTypes.hpp:45
Vec4 operator/=(const Vec4 &rhs)
Performs division and assigns result to vector variable.
Shader (GPU-side) data type for mutable variables of 2-element boolean vector type.
Definition: vppLangVectorTypes.hpp:262
IVec4 operator+(const IVec4 &rhs) const
Addition operation on vector components.
BVec4(const std::initializer_list< bool > &init)
Vector initialization with curly braces syntax.
IVec4(const std::initializer_list< int > &init)
Vector initialization with curly braces syntax.
IVec4 operator%(const IVec4 &rhs) const
Remainder operation on vector components.
IVec4 operator^(const IVec4 &rhs) const
Bitwise xor operation on vector components.
Shader (GPU-side) data type for 3-element 64-bit floating point vectors.
Definition: vppLangVectorTypes.hpp:886
BVec4 operator<(const IVec4 &rhs) const
Comparison (less) operation on vector components.
Shader (GPU-side) data type for 3 columns, 4 rows 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:184
Shader (GPU-side) data type for 2 columns, 4 rows 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:175
Vec4 operator*(const Vec4 &rhs) const
Multiplication operation on vector components.
Shader (GPU-side) data type for mutable variables of 3-element 32-bit integer vector type...
Definition: vppLangVectorTypes.hpp:775
Shader (GPU-side) data type for 2-element 32-bit integer vectors.
Definition: vppLangVectorTypes.hpp:785
Shader (GPU-side) data type for 4-element 32-bit unsigned integer vectors.
Definition: vppLangVectorTypes.hpp:806
Shader (GPU-side) data type for mutable variables of 4-element 32-bit unsigned integer vector type...
Definition: vppLangVectorTypes.hpp:816
BVec4 operator!=(const BVec4 &rhs) const
Comparison (not equal) operation on vector components.
Shader (GPU-side) data type for 4-element 32-bit integer vectors.
Definition: vppLangVectorTypes.hpp:608
BVec4 operator||(const BVec4 &rhs) const
Logical OR operation on vector components.
Shader (GPU-side) data type for 4x4 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:59
Shader (GPU-side) data type for mutable variables of 3-element 32-bit float vector type...
Definition: vppLangVectorTypes.hpp:551
Shader (GPU-side) data type for 32-bit floating point values.
Definition: vppLangScalarTypes.hpp:330
BVec4 operator>(const BVec4 &rhs) const
Comparison (greater) operation on vector components.
Shader (GPU-side) data type for 2-element 32-bit float vectors.
Definition: vppLangVectorTypes.hpp:561
auto operator[](IndexT index) const
Component selection operation.
BVec4 operator &&(const BVec4 &rhs) const
Logical AND operation on vector components.
auto operator[](ESwizzle sw) const
Component selection operation.
Shader (GPU-side) data type for 4-element 32-bit float vectors.
Definition: vppLangVectorTypes.hpp:298
Shader (GPU-side) data type for mutable variables of 2-element 32-bit float vector type...
Definition: vppLangVectorTypes.hpp:572
BVec4 operator<=(const IVec4 &rhs) const
Comparison (less or equal) operation on vector components.
auto operator[](ESwizzle sw) const
Component selection operation.
Shader (GPU-side) data type for mutable variables of 3-element boolean vector type.
Definition: vppLangVectorTypes.hpp:241
Definition: vppLangVectorTypes.hpp:923
Vec4 operator*=(const Vec4 &rhs)
Performs multiplication and assigns result to vector variable.
BVec4 operator!=(const Vec4 &rhs) const
Comparison (not equal) operation on vector components.
BVec4 operator==(const BVec4 &rhs) const
Comparison (equal) operation on vector components.
Vec4 operator|=(const Vec4 &rhs)
Performs bitwise OR and assigns result to vector variable.
BVec4 operator!() const
Logical NOT operation on vector components.
Shader (GPU-side) data type for mutable variables of 4-element 32-bit integer vector type...
Definition: vppLangVectorTypes.hpp:754
IVec4 operator-() const
Arithmetic negation operation on vector components.
Vec4 operator &=(const Vec4 &rhs)
Performs bitwise AND and assigns result to vector variable.
Shader (GPU-side) data type for mutable variables of 2-element 64-bit float vector type...
Definition: vppLangVectorTypes.hpp:918
Shader (GPU-side) data type for mutable variables of 3-element 32-bit unsigned integer vector type...
Definition: vppLangVectorTypes.hpp:836
Shader (GPU-side) data type for 3-element 32-bit integer vectors.
Definition: vppLangVectorTypes.hpp:764
Shader (GPU-side) data type for mutable variables of 4-element 32-bit float vector type...
Definition: vppLangVectorTypes.hpp:435
Vec4 operator+=(const Vec4 &rhs)
Performs addition and assigns result to vector variable.
Vec4 operator%=(const Vec4 &rhs)
Computes remainder and assigns result to vector variable.
Shader (GPU-side) data type for 3-element 32-bit float vectors.
Definition: vppLangVectorTypes.hpp:540
static const size_t item_count
Number of elements in this vector.
Definition: vppLangVectorTypes.hpp:732
IVec4 operator~() const
Bitwise negation operation on vector components.
BVec4 operator>(const IVec4 &rhs) const
Comparison (greater) operation on vector components.
Shader (GPU-side) data type for mutable variables of 4-element boolean vector type.
Definition: vppLangVectorTypes.hpp:156
Vec4(const std::initializer_list< float > &init)
Vector initialization with curly braces syntax.
BVec4 operator<(const BVec4 &rhs) const
Comparison (less) operation on vector components.
IVec4 operator &(const IVec4 &rhs) const
Bitwise and operation on vector components.
BVec4 operator<(const Vec4 &rhs) const
Comparison (less) operation on vector components.
Vec4 operator%(const Vec4 &rhs) const
Remainder operation on vector components.
Vec4 operator^=(const Vec4 &rhs)
Performs bitwise XOR and assigns result to vector variable.