OpenVDB: nanovdb/NanoVDB.h File Reference

OpenVDB 12.1.0

Loading...
Searching...
No Matches
NanoVDB.h File Reference

Implements a light-weight self-contained VDB data-structure in a single file! In other words, this is a significantly watered-down version of the OpenVDB implementation, with few dependencies - so a one-stop-shop for a minimalistic VDB data structure that run on most platforms! More...

`#include <nanovdb/util/Util.h>`
`#include <nanovdb/math/Math.h>`

Go to the source code of this file.

## Classes
class | ValueIndex
| Dummy type for a voxel whose value equals an offset into an external value array. More...
class | ValueOnIndex
| Dummy type for a voxel whose value equals an offset into an external value array of active values. More...
class | ValueIndexMask
| Like `ValueIndex` but with a mutable mask. More...
class | ValueOnIndexMask
| Like `ValueOnIndex` but with a mutable mask. More...
class | ValueMask
| Dummy type for a voxel whose value equals its binary active state. More...
class | Half
| Dummy type for a 16 bit floating point values (placeholder for IEEE 754 Half) More...
class | Fp4
| Dummy type for a 4bit quantization of float point values. More...
class | Fp8
| Dummy type for a 8bit quantization of float point values. More...
class | Fp16
| Dummy type for a 16bit quantization of float point values. More...
class | FpN
| Dummy type for a variable bit quantization of floating point values. More...
class | Point
| Dummy type for indexing points into voxels. More...
struct | BuildTraits< T >
| Define static boolean tests for template build types. More...
struct | BuildToValueMap< T >
| Maps one type (e.g. the build types above) to other (actual) types. More...
struct | BuildToValueMap< ValueIndex >
struct | BuildToValueMap< ValueOnIndex >
struct | BuildToValueMap< ValueIndexMask >
struct | BuildToValueMap< ValueOnIndexMask >
struct | BuildToValueMap< ValueMask >
struct | BuildToValueMap< Half >
struct | BuildToValueMap< Fp4 >
struct | BuildToValueMap< Fp8 >
struct | BuildToValueMap< Fp16 >
struct | BuildToValueMap< FpN >
struct | BuildToValueMap< Point >
class | Version
| Bit-compacted representation of all three version numbers. More...
struct | TensorTraits< T, 0 >
struct | TensorTraits< T, 1 >
struct | FloatTraits< T, int >
struct | FloatTraits< T, 8 >
struct | FloatTraits< bool, 1 >
struct | FloatTraits< ValueIndex, 1 >
struct | FloatTraits< ValueIndexMask, 1 >
struct | FloatTraits< ValueOnIndex, 1 >
struct | FloatTraits< ValueOnIndexMask, 1 >
struct | FloatTraits< ValueMask, 1 >
struct | FloatTraits< Point, 1 >
struct | BitArray< 8 >
struct | BitArray< 16 >
struct | BitArray< 32 >
struct | BitArray< 64 >
class | BitFlags< N >
class | Mask< LOG2DIM >
| Bit-mask to encode active states and facilitate sequential iterators and a fast codec for I/O compression. More...
class | Mask< LOG2DIM >::Iterator< On >
class | Mask< LOG2DIM >::DenseIterator
struct | Map
| Defines an affine transform and its inverse represented as a 3x3 matrix and a vec3 translation. More...
struct | GridBlindMetaData
struct | NodeTrait< GridOrTreeOrRootT, 0 >
struct | NodeTrait< const GridOrTreeOrRootT, 0 >
struct | NodeTrait< GridOrTreeOrRootT, 1 >
struct | NodeTrait< const GridOrTreeOrRootT, 1 >
struct | NodeTrait< GridOrTreeOrRootT, 2 >
struct | NodeTrait< const GridOrTreeOrRootT, 2 >
struct | NodeTrait< GridOrTreeOrRootT, 3 >
struct | NodeTrait< const GridOrTreeOrRootT, 3 >
class | Checksum
| Class that encapsulates two CRC32 checksums, one for the Grid, Tree and Root node meta data and one for the remaining grid nodes. More...
struct | GridData
| Struct with all the member data of the Grid (useful during serialization of an openvdb grid) More...
class | Grid< TreeT >
| Highest level of the data structure. Contains a tree and a world->index transform (that currently only supports uniform scaling and translation). More...
struct | TreeData
struct | GridTree< GridT >
| defines a tree type from a grid type while preserving constness More...
struct | GridTree< const GridT >
class | Tree< RootT >
| VDB Tree, which is a thin wrapper around a RootNode. More...
struct | RootData< ChildT >
| Struct with all the member data of the RootNode (useful during serialization of an openvdb RootNode) More...
struct | RootData< ChildT >::Tile
class | RootData< ChildT >::TileIter< DataT >
class | RootNode< ChildT >
| Top-most node of the VDB tree structure. More...
class | RootNode< ChildT >::BaseIter< RootT >
class | RootNode< ChildT >::ChildIter< RootT >
class | RootNode< ChildT >::ValueIter< RootT >
class | RootNode< ChildT >::ValueOnIter< RootT >
class | RootNode< ChildT >::DenseIter< RootT >
struct | InternalData< ChildT, LOG2DIM >
| Struct with all the member data of the InternalNode (useful during serialization of an openvdb InternalNode) More...
union | InternalData< ChildT, LOG2DIM >::Tile
class | InternalNode< ChildT, Log2Dim >
| Internal nodes of a VDB tree. More...
class | InternalNode< ChildT, Log2Dim >::ChildIter< ParentT >
| Visits child nodes of this node only. More...
class | InternalNode< ChildT, Log2Dim >::ValueIterator
| Visits all tile values in this node, i.e. both inactive and active tiles. More...
class | InternalNode< ChildT, Log2Dim >::ValueOnIterator
| Visits active tile values of this node only. More...
class | InternalNode< ChildT, Log2Dim >::DenseIterator
| Visits all tile values and child nodes of this node. More...
struct | LeafData< ValueT, CoordT, MaskT, LOG2DIM >
| Stuct with all the member data of the LeafNode (useful during serialization of an openvdb LeafNode) More...
struct | LeafFnBase< CoordT, MaskT, LOG2DIM >
| Base-class for quantized float leaf nodes. More...
struct | LeafData< Fp4, CoordT, MaskT, LOG2DIM >
| Stuct with all the member data of the LeafNode (useful during serialization of an openvdb LeafNode) More...
struct | LeafData< Fp8, CoordT, MaskT, LOG2DIM >
struct | LeafData< Fp16, CoordT, MaskT, LOG2DIM >
struct | LeafData< FpN, CoordT, MaskT, LOG2DIM >
struct | LeafData< bool, CoordT, MaskT, LOG2DIM >
struct | LeafData< ValueMask, CoordT, MaskT, LOG2DIM >
struct | LeafIndexBase< CoordT, MaskT, LOG2DIM >
struct | LeafData< ValueIndex, CoordT, MaskT, LOG2DIM >
struct | LeafData< ValueOnIndex, CoordT, MaskT, LOG2DIM >
struct | LeafData< ValueIndexMask, CoordT, MaskT, LOG2DIM >
struct | LeafData< ValueOnIndexMask, CoordT, MaskT, LOG2DIM >
struct | LeafData< Point, CoordT, MaskT, LOG2DIM >
class | LeafNode< BuildT, CoordT, MaskT, Log2Dim >
| Leaf nodes of the VDB tree. (defaults to 8x8x8 = 512 voxels) More...
struct | LeafNode< BuildT, CoordT, MaskT, Log2Dim >::ChildNodeType
class | LeafNode< BuildT, CoordT, MaskT, Log2Dim >::ValueOnIterator
| Visits all active values in a leaf node. More...
class | LeafNode< BuildT, CoordT, MaskT, Log2Dim >::ValueOffIterator
| Visits all inactive values in a leaf node. More...
class | LeafNode< BuildT, CoordT, MaskT, Log2Dim >::ValueIterator
| Visits all values in a leaf node, i.e. both active and inactive values. More...
struct | NanoNode< BuildT, 0 >
struct | NanoNode< BuildT, 1 >
struct | NanoNode< BuildT, 2 >
struct | NanoNode< BuildT, 3 >
class | ReadAccessor< BuildT, -1, -1, -1 >
| A read-only value accessor with three levels of node caching. This allows for inverse tree traversal during lookup, which is on average significantly faster than calling the equivalent method on the tree (i.e. top-down traversal). More...
class | ReadAccessor< BuildT, LEVEL0, -1, -1 >
| Node caching at a single tree level. More...
class | ReadAccessor< BuildT, LEVEL0, LEVEL1, -1 >
class | ReadAccessor< BuildT, 0, 1, 2 >
| Node caching at all (three) tree levels.
class | GridMetaData
| This is a convenient class that allows for access to grid meta-data that are independent of the value type of a grid. That is, this class can be used to get information about a grid without actually knowing its ValueType. More...
class | PointAccessor< AttT, BuildT >
| Class to access points at a specific voxel location. More...
class | PointAccessor< AttT, Point >
class | ChannelAccessor< ChannelT, IndexT >
| Class to access values in channels at a specific voxel location. More...
struct | FileHeader
| Data encoded at the head of each segment of a file or stream. More...
struct | FileMetaData
struct | GetValue< BuildT >
| Below is an example of a struct used for random get methods. More...
struct | SetValue< BuildT >
struct | SetVoxel< BuildT >
struct | GetState< BuildT >
| Implements Tree::isActive(math::Coord) More...
struct | GetDim< BuildT >
| Implements Tree::getDim(math::Coord) More...
struct | GetLeaf< BuildT >
| Return the pointer to the leaf node that contains math::Coord. Implements Tree::probeLeaf(math::Coord) More...
struct | GetLower< BuildT >
| Return point to the lower internal node where math::Coord maps to one of its values, i.e. terminates. More...
struct | GetUpper< BuildT >
| Return point to the upper internal node where math::Coord maps to one of its values, i.e. terminates. More...
struct | GetTile< BuildT >
| Return point to the root Tile where math::Coord maps to one of its values, i.e. terminates. More...
struct | ProbeValue< BuildT >
| Implements Tree::probeLeaf(math::Coord) More...
struct | GetNodeInfo< BuildT >
| Implements Tree::getNodeInfo(math::Coord) More...
struct | GetNodeInfo< BuildT >::NodeInfo

