diff options
author | Steven Bennetts <steve@lindenlab.com> | 2008-06-06 22:43:38 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2008-06-06 22:43:38 +0000 |
commit | ad332810078a0bbb8fa08fcbfdf3d756de6914f6 (patch) | |
tree | 1608b2db5d620d323673607ea7ddadfba9d58bda /indra/newview/llviewerdisplay.cpp | |
parent | a7d9a543e587ffe84b355db7a2e8193bfe6c68b6 (diff) |
QAR-650 - Viewer RC 9 merge -> release (post cmake)
merge release@88802 Branch_1-20-Viewer-2-merge-1@89178 -> release
Diffstat (limited to 'indra/newview/llviewerdisplay.cpp')
-rw-r--r-- | indra/newview/llviewerdisplay.cpp | 105 |
1 files changed, 76 insertions, 29 deletions
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index a24f4b36de..c75bcdc9e8 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -34,7 +34,7 @@ #include "llviewerdisplay.h" #include "llgl.h" -#include "llglimmediate.h" +#include "llrender.h" #include "llglheaders.h" #include "llagent.h" #include "llviewercontrol.h" @@ -81,8 +81,6 @@ #include "llpostprocess.h" extern LLPointer<LLImageGL> gStartImageGL; -extern BOOL gDisplaySwapBuffers; - LLPointer<LLImageGL> gDisconnectedImagep = NULL; @@ -96,14 +94,18 @@ const F32 RESTORE_GL_TIME = 5.f; // Wait this long while reloading textures bef BOOL gForceRenderLandFence = FALSE; BOOL gDisplaySwapBuffers = FALSE; +BOOL gDepthDirty = FALSE; BOOL gResizeScreenTexture = FALSE; BOOL gSnapshot = FALSE; +U32 gRecentFrameCount = 0; // number of 'recent' frames +LLFrameTimer gRecentFPSTime; +LLFrameTimer gRecentMemoryTime; + // Rendering stuff void pre_show_depth_buffer(); void post_show_depth_buffer(); void render_ui_and_swap(); -void render_ui_and_swap_if_needed(); void render_hud_attachments(); void render_ui_3d(); void render_ui_2d(); @@ -142,7 +144,7 @@ void display_startup() gPipeline.disableLights(); gViewerWindow->setup2DRender(); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); gGL.color4f(1,1,1,1); gViewerWindow->draw(); @@ -181,6 +183,26 @@ void display_update_camera() LLWorld::getInstance()->setLandFarClip(final_far); } +// Write some stats to llinfos +void display_stats() +{ + F32 fps_log_freq = gSavedSettings.getF32("FPSLogFrequency"); + if (fps_log_freq > 0.f && gRecentFPSTime.getElapsedTimeF32() >= fps_log_freq) + { + F32 fps = gRecentFrameCount / fps_log_freq; + llinfos << llformat("FPS: %.02f", fps) << llendl; + gRecentFrameCount = 0; + gRecentFPSTime.reset(); + } + F32 mem_log_freq = gSavedSettings.getF32("MemoryLogFrequency"); + if (mem_log_freq > 0.f && gRecentMemoryTime.getElapsedTimeF32() >= mem_log_freq) + { + gMemoryAllocated = getCurrentRSS(); + U32 memory = (U32)(gMemoryAllocated / (1024*1024)); + llinfos << llformat("MEMORY: %d MB", memory) << llendl; + gRecentMemoryTime.reset(); + } +} // Paint the display! void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) @@ -222,9 +244,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gViewerWindow->checkSettings(); + LLAppViewer::instance()->pingMainloopTimeout("Display:Pick"); gViewerWindow->performPick(); + LLAppViewer::instance()->pingMainloopTimeout("Display:CheckStates"); LLGLState::checkStates(); LLGLState::checkTextureChannels(); @@ -256,6 +280,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // if (LLStartUp::getStartupState() < STATE_STARTED) { + LLAppViewer::instance()->pingMainloopTimeout("Display:Startup"); display_startup(); return; } @@ -267,6 +292,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // Update GL Texture statistics (used for discard logic?) // + LLAppViewer::instance()->pingMainloopTimeout("Display:TextureStats"); gFrameStats.start(LLFrameStats::UPDATE_TEX_STATS); stop_glerror(); @@ -277,6 +303,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gPipeline.mBackfaceCull = TRUE; gFrameCount++; + gRecentFrameCount++; if (gFocusMgr.getAppHasFocus()) { gForegroundFrameCount++; @@ -289,6 +316,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (gTeleportDisplay) { + LLAppViewer::instance()->pingMainloopTimeout("Display:Teleport"); const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived. S32 attach_count = 0; @@ -367,6 +395,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) } else if(LLAppViewer::instance()->logoutRequestSent()) { + LLAppViewer::instance()->pingMainloopTimeout("Display:Logout"); F32 percent_done = gLogoutTimer.getElapsedTimeF32() * 100.f / gLogoutMaxTime; if (percent_done > 100.f) { @@ -383,6 +412,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) else if (gRestoreGL) { + LLAppViewer::instance()->pingMainloopTimeout("Display:RestoreGL"); F32 percent_done = gRestoreGLTimer.getElapsedTimeF32() * 100.f / RESTORE_GL_TIME; if( percent_done > 100.f ) { @@ -412,6 +442,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // // + LLAppViewer::instance()->pingMainloopTimeout("Display:Camera"); LLViewerCamera::getInstance()->setZoomParameters(zoom_factor, subfield); LLViewerCamera::getInstance()->setNear(MIN_NEAR_PLANE); @@ -423,9 +454,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (gDisconnected) { - render_ui_and_swap_if_needed(); - gDisplaySwapBuffers = TRUE; - + LLAppViewer::instance()->pingMainloopTimeout("Display:Disconnected"); + render_ui_and_swap(); render_disconnected_background(); } @@ -434,6 +464,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // Set rendering options // // + LLAppViewer::instance()->pingMainloopTimeout("Display:RenderSetup"); stop_glerror(); if (gSavedSettings.getBOOL("ShowDepthBuffer")) { @@ -462,10 +493,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // do render-to-texture stuff here if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES)) { + LLAppViewer::instance()->pingMainloopTimeout("Display:DynamicTextures"); LLFastTimer t(LLFastTimer::FTM_UPDATE_TEXTURES); if (LLDynamicTexture::updateAllInstances()) { - glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); + gGL.setColorMask(true, true); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } } @@ -474,6 +506,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (!gDisconnected) { + LLAppViewer::instance()->pingMainloopTimeout("Display:Update"); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) { //don't draw hud objects in this frame gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); @@ -511,9 +544,12 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) } } + LLAppViewer::instance()->pingMainloopTimeout("Display:Cull"); + //Increment drawable frame counter LLDrawable::incrementVisible(); + LLSpatialGroup::sNoDelete = TRUE; LLPipeline::sUseOcclusion = (!gUseWireframe && LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") @@ -524,10 +560,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLVOAvatar::sMaxVisible = gSavedSettings.getS32("RenderAvatarMaxVisible"); S32 occlusion = LLPipeline::sUseOcclusion; - if (!gDisplaySwapBuffers) + if (gDepthDirty) { //depth buffer is invalid, don't overwrite occlusion state LLPipeline::sUseOcclusion = llmin(occlusion, 1); } + gDepthDirty = FALSE; static LLCullResult result; gPipeline.updateCull(*LLViewerCamera::getInstance(), result, water_clip); @@ -537,6 +574,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gPipeline.canUseVertexShaders() && LLPipeline::sRenderGlow; + LLAppViewer::instance()->pingMainloopTimeout("Display:Swap"); + // now do the swap buffer (just before rendering to framebuffer) { //swap and flush state from previous frame { @@ -550,14 +589,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gPipeline.resizeScreenTexture(); } - glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); + gGL.setColorMask(true, true); glClearColor(0,0,0,0); if (!for_snapshot) { - render_ui_and_swap_if_needed(); - gDisplaySwapBuffers = TRUE; - glh::matrix4f proj = glh_get_current_projection(); glh::matrix4f mod = glh_get_current_modelview(); glViewport(0,0,512,512); @@ -576,6 +612,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (!for_snapshot) { + LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery"); gPipeline.processImagery(*LLViewerCamera::getInstance()); gPipeline.generateWaterReflection(*LLViewerCamera::getInstance()); } @@ -587,6 +624,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // Can put objects onto the retextured list. // // Doing this here gives hardware occlusion queries extra time to complete + LLAppViewer::instance()->pingMainloopTimeout("Display:UpdateImages"); gFrameStats.start(LLFrameStats::IMAGE_UPDATE); { @@ -610,6 +648,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // In the case of alpha objects, z-sorts them first. // Also creates special lists for outlines and selected face rendering. // + LLAppViewer::instance()->pingMainloopTimeout("Display:StateSort"); { gFrameStats.start(LLFrameStats::STATE_SORT); gPipeline.stateSort(*LLViewerCamera::getInstance(), result); @@ -631,6 +670,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLPipeline::sUseOcclusion = occlusion; { + LLAppViewer::instance()->pingMainloopTimeout("Display:Sky"); LLFastTimer t(LLFastTimer::FTM_UPDATE_SKY); gSky.updateSky(); } @@ -642,6 +682,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } + LLAppViewer::instance()->pingMainloopTimeout("Display:Render"); + //// render frontmost floater opaque for occlusion culling purposes //LLFloater* frontmost_floaterp = gFloaterView->getFrontmost(); //// assumes frontmost floater with focus is opaque @@ -681,20 +723,20 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (to_texture) { - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + gGL.setColorMask(true, true); gPipeline.mScreen.bindTarget(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); + gGL.setColorMask(true, false); } if (!(LLAppViewer::instance()->logoutRequestSent() && LLAppViewer::instance()->hasSavedFinalSnapshot()) && !gRestoreGL) { - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); + gGL.setColorMask(true, false); LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; gPipeline.renderGeom(*LLViewerCamera::getInstance(), TRUE); LLPipeline::sUnderWaterRender = FALSE; - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + gGL.setColorMask(true, true); //store this frame's modelview matrix for use //when rendering next frame's occlusion queries @@ -715,11 +757,19 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) /// Using render to texture would be faster/better, but I don't have a /// grasp of their full display stack just yet. // gPostProcess->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); + + if (!for_snapshot) + { + render_ui_and_swap(); + } + + LLSpatialGroup::sNoDelete = FALSE; } gFrameStats.start(LLFrameStats::RENDER_UI); if (gHandleKeysAsync) { + LLAppViewer::instance()->pingMainloopTimeout("Display:Keystrokes"); process_keystrokes_async(); stop_glerror(); } @@ -732,6 +782,10 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) send_agent_resume(); LLPipeline::sRenderFrameTest = FALSE; } + + display_stats(); + + LLAppViewer::instance()->pingMainloopTimeout("Display:Done"); } void render_hud_attachments() @@ -926,19 +980,13 @@ void render_ui_and_swap() glh_set_current_modelview(saved_view); glPopMatrix(); -} -void render_ui_and_swap_if_needed() -{ if (gDisplaySwapBuffers) { - render_ui_and_swap(); - - { - LLFastTimer t(LLFastTimer::FTM_SWAP); - gViewerWindow->mWindow->swapBuffers(); - } + LLFastTimer t(LLFastTimer::FTM_SWAP); + gViewerWindow->mWindow->swapBuffers(); } + gDisplaySwapBuffers = TRUE; } void renderCoordinateAxes() @@ -1073,7 +1121,7 @@ void render_ui_2d() } stop_glerror(); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); // render outline for HUD if (gAgent.getAvatarObject() && gAgent.getAvatarObject()->mHUDCurZoom < 0.98f) @@ -1100,7 +1148,6 @@ void render_ui_2d() LLFontGL::sCurOrigin.set(0, 0); } - void render_disconnected_background() { gGL.color4f(1,1,1,1); |