VPP  0.8
A high-level modern C++ API for Vulkan
vppLangScalarTypes.hpp
1 /*
2  Copyright 2016-2019 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 Bool
46 {
47 public:
54  Bool ( bool value );
55 
57  Bool operator|| ( const Bool& rhs ) const;
58 
60  Bool operator&& ( const Bool& rhs ) const;
61 
63  Bool operator!() const;
64 
66  Bool operator== ( const Bool& rhs ) const;
67 
69  Bool operator!= ( const Bool& rhs ) const;
70 };
71 
72 // -----------------------------------------------------------------------------
100 class VBool
101 {
102 public:
103  VBool();
104  VBool ( const Bool& rvalue );
105 
106  const VBool& operator= ( const Bool& rhs );
107  operator Bool() const;
108 
109  Bool operator|| ( const Bool& rhs ) const;
110  Bool operator&& ( const Bool& rhs ) const;
111  Bool operator!() const;
112 
113  Bool operator== ( const Bool& rhs ) const;
114  Bool operator!= ( const Bool& rhs ) const;
115 };
116 
117 // -----------------------------------------------------------------------------
129 class WBool
130 {
131 };
132 
133 // -----------------------------------------------------------------------------
143 class Void
144 {
145 };
146 
147 // -----------------------------------------------------------------------------
162 class Int
163 {
164 public:
167  Int();
168 
175  Int ( int value );
176 
178  Int operator+ ( const Int& rhs ) const;
179 
181  Int operator- ( const Int& rhs ) const;
182 
184  Int operator* ( const Int& rhs ) const;
185 
187  Int operator/ ( const Int& rhs ) const;
188 
213  Int operator% ( const Int& rhs ) const;
214 
216  Int operator<< ( const Int& rhs ) const;
217 
219  Int operator>> ( const Int& rhs ) const;
220 
222  Int operator| ( const Int& rhs ) const;
223 
225  Int operator^ ( const Int& rhs ) const;
226 
228  Int operator& ( const Int& rhs ) const;
229 
231  Int operator-() const;
232 
234  Int operator~() const;
235 
237  Bool operator== ( const Int& rhs ) const;
238 
240  Bool operator!= ( const Int& rhs ) const;
241 
243  Bool operator> ( const Int& rhs ) const;
244 
246  Bool operator>= ( const Int& rhs ) const;
247 
249  Bool operator< ( const Int& rhs ) const;
250 
252  Bool operator<= ( const Int& rhs ) const;
253 };
254 
255 // -----------------------------------------------------------------------------
256 
271 class UInt
272 {
273 public:
276  UInt();
277 
284  UInt ( unsigned int value );
285 
287  UInt operator+ ( const UInt& rhs ) const;
288 
290  UInt operator- ( const UInt& rhs ) const;
291 
293  UInt operator* ( const UInt& rhs ) const;
294 
296  UInt operator/ ( const UInt& rhs ) const;
297 
299  UInt operator% ( const UInt& rhs ) const;
300 
302  UInt operator<< ( const UInt& rhs ) const;
303 
305  UInt operator>> ( const UInt& rhs ) const;
306 
308  UInt operator| ( const UInt& rhs ) const;
309 
311  UInt operator^ ( const UInt& rhs ) const;
312 
314  UInt operator& ( const UInt& rhs ) const;
315 
317  UInt operator-() const;
318 
320  UInt operator~() const;
321 
323  Bool operator== ( const UInt& rhs ) const;
324 
326  Bool operator!= ( const UInt& rhs ) const;
327 
329  Bool operator> ( const UInt& rhs ) const;
330 
332  Bool operator>= ( const UInt& rhs ) const;
333 
335  Bool operator< ( const UInt& rhs ) const;
336 
338  Bool operator<= ( const UInt& rhs ) const;
339 };
340 
341 // -----------------------------------------------------------------------------
356 class Float
357 {
358 public:
361  Float();
362 
369  Float ( float value );
370 
372  Float operator+ ( const Float& rhs ) const;
373 
375  Float operator- ( const Float& rhs ) const;
376 
378  Float operator* ( const Float& rhs ) const;
379 
381  Float operator/ ( const Float& rhs ) const;
382 
384  Float operator% ( const Float& rhs ) const;
385 
387  Float operator-() const;
388 
390  Bool operator== ( const Float& rhs ) const;
391 
393  Bool operator!= ( const Float& rhs ) const;
394 
396  Bool operator> ( const Float& rhs ) const;
397 
399  Bool operator>= ( const Float& rhs ) const;
400 
402  Bool operator< ( const Float& rhs ) const;
403 
405  Bool operator<= ( const Float& rhs ) const;
406 };
407 
408 // -----------------------------------------------------------------------------
423 class Double
424 {
425 public:
428  Double();
429 
436  Double ( double value );
437 
439  Double operator+ ( const Double& rhs ) const;
440 
442  Double operator- ( const Double& rhs ) const;
443 
445  Double operator* ( const Double& rhs ) const;
446 
448  Double operator/ ( const Double& rhs ) const;
449 
451  Double operator% ( const Double& rhs ) const;
452 
454  Double operator-() const;
455 
457  Bool operator== ( const Double& rhs ) const;
458 
460  Bool operator!= ( const Double& rhs ) const;
461 
463  Bool operator> ( const Double& rhs ) const;
464 
466  Bool operator>= ( const Double& rhs ) const;
467 
469  Bool operator< ( const Double& rhs ) const;
470 
472  Bool operator<= ( const Double& rhs ) const;
473 };
474 
475 // -----------------------------------------------------------------------------
484 class Int64
485 {
486 };
487 
488 // -----------------------------------------------------------------------------
497 class UInt64
498 {
499 };
500 
501 // -----------------------------------------------------------------------------
529 class VInt
530 {
532  VInt();
533 
535  VInt ( const Int& rvalue );
536 
538  operator Int() const;
539 
541  const VInt& operator= ( const Int& rhs );
542 
544  Int operator+= ( const Int& rhs );
545 
547  Int operator-= ( const Int& rhs );
548 
550  Int operator*= ( const Int& rhs );
551 
553  Int operator/= ( const Int& rhs );
554 
556  Int operator%= ( const Int& rhs );
557 
559  Int operator<<= ( const Int& rhs );
560 
562  Int operator>>= ( const Int& rhs );
563 
565  Int operator&= ( const Int& rhs );
566 
568  Int operator|= ( const Int& rhs );
569 
571  Int operator^= ( const Int& rhs );
572 
574  Int operator++();
575 
577  Int operator++ ( int );
578 
580  Int operator--();
581 
583  Int operator-- ( int );
584 };
585 
586 // -----------------------------------------------------------------------------
614 class VUInt
615 {
617  VUInt();
618 
620  VUInt ( const UInt& rvalue );
621 
623  operator UInt() const;
624 
626  const VUInt& operator= ( const UInt& rhs );
627 
629  UInt operator+= ( const UInt& rhs );
630 
632  UInt operator-= ( const UInt& rhs );
633 
635  UInt operator*= ( const UInt& rhs );
636 
638  UInt operator/= ( const UInt& rhs );
639 
641  UInt operator%= ( const UInt& rhs );
642 
644  UInt operator<<= ( const UInt& rhs );
645 
647  UInt operator>>= ( const UInt& rhs );
648 
650  UInt operator&= ( const UInt& rhs );
651 
653  UInt operator|= ( const UInt& rhs );
654 
656  UInt operator^= ( const UInt& rhs );
657 
659  UInt operator++();
660 
662  UInt operator++ ( int );
663 
665  UInt operator--();
666 
668  UInt operator-- ( int );
669 };
670 
671 // -----------------------------------------------------------------------------
701 class WInt
702 {
703 };
704 
705 // -----------------------------------------------------------------------------
717 class WUInt
718 {
719 };
720 
721 // -----------------------------------------------------------------------------
728 class VInt64
729 {
730 };
731 
732 // -----------------------------------------------------------------------------
739 class VUInt64
740 {
741 };
742 
743 // -----------------------------------------------------------------------------
755 class WInt64
756 {
757 };
758 
759 // -----------------------------------------------------------------------------
771 class WUInt64
772 {
773 };
774 
775 // -----------------------------------------------------------------------------
803 class VFloat
804 {
805 };
806 
807 // -----------------------------------------------------------------------------
819 class WFloat
820 {
821 };
822 
823 // -----------------------------------------------------------------------------
851 class VDouble
852 {
853 };
854 
855 // -----------------------------------------------------------------------------
867 class WDouble
868 {
869 };
870 
871 // -----------------------------------------------------------------------------
910 template< class ScalarT >
911 class Pointer
912 {
913 public:
919  ScalarT Load() const;
920 
926  void Store ( const ScalarT& value ) const;
927 
936  ScalarT Exchange ( const ScalarT& value ) const;
937 
947  ScalarT CompareExchange (
948  const ScalarT& newValue,
949  const ScalarT& oldValue ) const;
950 
958  ScalarT Increment() const;
959 
967  ScalarT Decrement() const;
968 
977  ScalarT Add ( const ScalarT& value ) const;
978 
985  ScalarT Sub ( const ScalarT& value ) const;
986 
995  ScalarT Min ( const ScalarT& value ) const;
996 
1005  ScalarT Max ( const ScalarT& value ) const;
1006 
1015  ScalarT And ( const ScalarT& value ) const;
1016 
1025  ScalarT Or ( const ScalarT& value ) const;
1026 
1035  ScalarT Xor ( const ScalarT& value ) const;
1036 };
1037 
1038 // -----------------------------------------------------------------------------
1039 } // namespace vpp
1040 // -----------------------------------------------------------------------------
Double()
Construct a zero r-value.
Int operator%(const Int &rhs) const
Standard remainder operator.
Bool operator>(const UInt &rhs) const
Standard comparison operator (true if greater).
Bool operator>(const Float &rhs) const
Standard comparison operator (true if greater).
Bool operator!=(const Float &rhs) const
Standard comparison operator (true if not equal).
Float operator*(const Float &rhs) const
Standard multiplication operator.
Int()
Construct a zero r-value.
Shader (GPU-side) data type for mutable variables of boolean type.
Definition: vppLangScalarTypes.hpp:100
Int operator-() const
Standard sign reversal operator.
Bool(bool value)
Construct a r-value from specified C++ value.
Bool operator>=(const Int &rhs) const
Standard comparison operator (true if greater or equal).
Bool operator==(const UInt &rhs) const
Standard comparison operator (true if equal).
Shader (GPU-side) data type for mutable variables of 64-bit unsigned integer type.
Definition: vppLangScalarTypes.hpp:739
Shader (GPU-side) data type for 32-bit unsigned integer values.
Definition: vppLangScalarTypes.hpp:271
Shader (GPU-side) data type for workgroup variables of 64-bit unsigned integer type.
Definition: vppLangScalarTypes.hpp:771
UInt operator/(const UInt &rhs) const
Standard division operator.
Bool operator<=(const Int &rhs) const
Standard comparison operator (true if less or equal).
Int operator~() const
Standard bitwise negation operator.
The VPP namespace.
Definition: main.hpp:1
ScalarT Load() const
Reads the target variable.
Bool operator==(const Float &rhs) const
Standard comparison operator (true if equal).
Int operator*(const Int &rhs) const
Standard multiplication operator.
Bool operator<=(const Float &rhs) const
Standard comparison operator (true if less or equal).
UInt operator &(const UInt &rhs) const
Standard bitwise and operator.
Int operator<<(const Int &rhs) const
Standard left shift operator.
UInt operator%(const UInt &rhs) const
Standard remainder operator.
Int operator/(const Int &rhs) const
Standard division operator.
Bool operator||(const Bool &rhs) const
Standard logical or operator.
ScalarT Add(const ScalarT &value) const
Atomically adds specified value to the target variable. Returns previous value.
Bool operator<=(const Double &rhs) const
Standard comparison operator (true if less or equal).
Bool operator!=(const Double &rhs) const
Standard comparison operator (true if not equal).
ScalarT Xor(const ScalarT &value) const
Atomically computes bitwise XOR of specified value and the target variable and stores it to the targe...
Shader (GPU-side) data type for workgroup variables of 32-bit signed integer type.
Definition: vppLangScalarTypes.hpp:701
Bool operator>(const Int &rhs) const
Standard comparison operator (true if greater).
Shader (GPU-side) data type for 64-bit unsigned integer values.
Definition: vppLangScalarTypes.hpp:497
Float operator%(const Float &rhs) const
Standard remainder operator. Result sign is taken from the first operand.
UInt operator-() const
Standard sign reversal operator.
Double operator-() const
Standard sign reversal operator.
void Store(const ScalarT &value) const
Stores specified value to the target variable.
Int operator^(const Int &rhs) const
Standard bitwise xor operator.
Int operator>>(const Int &rhs) const
Standard right shift operator.
Bool operator!=(const UInt &rhs) const
Standard comparison operator (true if not equal).
UInt operator>>(const UInt &rhs) const
Standard right shift operator.
Bool operator>=(const Double &rhs) const
Standard comparison operator (true if greater or equal).
Bool operator!() const
Standard logical not operator.
Float operator+(const Float &rhs) const
Standard addition operator.
UInt operator<<(const UInt &rhs) const
Standard left shift operator.
Bool operator==(const Double &rhs) const
Standard comparison operator (true if equal).
Shader (GPU-side) data type for mutable variables of 32-bit floating point type.
Definition: vppLangScalarTypes.hpp:803
Bool operator!=(const Bool &rhs) const
Standard comparison operator (true if not equal).
Shader (GPU-side) data type for workgroup variables of 64-bit floating point type.
Definition: vppLangScalarTypes.hpp:867
Shader (GPU-side) data type for pointers to workgroup and global scoped variables.
Definition: vppLangScalarTypes.hpp:911
Int operator &(const Int &rhs) const
Standard bitwise and operator.
Shader (GPU-side) data type for workgroup variables of boolean type.
Definition: vppLangScalarTypes.hpp:129
Bool operator &&(const Bool &rhs) const
Standard logical and operator.
Double operator*(const Double &rhs) const
Standard multiplication operator.
Bool operator<=(const UInt &rhs) const
Standard comparison operator (true if less or equal).
Bool operator<(const Int &rhs) const
Standard comparison operator (true if less).
Bool operator<(const Float &rhs) const
Standard comparison operator (true if less).
UInt operator~() const
Standard bitwise negation operator.
UInt operator+(const UInt &rhs) const
Standard addition operator.
Int operator|(const Int &rhs) const
Standard bitwise or operator.
Shader (GPU-side) data type for 32-bit floating point values.
Definition: vppLangScalarTypes.hpp:356
ScalarT Exchange(const ScalarT &value) const
Atomically exchanges specified value with the target variable. Returns previous value.
Bool operator!=(const Int &rhs) const
Standard comparison operator (true if not equal).
Shader (GPU-side) data type for mutable variables of 32-bit unsigned integer type.
Definition: vppLangScalarTypes.hpp:614
ScalarT Increment() const
Atomically increments the target variable.
Shader (GPU-side) data type for mutable variables of 64-bit signed integer type.
Definition: vppLangScalarTypes.hpp:728
Bool operator==(const Int &rhs) const
Standard comparison operator (true if equal).
Int operator+(const Int &rhs) const
Standard addition operator.
Bool operator>(const Double &rhs) const
Standard comparison operator (true if greater).
ScalarT Decrement() const
Atomically decrements the target variable.
Shader (GPU-side) data type for workgroup variables of 32-bit floating point type.
Definition: vppLangScalarTypes.hpp:819
Shader (GPU-side) data type for mutable variables of 32-bit signed integer type.
Definition: vppLangScalarTypes.hpp:529
UInt operator^(const UInt &rhs) const
Standard bitwise xor operator.
Float operator/(const Float &rhs) const
Standard division operator.
Bool operator==(const Bool &rhs) const
Standard comparison operator (true if equal).
Shader (GPU-side) void data type.
Definition: vppLangScalarTypes.hpp:143
Bool operator>=(const Float &rhs) const
Standard comparison operator (true if greater or equal).
Shader (GPU-side) data type for 32-bit signed integer values.
Definition: vppLangScalarTypes.hpp:162
Shader (GPU-side) data type for 64-bit floating point values.
Definition: vppLangScalarTypes.hpp:423
UInt operator*(const UInt &rhs) const
Standard multiplication operator.
ScalarT Or(const ScalarT &value) const
Atomically computes bitwise OR of specified value and the target variable and stores it to the target...
Float()
Construct a zero r-value.
Bool operator<(const UInt &rhs) const
Standard comparison operator (true if less).
ScalarT CompareExchange(const ScalarT &newValue, const ScalarT &oldValue) const
Atomically exchanges specified value with the target variable, but only if current value is equal to ...
Shader (GPU-side) data type for workgroup variables of 32-bit unsigned integer type.
Definition: vppLangScalarTypes.hpp:717
UInt()
Construct a zero r-value.
ScalarT And(const ScalarT &value) const
Atomically computes bitwise AND of specified value and the target variable and stores it to the targe...
ScalarT Max(const ScalarT &value) const
Atomically computes maximum of specified value and the target variable and stores it to the target va...
Bool operator<(const Double &rhs) const
Standard comparison operator (true if less).
Double operator+(const Double &rhs) const
Standard addition operator.
Shader (GPU-side) data type for workgroup variables of 64-bit unsigned integer type.
Definition: vppLangScalarTypes.hpp:755
Shader (GPU-side) data type for boolean values.
Definition: vppLangScalarTypes.hpp:45
UInt operator|(const UInt &rhs) const
Standard bitwise or operator.
Double operator%(const Double &rhs) const
Standard remainder operator. Result sign is taken from the first operand.
ScalarT Sub(const ScalarT &value) const
Atomically subtracts specified value from the target variable. Returns previous value.
Float operator-() const
Standard sign reversal operator.
Shader (GPU-side) data type for mutable variables of 64-bit floating point type.
Definition: vppLangScalarTypes.hpp:851
Bool operator>=(const UInt &rhs) const
Standard comparison operator (true if greater or equal).
Shader (GPU-side) data type for 64-bit signed integer values.
Definition: vppLangScalarTypes.hpp:484
Double operator/(const Double &rhs) const
Standard division operator.
ScalarT Min(const ScalarT &value) const
Atomically computes minimum of specified value and the target variable and stores it to the target va...