## Namespaces
namespace | nanovdb
namespace | nanovdb::io

## Macros
#define | NANOVDB_DATA_ALIGNMENT 32
#define | NANOVDB_MAGIC_NUMB 0x304244566f6e614eUL
#define | NANOVDB_MAGIC_GRID 0x314244566f6e614eUL
#define | NANOVDB_MAGIC_FILE 0x324244566f6e614eUL
#define | NANOVDB_MAGIC_MASK 0x00FFFFFFFFFFFFFFUL
#define | NANOVDB_USE_NEW_MAGIC_NUMBERS
#define | NANOVDB_MAJOR_VERSION_NUMBER 32
#define | NANOVDB_MINOR_VERSION_NUMBER 8
#define | NANOVDB_PATCH_VERSION_NUMBER 0
#define | TBB_SUPPRESS_DEPRECATED_MESSAGES 1
#define | NANOVDB_USE_SINGLE_ROOT_KEY
#define | NANOVDB_FPN_BRANCHLESS
#define | NANOVDB_ALIGN(n)

## Typedefs
template<typename BuildT>
using | DefaultReadAccessor = ReadAccessor<BuildT, 0, 1, 2>
template<typename BuildT>
using | NanoLeaf = LeafNode<BuildT, Coord, Mask, 3>
| Template specializations to the default configuration used in OpenVDB: Root -> 32^3 -> 16^3 -> 8^3.
template<typename BuildT>
using | NanoLower = InternalNode<NanoLeaf<BuildT>, 4>
template<typename BuildT>
using | NanoUpper = InternalNode<NanoLower<BuildT>, 5>
template<typename BuildT>
using | NanoRoot = RootNode<NanoUpper<BuildT>>
template<typename BuildT>
using | NanoTree = Tree<NanoRoot<BuildT>>
template<typename BuildT>
using | NanoGrid = Grid<NanoTree<BuildT>>
using | FloatTree = NanoTree<float>
using | Fp4Tree = NanoTree<Fp4>
using | Fp8Tree = NanoTree<Fp8>
using | Fp16Tree = NanoTree<Fp16>
using | FpNTree = NanoTree<FpN>
using | DoubleTree = NanoTree<double>
using | Int32Tree = NanoTree<int32_t>
using | UInt32Tree = NanoTree<uint32_t>
using | Int64Tree = NanoTree<int64_t>
using | Vec3fTree = NanoTree<Vec3f>
using | Vec3dTree = NanoTree<Vec3d>
using | Vec4fTree = NanoTree<Vec4f>
using | Vec4dTree = NanoTree<Vec4d>
using | Vec3ITree = NanoTree<Vec3i>
using | MaskTree = NanoTree<ValueMask>
using | BoolTree = NanoTree<bool>
using | IndexTree = NanoTree<ValueIndex>
using | OnIndexTree = NanoTree<ValueOnIndex>
using | IndexMaskTree = NanoTree<ValueIndexMask>
using | OnIndexMaskTree = NanoTree<ValueOnIndexMask>
using | FloatGrid = Grid<FloatTree>
using | Fp4Grid = Grid<Fp4Tree>
using | Fp8Grid = Grid<Fp8Tree>
using | Fp16Grid = Grid<Fp16Tree>
using | FpNGrid = Grid<FpNTree>
using | DoubleGrid = Grid<DoubleTree>
using | Int32Grid = Grid<Int32Tree>
using | UInt32Grid = Grid<UInt32Tree>
using | Int64Grid = Grid<Int64Tree>
using | Vec3fGrid = Grid<Vec3fTree>
using | Vec3dGrid = Grid<Vec3dTree>
using | Vec4fGrid = Grid<Vec4fTree>
using | Vec4dGrid = Grid<Vec4dTree>
using | Vec3IGrid = Grid<Vec3ITree>
using | MaskGrid = Grid<MaskTree>
using | BoolGrid = Grid<BoolTree>
using | PointGrid = Grid<Point>
using | IndexGrid = Grid<IndexTree>
using | OnIndexGrid = Grid<OnIndexTree>
using | IndexMaskGrid = Grid<IndexMaskTree>
using | OnIndexMaskGrid = Grid<OnIndexMaskTree>

