NVIDIA / gvdb-voxels

Sparse volume compute and rendering on NVIDIA GPUs
Other
673 stars 144 forks source link

AtlasRetrieveTexXYZ passes int argument to kernelRetrieveTexXYZ expecting int3. #82

Closed digbeta closed 4 years ago

digbeta commented 4 years ago

In the function AtlasRetrieveTexXYZ in gvdb_allocator.cpp:769, cuLaunchKernel is called, passing brickres (an int) to kernelRetrieveTexXYZ. kernelRetrieveTexXYZ, however, expects an int3 value, resulting in invalid memory access errors. The kernel uses texture references, which the docs indicate have been deprecated, but I wanted to note this in case it snags anyone else.

https://github.com/NVIDIA/gvdb-voxels/blob/c530d1aa0a501fc4c24e3c89be1da197957bd44c/source/gvdb_library/src/gvdb_allocator.cpp#L767-L776

https://github.com/NVIDIA/gvdb-voxels/blob/c530d1aa0a501fc4c24e3c89be1da197957bd44c/source/gvdb_library/kernels/cuda_gvdb_copydata.cu#L87-L92

NBickford-NV commented 4 years ago

Yep, this is a bug! I just pushed a change that should fix this by passing a Vector3DI instead of an int to this function and changing line 773. (It almost looks like the original author was trying to pass &mAtlas[chan].subdim.x, which would have worked, but the copy made it fail.) Thank you!

Unfortunately, I haven't been able to spot the use of texture references in this kernel yet - we've tried to remove them in 1.1.1, but please let me know when you spot any! - it looks like it's passing in a CUDA texture object, and then using template T tex3D(cudaTextureObject_t texObj, float x, float y, float z) from CUDA section B.8.1.8, which seems OK so far?

digbeta commented 4 years ago

Cool, I'll check the fix this week. Yes, you're correct, I am just learning about texture ref's vs. objects and was wrong about that. Thanks for the quick fix!

NBickford-NV commented 4 years ago

Good to hear, thank you! I'll go ahead and close this issue, then.