12#define NANOVDB_USE_SINGLE_ROOT_KEY
13#define NANOVDB_DATA_ALIGNMENT 32
19template<
typename DstT,
typename SrcT>
42template<u
int32_t LOG2DIM>
struct Mask {
55template<
typename TreeT>
struct alignas(NANOVDB_DATA_ALIGNMENT)
Grid {
77 return *
reinterpret_cast<ccl_global const TreeT *
>(
this + 1);
83template<
typename RootT>
struct alignas(NANOVDB_DATA_ALIGNMENT)
Tree {
94 return *
reinterpret_cast<ccl_global const RootT *
>(
101template<
typename ChildT>
struct alignas(NANOVDB_DATA_ALIGNMENT)
RootNode {
105#ifdef NANOVDB_USE_SINGLE_ROOT_KEY
117 return ijk & ~ChildT
::MASK;
129 struct alignas(NANOVDB_DATA_ALIGNMENT)
Tile {
160template<
typename ChildT, u
int32_t Log2Dim = ChildT::LOG2DIM + 1>
180 alignas(32) Tile
mTable[1u << (3 * Log2Dim)];
196 return (((ijk.
x &
MASK) >> ChildT::TOTAL) << (2 *
LOG2DIM)) |
197 (((ijk.
y &
MASK) >> ChildT::TOTAL) << (
LOG2DIM)) | ((ijk.
z &
MASK) >> ChildT::TOTAL);
203template<
typename ValueT, u
int32_t LOG2DIM>
struct alignas(NANOVDB_DATA_ALIGNMENT)
LeafData {
226template<u
int32_t LOG2DIM>
struct alignas(NANOVDB_DATA_ALIGNMENT)
LeafFnBase {
241template<u
int32_t LOG2DIM>
struct alignas(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp16, LOG2DIM> {
258template<u
int32_t LOG2DIM>
struct alignas(NANOVDB_DATA_ALIGNMENT)
LeafData<
FpN, LOG2DIM> {
266 const int b =
base.mFlags >> 5;
268 code >>= (i & ((32 >>
b) - 1)) <<
b;
269 code &= (1 << (1 <<
b)) - 1;
276template<
typename BuildT, u
int32_t Log2Dim = 3>
struct alignas(NANOVDB_DATA_ALIGNMENT)
LeafNode {
297 return data.getValue(offset);
331 if (
tile ==
nullptr) {
332 return mRoot->mBackground;
334 if (
tile->child == 0) {
339 const uint32_t upper_n = upper->CoordToOffset(ijk);
340 if (upper->mChildMask.isOff(upper_n)) {
341 return upper->mTable[upper_n].value;
344 ccl_global const auto *lower = upper->getChild(upper_n);
345 const uint32_t lower_n = lower->CoordToOffset(ijk);
346 if (lower->mChildMask.isOff(lower_n)) {
347 return lower->mTable[lower_n].value;
350 ccl_global const LeafT *leaf = lower->getChild(lower_n);
351 return leaf->getValue(ijk);
361 mutable Coord mKeys[3];
371 mNode{nullptr, nullptr, nullptr}
377 return (ijk.
x &
int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL].x &&
378 (ijk.
y &
int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL].
y &&
379 (ijk.
z &
int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL].z;
383 const Coord ijk)
const
386 if (
tile->child != 0) {
393 return node.mBackground;
397 const Coord ijk)
const
399 return node.getValue(ijk);
402 template<
typename NodeT>
404 const Coord ijk)
const
406 const uint32_t n = node.CoordToOffset(ijk);
407 if (node.mChildMask.isOff(n)) {
408 return node.mTable[n].value;
410 ccl_global const auto *child = node.getChild(n);
429 template<
typename NodeT>
432 mKeys[NodeT::LEVEL] = ijk & ~NodeT
::MASK;
433 mNode[NodeT::LEVEL] = node;
void BLI_kdtree_nd_ insert(KDTree *tree, int index, const float co[KD_DIMS]) ATTR_NONNULL(1
ccl_device_inline_method ValueType getValueAndCache(ccl_global const LeafT &node, const Coord ijk) const
ccl_device_inline_method void insert(const Coord ijk, ccl_global const NodeT *node) const
typename RootT::ValueType ValueType
ccl_device_inline_method ValueType getValueAndCache(ccl_global const NodeT &node, const Coord ijk) const
ccl_device_inline_method CachedReadAccessor(ccl_global const RootT &root)
ccl_device_inline_method bool isCached(const Coord ijk) const
ccl_device_inline_method ValueType getValue(const Coord ijk) const
ccl_device_inline_method ValueType getValueAndCache(ccl_global const RootT &node, const Coord ijk) const
typename RootT::ValueType ValueType
ccl_device_inline_method ValueType getValue(const Coord ijk) const
ccl_device_inline_method ReadAccessor(ccl_global const RootT &root)
local_group_size(16, 16) .push_constant(Type b
#define CCL_NAMESPACE_END
#define ccl_static_constexpr
#define ccl_device_inline_method
draw_view in_light_buf[] float
ccl_global const KernelWorkTile * tile
ccl_device ccl_global const DstT * PtrAdd(ccl_global const SrcT *p, int64_t offset)
LeafNode< BuildT, 3 > NanoLeaf
InternalNode< NanoLeaf< BuildT >, 4 > NanoLower
InternalNode< NanoLower< BuildT >, 5 > NanoUpper
Grid< NanoTree< BuildT > > NanoGrid
RootNode< NanoUpper< BuildT > > NanoRoot
Tree< NanoRoot< BuildT > > NanoTree
unsigned __int64 uint64_t
ccl_device_inline_method Coord operator&(int32_t n) const
ccl_device_inline_method Coord(int32_t x, int32_t y, int32_t z)
ccl_device_inline_method Coord(int32_t n)
typename TreeT::BuildType BuildType
ccl_device_inline_method ccl_global const TreeT & tree() const ccl_global
ccl_static_constexpr int MaxNameSize
char mGridName[MaxNameSize]
ccl_static_constexpr uint32_t MASK
Mask< Log2Dim > mValueMask
ccl_static_constexpr uint32_t LEVEL
typename ChildT::ValueType ValueType
ccl_static_constexpr uint32_t SIZE
Mask< Log2Dim > mChildMask
static ccl_device_inline_method uint32_t CoordToOffset(const Coord ijk)
ccl_static_constexpr uint32_t LOG2DIM
ccl_device_inline_method ccl_global const NanoLeaf< BuildT > * getChild(uint32_t n) const ccl_global
Tile mTable[1u<<(3 *Log2Dim)]
ccl_static_constexpr uint32_t TOTAL
typename ChildT::BuildType BuildType
ccl_static_constexpr uint32_t DIM
LeafFnBase< LOG2DIM > base
uint16_t mCode[1u<< 3 *LOG2DIM]
ccl_device_inline_method float getValue(uint32_t i) const ccl_global
LeafFnBase< LOG2DIM > base
ccl_device_inline_method float getValue(uint32_t i) const ccl_global
ccl_device_inline_method ValueType getValue(uint32_t i) const ccl_global
ValueType mValues[1u<< 3 *LOG2DIM]
Mask< LOG2DIM > mValueMask
Mask< LOG2DIM > mValueMask
ccl_static_constexpr uint32_t DIM
ccl_static_constexpr uint32_t LOG2DIM
ccl_static_constexpr uint32_t TOTAL
ccl_device_inline_method ValueType getValue(uint32_t offset) const ccl_global
typename DataType::BuildType BuildType
ccl_static_constexpr uint32_t MASK
LeafData< BuildT, Log2Dim > DataType
ccl_static_constexpr uint32_t SIZE
typename DataType::ValueType ValueType
ccl_static_constexpr uint32_t LEVEL
static ccl_device_inline_method uint32_t CoordToOffset(const Coord ijk)
ccl_device_inline_method ValueType getValue(const Coord ijk) const ccl_global
ccl_static_constexpr uint32_t SIZE
ccl_static_constexpr uint32_t WORD_COUNT
uint64_t mWords[WORD_COUNT]
ccl_device_inline_method bool isOff(uint32_t n) const ccl_global
static ccl_device_inline_method uint64_t CoordToKey(const Coord ijk)
typename ChildT::ValueType ValueType
typename ChildT::BuildType BuildType
ccl_device_inline_method ccl_global const Tile * probeTile(const Coord ijk) const ccl_global
ccl_device_inline_method ccl_global const NanoUpper< BuildT > * getChild(ccl_global const Tile *tile) const ccl_global
ccl_static_constexpr uint32_t LEVEL
typename RootT::ValueType ValueType
typename RootT::BuildType BuildType
ccl_device_inline_method ccl_global const RootT & root() const ccl_global