## Enumerations
enum class | GridType : uint32_t { Unknown = 0 , Float = 1 , Double = 2 , Int16 = 3 , Int32 = 4 , Int64 = 5 , Vec3f = 6 , Vec3d = 7 , Mask = 8 , Half = 9 , UInt32 = 10 , Boolean = 11 , RGBA8 = 12 , Fp4 = 13 , Fp8 = 14 , Fp16 = 15 , FpN = 16 , Vec4f = 17 , Vec4d = 18 , Index = 19 , OnIndex = 20 , IndexMask = 21 , OnIndexMask = 22 , PointIndex = 23 , Vec3u8 = 24 , Vec3u16 = 25 , UInt8 = 26 , End = 27 , StrLen = End + 12 }
| List of types that are currently supported by NanoVDB. More...
enum class | GridClass : uint32_t { Unknown = 0 , LevelSet = 1 , FogVolume = 2 , Staggered = 3 , PointIndex = 4 , PointData = 5 , Topology = 6 , VoxelVolume = 7 , IndexGrid = 8 , TensorGrid = 9 , End = 10 , StrLen = End + 7 }
| Classes (superset of OpenVDB) that are currently supported by NanoVDB. More...
enum class | GridFlags : uint32_t { HasLongGridName = 1 << 0 , HasBBox = 1 << 1 , HasMinMax = 1 << 2 , HasAverage = 1 << 3 , HasStdDeviation = 1 << 4 , IsBreadthFirst = 1 << 5 , End = 1 << 6 , StrLen = End + 23 }
| Grid flags which indicate what extra information is present in the grid buffer. More...
enum class | MagicType : uint32_t { Unknown = 0 , OpenVDB = 1 , NanoVDB = 2 , NanoGrid = 3 , NanoFile = 4 , End = 5 , StrLen = End + 14 }
| Enums used to identify magic numbers recognized by NanoVDB. More...
enum class | PointType : uint32_t { Disable = 0 , PointID = 1 , World64 = 2 , World32 = 3 , Grid64 = 4 , Grid32 = 5 , Voxel32 = 6 , Voxel16 = 7 , Voxel8 = 8 , Default = 9 , End =10 }
enum class | GridBlindDataClass : uint32_t { Unknown = 0 , IndexArray = 1 , AttributeArray = 2 , GridName = 3 , ChannelArray = 4 , End = 5 }
| Blind-data Classes that are currently supported by NanoVDB. More...
enum class | GridBlindDataSemantic : uint32_t { Unknown = 0 , PointPosition = 1 , PointColor = 2 , PointNormal = 3 , PointRadius = 4 , PointVelocity = 5 , PointId = 6 , WorldCoords = 7 , GridCoords = 8 , VoxelCoords = 9 , End = 10 }
| Blind-data Semantics that are currently understood by NanoVDB. More...
enum class | CheckMode : uint32_t { Disable = 0 , Empty = 0 , Half = 1 , Partial = 1 , Default = 1 , Full = 2 , End = 3 , StrLen = 9 + End }
| List of different modes for computing for a checksum. More...
enum class | Codec : uint16_t { NONE = 0 , ZIP = 1 , BLOSC = 2 , End = 3 , StrLen = 6 + End }
| Define compression codecs. More...

