History

some debug timing and voxel stats display

ZappoMan committed 13 years ago

Commit 023a5211 parent ca7225e2 files · +62 −31Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+61−31
@@ -356,8 +356,9 @@ void Application::initializeGL() { · 355 unmodified lines
356 356
357void Application::paintGL() {357void Application::paintGL() {
358 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));358 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
359 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::paintGL()");359 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
360 360 PerformanceWarning warn(showWarnings, "Application::paintGL()");
361
361 glEnable(GL_LINE_SMOOTH);362 glEnable(GL_LINE_SMOOTH);
362 363
363 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {364 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
@@ -545,6 +546,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 181 unmodified lines
545 }546 }
546 547
547 bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier);548 bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier);
549 bool isMeta = event->modifiers().testFlag(Qt::ControlModifier);
548 switch (event->key()) {550 switch (event->key()) {
549 case Qt::Key_Shift:551 case Qt::Key_Shift:
550 if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) {552 if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) {
@@ -619,8 +621,10 @@ void Application::keyPressEvent(QKeyEvent* event) { · 68 unmodified lines
619 break;621 break;
620 622
621 case Qt::Key_S:623 case Qt::Key_S:
622 if (isShifted) {624 if (isShifted && !isMeta) {
623 _voxels.collectStatsForTreesAndVBOs();625 _voxels.collectStatsForTreesAndVBOs();
626 } else if (isShifted && isMeta) {
627 Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
624 } else if (_nudgeStarted) {628 } else if (_nudgeStarted) {
625 if (_lookingAlongX) {629 if (_lookingAlongX) {
626 if (_lookingAwayFromOrigin) {630 if (_lookingAwayFromOrigin) {
@@ -1238,6 +1242,8 @@ static glm::vec3 getFaceVector(BoxFace face) { · 611 unmodified lines
1238}1242}
1239 1243
1240void Application::idle() {1244void Application::idle() {
1245 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1246 PerformanceWarning warn(showWarnings, "Application::idle()");
1241 1247
1242 timeval check;1248 timeval check;
1243 gettimeofday(&check, NULL);1249 gettimeofday(&check, NULL);
@@ -1252,7 +1258,7 @@ void Application::idle() { · 8 unmodified lines
1252 _glWidget->updateGL();1258 _glWidget->updateGL();
1253 _lastTimeUpdated = check;1259 _lastTimeUpdated = check;
1254 _idleLoopStdev.addValue(timeSinceLastUpdate);1260 _idleLoopStdev.addValue(timeSinceLastUpdate);
1255 1261
1256 // Record standard deviation and reset counter if needed1262 // Record standard deviation and reset counter if needed
1257 const int STDEV_SAMPLES = 500;1263 const int STDEV_SAMPLES = 500;
1258 if (_idleLoopStdev.getSamples() > STDEV_SAMPLES) {1264 if (_idleLoopStdev.getSamples() > STDEV_SAMPLES) {
@@ -1783,7 +1789,28 @@ void Application::renderFollowIndicator() { · 524 unmodified lines
1783 }1789 }
1784}1790}
1785 1791
1792void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) {
1793 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1794 PerformanceWarning warn(showWarnings, "Application::updateAvatars()");
1795 NodeList* nodeList = NodeList::getInstance();
1796
1797 for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
1798 node->lock();
1799 if (node->getLinkedData() != NULL) {
1800 Avatar *avatar = (Avatar *)node->getLinkedData();
1801 if (!avatar->isInitialized()) {
1802 avatar->init();
1803 }
1804 avatar->simulate(deltaTime, NULL);
1805 avatar->setMouseRay(mouseRayOrigin, mouseRayDirection);
1806 }
1807 node->unlock();
1808 }
1809}
1810
1786void Application::update(float deltaTime) {1811void Application::update(float deltaTime) {
1812 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1813 PerformanceWarning warn(showWarnings, "Application::update()");
1787 1814
1788 // Use Transmitter Hand to move hand if connected, else use mouse1815 // Use Transmitter Hand to move hand if connected, else use mouse
1789 if (_myTransmitter.isConnected()) {1816 if (_myTransmitter.isConnected()) {
@@ -1884,6 +1911,8 @@ void Application::update(float deltaTime) { · 94 unmodified lines
1884 (fabs(_myAvatar.getVelocity().x) +1911 (fabs(_myAvatar.getVelocity().x) +
1885 fabs(_myAvatar.getVelocity().y) +1912 fabs(_myAvatar.getVelocity().y) +
1886 fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {1913 fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {
1914 PerformanceWarning warn(showWarnings, "Application::update()... findRayIntersection()");
1915
1887 if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {1916 if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
1888 if (distance < MAX_VOXEL_EDIT_DISTANCE) {1917 if (distance < MAX_VOXEL_EDIT_DISTANCE) {
1889 // find the nearest voxel with the desired scale1918 // find the nearest voxel with the desired scale
@@ -1991,22 +2020,11 @@ void Application::update(float deltaTime) { · 101 unmodified lines
1991 _voxelProcessor.threadRoutine();2020 _voxelProcessor.threadRoutine();
1992 _voxelEditSender.threadRoutine();2021 _voxelEditSender.threadRoutine();
1993 }2022 }
2023
1994 2024
1995 //loop through all the other avatars and simulate them...2025 //loop through all the other avatars and simulate them...
1996 NodeList* nodeList = NodeList::getInstance();2026 updateAvatars(deltaTime, mouseRayOrigin, mouseRayDirection);
1997 for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {2027
1998 node->lock();
1999 if (node->getLinkedData() != NULL) {
2000 Avatar *avatar = (Avatar *)node->getLinkedData();
2001 if (!avatar->isInitialized()) {
2002 avatar->init();
2003 }
2004 avatar->simulate(deltaTime, NULL);
2005 avatar->setMouseRay(mouseRayOrigin, mouseRayDirection);
2006 }
2007 node->unlock();
2008 }
2009
2010 // Simulate myself2028 // Simulate myself
2011 if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) {2029 if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) {
2012 _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition()));2030 _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition()));
@@ -2041,6 +2059,7 @@ void Application::update(float deltaTime) { · 28 unmodified lines
2041 if (_voxels.findRayIntersection(_transmitterPickStart, direction, detail, distance, face)) {2059 if (_voxels.findRayIntersection(_transmitterPickStart, direction, detail, distance, face)) {
2042 minDistance = min(minDistance, distance);2060 minDistance = min(minDistance, distance);
2043 }2061 }
2062 NodeList* nodeList = NodeList::getInstance();
2044 for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {2063 for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
2045 node->lock();2064 node->lock();
2046 if (node->getLinkedData() != NULL) {2065 if (node->getLinkedData() != NULL) {
@@ -2134,6 +2153,8 @@ void Application::update(float deltaTime) { · 87 unmodified lines
2134}2153}
2135 2154
2136void Application::updateAvatar(float deltaTime) {2155void Application::updateAvatar(float deltaTime) {
2156 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2157 PerformanceWarning warn(showWarnings, "Application::updateAvatar()");
2137 2158
2138 // rotate body yaw for yaw received from multitouch2159 // rotate body yaw for yaw received from multitouch
2139 _myAvatar.setOrientation(_myAvatar.getOrientation()2160 _myAvatar.setOrientation(_myAvatar.getOrientation()
@@ -2990,10 +3011,11 @@ void Application::displayStats() { · 850 unmodified lines
2990 std::stringstream voxelStats;3011 std::stringstream voxelStats;
2991 voxelStats.precision(4);3012 voxelStats.precision(4);
2992 voxelStats << "Voxels Rendered: " << _voxels.getVoxelsRendered() / 1000.f << "K " <<3013 voxelStats << "Voxels Rendered: " << _voxels.getVoxelsRendered() / 1000.f << "K " <<
3014 "Written: " << _voxels.getVoxelsWritten()/1000.f << "K " <<
2993 "Updated: " << _voxels.getVoxelsUpdated()/1000.f << "K " <<3015 "Updated: " << _voxels.getVoxelsUpdated()/1000.f << "K " <<
2994 "Max: " << _voxels.getMaxVoxels()/1000.f << "K ";3016 "Max: " << _voxels.getMaxVoxels()/1000.f << "K ";
2995 statsVerticalOffset += PELS_PER_LINE;3017 statsVerticalOffset += PELS_PER_LINE;
2996 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());3018 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
2997 3019
2998 voxelStats.str("");3020 voxelStats.str("");
2999 voxelStats << 3021 voxelStats <<
@@ -3003,37 +3025,40 @@ void Application::displayStats() { · 3 unmodified lines
3003 if (_voxels.hasVoxelMemoryUsageGPU()) {3025 if (_voxels.hasVoxelMemoryUsageGPU()) {
3004 voxelStats << "GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB ";3026 voxelStats << "GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB ";
3005 }3027 }
3028 statsVerticalOffset += PELS_PER_LINE;
3029 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3006 3030
3007 // Some debugging for memory usage of VoxelNodes3031 voxelStats.str("");
3008 //voxelStats << "VoxelNode size: " << sizeof(VoxelNode) << " bytes ";3032 voxelStats <<
3009 //voxelStats << "AABox size: " << sizeof(AABox) << " bytes ";3033 "Local Voxels Total: " << VoxelNode::getNodeCount() << ", " <<
3010 3034 "Internal: " << VoxelNode::getInternalNodeCount() << " , " <<
3035 "Leaves: " << VoxelNode::getLeafNodeCount() << "";
3011 statsVerticalOffset += PELS_PER_LINE;3036 statsVerticalOffset += PELS_PER_LINE;
3012 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());3037 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3013 3038
3014 voxelStats.str("");3039 voxelStats.str("");
3015 char* voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_VOXELS);3040 char* voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_VOXELS);
3016 voxelStats << "Voxels Sent from Server: " << voxelDetails;3041 voxelStats << "Voxels Sent from Server: " << voxelDetails;
3017 statsVerticalOffset += PELS_PER_LINE;3042 statsVerticalOffset += PELS_PER_LINE;
3018 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());3043 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3019 3044
3020 voxelStats.str("");3045 voxelStats.str("");
3021 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ELAPSED);3046 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ELAPSED);
3022 voxelStats << "Scene Send Time from Server: " << voxelDetails;3047 voxelStats << "Scene Send Time from Server: " << voxelDetails;
3023 statsVerticalOffset += PELS_PER_LINE;3048 statsVerticalOffset += PELS_PER_LINE;
3024 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());3049 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3025 3050
3026 voxelStats.str("");3051 voxelStats.str("");
3027 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ENCODE);3052 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ENCODE);
3028 voxelStats << "Encode Time on Server: " << voxelDetails;3053 voxelStats << "Encode Time on Server: " << voxelDetails;
3029 statsVerticalOffset += PELS_PER_LINE;3054 statsVerticalOffset += PELS_PER_LINE;
3030 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());3055 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3031 3056
3032 voxelStats.str("");3057 voxelStats.str("");
3033 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_MODE);3058 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_MODE);
3034 voxelStats << "Sending Mode: " << voxelDetails;3059 voxelStats << "Sending Mode: " << voxelDetails;
3035 statsVerticalOffset += PELS_PER_LINE;3060 statsVerticalOffset += PELS_PER_LINE;
3036 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());3061 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3037 3062
3038 Node *avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);3063 Node *avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
3039 char avatarMixerStats[200];3064 char avatarMixerStats[200];
@@ -3048,7 +3073,7 @@ void Application::displayStats() { · 8 unmodified lines
3048 statsVerticalOffset += PELS_PER_LINE;3073 statsVerticalOffset += PELS_PER_LINE;
3049 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarMixerStats);3074 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarMixerStats);
3050 statsVerticalOffset += PELS_PER_LINE;3075 statsVerticalOffset += PELS_PER_LINE;
3051 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)LeapManager::statusString().c_str());3076 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)LeapManager::statusString().c_str());
3052 3077
3053 if (_perfStatsOn) {3078 if (_perfStatsOn) {
3054 // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups3079 // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups
@@ -3234,7 +3259,6 @@ void Application::renderCoverageMapsRecursively(CoverageMap* map) { · 179 unmodified lines
3234 3259
3235 3260
3236 3261
3237/////////////////////////////////////////////////////////////////////////////////////
3238// renderViewFrustum()3262// renderViewFrustum()
3239//3263//
3240// Description: this will render the view frustum bounds for EITHER the head3264// Description: this will render the view frustum bounds for EITHER the head
@@ -3316,7 +3340,7 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 75 unmodified lines
3316 || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES3340 || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES
3317 || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_FAR_PLANE) {3341 || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_FAR_PLANE) {
3318 // viewFrustum.getFar plane - bottom edge 3342 // viewFrustum.getFar plane - bottom edge
3319 glColor3f(0,1,0); // GREEN!!!3343 glColor3f(0,1,0);
3320 glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z);3344 glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z);
3321 glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z);3345 glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z);
3322 3346
@@ -3684,6 +3708,9 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng · 361 unmodified lines
3684 3708
3685// Receive packets from other nodes/servers and decide what to do with them!3709// Receive packets from other nodes/servers and decide what to do with them!
3686void* Application::networkReceive(void* args) {3710void* Application::networkReceive(void* args) {
3711 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3712 "Application::networkReceive()");
3713
3687 sockaddr senderAddress;3714 sockaddr senderAddress;
3688 ssize_t bytesReceived;3715 ssize_t bytesReceived;
3689 3716
@@ -3711,6 +3738,9 @@ void* Application::networkReceive(void* args) { · 21 unmodified lines
3711 case PACKET_TYPE_ERASE_VOXEL:3738 case PACKET_TYPE_ERASE_VOXEL:
3712 case PACKET_TYPE_VOXEL_STATS:3739 case PACKET_TYPE_VOXEL_STATS:
3713 case PACKET_TYPE_ENVIRONMENT_DATA: {3740 case PACKET_TYPE_ENVIRONMENT_DATA: {
3741 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3742 "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()");
3743
3714 // add this packet to our list of voxel packets and process them on the voxel processing3744 // add this packet to our list of voxel packets and process them on the voxel processing
3715 app->_voxelProcessor.queueReceivedPacket(senderAddress, app->_incomingPacket, bytesReceived);3745 app->_voxelProcessor.queueReceivedPacket(senderAddress, app->_incomingPacket, bytesReceived);
3716 break;3746 break;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t