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 | 98 | switch(command) { |
| 99 | 99 | case PACKET_HEADER_VOXEL_DATA: |
| 100 | + { | |
| 101 | + double start = usecTimestampNow(); | |
| 100 | 102 | // ask the VoxelTree to read the bitstream into the tree |
| 101 | 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 | 115 | break; |
| 103 | 116 | case PACKET_HEADER_ERASE_VOXEL: |
| 104 | 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 | 150 | void VoxelSystem::setupNewVoxelsForDrawing() { |
| 151 | + double start = usecTimestampNow(); | |
| 138 | 152 | _voxelsUpdated = newTreeToArrays(_tree->rootNode); |
| 139 | 153 | if (_voxelsUpdated) { |
| 140 | 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 | 167 | // copy the newly written data to the arrays designated for reading |
| 144 | 168 | copyWrittenDataToReadArrays(); |
| 145 | 169 | } |
| 146 | 170 | |
| 147 | 171 | void VoxelSystem::copyWrittenDataToReadArrays() { |
| 172 | + double start = usecTimestampNow(); | |
| 148 | 173 | if (_voxelsDirty) { |
| 149 | 174 | // lock on the buffer write lock so we can't modify the data when the GPU is reading it |
| 150 | 175 | pthread_mutex_lock(&_bufferWriteLock); |
| @@ -154,6 +179,16 @@ void VoxelSystem::copyWrittenDataToReadArrays() { · 3 unmodified lines | ||
| 154 | 179 | memcpy(_readColorsArray, _writeColorsArray, bytesOfColors ); |
| 155 | 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 | 194 | int VoxelSystem::newTreeToArrays(VoxelNode* node) { |
| @@ -296,6 +331,7 @@ void VoxelSystem::init() { · 136 unmodified lines | ||
| 296 | 331 | } |
| 297 | 332 | |
| 298 | 333 | void VoxelSystem::updateVBOs() { |
| 334 | + double start = usecTimestampNow(); | |
| 299 | 335 | if (_voxelsDirty) { |
| 300 | 336 | glBufferIndex segmentStart = 0; |
| 301 | 337 | glBufferIndex segmentEnd = 0; |
| @@ -327,9 +363,20 @@ void VoxelSystem::updateVBOs() { · 25 unmodified lines | ||
| 327 | 363 | } |
| 328 | 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 | 378 | void VoxelSystem::render() { |
| 379 | + double start = usecTimestampNow(); | |
| 333 | 380 | glPushMatrix(); |
| 334 | 381 | updateVBOs(); |
| 335 | 382 | // tell OpenGL where to find vertex and color information |
| @@ -362,6 +409,16 @@ void VoxelSystem::render() { · 26 unmodified lines | ||
| 362 | 409 | |
| 363 | 410 | // scale back down to 1 so heads aren't massive |
| 364 | 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 | 424 | int VoxelSystem::_nodeCount = 0; |