## Functions
template<class EnumT>
__hostdev__ constexpr uint32_t | strlen ()
| return the number of characters (including null termination) required to convert enum type to a string
__hostdev__ char * | toStr (char *dst, GridType gridType)
| Maps a GridType to a c-string.
__hostdev__ char * | toStr (char *dst, GridClass gridClass)
| Retuns a c-string used to describe a GridClass.
__hostdev__ const char * | toStr (char *dst, GridFlags gridFlags)
| Retuns a c-string used to describe a GridFlags.
__hostdev__ MagicType | toMagic (uint64_t magic)
| maps 64 bits of magic number to enum
__hostdev__ char * | toStr (char *dst, MagicType magic)
| print 64-bit magic number to string
static __hostdev__ bool | isAligned (const void *p)
| return true if the specified pointer is 32 byte aligned
static __hostdev__ uint64_t | alignmentPadding (const void *p)
| return the smallest number of bytes that when added to the specified pointer results in a 32 byte aligned pointer.
template<typename T>
static __hostdev__ T * | alignPtr (T *p)
| offset the specified pointer so it is 32 byte aligned. Works with both const and non-const pointers.
__hostdev__ bool | isFloatingPoint (GridType gridType)
| return true if the GridType maps to a floating point type
__hostdev__ bool | isFloatingPointVector (GridType gridType)
| return true if the GridType maps to a floating point vec3.
__hostdev__ bool | isInteger (GridType gridType)
| Return true if the GridType maps to a POD integer type.
__hostdev__ bool | isIndex (GridType gridType)
| Return true if the GridType maps to a special index type (not a POD integer type).
__hostdev__ bool | isValid (GridType gridType, GridClass gridClass)
| return true if the combination of GridType and GridClass is valid.
__hostdev__ bool | isValid (const GridBlindDataClass &blindClass, const GridBlindDataSemantic &blindSemantics, const GridType &blindType)
| return true if the combination of GridBlindDataClass, GridBlindDataSemantic and GridType is valid.
__hostdev__ char * | toStr (char *dst, const Version &v)
| print the verion number to a c-string
template<typename BuildT>
__hostdev__ GridType | toGridType ()
| Maps from a templated build type to a GridType enum.
template<typename BuildT>
__hostdev__ GridType | mapToGridType ()
template<typename BuildT>
__hostdev__ GridClass | toGridClass (GridClass defaultClass=GridClass::Unknown)
| Maps from a templated build type to a GridClass enum.
template<typename BuildT>
__hostdev__ GridClass | mapToGridClass (GridClass defaultClass=GridClass::Unknown)
__hostdev__ char * | toStr (char *dst, CheckMode mode)
| Prints CheckMode enum to a c-string.
__hostdev__ CheckMode | toCheckMode (const Checksum &checksum)
| Maps 64 bit checksum to CheckMode enum.
template<typename OpT, typename GridDataT, typename... ArgsT>
auto | callNanoGrid (GridDataT *gridData, ArgsT &&... args)
| Below is an example of the struct used for generic programming with callNanoGrid.
template<int LEVEL0 = -1, int LEVEL1 = -1, int LEVEL2 = -1, typename ValueT = float>
ReadAccessor< ValueT, LEVEL0, LEVEL1, LEVEL2 > | createAccessor (const NanoGrid< ValueT > &grid)
| Free-standing function for convenient creation of a ReadAccessor with optional and customizable node caching.
template<int LEVEL0 = -1, int LEVEL1 = -1, int LEVEL2 = -1, typename ValueT = float>
ReadAccessor< ValueT, LEVEL0, LEVEL1, LEVEL2 > | createAccessor (const NanoTree< ValueT > &tree)
template<int LEVEL0 = -1, int LEVEL1 = -1, int LEVEL2 = -1, typename ValueT = float>
ReadAccessor< ValueT, LEVEL0, LEVEL1, LEVEL2 > | createAccessor (const NanoRoot< ValueT > &root)
__hostdev__ const char * | toStr (char *dst, Codec codec)
__hostdev__ Codec | toCodec (const char *str)
template<typename StreamT>
void | writeUncompressedGrid (StreamT &os, const GridData *gridData, bool raw=false)
| This is a standalone alternative to io::writeGrid(...,Codec::NONE) defined in util/IO.h Unlike the latter this function has no dependencies at all, not even NanoVDB.h, so it also works if client code only includes PNanoVDB.h!
template<typename GridHandleT, template< typename... > class VecT>
void | writeUncompressedGrids (const char *fileName, const VecT< GridHandleT > &handles, bool raw=false)
| write multiple NanoVDB grids to a single file, without compression.
template<typename GridHandleT, typename StreamT, template< typename... > class VecT>
VecT< GridHandleT > | readUncompressedGrids (StreamT &is, const typename GridHandleT::BufferType &pool=typename GridHandleT::BufferType())
| read all uncompressed grids from a stream and return their handles.
template<typename GridHandleT, template< typename... > class VecT>
VecT< GridHandleT > | readUncompressedGrids (const char *fileName, const typename GridHandleT::BufferType &buffer=typename GridHandleT::BufferType())
| Read a multiple un-compressed NanoVDB grids from a file and return them as a vector.

