HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CE_VDBGrid.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: CE_VDBGrid.h ( CE Library, C++)
7  *
8  * COMMENTS: Compute Engine Grid.
9  */
10 
11 #ifndef __CE_VDBGrid__
12 #define __CE_VDBGrid__
13 
14 #include "CE_API.h"
15 
16 #include <UT/UT_Array.h>
17 #include <UT/UT_NonCopyable.h>
18 #include <UT/UT_VectorTypes.h>
19 
20 #include <SYS/SYS_Types.h>
21 
22 #include <openvdb/Platform.h>
23 #include <openvdb/openvdb.h>
24 
26 {
27 public:
30  {
31  releaseBuffer();
32  releaseTileStarts();
33  };
34 
36 
37  /// Return the underlying OpenCL buffer that can be used in kernel
38  /// invocations.
39  const cl::Buffer &buffer() const { return myBuffer; }
40  exint bufferSize() const { return myBufSize; }
41 
42  const cl::Buffer &tileStarts() const { return myTileStartsBuffer; }
43  exint numTiles() const { return myTileStartsCount; }
44 
45  /// If the current OpenCL buffer is valid.
46  bool hasBuffer() const { return (myBuffer() != 0);}
47  bool hasTileStarts() const { return (myTileStartsBuffer() != 0); }
48 
49  /// Initialize the CE_VDBGrid from the supplied VDB grid.
50  void initFromVDB(const openvdb::GridBase &grid);
51 
52  /// Initialize the CE_VDBGrid from the supplied buffers of a nanovdb.
53  void initFromDeviceBuffers(cl::Buffer gridbuffer, exint gridsize, cl::Buffer tilestartbuffer, exint tilestartcount);
54 
55  /// Build the tile start buffer from the provided grid, this will
56  /// be one tile per dense leaf node
57  void buildTileStarts(const openvdb::GridBase &grid);
58 
59  /// Create a VDB grid from the CE VDB grid
60  openvdb::GridBase::Ptr createVDB() const;
61 
62 protected:
63 
64  void releaseBuffer();
65  void releaseTileStarts();
66 
68  exint myBufSize = -1;
69 
72  exint myTileStartsCount = -1;
73 };
74 
75 #endif
76 
#define CE_API
Definition: CE_API.h:11
const cl::Buffer & tileStarts() const
Definition: CE_VDBGrid.h:42
UT_Array< UT_Vector3i > myTileStarts
Definition: CE_VDBGrid.h:70
int64 exint
Definition: SYS_Types.h:125
bool hasTileStarts() const
Definition: CE_VDBGrid.h:47
exint bufferSize() const
Definition: CE_VDBGrid.h:40
Definition: core.h:760
cl::Buffer myTileStartsBuffer
Definition: CE_VDBGrid.h:71
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
exint numTiles() const
Definition: CE_VDBGrid.h:43
cl::Buffer myBuffer
Definition: CE_VDBGrid.h:67
Memory buffer interface.
Definition: cl.hpp:1867
bool hasBuffer() const
If the current OpenCL buffer is valid.
Definition: CE_VDBGrid.h:46