OpenVDB 14.0.0
Loading...
Searching...
No Matches
GridHandle.h File Reference

Defines GridHandle, which manages a memory buffer containing one or more NanoVDB grids: host-resident, or a single-space buffer such as cuda::Buffer. More...

#include <fstream>
#include <iostream>
#include <cstring>
#include <stdexcept>
#include <string>
#include <vector>
#include <initializer_list>
#include <cstddef>
#include <type_traits>
#include <utility>
#include <nanovdb/NanoVDB.h>
#include <nanovdb/HostBuffer.h>
#include <nanovdb/tools/GridChecksum.h>

Go to the source code of this file.

Classes

struct  BufferDeclaresDeviceDual< BufferT, typename >
 Detects a BufferTraits specialization that still declares the hasDeviceDual member removed in NanoVDB 14.0, so GridHandle can reject it instead of parsing the device-only grids as an empty host buffer. More...
struct  BufferDeclaresDeviceDual< BufferT, std::void_t< decltype(BufferTraits< BufferT >::hasDeviceDual)> >
class  GridHandle< BufferT >
 This class serves to manage a buffer containing one or more NanoVDB Grids. More...
struct  LayoutCopy
 Wraps a byte-for-byte copy of a handle's buffer in a handle with that handle's layout. The layout already passed a header parse or GridHandle::adopt when the source was made, so it is not checked again. This also carries grids at unaligned offsets, which the constructors accept and GridHandle::adopt rejects. Used by cuda::copyTo. More...

Namespaces

namespace  nanovdb
 Defines a simple memory pool used to call cub functions that use dynamic temporary storage.
namespace  nanovdb::detail

Functions

template<typename BufferT>
BufferT createHostStorage (uint64_t bytes, const BufferT &pool)
 Allocates bytes of host-readable storage for a GridHandle: through BufferT::create for buffers that provide it, and through pool's resource for a host-accessible single-space buffer (e.g. a pinned-resource cuda::Buffer). The braced third argument selects the uninitialized-storage constructor without naming its tag type, so this header stays CUDA-free.
template<typename BufferT>
BufferT createHostStorage (uint64_t bytes, const BufferT *pool)
 Pointer-taking form for callers whose pool is optional: a null pool default-constructs the buffer type as the prototype, which for a single-space buffer means a default-constructed resource.
void validateGridLayout (const std::vector< GridHandleMetaData > &meta, uint64_t bytes)
 Checks that meta describes grids laid out back to back from offset zero inside bytes of storage, each starting at a multiple of NANOVDB_DATA_ALIGNMENT and naming a grid type below GridType::End. This is all the validation a handle adopting caller-supplied metadata performs: no header is read. No grids at all is accepted only over an empty buffer (an empty handle).
void parseHostGridChain (const GridData *head, uint64_t bytes, std::vector< GridHandleMetaData > &meta)
 Validates the grid chain in bytes of host-readable memory headed by head and fills meta with one entry per grid: every header must be valid, carry its expected index and the chain's total count, and fit inside the buffer, so a truncated buffer or a forged header is rejected before its metadata is trusted. This is the host counterpart of the device-side chain parse. Like it, this does not require grid offsets to be aligned, unlike GridHandle::adopt.
template<typename BufferT, template< class, class... > class VectorT = std::vector>
VectorT< GridHandle< BufferT > > splitGrids (const GridHandle< BufferT > &handle, const BufferT *other=nullptr)
 Split all grids in a single GridHandle into a vector of multiple GridHandles each with a single grid.
template<typename BufferT, template< class, class... > class VectorT>
GridHandle< BufferT > mergeGrids (const VectorT< GridHandle< BufferT > > &handles, const BufferT *pool=nullptr)
 Combines (or merges) multiple GridHandles into a single GridHandle containing all grids.

Detailed Description

Defines GridHandle, which manages a memory buffer containing one or more NanoVDB grids: host-resident, or a single-space buffer such as cuda::Buffer.

Author
Ken Museth
Date
January 8, 2020