## Detailed Description

Implements a light-weight self-contained VDB data-structure in a single file! In other words, this is a significantly watered-down version of the OpenVDB implementation, with few dependencies - so a one-stop-shop for a minimalistic VDB data structure that run on most platforms!

Author
  Ken Museth

Date
  January 8, 2020

Note
  It is important to note that NanoVDB (by design) is a read-only sparse GPU (and CPU) friendly data structure intended for applications like rendering and collision detection. As such it obviously lacks a lot of the functionality and features of OpenVDB grids. NanoVDB is essentially a compact linearized (or serialized) representation of an OpenVDB tree with getValue methods only. For best performance use the ReadAccessor::getValue method as opposed to the Tree::getValue method. Note that since a ReadAccessor caches previous access patterns it is by design not thread-safe, so use one instantiation per thread (it is very light-weight). Also, it is not safe to copy accessors between the GPU and CPU! In fact, client code should only interface with the API of the Grid class (all other nodes of the NanoVDB data structure can safely be ignored by most client codes)!

Warning
  NanoVDB grids can only be constructed via tools like createNanoGrid or the GridBuilder. This explains why none of the grid nodes defined below have public constructors or destructors.

Please see the following paper for more details on the data structure: K. Museth, “VDB: High-Resolution Sparse Volumes with Dynamic Topology”, ACM Transactions on Graphics 32(3), 2013, which can be found here: http://www.museth.org/Ken/Publications_files/Museth_TOG13.pdf

