worklist/hifi — pull request #253 by ZappoMan (2013-05-09 03:39:22+00:00)
Title: Optimized performance of newTreeToArrays() by implementing blended VBO strategy

- Introduced concept of sometimes only updating the new/changed part of the VBO
while other times updating the full VBO. This allows us to get the speed
advantage of only partial VBO updates when nodes haven't been removed
- Some debugging output related to _alwaysRenderFullVBO
- added cleanupRemovedVoxels() which actually deletes the nodes that were
previously removed (fixes a memory leak!!)

This is giving some big results on large voxel scenes... here's a log...

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Old code, always updates the full VBOs on all calls to treeToArrays()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

WARNING! copyWrittenDataToReadArrays() took 8.986000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 166.466000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=yes took 9.423000 milliseconds
WARNING! render() took 9.501000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=yes took 153.106000 milliseconds <<<<<<<<<<<<<<< NOTE: 153 milliseconds
WARNING! copyWrittenDataToReadArrays() took 11.731000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 164.895000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=yes took 13.575000 milliseconds
WARNING! render() took 13.652000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=yes took 154.161000 milliseconds <<<<<<<<<<<<<<< NOTE: 154 milliseconds
WARNING! copyWrittenDataToReadArrays() took 8.280000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 162.492000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=yes took 8.350000 milliseconds
WARNING! render() took 8.427000 milliseconds
removeOutOfView() scanned=4782 removed=0 inside=3334 intersect=4781 outside=0 _removedVoxels.count()=0
WARNING! removeOutOfView() took 4.063000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=yes took 154.011000 milliseconds <<<<<<<<<<<<<<< NOTE: 154 milliseconds
WARNING! copyWrittenDataToReadArrays() took 11.812000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 169.948000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=yes took 13.553000 milliseconds
WARNING! render() took 13.631000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=yes took 162.711000 milliseconds <<<<<<<<<<<<<<< NOTE: 162 milliseconds
WARNING! copyWrittenDataToReadArrays() took 9.391000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 172.157000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=yes took 9.903000 milliseconds
WARNING! render() took 9.991000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=yes took 154.385000 milliseconds <<<<<<<<<<<<<<< NOTE: 154 milliseconds
WARNING! copyWrittenDataToReadArrays() took 8.362000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 162.791000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=yes took 8.960000 milliseconds
WARNING! render() took 9.041000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=yes took 154.286000 milliseconds <<<<<<<<<<<<<<< NOTE: 154 milliseconds
WARNING! copyWrittenDataToReadArrays() took 13.521000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 167.861000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=yes took 14.482000 milliseconds
WARNING! render() took 14.568000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=yes took 154.566000 milliseconds <<<<<<<<<<<<<<< NOTE: 154 milliseconds
WARNING! copyWrittenDataToReadArrays() took 11.991000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 166.632000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=yes took 13.832000 milliseconds
WARNING! render() took 13.912000 milliseconds

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// New code, for most calls to treeToArrays() it only updates the portions of the VBOs that have changed, e.g. new voxels
// only updates the full VBOs after calls to cleanupRemovedVoxels() voxels
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

WARNING! updateVBOs() _alwaysRenderFullVBO=no took 9.442000 milliseconds
WARNING! render() took 9.515000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=no took 30.265000 milliseconds <<<<<<<<<<<<<<< NOTE: 30 milliseconds
WARNING! copyWrittenDataToReadArrays() took 9.309000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 39.617000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=no took 9.984000 milliseconds
WARNING! render() took 10.060000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=no took 30.354000 milliseconds <<<<<<<<<<<<<<< NOTE: 30 milliseconds
WARNING! copyWrittenDataToReadArrays() took 11.021000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 41.428000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=no took 11.411000 milliseconds
WARNING! render() took 11.493000 milliseconds
removeOutOfView() scanned=4769 removed=188 inside=3056 intersect=4768 outside=188 _removedVoxels.count()=188
WARNING! removeOutOfView() took 4.221000 milliseconds <<<<<<<<<<<<<<< NOTE: we called removeOutOfView
WARNING! setupNewVoxelsForDrawing() took 4.307000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=yes took 175.919000 milliseconds <<<<<<<<<<<<<<< NOTE: 175 milliseconds
WARNING! copyWrittenDataToReadArrays() took 13.871000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 189.853000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=no took 15.876000 milliseconds
WARNING! render() took 15.953000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=no took 29.473000 milliseconds <<<<<<<<<<<<<<< NOTE: 29 milliseconds
WARNING! copyWrittenDataToReadArrays() took 9.511000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 39.027000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=no took 9.237000 milliseconds
WARNING! render() took 9.309000 milliseconds
removeOutOfView() scanned=4819 removed=0 inside=3056 intersect=4818 outside=0 _removedVoxels.count()=0
WARNING! removeOutOfView() took 3.821000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 3.829000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=no took 29.440000 milliseconds <<<<<<<<<<<<<<< NOTE: 29 milliseconds
WARNING! copyWrittenDataToReadArrays() took 14.134000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 43.644000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=no took 16.233000 milliseconds
WARNING! render() took 16.310000 milliseconds
removeOutOfView() scanned=4819 removed=0 inside=3057 intersect=4818 outside=0 _removedVoxels.count()=0
WARNING! removeOutOfView() took 3.886000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 3.894000 milliseconds
WARNING! newTreeToArrays() _alwaysRenderFullVBO=no took 29.724000 milliseconds <<<<<<<<<<<<<<< NOTE: 29 milliseconds
WARNING! copyWrittenDataToReadArrays() took 9.636000 milliseconds
WARNING! setupNewVoxelsForDrawing() took 39.401000 milliseconds
WARNING! updateVBOs() _alwaysRenderFullVBO=no took 10.639000 milliseconds
WARNING! render() took 10.711000 milliseconds