You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#2310 defaults nanovdb::Mask's copy constructor, making it trivially copyable. That satisfies cuda::Buffer<T, R>'s is_trivially_copyable<T> requirement, so the scratch buffers that exist solely to hold arrays of Mask<N> can become typed cuda::Buffer<Mask<N>, ...> instead of Buffer<std::byte> (or a legacy buffer) plus a cast. A census of the tree found exactly seven such sidecar sites; recording them here so they don't need re-finding.
Pure retypes (change the element type, delete the cast)
tools::cuda::MeshToGrid — the retainMaskBuffer in the first getHandle overload (allocated as bytes, reinterpret_cast to Mask<3>*, memset to 0xFF for all-on init).
tools::cuda::MeshToGrid — the per-subdivision-pass maskBuffer holding CTA hit results (Mask<3>). Its sibling countsBuffer is a separate allocation, so no offset arithmetic is affected.
tools::cuda::MeshToGrid — the retainMaskBuffer in the UDF-sidecar getHandle overload (same shape as 1).
examples/ex_dilate_nanovdb_cuda — dstLeafMaskBuffer in the kernels file (Mask<3> array).
unittest/TestNanoVDB.cu — the leaf-mask buffer in the dilation test (currently on the legacy dual-space buffer via create() + deviceData(); retyping folds into its migration to cuda::Buffer).
Retype with a small refactor
tools::cuda::TopologyBuilder::mUpperMasks (Mask<5> array): the builder's single byte-buffer ScratchT alias is shared by ~9 members, so typing the mask members means per-member aliases; the deviceUpperMasks() accessor returns void* and each consumer in util/cuda/Morphology.cuh and MeshToGrid.cuh casts — the accessor should return Mask<5>* and the casts go.
tools::cuda::TopologyBuilder::mLowerMasks (Mask<4>, viewed as a 2D Mask<4>(*)[Mask<5>::SIZE]): same alias/accessor refactor; note the 2D array-shape cast at the use site remains even after the element type is fixed.
Notes
The zero/0xFF cudaMemsetAsync initializations stay as-is (a typed buffer's storage is still just bytes to initialize; noInit construction plus memset remains the right pattern).
VoxelBlockManager has no mask sidecar despite being the intuitive candidate — its scratch arrays are uint32_t/uint64_t (typed-buffer candidates of their own, but not Mask).
Out of scope: casts into grid internals (NanoVDB grids are byte blobs by design), shared-memory reinterpretations, and the union workaround in MeshToGrid's leaf-mask kernel — the latter is blocked by Mask's user-provided zeroing default constructor, which NanoVDB: default Mask's copy constructor #2310 deliberately leaves alone.
Context
#2310 defaults
nanovdb::Mask's copy constructor, making it trivially copyable. That satisfiescuda::Buffer<T, R>'sis_trivially_copyable<T>requirement, so the scratch buffers that exist solely to hold arrays ofMask<N>can become typedcuda::Buffer<Mask<N>, ...>instead ofBuffer<std::byte>(or a legacy buffer) plus a cast. A census of the tree found exactly seven such sidecar sites; recording them here so they don't need re-finding.Pure retypes (change the element type, delete the cast)
tools::cuda::MeshToGrid— theretainMaskBufferin the firstgetHandleoverload (allocated as bytes,reinterpret_casttoMask<3>*, memset to 0xFF for all-on init).tools::cuda::MeshToGrid— the per-subdivision-passmaskBufferholding CTA hit results (Mask<3>). Its siblingcountsBufferis a separate allocation, so no offset arithmetic is affected.tools::cuda::MeshToGrid— theretainMaskBufferin the UDF-sidecargetHandleoverload (same shape as 1).examples/ex_dilate_nanovdb_cuda—dstLeafMaskBufferin the kernels file (Mask<3>array).unittest/TestNanoVDB.cu— the leaf-mask buffer in the dilation test (currently on the legacy dual-space buffer viacreate()+deviceData(); retyping folds into its migration tocuda::Buffer).Retype with a small refactor
tools::cuda::TopologyBuilder::mUpperMasks(Mask<5>array): the builder's single byte-bufferScratchTalias is shared by ~9 members, so typing the mask members means per-member aliases; thedeviceUpperMasks()accessor returnsvoid*and each consumer inutil/cuda/Morphology.cuhandMeshToGrid.cuhcasts — the accessor should returnMask<5>*and the casts go.tools::cuda::TopologyBuilder::mLowerMasks(Mask<4>, viewed as a 2DMask<4>(*)[Mask<5>::SIZE]): same alias/accessor refactor; note the 2D array-shape cast at the use site remains even after the element type is fixed.Notes
cudaMemsetAsyncinitializations stay as-is (a typed buffer's storage is still just bytes to initialize;noInitconstruction plus memset remains the right pattern).VoxelBlockManagerhas no mask sidecar despite being the intuitive candidate — its scratch arrays areuint32_t/uint64_t(typed-buffer candidates of their own, but notMask).Mask's user-provided zeroing default constructor, which NanoVDB: default Mask's copy constructor #2310 deliberately leaves alone.