NanoVDB was first published there: https://dl.acm.org/doi/fullHtml/10.1145/3450623.3464653

Overview: This file implements the following fundamental class that when combined forms the backbone of the VDB tree data structure:

Coord- a signed integer coordinate Vec3 - a 3D vector Vec4 - a 4D vector BBox - a bounding box Mask - a bitmask essential to the non-root tree nodes Map - an affine coordinate transformation Grid - contains a Tree and a map for world<->index transformations. Use this class as the main API with client code! Tree - contains a RootNode and getValue methods that should only be used for debugging RootNode - the top-level node of the VDB data structure InternalNode - the internal nodes of the VDB data structure LeafNode - the lowest level tree nodes that encode voxel values and state ReadAccessor - implements accelerated random access operations

Semantics: A VDB data structure encodes values and (binary) states associated with signed integer coordinates. Values encoded at the leaf node level are denoted voxel values, and values associated with other tree nodes are referred to as tile values, which by design cover a larger coordinate index domain.

Memory layout:

It's important to emphasize that all the grid data (defined below) are explicitly 32 byte aligned, which implies that any memory buffer that contains a NanoVDB grid must also be at 32 byte aligned. That is, the memory address of the beginning of a buffer (see ascii diagram below) must be divisible by 32, i.e. uintptr_t(&buffer)%32 == 0! If this is not the case, the C++ standard says the behaviour is undefined! Normally this is not a concerns on GPUs, because they use 256 byte aligned allocations, but the same cannot be said about the CPU.

