aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerdisplay.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llviewerdisplay.cpp78
1 files changed, 54 insertions, 24 deletions
diff --git a/linden/indra/newview/llviewerdisplay.cpp b/linden/indra/newview/llviewerdisplay.cpp
index 47c9c32..b9a5986 100644
--- a/linden/indra/newview/llviewerdisplay.cpp
+++ b/linden/indra/newview/llviewerdisplay.cpp
@@ -81,8 +81,6 @@
81#include "llpostprocess.h" 81#include "llpostprocess.h"
82 82
83extern LLPointer<LLImageGL> gStartImageGL; 83extern LLPointer<LLImageGL> gStartImageGL;
84extern BOOL gDisplaySwapBuffers;
85
86 84
87LLPointer<LLImageGL> gDisconnectedImagep = NULL; 85LLPointer<LLImageGL> gDisconnectedImagep = NULL;
88 86
@@ -96,17 +94,18 @@ const F32 RESTORE_GL_TIME = 5.f; // Wait this long while reloading textures bef
96 94
97BOOL gForceRenderLandFence = FALSE; 95BOOL gForceRenderLandFence = FALSE;
98BOOL gDisplaySwapBuffers = FALSE; 96BOOL gDisplaySwapBuffers = FALSE;
97BOOL gDepthDirty = FALSE;
99BOOL gResizeScreenTexture = FALSE; 98BOOL gResizeScreenTexture = FALSE;
100BOOL gSnapshot = FALSE; 99BOOL gSnapshot = FALSE;
101 100
102U32 gRecentFrameCount = 0; // number of 'recent' frames 101U32 gRecentFrameCount = 0; // number of 'recent' frames
103LLFrameTimer gRecentTime; 102LLFrameTimer gRecentFPSTime;
103LLFrameTimer gRecentMemoryTime;
104 104
105// Rendering stuff 105// Rendering stuff
106void pre_show_depth_buffer(); 106void pre_show_depth_buffer();
107void post_show_depth_buffer(); 107void post_show_depth_buffer();
108void render_ui_and_swap(); 108void render_ui_and_swap();
109void render_ui_and_swap_if_needed();
110void render_hud_attachments(); 109void render_hud_attachments();
111void render_ui_3d(); 110void render_ui_3d();
112void render_ui_2d(); 111void render_ui_2d();
@@ -187,13 +186,21 @@ void display_update_camera()
187// Write some stats to llinfos 186// Write some stats to llinfos
188void display_stats() 187void display_stats()
189{ 188{
190 F32 log_freq = gSavedSettings.getF32("FPSLogFrequency"); 189 F32 fps_log_freq = gSavedSettings.getF32("FPSLogFrequency");
191 if (log_freq > 0.f && gRecentTime.getElapsedTimeF32() >= log_freq) 190 if (fps_log_freq > 0.f && gRecentFPSTime.getElapsedTimeF32() >= fps_log_freq)
192 { 191 {
193 F32 fps = gRecentFrameCount / log_freq; 192 F32 fps = gRecentFrameCount / fps_log_freq;
194 llinfos << llformat("FPS: %.02f", fps) << llendl; 193 llinfos << llformat("FPS: %.02f", fps) << llendl;
195 gRecentFrameCount = 0; 194 gRecentFrameCount = 0;
196 gRecentTime.reset(); 195 gRecentFPSTime.reset();
196 }
197 F32 mem_log_freq = gSavedSettings.getF32("MemoryLogFrequency");
198 if (mem_log_freq > 0.f && gRecentMemoryTime.getElapsedTimeF32() >= mem_log_freq)
199 {
200 gMemoryAllocated = getCurrentRSS();
201 U32 memory = (U32)(gMemoryAllocated / (1024*1024));
202 llinfos << llformat("MEMORY: %d MB", memory) << llendl;
203 gRecentMemoryTime.reset();
197 } 204 }
198} 205}
199 206
@@ -237,9 +244,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
237 244
238 gViewerWindow->checkSettings(); 245 gViewerWindow->checkSettings();
239 246
247 LLAppViewer::instance()->pingMainloopTimeout("Display:Pick");
240 gViewerWindow->performPick(); 248 gViewerWindow->performPick();
241 249
242 250
251 LLAppViewer::instance()->pingMainloopTimeout("Display:CheckStates");
243 LLGLState::checkStates(); 252 LLGLState::checkStates();
244 LLGLState::checkTextureChannels(); 253 LLGLState::checkTextureChannels();
245 254
@@ -271,6 +280,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
271 // 280 //
272 if (LLStartUp::getStartupState() < STATE_STARTED) 281 if (LLStartUp::getStartupState() < STATE_STARTED)
273 { 282 {
283 LLAppViewer::instance()->pingMainloopTimeout("Display:Startup");
274 display_startup(); 284 display_startup();
275 return; 285 return;
276 } 286 }
@@ -282,6 +292,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
282 // Update GL Texture statistics (used for discard logic?) 292 // Update GL Texture statistics (used for discard logic?)
283 // 293 //
284 294
295 LLAppViewer::instance()->pingMainloopTimeout("Display:TextureStats");
285 gFrameStats.start(LLFrameStats::UPDATE_TEX_STATS); 296 gFrameStats.start(LLFrameStats::UPDATE_TEX_STATS);
286 stop_glerror(); 297 stop_glerror();
287 298
@@ -305,6 +316,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
305 316
306 if (gTeleportDisplay) 317 if (gTeleportDisplay)
307 { 318 {
319 LLAppViewer::instance()->pingMainloopTimeout("Display:Teleport");
308 const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived. 320 const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived.
309 321
310 S32 attach_count = 0; 322 S32 attach_count = 0;
@@ -383,6 +395,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
383 } 395 }
384 else if(LLAppViewer::instance()->logoutRequestSent()) 396 else if(LLAppViewer::instance()->logoutRequestSent())
385 { 397 {
398 LLAppViewer::instance()->pingMainloopTimeout("Display:Logout");
386 F32 percent_done = gLogoutTimer.getElapsedTimeF32() * 100.f / gLogoutMaxTime; 399 F32 percent_done = gLogoutTimer.getElapsedTimeF32() * 100.f / gLogoutMaxTime;
387 if (percent_done > 100.f) 400 if (percent_done > 100.f)
388 { 401 {
@@ -399,6 +412,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
399 else 412 else
400 if (gRestoreGL) 413 if (gRestoreGL)
401 { 414 {
415 LLAppViewer::instance()->pingMainloopTimeout("Display:RestoreGL");
402 F32 percent_done = gRestoreGLTimer.getElapsedTimeF32() * 100.f / RESTORE_GL_TIME; 416 F32 percent_done = gRestoreGLTimer.getElapsedTimeF32() * 100.f / RESTORE_GL_TIME;
403 if( percent_done > 100.f ) 417 if( percent_done > 100.f )
404 { 418 {
@@ -428,6 +442,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
428 // 442 //
429 // 443 //
430 444
445 LLAppViewer::instance()->pingMainloopTimeout("Display:Camera");
431 LLViewerCamera::getInstance()->setZoomParameters(zoom_factor, subfield); 446 LLViewerCamera::getInstance()->setZoomParameters(zoom_factor, subfield);
432 LLViewerCamera::getInstance()->setNear(MIN_NEAR_PLANE); 447 LLViewerCamera::getInstance()->setNear(MIN_NEAR_PLANE);
433 448
@@ -439,9 +454,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
439 454
440 if (gDisconnected) 455 if (gDisconnected)
441 { 456 {
442 render_ui_and_swap_if_needed(); 457 LLAppViewer::instance()->pingMainloopTimeout("Display:Disconnected");
443 gDisplaySwapBuffers = TRUE; 458 render_ui_and_swap();
444
445 render_disconnected_background(); 459 render_disconnected_background();
446 } 460 }
447 461
@@ -450,6 +464,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
450 // Set rendering options 464 // Set rendering options
451 // 465 //
452 // 466 //
467 LLAppViewer::instance()->pingMainloopTimeout("Display:RenderSetup");
453 stop_glerror(); 468 stop_glerror();
454 if (gSavedSettings.getBOOL("ShowDepthBuffer")) 469 if (gSavedSettings.getBOOL("ShowDepthBuffer"))
455 { 470 {
@@ -478,6 +493,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
478 // do render-to-texture stuff here 493 // do render-to-texture stuff here
479 if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES)) 494 if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES))
480 { 495 {
496 LLAppViewer::instance()->pingMainloopTimeout("Display:DynamicTextures");
481 LLFastTimer t(LLFastTimer::FTM_UPDATE_TEXTURES); 497 LLFastTimer t(LLFastTimer::FTM_UPDATE_TEXTURES);
482 if (LLDynamicTexture::updateAllInstances()) 498 if (LLDynamicTexture::updateAllInstances())
483 { 499 {
@@ -490,6 +506,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
490 506
491 if (!gDisconnected) 507 if (!gDisconnected)
492 { 508 {
509 LLAppViewer::instance()->pingMainloopTimeout("Display:Update");
493 if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) 510 if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD))
494 { //don't draw hud objects in this frame 511 { //don't draw hud objects in this frame
495 gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); 512 gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD);
@@ -527,9 +544,12 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
527 } 544 }
528 } 545 }
529 546
547 LLAppViewer::instance()->pingMainloopTimeout("Display:Cull");
548
530 //Increment drawable frame counter 549 //Increment drawable frame counter
531 LLDrawable::incrementVisible(); 550 LLDrawable::incrementVisible();
532 551
552 LLSpatialGroup::sNoDelete = TRUE;
533 LLPipeline::sUseOcclusion = 553 LLPipeline::sUseOcclusion =
534 (!gUseWireframe 554 (!gUseWireframe
535 && LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") 555 && LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion")
@@ -540,10 +560,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
540 LLVOAvatar::sMaxVisible = gSavedSettings.getS32("RenderAvatarMaxVisible"); 560 LLVOAvatar::sMaxVisible = gSavedSettings.getS32("RenderAvatarMaxVisible");
541 561
542 S32 occlusion = LLPipeline::sUseOcclusion; 562 S32 occlusion = LLPipeline::sUseOcclusion;
543 if (!gDisplaySwapBuffers) 563 if (gDepthDirty)
544 { //depth buffer is invalid, don't overwrite occlusion state 564 { //depth buffer is invalid, don't overwrite occlusion state
545 LLPipeline::sUseOcclusion = llmin(occlusion, 1); 565 LLPipeline::sUseOcclusion = llmin(occlusion, 1);
546 } 566 }
567 gDepthDirty = FALSE;
547 568
548 static LLCullResult result; 569 static LLCullResult result;
549 gPipeline.updateCull(*LLViewerCamera::getInstance(), result, water_clip); 570 gPipeline.updateCull(*LLViewerCamera::getInstance(), result, water_clip);
@@ -553,6 +574,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
553 gPipeline.canUseVertexShaders() && 574 gPipeline.canUseVertexShaders() &&
554 LLPipeline::sRenderGlow; 575 LLPipeline::sRenderGlow;
555 576
577 LLAppViewer::instance()->pingMainloopTimeout("Display:Swap");
578
556 // now do the swap buffer (just before rendering to framebuffer) 579 // now do the swap buffer (just before rendering to framebuffer)
557 { //swap and flush state from previous frame 580 { //swap and flush state from previous frame
558 { 581 {
@@ -571,9 +594,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
571 594
572 if (!for_snapshot) 595 if (!for_snapshot)
573 { 596 {
574 render_ui_and_swap_if_needed();
575 gDisplaySwapBuffers = TRUE;
576
577 glh::matrix4f proj = glh_get_current_projection(); 597 glh::matrix4f proj = glh_get_current_projection();
578 glh::matrix4f mod = glh_get_current_modelview(); 598 glh::matrix4f mod = glh_get_current_modelview();
579 glViewport(0,0,512,512); 599 glViewport(0,0,512,512);
@@ -592,6 +612,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
592 612
593 if (!for_snapshot) 613 if (!for_snapshot)
594 { 614 {
615 LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery");
595 gPipeline.processImagery(*LLViewerCamera::getInstance()); 616 gPipeline.processImagery(*LLViewerCamera::getInstance());
596 gPipeline.generateWaterReflection(*LLViewerCamera::getInstance()); 617 gPipeline.generateWaterReflection(*LLViewerCamera::getInstance());
597 } 618 }
@@ -603,6 +624,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
603 // Can put objects onto the retextured list. 624 // Can put objects onto the retextured list.
604 // 625 //
605 // Doing this here gives hardware occlusion queries extra time to complete 626 // Doing this here gives hardware occlusion queries extra time to complete
627 LLAppViewer::instance()->pingMainloopTimeout("Display:UpdateImages");
606 gFrameStats.start(LLFrameStats::IMAGE_UPDATE); 628 gFrameStats.start(LLFrameStats::IMAGE_UPDATE);
607 629
608 { 630 {
@@ -626,6 +648,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
626 // In the case of alpha objects, z-sorts them first. 648 // In the case of alpha objects, z-sorts them first.
627 // Also creates special lists for outlines and selected face rendering. 649 // Also creates special lists for outlines and selected face rendering.
628 // 650 //
651 LLAppViewer::instance()->pingMainloopTimeout("Display:StateSort");
629 { 652 {
630 gFrameStats.start(LLFrameStats::STATE_SORT); 653 gFrameStats.start(LLFrameStats::STATE_SORT);
631 gPipeline.stateSort(*LLViewerCamera::getInstance(), result); 654 gPipeline.stateSort(*LLViewerCamera::getInstance(), result);
@@ -647,6 +670,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
647 LLPipeline::sUseOcclusion = occlusion; 670 LLPipeline::sUseOcclusion = occlusion;
648 671
649 { 672 {
673 LLAppViewer::instance()->pingMainloopTimeout("Display:Sky");
650 LLFastTimer t(LLFastTimer::FTM_UPDATE_SKY); 674 LLFastTimer t(LLFastTimer::FTM_UPDATE_SKY);
651 gSky.updateSky(); 675 gSky.updateSky();
652 } 676 }
@@ -658,6 +682,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
658 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 682 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
659 } 683 }
660 684
685 LLAppViewer::instance()->pingMainloopTimeout("Display:Render");
686
661 //// render frontmost floater opaque for occlusion culling purposes 687 //// render frontmost floater opaque for occlusion culling purposes
662 //LLFloater* frontmost_floaterp = gFloaterView->getFrontmost(); 688 //LLFloater* frontmost_floaterp = gFloaterView->getFrontmost();
663 //// assumes frontmost floater with focus is opaque 689 //// assumes frontmost floater with focus is opaque
@@ -731,11 +757,19 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
731 /// Using render to texture would be faster/better, but I don't have a 757 /// Using render to texture would be faster/better, but I don't have a
732 /// grasp of their full display stack just yet. 758 /// grasp of their full display stack just yet.
733 // gPostProcess->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); 759 // gPostProcess->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight());
760
761 if (!for_snapshot)
762 {
763 render_ui_and_swap();
764 }
765
766 LLSpatialGroup::sNoDelete = FALSE;
734 } 767 }
735 gFrameStats.start(LLFrameStats::RENDER_UI); 768 gFrameStats.start(LLFrameStats::RENDER_UI);
736 769
737 if (gHandleKeysAsync) 770 if (gHandleKeysAsync)
738 { 771 {
772 LLAppViewer::instance()->pingMainloopTimeout("Display:Keystrokes");
739 process_keystrokes_async(); 773 process_keystrokes_async();
740 stop_glerror(); 774 stop_glerror();
741 } 775 }
@@ -750,6 +784,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
750 } 784 }
751 785
752 display_stats(); 786 display_stats();
787
788 LLAppViewer::instance()->pingMainloopTimeout("Display:Done");
753} 789}
754 790
755void render_hud_attachments() 791void render_hud_attachments()
@@ -944,19 +980,13 @@ void render_ui_and_swap()
944 980
945 glh_set_current_modelview(saved_view); 981 glh_set_current_modelview(saved_view);
946 glPopMatrix(); 982 glPopMatrix();
947}
948 983
949void render_ui_and_swap_if_needed()
950{
951 if (gDisplaySwapBuffers) 984 if (gDisplaySwapBuffers)
952 { 985 {
953 render_ui_and_swap(); 986 LLFastTimer t(LLFastTimer::FTM_SWAP);
954 987 gViewerWindow->mWindow->swapBuffers();
955 {
956 LLFastTimer t(LLFastTimer::FTM_SWAP);
957 gViewerWindow->mWindow->swapBuffers();
958 }
959 } 988 }
989 gDisplaySwapBuffers = TRUE;
960} 990}
961 991
962void renderCoordinateAxes() 992void renderCoordinateAxes()