Skip to main content

SpatialTree

The SpatialTree class offers a powerful framework for creating and managing spatial data structures like bounding volume hierarchies (BVH). It supports flexible modes for handling single and multiple trees, different hash modes for efficient spatial partitioning, and various flags to control optimizations, memory management, and operation behaviors. Its methods allow for the creation, dispatch, and manipulation of trees, making it well-suited for high-performance applications such as graphics rendering, physics simulations, and spatial data processing.

#include <parallel/TellusimSpatialTree.h>

Constructors

SpatialTree()

Methods

Clear tree.

void clear()

Check tree.

bool isCreated(Flags flags) const

Tree parameters.

uint32_t getGroupSize() const
uint32_t getBoundsNodes() const
uint32_t getMaxNodes() const
uint32_t getMaxRegions() const
RadixSort getRadixSort() const
Buffer getHashBuffer() const
Buffer getParentsBuffer() const
Buffer getCounterBuffer() const

Create spatial tree.

bool create(const Device &device, Mode mode, RadixSort &sort, uint32_t size, uint32_t groups = 256, uint32_t regions = 1, Async *async = nullptr)
bool create(const Device &device, Flags flags, RadixSort &sort, uint32_t size, uint32_t groups = 256, uint32_t regions = 1, Async *async = nullptr)
TypeNameDescription
RadixSortsortRadix sort.
uint32_tsizeSpatial tree data size.
uint32_tgroupsSpatial tree group size.
uint32_tregionsMaximum number of multiple regions.

Dispatch single in-place spatial tree generation.

bool dispatch(Compute &compute, Hash hash, Buffer &nodes, uint32_t offset, uint32_t size, Flags flags = FlagNone)
TypeNameDescription
SpatialTree::HashhashSpatial tree hash mode.
BuffernodesBuffer of spatial tree nodes.
uint32_toffsetSpatial tree nodes offset index.
uint32_tsizeNumber of spatial elements.

Dispatch multiple in-place spatial tree generation.

bool dispatch(Compute &compute, Hash hash, Buffer &nodes, uint32_t count, const uint32_t *offsets, const uint32_t *sizes, Flags flags = FlagNone)
TypeNameDescription
SpatialTree::HashhashSpatial tree hash mode.
BuffernodesBuffer of spatial tree nodes.
uint32_tcountNumber of regions to create.
uint32_toffsetsSpatial tree nodes offset index.
uint32_tsizesNumber of spatial elements.

Dispatch single in-place spatial tree generation.

bool dispatchIndirect(Compute &compute, Hash hash, Buffer &nodes, Buffer &dispatch, uint32_t offset, uint32_t max_size = Maxu32, Flags flags = FlagNone)
TypeNameDescription
SpatialTree::HashhashSpatial tree hash mode.
BuffernodesBuffer of spatial tree nodes.
BufferdispatchDispatch indirect buffer.
uint32_toffsetDispatch indirect buffer offset.
uint32_tmax_sizeMaximum number of spatial elements.

Dispatch multiple in-place spatial tree generation.

bool dispatchIndirect(Compute &compute, Hash hash, Buffer &nodes, uint32_t count, Buffer &dispatch, uint32_t offset, uint32_t max_size = Maxu32, Flags flags = FlagNone)
TypeNameDescription
SpatialTree::HashhashSpatial tree hash mode.
BuffernodesBuffer of spatial tree nodes.
uint32_tcountNumber of regions to create.
BufferdispatchDispatch indirect buffer.
uint32_toffsetDispatch indirect buffer offset.
uint32_tmax_sizeMaximum number of spatial elements.

Enums

Mode

Tree modes.

NameValueDescription
ModeSingle0Single mode.
ModeMultiple1Multiple mode.
NumModes2

Hash

Hash modes.

NameValueDescription
HashXYZ10010-bit 3D spatial hash.
HashXYZ919-bit 3D spatial hash.
HashXYZ828-bit 3D spatial hash.
HashXY15315-bit 2D spatial hash.
HashXY14414-bit 2D spatial hash.
HashXY12512-bit 2D spatial hash.
HashXY10610-bit 2D spatial hash.

Flags

Tree flags.

NameValueDescription
FlagNone0
FlagSingle(1 << ModeSingle)Enable Single BVH mode.
FlagMultiple(1 << ModeMultiple)Enable Multi BVH mode.
FlagUpdate(1 << (NumModes + 0))Update BVH bounds only.
FlagOptimize(1 << (NumModes + 1))Optimize tree for stack-less traversal.
FlagTracing(1 << (NumModes + 2))Set FlagTracing on data buffer.
FlagScratch(1 << (NumModes + 3))Set FlagScratch on data buffer.
FlagAtomic(1 << (NumModes + 4))Use Atomic-based merge step.
FlagLeafNodef16(1 << (NumModes + 5))Use LeafNodef16 type for leaf nodes.
FlagSpatialData(1 << (NumModes + 6))Do not update leaf nodes spatial parameter.
FlagSingleUpdate(FlagSingle | FlagUpdate)
FlagMultipleUpdate(FlagMultiple | FlagUpdate)
FlagSingleOptimize(FlagSingle | FlagOptimize)
FlagMultipleOptimize(FlagMultiple | FlagOptimize)
FlagsAll(FlagSingle | FlagMultiple)
FlagsAllOptimize(FlagsAll | FlagOptimize)

Structs

Node

.

Variables

TypeNameDescription
float32_t[3]bound_minBound minimum.
float32_tis_enabledEnabled flag.
float32_t[3]bound_maxBound maximum.
uint32_tdataLeaf-node user data.
uint32_tleftLeft child node index bigger than spatial node index in case of leaf node (not updated for leaf nodes).
uint32_trightRight child node index bigger than spatial node index in case of leaf node (not updated for leaf nodes).
uint32_tparentParent node index or next node visiting index for optimized tree.
uint32_tspatialSpatial node index for leaf node or number of leaf nodes for non-leaf nodes (not updated for leaf nodes if the FlagSpatialData is present).

LeafNodef16

.

Variables

TypeNameDescription
float32_t[3]centerBound center.
uint32_tdataLeaf-node user data.
uint16_t[3]sizeBound size (max - min, float16_t format).
uint16_tis_enabledEnabled flag (float16_t format).
uint32_tdata_1Loaf-node user data.
uint32_tdata_2Leaf-node user data.
uint32_tleftLeft child node index bigger than spatial node index in case of leaf node (not updated for leaf nodes).
uint32_trightRight child node index bigger than spatial node index in case of leaf node (not updated for leaf nodes).
uint32_tparentParent node index or next node visiting index for optimized tree.
uint32_tspatialSpatial node index for leaf node or number of leaf nodes for non-leaf nodes (not updated for leaf nodes if the FlagSpatialData is present).

DispatchParameters

.

Variables

TypeNameDescription
uint32_toffsetSpatial tree nodes offset index.
uint32_tsizeNumber of spatial elements.
uint32_tpadding_0
uint32_tpadding_1