victorprad / InfiniTAM

A Framework for the Volumetric Integration of Depth Images
http://www.infinitam.org
Other
918 stars 351 forks source link

Saving entire mesh with swapping #25

Open connerbrooks opened 8 years ago

connerbrooks commented 8 years ago

Currently with swapping enabled if you attempt to save the mesh it will only save the memory of the isosurface that is currently on the GPU.

What is the best way to save the entirety of the mesh on both CPU and GPU?

manuel-kroeter commented 8 years ago

You could divide the scene into a regular grid. In order to get the mesh of the whole scene you just compute the mesh separately for each block of the grid. Of course you would need to implement the GPU-CPU swapping for entire blocks. This is also done by Nießner et al. in their Voxel Hashing code: https://github.com/nachtmar/VoxelHashing

connerbrooks commented 8 years ago

Yeah I know how VoxelHashing does it, but within the swapping architecture of InfiniTAM what would we want to do besides replacing the entire swapping engine with the implementation from VoxelHashing? We could just add a separate swapping engine that uses the Chunk based representation on the CPU and keeps the full AOI (~8m sphere around view frustum) on the GPU. I think this would be the best solution overall but I don't know if that would be something upstream would want.

With the current architecture I believe I can just use the CPU meshing implementation on the GlobalCache that's on the host, which would be a bit slow.

manuel-kroeter commented 8 years ago

Why do you need to change the current swapping engine? If you want to get the mesh you swap all the voxel blocks which are currently on GPU out to CPU. Then you copy the first chunk to GPU, compute the mesh, swap the mesh to CPU and delete the chunk on the GPU again. Do the same with all other chunks of the scene. You could add this CPU-GPU chunk copying to the meshing engine. The exsting swapping engine should not be affected at all. What do you mean that you can use the CPU meshing with GlobalCache? The global cache just stores the actual voxel data (SDF) but the voxel positions are stored only in the hash table on GPU.

raidendex commented 8 years ago

Any more information how to exactly achieve this? I've been trying to figure out how to at least force all of the cache to be swapped in and so far I can only force new things to remain on the GPU not anything that was scanned in earlier.

To do this I just change ITMSwappingEngine_CUDA.cu buildListToSwapIn_device() function from bool isNeededId = (swapStates[targetIdx].state == 1); to bool isNeededId = true;

Which basically keeps anything that was allocated on the GPU to remain there. But old stuff is not possible to bring back this way. I guess I just need a better understanding of what is going on with the whole swapping. So far I've been tracing various functions, but unable to find where the "magic" happens as of now.

Thanks.