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)
Type | Name | Description |
---|---|---|
RadixSort | sort | Radix sort. |
uint32_t | size | Spatial tree data size. |
uint32_t | groups | Spatial tree group size. |
uint32_t | regions | Maximum 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)
Type | Name | Description |
---|---|---|
SpatialTree::Hash | hash | Spatial tree hash mode. |
Buffer | nodes | Buffer of spatial tree nodes. |
uint32_t | offset | Spatial tree nodes offset index. |
uint32_t | size | Number 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)
Type | Name | Description |
---|---|---|
SpatialTree::Hash | hash | Spatial tree hash mode. |
Buffer | nodes | Buffer of spatial tree nodes. |
uint32_t | count | Number of regions to create. |
uint32_t | offsets | Spatial tree nodes offset index. |
uint32_t | sizes | Number 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)
Type | Name | Description |
---|---|---|
SpatialTree::Hash | hash | Spatial tree hash mode. |
Buffer | nodes | Buffer of spatial tree nodes. |
Buffer | dispatch | Dispatch indirect buffer. |
uint32_t | offset | Dispatch indirect buffer offset. |
uint32_t | max_size | Maximum 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)
Type | Name | Description |
---|---|---|
SpatialTree::Hash | hash | Spatial tree hash mode. |
Buffer | nodes | Buffer of spatial tree nodes. |
uint32_t | count | Number of regions to create. |
Buffer | dispatch | Dispatch indirect buffer. |
uint32_t | offset | Dispatch indirect buffer offset. |
uint32_t | max_size | Maximum number of spatial elements. |
Enums
Mode
Tree modes.
Name | Value | Description |
---|---|---|
ModeSingle | 0 | Single mode. |
ModeMultiple | 1 | Multiple mode. |
NumModes | 2 |
Hash
Hash modes.
Name | Value | Description |
---|---|---|
HashXYZ10 | 0 | 10-bit 3D spatial hash. |
HashXYZ9 | 1 | 9-bit 3D spatial hash. |
HashXYZ8 | 2 | 8-bit 3D spatial hash. |
HashXY15 | 3 | 15-bit 2D spatial hash. |
HashXY14 | 4 | 14-bit 2D spatial hash. |
HashXY12 | 5 | 12-bit 2D spatial hash. |
HashXY10 | 6 | 10-bit 2D spatial hash. |
Flags
Tree flags.
Name | Value | Description |
---|---|---|
FlagNone | 0 | |
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
Type | Name | Description |
---|---|---|
float32_t[3] | bound_min | Bound minimum. |
float32_t | is_enabled | Enabled flag. |
float32_t[3] | bound_max | Bound maximum. |
uint32_t | data | Leaf-node user data. |
uint32_t | left | Left child node index bigger than spatial node index in case of leaf node (not updated for leaf nodes). |
uint32_t | right | Right child node index bigger than spatial node index in case of leaf node (not updated for leaf nodes). |
uint32_t | parent | Parent node index or next node visiting index for optimized tree. |
uint32_t | spatial | Spatial 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
Type | Name | Description |
---|---|---|
float32_t[3] | center | Bound center. |
uint32_t | data | Leaf-node user data. |
uint16_t[3] | size | Bound size (max - min, float16_t format). |
uint16_t | is_enabled | Enabled flag (float16_t format). |
uint32_t | data_1 | Loaf-node user data. |
uint32_t | data_2 | Leaf-node user data. |
uint32_t | left | Left child node index bigger than spatial node index in case of leaf node (not updated for leaf nodes). |
uint32_t | right | Right child node index bigger than spatial node index in case of leaf node (not updated for leaf nodes). |
uint32_t | parent | Parent node index or next node visiting index for optimized tree. |
uint32_t | spatial | Spatial 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
Type | Name | Description |
---|---|---|
uint32_t | offset | Spatial tree nodes offset index. |
uint32_t | size | Number of spatial elements. |
uint32_t | padding_0 | |
uint32_t | padding_1 |