VPP  0.8
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 // -----------------------------------------------------------------------------
172 class VBVec4
173 {
175  VBVec4();
176 
178  VBVec4 ( const BVec4& rhs );
179 
181  VBVec4 ( const VBVec4& rhs );
182 
186  VBVec4 ( const std::initializer_list< bool >& initValue );
187 
194  template< class Arg1T, class Arg2T >
195  VBVec4 ( const Arg1T& arg1, const Arg2T& arg2 );
196 
203  template< class Arg1T, class Arg2T, class Arg3T >
204  VBVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
205 
212  template< class Arg1T, class Arg2T, class Arg3T, class Arg4T >
213  VBVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
214 
218  const VBVec4& operator= ( const BVec4& rhs );
219 
223  const VBVec4& operator= ( const VBVec4& rhs );
224 
228  operator BVec4() const;
229 
231  template< typename IndexT >
232  auto operator[]( IndexT index ) const;
233 
235  static const size_t item_count = 4;
236 };
237 
238 // -----------------------------------------------------------------------------
246 class BVec3 {};
247 
248 // -----------------------------------------------------------------------------
257 class VBVec3 {};
258 
259 // -----------------------------------------------------------------------------
267 class BVec2 {};
268 
269 // -----------------------------------------------------------------------------
278 class VBVec2 {};
279 
280 // -----------------------------------------------------------------------------
314 class Vec4
315 {
316 public:
327  Vec4 ( const std::initializer_list< float >& init );
328 
333  Vec4 ( float init );
334 
339  Vec4 ( const Vec4& rhs );
340 
347  template< class Arg1T >
348  explicit Vec4 ( const Arg1T& arg1 );
349 
357  template< class Arg1T, class Arg2T >
358  Vec4 ( const Arg1T& arg1, const Arg2T& arg2 );
359 
367  template< class Arg1T, class Arg2T, class Arg3T >
368  Vec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
369 
377  template< class Arg1T, class Arg2T, class Arg3T, class Arg4T >
378  Vec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
379 
381  Vec4 operator+ ( const Vec4& rhs ) const;
382 
384  Vec4 operator- ( const Vec4& rhs ) const;
385 
387  Vec4 operator* ( const Vec4& rhs ) const;
388 
390  Vec4 operator/ ( const Vec4& rhs ) const;
391 
393  Vec4 operator% ( const Vec4& rhs ) const;
394 
396  Vec4 operator-() const;
397 
399  BVec4 operator== ( const Vec4& rhs ) const;
400 
402  BVec4 operator!= ( const Vec4& rhs ) const;
403 
405  BVec4 operator> ( const Vec4& rhs ) const;
406 
408  BVec4 operator>= ( const Vec4& rhs ) const;
409 
411  BVec4 operator< ( const Vec4& rhs ) const;
412 
414  BVec4 operator<= ( const Vec4& rhs ) const;
415 
417  Vec4 operator* ( const Float& rhs ) const;
418 
420  Vec2 operator* ( const Mat2x4& rhs ) const;
421 
423  Vec3 operator* ( const Mat3x4& rhs ) const;
424 
426  Vec4 operator* ( const Mat4& rhs ) const;
427 
429  auto operator[]( ESwizzle sw ) const;
430 
432  static const size_t item_count = 4;
433 };
434 
435 // -----------------------------------------------------------------------------
436 // -----------------------------------------------------------------------------
437 
467 class VVec4
468 {
469 public:
471  VVec4();
472 
474  VVec4 ( const Vec4& rhs );
475 
477  VVec4 ( const VVec4& rhs );
478 
482  VVec4 ( const std::initializer_list< float >& initValue );
483 
490  template< class Arg1T, class Arg2T >
491  VVec4 ( const Arg1T& arg1, const Arg2T& arg2 );
492 
499  template< class Arg1T, class Arg2T, class Arg3T >
500  VVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
501 
508  template< class Arg1T, class Arg2T, class Arg3T, class Arg4T >
509  VVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
510 
514  const VVec4& operator= ( const Vec4& rhs );
515 
519  const VVec4& operator= ( const VVec4& rhs );
520 
524  operator Vec4() const;
525 
527  inline Vec4 operator+= ( const Vec4& rhs );
528 
530  inline Vec4 operator-= ( const Vec4& rhs );
531 
533  inline Vec4 operator*= ( const Vec4& rhs );
534 
536  inline Vec4 operator/= ( const Vec4& rhs );
537 
539  inline Vec4 operator%= ( const Vec4& rhs );
540 
542  inline Vec4 operator<<= ( const Vec4& rhs );
543 
545  inline Vec4 operator>>= ( const Vec4& rhs );
546 
548  inline Vec4 operator&= ( const Vec4& rhs );
549 
551  inline Vec4 operator|= ( const Vec4& rhs );
552 
554  inline Vec4 operator^= ( const Vec4& rhs );
555 
557  template< typename IndexT >
558  auto operator[]( IndexT index ) const;
559 
561  static const size_t item_count = 4;
562 };
563 
564 // -----------------------------------------------------------------------------
572 class Vec3 {};
573 
574 // -----------------------------------------------------------------------------
583 class VVec3 {};
584 
585 // -----------------------------------------------------------------------------
593 class Vec2 {};
594 
595 // -----------------------------------------------------------------------------
604 class VVec2 {};
605 
606 // -----------------------------------------------------------------------------
640 class IVec4
641 {
642 public:
653  IVec4 ( const std::initializer_list< int >& init );
654 
659  IVec4 ( int init );
660 
665  IVec4 ( const IVec4& rhs );
666 
673  template< class Arg1T >
674  explicit IVec4 ( const Arg1T& arg1 );
675 
683  template< class Arg1T, class Arg2T >
684  IVec4 ( const Arg1T& arg1, const Arg2T& arg2 );
685 
693  template< class Arg1T, class Arg2T, class Arg3T >
694  IVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
695 
703  template< class Arg1T, class Arg2T, class Arg3T, class Arg4T >
704  IVec4 ( const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
705 
707  IVec4 operator+ ( const IVec4& rhs ) const;
708 
710  IVec4 operator- ( const IVec4& rhs ) const;
711 
713  IVec4 operator* ( const IVec4& rhs ) const;
714 
716  IVec4 operator/ ( const IVec4& rhs ) const;
717 
719  IVec4 operator% ( const IVec4& rhs ) const;
720 
722  IVec4 operator<< ( const IVec4& rhs ) const;
723 
725  IVec4 operator>> ( const IVec4& rhs ) const;
726 
728  IVec4 operator| ( const IVec4& rhs ) const;
729 
731  IVec4 operator^ ( const IVec4& rhs ) const;
732 
734  IVec4 operator& ( const IVec4& rhs ) const;
735 
737  IVec4 operator-() const;
738 
740  IVec4 operator~() const;
741 
743  BVec4 operator== ( const IVec4& rhs ) const;
744 
746  BVec4 operator!= ( const IVec4& rhs ) const;
747 
749  BVec4 operator> ( const IVec4& rhs ) const;
750 
752  BVec4 operator>= ( const IVec4& rhs ) const;
753 
755  BVec4 operator< ( const IVec4& rhs ) const;
756 
758  BVec4 operator<= ( const IVec4& rhs ) const;
759 
761  auto operator[]( ESwizzle sw ) const;
762 
764  static const size_t item_count = 4;
765 };
766 
767 // -----------------------------------------------------------------------------
768 // -----------------------------------------------------------------------------
769 
786 class VIVec4 {};
787 
788 // -----------------------------------------------------------------------------
796 class IVec3 {};
797 
798 // -----------------------------------------------------------------------------
807 class VIVec3 {};
808 
809 // -----------------------------------------------------------------------------
817 class IVec2 {};
818 
819 // -----------------------------------------------------------------------------
828 class VIVec2 {};
829 
830 // -----------------------------------------------------------------------------
838 class UVec4 {};
839 
840 // -----------------------------------------------------------------------------
848 class VUVec4 {};
849 
850 // -----------------------------------------------------------------------------
858 class UVec3 {};
859 
860 // -----------------------------------------------------------------------------
868 class VUVec3 {};
869 
870 // -----------------------------------------------------------------------------
878 class UVec2 {};
879 
880 // -----------------------------------------------------------------------------
888 class VUVec2 {};
889 
890 // -----------------------------------------------------------------------------
898 class DVec4 {};
899 
900 // -----------------------------------------------------------------------------
908 class VDVec4 {};
909 
910 // -----------------------------------------------------------------------------
918 class DVec3 {};
919 
920 // -----------------------------------------------------------------------------
929 class VDVec3 {};
930 
931 // -----------------------------------------------------------------------------
939 class DVec2 {};
940 
941 // -----------------------------------------------------------------------------
950 class VDVec2 {};
951 
952 // -----------------------------------------------------------------------------
953 // -----------------------------------------------------------------------------
954 
955 class PHVec4
956 {
957 public:
958  PHVec4 ( const PHVec4& rhs );
959  operator Vec4() const;
960 };
961 
962 // -----------------------------------------------------------------------------
963 } // namespace vpp
964 // -----------------------------------------------------------------------------
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:929
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:561
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:432
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:908
Shader (GPU-side) data type for 3-element boolean vectors.
Definition: vppLangVectorTypes.hpp:246
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:888
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:939
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:898
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:828
Shader (GPU-side) data type for 3-element 32-bit unsigned integer vectors.
Definition: vppLangVectorTypes.hpp:858
VVec4()
Constructs uninitialized vector variable.
Shader (GPU-side) data type for 2-element 32-bit unsigned integer vectors.
Definition: vppLangVectorTypes.hpp:878
Shader (GPU-side) data type for 2-element boolean vectors.
Definition: vppLangVectorTypes.hpp:267
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:278
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:918
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:807
Shader (GPU-side) data type for 2-element 32-bit integer vectors.
Definition: vppLangVectorTypes.hpp:817
Shader (GPU-side) data type for 4-element 32-bit unsigned integer vectors.
Definition: vppLangVectorTypes.hpp:838
Shader (GPU-side) data type for mutable variables of 4-element 32-bit unsigned integer vector type...
Definition: vppLangVectorTypes.hpp:848
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:640
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:583
Shader (GPU-side) data type for 32-bit floating point values.
Definition: vppLangScalarTypes.hpp:356
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:593
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:314
Shader (GPU-side) data type for mutable variables of 2-element 32-bit float vector type...
Definition: vppLangVectorTypes.hpp:604
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:257
Definition: vppLangVectorTypes.hpp:955
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:786
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:950
Shader (GPU-side) data type for mutable variables of 3-element 32-bit unsigned integer vector type...
Definition: vppLangVectorTypes.hpp:868
Shader (GPU-side) data type for 3-element 32-bit integer vectors.
Definition: vppLangVectorTypes.hpp:796
Shader (GPU-side) data type for mutable variables of 4-element 32-bit float vector type...
Definition: vppLangVectorTypes.hpp:467
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:572
static const size_t item_count
Number of elements in this vector.
Definition: vppLangVectorTypes.hpp:764
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:172
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.