VPP  0.8
A high-level modern C++ API for Vulkan
vppLangAggregates.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 
41 enum ETag
42 {
44  CPU,
45 
47  GPU,
48 
51 };
52 
53 // -----------------------------------------------------------------------------
93 template< class DefinitionT >
95 {
96 };
97 
98 // -----------------------------------------------------------------------------
120 template< class FieldT, std::uint32_t FLAGS = 0 >
121 class Field
122 {
123 public:
124 };
125 
126 // -----------------------------------------------------------------------------
138 template< class ItemT >
139 class VArray
140 {
141 public:
151  VArray ( int s );
152 
156  template< typename IndexT >
157  auto operator[]( IndexT index ) const;
158 
162  Int Size() const;
163 
167  int size() const;
168 };
169 
170 // -----------------------------------------------------------------------------
214 template< class ItemT >
215 class WArray
216 {
217 public:
227  WArray ( int s );
228 
232  template< typename IndexT >
233  auto operator[]( IndexT index ) const;
234 
238  Int Size() const;
239 
243  int size() const;
244 };
245 
246 // -----------------------------------------------------------------------------
259 template< class ItemT >
260 class WArray2
261 {
262 public:
272  WArray2 ( int nRows, int nColumns );
273 
280  template< typename IndexT >
281  WArray< ItemT > operator[]( IndexT index ) const;
282 
286  template< typename IndexT >
287  auto operator()( IndexT iRow, IndexT iCol ) const;
288 
292  Int Size() const;
293 
297  int size() const;
298 
302  Int Rows() const;
303 
307  int rows() const;
308 
312  Int Cols() const;
313 
317  int cols() const;
318 };
319 
320 // -----------------------------------------------------------------------------
321 
322 template< class ItemT >
323 class WArray3
324 {
325 public:
334  WArray3 ( int nl, int nr, int nc );
335 
342  template< typename IndexT >
343  WArray2< ItemT > operator[]( const IndexT& index ) const;
344 
348  template< typename IndexT >
349  auto operator()( const IndexT& iLayer, const IndexT& iRow, const IndexT& iCol ) const;
350 
354  Int Size() const;
355 
359  int size() const;
360 
364  Int Layers() const;
365 
369  int layers() const;
370 
374  Int Rows() const;
375 
379  int rows() const;
380 
384  Int Cols() const;
385 
389  int cols() const;
390 };
391 
392 // -----------------------------------------------------------------------------
393 } // namespace vpp
394 // -----------------------------------------------------------------------------
int cols() const
Returns CPU-level value equal to number of columns in the array.
Selects CPU version of the structure.
Definition: vppLangAggregates.hpp:44
Declares workgroup-scoped variable of two-dimensional array type.
Definition: vppLangAggregates.hpp:260
auto operator()(const IndexT &iLayer, const IndexT &iRow, const IndexT &iCol) const
Allows read/write access to elements of the array.
WArray(int s)
Constucts workgroup-scoped array of specified size.
Declares mutable shader local variable of array type.
Definition: vppLangAggregates.hpp:139
WArray3(int nl, int nr, int nc)
Constructs a shared 3-dimensional array with specified number of layers, rows and columns...
Int Size() const
Returns GPU-level value equal to the size of the array.
The VPP namespace.
Definition: main.hpp:1
ETag
Enumeration type allowing to select the flavor of shader structural type: the CPU or GPU version...
Definition: vppLangAggregates.hpp:41
Definition: vppLangAggregates.hpp:323
int size() const
Returns CPU-level value equal to number of rows in the array.
int size() const
Returns CPU-level value equal to the size of the array.
WArray2(int nRows, int nColumns)
Constructs a shared 2-dimensional array with specified number of rows and columns.
auto operator()(IndexT iRow, IndexT iCol) const
Allows read/write access to elements of the array.
int size() const
Returns CPU-level value equal to the size of the array.
Int Cols() const
Returns GPU-level value equal to number of columns in the array.
WArray2< ItemT > operator[](const IndexT &index) const
Allows read/write access to individual 2-dimensional layers of the array.
int rows() const
Returns CPU-level value equal to number of rows in the array.
Int Size() const
Returns GPU-level value equal to the size of the array.
Int Rows() const
Returns GPU-level value equal to number of rows in the array.
Internal use only.
Definition: vppLangAggregates.hpp:50
auto operator[](IndexT index) const
Allows read/write access to elements of the array.
WArray< ItemT > operator[](IndexT index) const
Allows read/write access to individual rows of the array.
Int Size() const
Returns GPU-level value equal to number of rows in the array.
Int Rows() const
Returns GPU-level value equal to number of rows in the array.
int cols() const
Returns CPU-level value equal to number of columns in the array.
int size() const
Returns CPU-level value equal to number of layers in the array.
Int Cols() const
Returns GPU-level value equal to number of columns in the array.
int rows() const
Returns CPU-level value equal to number of rows in the array.
Shader (GPU-side) data type for 32-bit signed integer values.
Definition: vppLangScalarTypes.hpp:162
VArray(int s)
Constucts local array of specified size.
Template for defining local structure data fields.
Definition: vppLangAggregates.hpp:121
Int Size() const
Returns GPU-level value equal to number of layers in the array.
int layers() const
Returns CPU-level value equal to number of layers in the array.
Base class for local data structures.
Definition: vppLangAggregates.hpp:94
auto operator[](IndexT index) const
Allows read/write access to elements of the array.
Selects GPU version of the structure.
Definition: vppLangAggregates.hpp:47
Declares workgroup-scoped variable of array type.
Definition: vppLangAggregates.hpp:215
Int Layers() const
Returns GPU-level value equal to number of layers in the array.