Showing the changes to interface/src/VoxelSystem.cpp (1 of 1 file). Show all
Unified · Split
| @@ -97,8 +97,21 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 96 unmodified lines | |||
| 97 | 97 | ||
| 98 | switch(command) { | 98 | switch(command) { |
| 99 | case PACKET_HEADER_VOXEL_DATA: | 99 | case PACKET_HEADER_VOXEL_DATA: |
| 100 | { | ||
| 101 | double start = usecTimestampNow(); | ||
| 100 | // ask the VoxelTree to read the bitstream into the tree | 102 | // ask the VoxelTree to read the bitstream into the tree |
| 101 | _tree->readBitstreamToTree(voxelData, numBytes - 1); | 103 | _tree->readBitstreamToTree(voxelData, numBytes - 1); |
| 104 | double end = usecTimestampNow(); | ||
| 105 | double elapsedmsec = (end - start)/1000.0; | ||
| 106 | if (elapsedmsec > 100) { | ||
| 107 | if (elapsedmsec > 1000) { | ||
| 108 | double elapsedsec = (end - start)/1000000.0; | ||
| 109 | printLog("WARNING! readBitstreamToTree() took %lf seconds\n",elapsedsec); | ||
| 110 | } else { | ||
| 111 | printLog("WARNING! readBitstreamToTree() took %lf milliseconds\n",elapsedmsec); | ||
| 112 | } | ||
| 113 | } | ||
| 114 | } | ||
| 102 | break; | 115 | break; |
| 103 | case PACKET_HEADER_ERASE_VOXEL: | 116 | case PACKET_HEADER_ERASE_VOXEL: |
| 104 | // ask the tree to read the "remove" bitstream | 117 | // ask the tree to read the "remove" bitstream |
| @@ -135,16 +148,28 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 30 unmodified lines | |||
| 135 | } | 148 | } |
| 136 | 149 | ||
| 137 | void VoxelSystem::setupNewVoxelsForDrawing() { | 150 | void VoxelSystem::setupNewVoxelsForDrawing() { |
| 151 | double start = usecTimestampNow(); | ||
| 138 | _voxelsUpdated = newTreeToArrays(_tree->rootNode); | 152 | _voxelsUpdated = newTreeToArrays(_tree->rootNode); |
| 139 | if (_voxelsUpdated) { | 153 | if (_voxelsUpdated) { |
| 140 | _voxelsDirty=true; | 154 | _voxelsDirty=true; |
| 141 | } | 155 | } |
| 156 | double end = usecTimestampNow(); | ||
| 157 | double elapsedmsec = (end - start)/1000.0; | ||
| 158 | if (elapsedmsec > 100) { | ||
| 159 | if (elapsedmsec > 1000) { | ||
| 160 | double elapsedsec = (end - start)/1000000.0; | ||
| 161 | printLog("WARNING! newTreeToArrays() took %lf seconds\n",elapsedsec); | ||
| 162 | } else { | ||
| 163 | printLog("WARNING! newTreeToArrays() took %lf milliseconds\n",elapsedmsec); | ||
| 164 | } | ||
| 165 | } | ||
| 142 | 166 | ||
| 143 | // copy the newly written data to the arrays designated for reading | 167 | // copy the newly written data to the arrays designated for reading |
| 144 | copyWrittenDataToReadArrays(); | 168 | copyWrittenDataToReadArrays(); |
| 145 | } | 169 | } |
| 146 | 170 | ||
| 147 | void VoxelSystem::copyWrittenDataToReadArrays() { | 171 | void VoxelSystem::copyWrittenDataToReadArrays() { |
| 172 | double start = usecTimestampNow(); | ||
| 148 | if (_voxelsDirty) { | 173 | if (_voxelsDirty) { |
| 149 | // lock on the buffer write lock so we can't modify the data when the GPU is reading it | 174 | // lock on the buffer write lock so we can't modify the data when the GPU is reading it |
| 150 | pthread_mutex_lock(&_bufferWriteLock); | 175 | pthread_mutex_lock(&_bufferWriteLock); |
| @@ -154,6 +179,16 @@ void VoxelSystem::copyWrittenDataToReadArrays() { · 3 unmodified lines | |||
| 154 | memcpy(_readColorsArray, _writeColorsArray, bytesOfColors ); | 179 | memcpy(_readColorsArray, _writeColorsArray, bytesOfColors ); |
| 155 | pthread_mutex_unlock(&_bufferWriteLock); | 180 | pthread_mutex_unlock(&_bufferWriteLock); |
| 156 | } | 181 | } |
| 182 | double end = usecTimestampNow(); | ||
| 183 | double elapsedmsec = (end - start)/1000.0; | ||
| 184 | if (elapsedmsec > 100) { | ||
| 185 | if (elapsedmsec > 1000) { | ||
| 186 | double elapsedsec = (end - start)/1000000.0; | ||
| 187 | printLog("WARNING! copyWrittenDataToReadArrays() took %lf seconds\n",elapsedsec); | ||
| 188 | } else { | ||
| 189 | printLog("WARNING! copyWrittenDataToReadArrays() took %lf milliseconds\n",elapsedmsec); | ||
| 190 | } | ||
| 191 | } | ||
| 157 | } | 192 | } |
| 158 | 193 | ||
| 159 | int VoxelSystem::newTreeToArrays(VoxelNode* node) { | 194 | int VoxelSystem::newTreeToArrays(VoxelNode* node) { |
| @@ -296,6 +331,7 @@ void VoxelSystem::init() { · 136 unmodified lines | |||
| 296 | } | 331 | } |
| 297 | 332 | ||
| 298 | void VoxelSystem::updateVBOs() { | 333 | void VoxelSystem::updateVBOs() { |
| 334 | double start = usecTimestampNow(); | ||
| 299 | if (_voxelsDirty) { | 335 | if (_voxelsDirty) { |
| 300 | glBufferIndex segmentStart = 0; | 336 | glBufferIndex segmentStart = 0; |
| 301 | glBufferIndex segmentEnd = 0; | 337 | glBufferIndex segmentEnd = 0; |
| @@ -327,9 +363,20 @@ void VoxelSystem::updateVBOs() { · 25 unmodified lines | |||
| 327 | } | 363 | } |
| 328 | _voxelsDirty = false; | 364 | _voxelsDirty = false; |
| 329 | } | 365 | } |
| 366 | double end = usecTimestampNow(); | ||
| 367 | double elapsedmsec = (end - start)/1000.0; | ||
| 368 | if (elapsedmsec > 100) { | ||
| 369 | if (elapsedmsec > 1000) { | ||
| 370 | double elapsedsec = (end - start)/1000000.0; | ||
| 371 | printLog("WARNING! updateVBOs() took %lf seconds\n",elapsedsec); | ||
| 372 | } else { | ||
| 373 | printLog("WARNING! updateVBOs() took %lf milliseconds\n",elapsedmsec); | ||
| 374 | } | ||
| 375 | } | ||
| 330 | } | 376 | } |
| 331 | 377 | ||
| 332 | void VoxelSystem::render() { | 378 | void VoxelSystem::render() { |
| 379 | double start = usecTimestampNow(); | ||
| 333 | glPushMatrix(); | 380 | glPushMatrix(); |
| 334 | updateVBOs(); | 381 | updateVBOs(); |
| 335 | // tell OpenGL where to find vertex and color information | 382 | // tell OpenGL where to find vertex and color information |
| @@ -362,6 +409,16 @@ void VoxelSystem::render() { · 26 unmodified lines | |||
| 362 | 409 | ||
| 363 | // scale back down to 1 so heads aren't massive | 410 | // scale back down to 1 so heads aren't massive |
| 364 | glPopMatrix(); | 411 | glPopMatrix(); |
| 412 | double end = usecTimestampNow(); | ||
| 413 | double elapsedmsec = (end - start)/1000.0; | ||
| 414 | if (elapsedmsec > 100) { | ||
| 415 | if (elapsedmsec > 1000) { | ||
| 416 | double elapsedsec = (end - start)/1000000.0; | ||
| 417 | printLog("WARNING! render() took %lf seconds\n",elapsedsec); | ||
| 418 | } else { | ||
| 419 | printLog("WARNING! render() took %lf milliseconds\n",elapsedmsec); | ||
| 420 | } | ||
| 421 | } | ||
| 365 | } | 422 | } |
| 366 | 423 | ||
| 367 | int VoxelSystem::_nodeCount = 0; | 424 | int VoxelSystem::_nodeCount = 0; |