GridData is always at the very beginning of the buffer immediately followed by TreeData! The remaining nodes and blind-data are allowed to be scattered throughout the buffer, though in practice they are arranged as:

GridData: 672 bytes (e.g. magic, checksum, major, flags, index, count, size, name, map, world bbox, voxel size, class, type, offset, count)

TreeData: 64 bytes (node counts and byte offsets)

... optional padding ...

RootData: size depends on ValueType (index bbox, voxel count, tile count, min/max/avg/standard deviation)

Array of: RootData::Tile

... optional padding ...

Array of: Upper InternalNodes of size 32^3: bbox, two bit masks, 32768 tile values, and min/max/avg/standard deviation values

... optional padding ...

Array of: Lower InternalNodes of size 16^3: bbox, two bit masks, 4096 tile values, and min/max/avg/standard deviation values

... optional padding ...

Array of: LeafNodes of size 8^3: bbox, bit masks, 512 voxel values, and min/max/avg/standard deviation values

... optional padding ...

Array of: GridBlindMetaData (288 bytes). The offset and count are defined in GridData::mBlindMetadataOffset and GridData::mBlindMetadataCount

... optional padding ...

Array of: blind data

Notation: "]---[" implies it has optional padding, and "][" implies zero padding

[GridData(672B)][TreeData(64B)]—[RootData][N x Root::Tile]—[InternalData<5>]—[InternalData<4>]—[LeafData<3>]—[BLINDMETA...]—[BLIND0]—[BLIND1]—etc. ^ ^ ^ ^ ^ ^ ^ | | | | | | GridBlindMetaData* +– Start of 32B aligned buffer | | | | +– Node0::DataType* leafData GridType::DataType* gridData | | | | | | | +– Node1::DataType* lowerData RootType::DataType* rootData –+ | | | +– Node2::DataType* upperData | +– RootType::DataType::Tile* tile

## Macro Definition Documentation

## ◆ NANOVDB_ALIGN

#define NANOVDB_ALIGN | ( |  | n | ) |

Value:
alignas(n)

## ◆ NANOVDB_DATA_ALIGNMENT

#define NANOVDB_DATA_ALIGNMENT 32

## ◆ NANOVDB_FPN_BRANCHLESS

#define NANOVDB_FPN_BRANCHLESS

## ◆ NANOVDB_MAGIC_FILE

#define NANOVDB_MAGIC_FILE 0x324244566f6e614eUL

## ◆ NANOVDB_MAGIC_GRID

#define NANOVDB_MAGIC_GRID 0x314244566f6e614eUL

## ◆ NANOVDB_MAGIC_MASK

#define NANOVDB_MAGIC_MASK 0x00FFFFFFFFFFFFFFUL

## ◆ NANOVDB_MAGIC_NUMB

#define NANOVDB_MAGIC_NUMB 0x304244566f6e614eUL

## ◆ NANOVDB_MAJOR_VERSION_NUMBER

#define NANOVDB_MAJOR_VERSION_NUMBER 32

## ◆ NANOVDB_MINOR_VERSION_NUMBER

#define NANOVDB_MINOR_VERSION_NUMBER 8

## ◆ NANOVDB_PATCH_VERSION_NUMBER

#define NANOVDB_PATCH_VERSION_NUMBER 0

## ◆ NANOVDB_USE_NEW_MAGIC_NUMBERS

#define NANOVDB_USE_NEW_MAGIC_NUMBERS

## ◆ NANOVDB_USE_SINGLE_ROOT_KEY

#define NANOVDB_USE_SINGLE_ROOT_KEY

## ◆ TBB_SUPPRESS_DEPRECATED_MESSAGES

#define TBB_SUPPRESS_DEPRECATED_MESSAGES 1