Skip to content

Commit a5cb22c

Browse files
committed
improved documentation
Signed-off-by: Ken <ken.museth@gmail.com>
1 parent dbddbbc commit a5cb22c

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

nanovdb/nanovdb/tools/cuda/IndexToGrid.cuh

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,24 +176,25 @@ template<typename SrcBuildT, typename DstBuildT>
176176
__global__ void processRootTilesKernel(typename IndexToGrid<SrcBuildT>::NodeAccessor *nodeAcc,
177177
const typename BuildToValueMap<DstBuildT>::type *srcValues)
178178
{
179-
const auto tid = blockIdx.x;
179+
const auto tileID = blockIdx.x, tileCount = nodeAcc->nodeCount[3];// note: tileID != childID!
180+
NANOVDB_ASSERT(tileID < tileCount);
180181

181-
// Process children and tiles
182-
const auto &srcTile = *nodeAcc->srcRoot().tile(tid);
183-
auto &dstTile = *nodeAcc->template dstRoot<DstBuildT>().tile(tid);
182+
// Process child nodes and tiles of the root node
183+
const auto &srcTile = *nodeAcc->srcRoot().tile(tileID);
184+
auto &dstTile = *nodeAcc->template dstRoot<DstBuildT>().tile(tileID);
184185
dstTile.key = srcTile.key;
185186
if (srcTile.child) {
186-
// IndexToGrid<>::NodeAccessor::nodeCount[4];// 0=leaf, 1=lower, 2=upper, 3=root tiles
187-
// |<--NanoRoot-->|<--Tile[0]...Tile[nodeCount[3]-1]-->|<--Child[0]...Child[ChildID]-->|
188-
// |<--------------------- offset ---------------------|
189-
// |<------------------------------- srcTile.child ------------------------------------|
190-
// |<---(srcTile.child-offset)---->|
191-
uint64_t offset = sizeof(NanoRoot<SrcBuildT>::Tile)*nodeAcc->nodeCount[3] + sizeof(NanoRoot<SrcBuildT>);// source
192-
const uint64_t childID = (srcTile.child - offset)/sizeof(NanoRoot<SrcBuildT>::ChildNodeType);// derived from source
193-
offset = sizeof(NanoRoot<DstBuildT>::Tile)*nodeAcc->nodeCount[3] + sizeof(NanoRoot<DstBuildT>);// destination
194-
dstTile.child = offset + childID*sizeof(NanoRoot<DstBuildT>::ChildNodeType);
195-
dstTile.value = srcValues[0];// set to background
196-
dstTile.state = false;
187+
// |<--NanoRoot-->|<--Tile[0]...Tile[tileCount-1]-->|<--Child[0]...child[childID-1]-->|
188+
// |<-------------------- offset -------------------|
189+
// |<-------------------------------- Tile::child ------------------------------------|
190+
// |<------ Tile::child-offset ----->|
191+
// |<--- ChildID x sizeof(ChildT) -->|
192+
uint64_t offset = sizeof(NanoRoot<SrcBuildT>) + tileCount*sizeof(NanoRoot<SrcBuildT>::Tile);// source offset
193+
const uint64_t childID = (srcTile.child - offset)/sizeof(NanoRoot<SrcBuildT>::ChildNodeType);// derived from source offset
194+
offset = sizeof(NanoRoot<DstBuildT>) + tileCount*sizeof(NanoRoot<DstBuildT>::Tile);// destination offset
195+
dstTile.child = offset + childID*sizeof(NanoRoot<DstBuildT>::ChildNodeType);
196+
dstTile.value = srcValues[0];// set to background
197+
dstTile.state = false;
197198
} else {
198199
dstTile.child = 0;// i.e. no child node
199200
dstTile.value = srcValues[srcTile.value];

0 commit comments

Comments
 (0)