12#define NANOVDB_USE_SINGLE_ROOT_KEY
13#define NANOVDB_DATA_ALIGNMENT 32
19template<
typename DstT,
typename SrcT>
36 return Coord(x & n, y & n,
z & n);
42template<u
int32_t LOG2DIM>
struct Mask {
55template<
typename TreeT>
struct alignas(NANOVDB_DATA_ALIGNMENT)
Grid {
64 char mGridName[MaxNameSize];
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 *
>(
95 mNodeOffset[3] ? PtrAdd<uint8_t>(
this, mNodeOffset[3]) :
nullptr);
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 {
138 const auto key = CoordToKey(ijk);
152 return PtrAdd<ChildT>(
this,
tile->child);
160template<
typename ChildT, u
int32_t Log2Dim = ChildT::LOG2DIM + 1>
180 alignas(32)
Tile mTable[1u << (3 * Log2Dim)];
184 return PtrAdd<ChildT>(
this, mTable[n].child);
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 {
292 return ((ijk.
x & MASK) << (2 * LOG2DIM)) | ((ijk.
y &
MASK) << LOG2DIM) | (ijk.
z &
MASK);
297 return data.getValue(offset);
302 return getValue(CoordToOffset(ijk));
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;
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) {
389 return getValueAndCache(*child, ijk);
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);
412 return getValueAndCache(*child, ijk);
417 if (isCached<LeafT>(ijk)) {
420 else if (isCached<LowerT>(ijk)) {
423 else if (isCached<UpperT>(ijk)) {
426 return getValueAndCache(*mRoot, ijk);
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
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
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)
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
Mask< Log2Dim > mValueMask
typename ChildT::ValueType ValueType
Mask< Log2Dim > mChildMask
static ccl_device_inline_method uint32_t CoordToOffset(const Coord ijk)
ccl_device_inline_method ccl_global const ChildT * getChild(uint32_t n) const ccl_global
typename ChildT::BuildType BuildType
LeafFnBase< LOG2DIM > base
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
Mask< LOG2DIM > mValueMask
Mask< LOG2DIM > mValueMask
ccl_device_inline_method ValueType getValue(uint32_t offset) const ccl_global
typename DataType::BuildType BuildType
typename DataType::ValueType ValueType
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 ChildT * getChild(ccl_global const Tile *tile) const ccl_global
typename RootT::ValueType ValueType
typename RootT::BuildType BuildType
ccl_device_inline_method ccl_global const RootT & root() const ccl_global