Skip to content

NanoVDB: encode points for any resource in PointsToGrid (CUDA)#2244

Open
harrism wants to merge 1 commit into
AcademySoftwareFoundation:masterfrom
harrism:nanovdb-points-encode-resource
Open

NanoVDB: encode points for any resource in PointsToGrid (CUDA)#2244
harrism wants to merge 1 commit into
AcademySoftwareFoundation:masterfrom
harrism:nanovdb-points-encode-resource

Conversation

@harrism

@harrism harrism commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #2231, part of #2232 (NanoVDB injectable CUDA memory resources).

What

tools::cuda::PointsToGrid<Point, ResourceT> now encodes points for any resource. Previously the point-encoder lived only in the PointsToGrid<Point> full specialization (= PointsToGrid<Point, DeviceResource>), so a Point build with a custom resource missed it and fell through to the generic no-op — silently producing a grid with no encoded point data, no error. This was the known limitation called out in #2231's follow-ups.

The encoder is folded into the generic PointsToGrid<BuildT, ResourceT>::processPoints, gated by if constexpr (util::is_same<BuildT, Point>::value); the now-redundant full specialization is removed.

Why existing paths are unchanged

  • Non-Point builds: the if constexpr block is discarded, leaving the prior no-op body verbatim.
  • Default-resource Point builds: ResourceT == DeviceResource, so the same encode kernels run with the same alignment — byte-for-byte the previous path.

The resource governs allocation only; the encode kernels operate on device data, so making the encoder resource-agnostic is correct.

Testing

New TestMemoryResource.PointsToGrid_PointEncodedWithCustomResource builds a NanoGrid<Point> via PointsToGrid with a custom resource and asserts the encoded coordinates match the input — red on current code (captures the no-op), green after the fix. RTX 6000 Ada / CUDA 12.6: memory-resource suite 9/9, CPU nanovdb_test_nanovdb 153/153, nanovdb_test_cuda 53/53.

Non-CUDA builds

No impact on NANOVDB_USE_CUDA=OFF — the change is confined to tools/cuda/PointsToGrid.cuh (#if defined(__CUDACC__)-gated) and a CUDA-only test.

🤖 Generated with Claude Code

The point-encode step in tools::cuda::PointsToGrid was only reachable for
the default DeviceResource, because it lived in the BuildT=Point full
specialization of processPoints (i.e. <Point, DeviceResource>). A Point
grid built with a custom resource fell through to the generic no-op and
was silently left with unencoded point data.

Fold the encode into the generic processPoints and gate it with
if constexpr(is_same<BuildT, Point>). The encode kernels run on device
data and are independent of the resource; only the trailing d_indx
deallocation routes through ResourceT. Non-Point builds and default-
resource Point builds are unchanged.

Add a regression test that builds a NanoGrid<Point> through a custom
resource and asserts every input point is recoverable from the encoded
per-voxel data.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Mark Harris <mharris@nvidia.com>
@harrism harrism requested a review from kmuseth as a code owner July 2, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant