17#include "../NanoVDB.h"
20#ifndef NANOVDB_NODEMANAGER_H_HAS_BEEN_INCLUDED
21#define NANOVDB_NODEMANAGER_H_HAS_BEEN_INCLUDED
26template <
typename BuildT>
30template<
typename BufferT = HostBuffer>
31class NodeManagerHandle;
40template <
typename BuildT,
typename BufferT = HostBuffer>
42 const BufferT& buffer = BufferT());
53template<
typename BufferT>
58 template<
typename BuildT>
61 template<
typename BuildT,
typename U = BufferT>
66 static T* no_const(
const T* ptr) {
return const_cast<T*
>(ptr); }
80 mBuffer = std::move(
other.mBuffer);
88 void reset() { mBuffer.clear(); }
91 BufferT&
buffer() {
return mBuffer; }
94 const BufferT&
buffer()
const {
return mBuffer; }
112 template<
typename BuildT>
118 template<
typename BuildT>
124 template<
typename BuildT,
typename U = BufferT>
131 template<
typename BuildT,
typename U = BufferT>
138 template<
typename U = BufferT>
139 typename std::enable_if<BufferTraits<U>::hasDeviceDual,
void>::type
145 data->mGrid = deviceGrid;
153 template<
typename U = BufferT>
154 typename std::enable_if<BufferTraits<U>::hasDeviceDual,
void>::type
164template<
typename BufferT>
165template<
typename BuildT>
166inline const NodeManager<BuildT>* NodeManagerHandle<BufferT>::getMgr()
const
169 T mgr =
reinterpret_cast<T>(mBuffer.data());
173template<
typename BufferT>
174template<
typename BuildT,
typename U>
175inline typename std::enable_if<BufferTraits<U>::hasDeviceDual,
const NodeManager<BuildT>*>::type
176NodeManagerHandle<BufferT>::getDeviceMgr()
const
179 T mgr =
reinterpret_cast<T>(mBuffer.data());
187template<
typename BuildT>
199 static constexpr bool FIXED_SIZE = Node0::FIXED_SIZE && Node1::FIXED_SIZE && Node2::FIXED_SIZE;
288template <
typename BuildT,
typename BufferT>
290 const BufferT& buffer)
304 int64_t *
ptr1 = data->mPtr[1] = data->mPtr[0] + grid.tree().nodeCount(0);
305 int64_t *
ptr2 = data->mPtr[2] = data->mPtr[1] + grid.tree().nodeCount(1);
307 for (
auto it2 = grid.tree().root().beginChild();
it2; ++
it2) {
HostBuffer - a buffer that contains a shared or private bump pool to either externally or internally ...
#define __hostdev__
Definition NanoVDB.h:192
#define NANOVDB_ASSERT(x)
Definition NanoVDB.h:173
#define NANOVDB_MAGIC_NUMBER
Definition NanoVDB.h:121
Definition DenseGrid.h:402
std::enable_if< BufferTraits< U >::hasDeviceDual, void >::type deviceUpload(void *stream=nullptr, bool sync=true)
Definition DenseGrid.h:474
std::enable_if< BufferTraits< U >::hasDeviceDual, void >::type deviceDownload(void *stream=nullptr, bool sync=true)
Definition DenseGrid.h:480
DenseGridHandle()=default
uint64_t size() const
Returns the size in bytes of the raw memory buffer managed by this DenseGridHandle's allocator.
Definition DenseGrid.h:440
uint8_t * data()
Returns a non-const pointer to the data.
Definition DenseGrid.h:432
const DenseGrid< ValueT > * grid() const
Returns a const pointer to the NanoVDB grid encoded in the DenseGridHandle.
Definition DenseGrid.h:447
NodeManagerHandle manages the memory of a NodeManager.
Definition NodeManager.h:55
NodeManagerHandle & operator=(const NodeManagerHandle &)=delete
Disallow copy assignment operation.
std::enable_if< BufferTraits< U >::hasDeviceDual, NodeManager< BuildT > * >::type deviceMgr()
Return a const pointer to the NodeManager encoded in this NodeManagerHandle on the device,...
Definition NodeManager.h:133
const uint8_t * data() const
Returns a const pointer to the data.
Definition NodeManager.h:104
BufferT & buffer()
Return a reference to the buffer.
Definition NodeManager.h:91
std::enable_if< BufferTraits< U >::hasDeviceDual, void >::type deviceDownload(void *stream=nullptr, bool sync=true)
Download the NodeManager to from the device, e.g. from GPU to CPU.
Definition NodeManager.h:155
NodeManagerHandle(BufferT &&buffer)
Move constructor from a buffer.
Definition NodeManager.h:70
NodeManagerHandle & operator=(NodeManagerHandle &&other) noexcept
Move copy assignment operation.
Definition NodeManager.h:78
uint64_t size() const
Returns the size in bytes of the raw memory buffer managed by this NodeManagerHandle's allocator.
Definition NodeManager.h:107
std::enable_if< BufferTraits< U >::hasDeviceDual, constNodeManager< BuildT > * >::type deviceMgr() const
Return a const pointer to the NodeManager encoded in this NodeManagerHandle on the device,...
Definition NodeManager.h:126
const BufferT & buffer() const
Return a const reference to the buffer.
Definition NodeManager.h:94
NodeManager< BuildT > * mgr()
Returns a pointer to the NodeManager encoded in this NodeManagerHandle.
Definition NodeManager.h:119
uint8_t * data()
Returns a non-const pointer to the data.
Definition NodeManager.h:99
std::enable_if< BufferTraits< U >::hasDeviceDual, void >::type deviceUpload(void *deviceGrid, void *stream=nullptr, bool sync=true)
Upload the NodeManager to the device, e.g. from CPU to GPU.
Definition NodeManager.h:140
const NodeManager< BuildT > * mgr() const
Returns a const pointer to the NodeManager encoded in this NodeManagerHandle.
Definition NodeManager.h:113
NodeManagerHandle()=default
Empty ctor.
NodeManagerHandle(const NodeManagerHandle &)=delete
Disallow copy-construction.
void reset()
clear the buffer
Definition NodeManager.h:88
NodeManagerHandle(NodeManagerHandle &&other) noexcept
Move copy-constructor.
Definition NodeManager.h:84
~NodeManagerHandle()
Default destructor.
Definition NodeManager.h:86
NodeManager allows for sequential access to nodes.
Definition NodeManager.h:189
NodeManager & operator=(const NodeManager &)=delete
Node1 & lower(uint32_t i)
Definition NodeManager.h:280
bool isLinear() const
return true if the nodes have both fixed size and are arranged breadth-first in memory....
Definition NodeManager.h:215
NodeManager & operator=(NodeManager &&)=delete
static uint64_t memUsage(const GridT &grid)
Return the memory footprint in bytes of the NodeManager derived from the specified grid.
Definition NodeManager.h:218
uint64_t nodeCount(int level) const
Return the number of tree nodes at the specified level.
Definition NodeManager.h:244
const Node2 & upper(uint32_t i) const
Return the i'th upper internal node with respect to breadth-first ordering.
Definition NodeManager.h:283
NodeManager(const NodeManager &)=delete
const Node0 & leaf(uint32_t i) const
Return the i'th leaf node with respect to breadth-first ordering.
Definition NodeManager.h:275
Node2 & upper(uint32_t i)
Definition NodeManager.h:284
NodeManager(NodeManager &&)=delete
GridT & grid()
Return a reference to the grid.
Definition NodeManager.h:231
Node0 & leaf(uint32_t i)
Definition NodeManager.h:276
static bool isLinear(const GridT &grid)
return true if the nodes have both fixed size and are arranged breadth-first in memory....
Definition NodeManager.h:211
uint64_t memUsage() const
Return the memory footprint in bytes of this instance.
Definition NodeManager.h:228
NodeT< LEVEL > & node(uint32_t i)
Return the i'th node with respect to breadth-first ordering.
Definition NodeManager.h:262
const NodeT< LEVEL > & node(uint32_t i) const
Return the i'th leaf node with respect to breadth-first ordering.
Definition NodeManager.h:248
const TreeT & tree() const
Definition NodeManager.h:236
RootT & root()
Return a reference to the root.
Definition NodeManager.h:239
TreeT & tree()
Return a reference to the tree.
Definition NodeManager.h:235
const GridT & grid() const
Definition NodeManager.h:232
const RootT & root() const
Definition NodeManager.h:240
const Node1 & lower(uint32_t i) const
Return the i'th lower internal node with respect to breadth-first ordering.
Definition NodeManager.h:279
static int64_t PtrDiff(const T1 *p, const T2 *q)
Definition NanoVDB.h:535
NodeManagerHandle< BufferT > createNodeManager(const NanoGrid< BuildT > &grid, const BufferT &buffer=BufferT())
brief Construct a NodeManager and return its handle
Definition NodeManager.h:289
static bool isValid(const void *p)
return true if the specified pointer is aligned and not NULL
Definition NanoVDB.h:504
typename GridT::TreeType type
Definition NanoVDB.h:2785
Definition NodeManager.h:45
int64_t * mPtr[3]
Definition NodeManager.h:48
uint8_t mPadding[7]
Definition NodeManager.h:49
int64_t mOff[3]
Definition NodeManager.h:48
uint64_t mMagic
Definition NodeManager.h:46
void * mGrid
Definition NodeManager.h:47
uint8_t mLinear
Definition NodeManager.h:49
Struct to derive node type from its level in a given grid, tree or root while preserving constness.
Definition NanoVDB.h:2343