Skip to content

Improvements to NanoVDB#2108

Merged
kmuseth merged 36 commits intoAcademySoftwareFoundation:masterfrom
kmuseth:GridIndex_to_OpenVDB
Oct 23, 2025
Merged

Improvements to NanoVDB#2108
kmuseth merged 36 commits intoAcademySoftwareFoundation:masterfrom
kmuseth:GridIndex_to_OpenVDB

Conversation

@kmuseth
Copy link
Copy Markdown
Contributor

@kmuseth kmuseth commented Oct 14, 2025

  • Major rewrite of nanovdb::NanoToOpenVDB, which now allows nanovdb::IndexGrids and blind (or side-car) data to be converted into an openvdb grid.
  • Added stand-alone function nanovd::writeUncompressedGrid that allows nanovdb::IndexGrids and blind (or side-car) data to be written directly to a stream.
  • Extended nanovdb::GridBlindDataSemantic with nanovdb::GridClass types to support conversion between IndexGrids and regular grids.
  • nanovdb_print now (optionally) prints the blind data count per grid.
  • Removed nanovdb::ValueIndexMask and nanovdb::ValueOnIndexMask since they are no longer used by fVDB (or elsewhere).
  • NanoVDB version is now 32.9.0, so the ABI of the grid is preserved but not the API. However, the API changes are very minor!

Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Ken <ken.museth@gmail.com>
Comment thread pendingchanges/nanovdb.txt Outdated
- Added Mat classes and other math types to NanoVDB
- Improvements to mGPU grid building and introduction of a separate test executable for mGPU tests
- Major rewrite of nanovdb::NanoToOpenVDB, which now allows nanovdb::IndexGrids and blind (or side-car) data to be converted into an openvdb grid.
- Added stand-alone function nanovd::writeUncompressedGrid that allows nanovdb::IndexGrids and blind (or side-car) data to be written directly to a stream.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nanovdb


if constexpr(!BuildTraits<NanoBuildT>::is_special) {
const auto* src = trait::mapPtr(srcLeaf->data()->mValues);// doesn't work for compressed data, bool or ValueMask
for (auto *dst = dstLeaf->buffer().data(), *end = dst + 512; dst != end; dst += 4, src += 4) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this loop needed? It seems like this could be a memcpy or std::copy.

Copy link
Copy Markdown
Contributor Author

@kmuseth kmuseth Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the documentation for std::copy it looks like it performs a pretty naive for-loop without loop-un-rolling. So, I'm convinced it will actually outperform my code ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switched to std::copy but kept the old implementation just in case it was in fact faster

if constexpr(!BuildTraits<NanoValueT>::is_special) {
if constexpr(util::is_same_v<NanoIndexT, ValueIndex>) {
const auto* src = trait::mapPtr(sideCar + srcLeaf->data()->mOffset);
for (auto *dst = dstLeaf->buffer().data(), *end = dst + 512; dst != end; dst += 4, src += 4) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

kmuseth and others added 4 commits October 19, 2025 15:01
Signed-off-by: Ken <ken.museth@gmail.com>
Signed-off-by: Andrew Reidmeyer <areidmeyer@nvidia.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
@kmuseth kmuseth added the ax label Oct 20, 2025
@kmuseth kmuseth changed the title major improvements to NanoToOpenVDB Improvements to NanoVDB Oct 20, 2025
@kmuseth kmuseth requested a review from matthewdcong October 20, 2025 18:47
Copy link
Copy Markdown
Contributor

@matthewdcong matthewdcong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the changes.

Copy link
Copy Markdown
Contributor

@sifakis sifakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just minor and highly optional comments

Improvements:
- Added nanovdb/tools/cuda/DilateGrid.cuh, which performs topology dilation on the GPU.
- Added nanovdb/tools/cuda/MergeGrids.cuh, which merges the topology of two grids on the GPU.
- Added nanovdb/tools/cuda/CoarsenGrid.cuh, which performs topological coarsening of grids on the GPU.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Optional) Additional features to mention, if useful:

  • Added nanovdb/tools/cuda/PruneGrid.cuh which prunes the topology of a grid using a sidecar mask on the GPU.
  • Added nanovdb/util/cuda/Injection.cuh which facilitates sidecar data copying - on the GPU - in the overlap of two grids with different topology.

} else {
const auto* src = trait::mapPtr(sideCar);
auto *dst = dstLeaf->buffer().data();
for (int i = 0; i < 512; i += 4) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat related to @matthewdcong 's comment above ... a possible optimization might be

            auto offset = srcLeaf->firstOffset();
            for (int w = 0; w < 8; ++w) {
                auto word = srcLeaf->valueMask().words()[w];
                for (int bit = 0; bit < 64; ++bit, word >>= 1) *dst++ = src[(word&0x1UL)?offset++:0];
            }

in order to avoid calls to popCnt; although those might vectorize on AVX512.
At any rate, this is not essential as leaf node allocation is likely the key contributor to runtime in this tool

Copy link
Copy Markdown
Contributor

@sifakis sifakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Signed-off-by: Ken <ken.museth@gmail.com>
- Major rewrite of nanovdb::NanoToOpenVDB, which now allows nanovdb::IndexGrids and blind (or sidecar) data to be converted into an openvdb grid.

Improvements:
- Improvements to mGPU grid building and introduction of a separate test executable for mGPU tests
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Optional). Consider mentioning:

  • Added support for LevelSet, FogVolume, and Staggered grid semantic. Added toGridClass and toSemantic to map Grid Blind data semantic to Grid class and vice versa.

Copy link
Copy Markdown
Contributor

@apradhana apradhana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nitpick comment regarding the Change Notes. Looks good to me!

Signed-off-by: Ken <ken.museth@gmail.com>
@kmuseth kmuseth merged commit a273ab3 into AcademySoftwareFoundation:master Oct 23, 2025
14 checks passed
@kmuseth kmuseth deleted the GridIndex_to_OpenVDB branch October 23, 2025 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants