diff options
Diffstat (limited to 'indra/newview/llviewerdisplay.cpp')
| -rw-r--r-- | indra/newview/llviewerdisplay.cpp | 148 |
1 files changed, 102 insertions, 46 deletions
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 10fa0fd3cd..314e32bffd 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -100,13 +100,13 @@ extern LLPointer<LLViewerTexture> gStartTexture; extern bool gShiftFrame; -LLPointer<LLViewerTexture> gDisconnectedImagep = NULL; +LLPointer<LLViewerTexture> gDisconnectedImagep = nullptr; // used to toggle renderer back on after teleport bool gTeleportDisplay = false; LLFrameTimer gTeleportDisplayTimer; LLFrameTimer gTeleportArrivalTimer; -const F32 RESTORE_GL_TIME = 5.f; // Wait this long while reloading textures before we raise the curtain +constexpr F32 RESTORE_GL_TIME = 5.f; // Wait this long while reloading textures before we raise the curtain bool gForceRenderLandFence = false; bool gDisplaySwapBuffers = false; @@ -120,9 +120,9 @@ bool gSnapshotNoPost = false; bool gShaderProfileFrame = false; // This is how long the sim will try to teleport you before giving up. -const F32 TELEPORT_EXPIRY = 15.0f; +constexpr F32 TELEPORT_EXPIRY = 15.0f; // Additional time (in seconds) to wait per attachment -const F32 TELEPORT_EXPIRY_PER_ATTACHMENT = 3.f; +constexpr F32 TELEPORT_EXPIRY_PER_ATTACHMENT = 3.f; U32 gRecentFrameCount = 0; // number of 'recent' frames LLFrameTimer gRecentFPSTime; @@ -130,8 +130,6 @@ LLFrameTimer gRecentMemoryTime; LLFrameTimer gAssetStorageLogTime; // Rendering stuff -void pre_show_depth_buffer(); -void post_show_depth_buffer(); void render_ui(F32 zoom_factor = 1.f, int subfield = 0); void swap(); void render_hud_attachments(); @@ -212,7 +210,8 @@ void display_update_camera() F32 final_far = gAgentCamera.mDrawDistance; if (gCubeSnapshot) { - final_far = gSavedSettings.getF32("RenderReflectionProbeDrawDistance"); + static LLCachedControl<F32> reflection_probe_draw_distance(gSavedSettings, "RenderReflectionProbeDrawDistance", 64.f); + final_far = reflection_probe_draw_distance(); } else if (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode()) { @@ -237,16 +236,19 @@ void display_update_camera() void display_stats() { LL_PROFILE_ZONE_SCOPED; - const F32 FPS_LOG_FREQUENCY = 10.f; + constexpr F32 FPS_LOG_FREQUENCY = 10.f; if (gRecentFPSTime.getElapsedTimeF32() >= FPS_LOG_FREQUENCY) { LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("DS - FPS"); + LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecording(); + F64 normalized_session_jitter = recording.getLastValue(LLStatViewer::NOTRMALIZED_FRAMETIME_JITTER_SESSION); + F64 normalized_period_jitter = recording.getLastValue(LLStatViewer::NORMALIZED_FRAMTIME_JITTER_PERIOD); F32 fps = gRecentFrameCount / FPS_LOG_FREQUENCY; - LL_INFOS() << llformat("FPS: %.02f", fps) << LL_ENDL; + LL_INFOS() << llformat("FPS: %.02f SESSION JITTER: %.4f PERIOD JITTER: %.4f", fps, normalized_session_jitter, normalized_period_jitter) << LL_ENDL; gRecentFrameCount = 0; gRecentFPSTime.reset(); } - F32 mem_log_freq = gSavedSettings.getF32("MemoryLogFrequency"); + static LLCachedControl<F32> mem_log_freq(gSavedSettings, "MemoryLogFrequency", 600.f); if (mem_log_freq > 0.f && gRecentMemoryTime.getElapsedTimeF32() >= mem_log_freq) { LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("DS - Memory"); @@ -256,7 +258,7 @@ void display_stats() LLMemory::logMemoryInfo(true) ; gRecentMemoryTime.reset(); } - const F32 ASSET_STORAGE_LOG_FREQUENCY = 60.f; + constexpr F32 ASSET_STORAGE_LOG_FREQUENCY = 60.f; if (gAssetStorageLogTime.getElapsedTimeF32() >= ASSET_STORAGE_LOG_FREQUENCY) { LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("DS - Asset Storage"); @@ -411,6 +413,7 @@ static void update_tp_display(bool minimized) void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) { LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Render"); + LL_PROFILE_GPU_ZONE("Render"); LLPerfStats::RecordSceneTime T (LLPerfStats::StatType_t::RENDER_DISPLAY); // render time capture - This is the main stat for overall rendering. @@ -572,8 +575,10 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) LLImageGL::updateStats(gFrameTimeSeconds); - LLVOAvatar::sRenderName = gSavedSettings.getS32("AvatarNameTagMode"); - LLVOAvatar::sRenderGroupTitles = (gSavedSettings.getBOOL("NameTagShowGroupTitles") && gSavedSettings.getS32("AvatarNameTagMode")); + static LLCachedControl<S32> avatar_name_tag_mode(gSavedSettings, "AvatarNameTagMode", 1); + static LLCachedControl<bool> name_tag_show_group_titles(gSavedSettings, "NameTagShowGroupTitles", true); + LLVOAvatar::sRenderName = avatar_name_tag_mode; + LLVOAvatar::sRenderGroupTitles = name_tag_show_group_titles && avatar_name_tag_mode > 0; gPipeline.mBackfaceCull = true; gFrameCount++; @@ -708,11 +713,14 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) if (!gDisconnected && !LLApp::isExiting()) { + // =========== MIRRORS ============= + // Render mirrors and associated hero probes before we render the rest of the scene. // This ensures the scene state in the hero probes are exactly the same as the rest of the scene before we render it. if (gPipeline.RenderMirrors && !gSnapshot) { LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Update hero probes"); + LL_PROFILE_GPU_ZONE("hero manager") gPipeline.mHeroProbeManager.update(); gPipeline.mHeroProbeManager.renderProbes(); } @@ -733,12 +741,14 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) display_update_camera(); stop_glerror(); + // =========== ENV: SKY, WATER ============= { LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Env Update"); // update all the sky/atmospheric/water settings LLEnvironment::instance().update(LLViewerCamera::getInstance()); } + // =========== EFFECTS (?) ============= // *TODO: merge these two methods { LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("HUD Update"); @@ -747,6 +757,7 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) stop_glerror(); } + // =========== GEOMETRY ============= { LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Update Geom"); const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds.value(); // 50 ms/second update time @@ -777,6 +788,8 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) LLGLState::checkStates(); + // =========== OCCLUSION ============= + static LLCullResult result; LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater(); @@ -796,18 +809,24 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) } gGL.setColorMask(true, true); - glClearColor(0,0,0,0); + glClearColor(0.f, 0.f, 0.f, 0.f); LLGLState::checkStates(); if (!for_snapshot) { - if (gFrameCount > 1 && !for_snapshot) - { //for some reason, ATI 4800 series will error out if you - //try to generate a shadow before the first frame is through + + // =========== SHADOWS ============= + + S32 RenderShadowDetail = gSavedSettings.getS32("RenderShadowDetail"); + + if(RenderShadowDetail > 0 && gFrameCount > 1) + { gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); } + // =========== IMPOSTORS ============= + LLVertexBuffer::unbind(); LLGLState::checkStates(); @@ -831,6 +850,9 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) glClear(GL_DEPTH_BUFFER_BIT); } + + // =========== IMAGES ============= + ////////////////////////////////////// // // Update images, using the image stats generated during object update/culling @@ -869,6 +891,9 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) LLGLState::checkStates(); + + // =========== SORTING OBJECTS ============= + /////////////////////////////////// // // StateSort @@ -902,6 +927,9 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) LLPipeline::sUseOcclusion = occlusion; + + // =========== SKY ============= + { LLAppViewer::instance()->pingMainloopTimeout("Display:Sky"); LL_PROFILE_ZONE_NAMED_CATEGORY_ENVIRONMENT("update sky"); //LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKY); @@ -953,6 +981,9 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) // gGL.popMatrix(); //} + + // =========== DEFERRED ============= + LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater(); LLGLState::checkStates(); @@ -961,10 +992,10 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) gGL.setColorMask(true, true); - gPipeline.mRT->deferredScreen.bindTarget(); + gPipeline.mRT->deferredScreen.bindTarget("", 1); if (gUseWireframe) { - F32 g = 0.5f; + constexpr F32 g = 0.5f; glClearColor(g, g, g, 1.f); } else @@ -973,6 +1004,9 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) } gPipeline.mRT->deferredScreen.clear(); + + // =========== RENDER GEOMETRY ============= + gGL.setColorMask(true, false); LLAppViewer::instance()->pingMainloopTimeout("Display:RenderGeom"); @@ -983,11 +1017,16 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("display - 5") LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; - if (gSavedSettings.getBOOL("RenderDepthPrePass")) + + // =========== RENDER DEPTH PREPASS (UNUSED) ============= + + static LLCachedControl<bool> render_depth_pre_pass(gSavedSettings, "RenderDepthPrePass", false); + + if (render_depth_pre_pass) { gGL.setColorMask(false, false); - static const U32 types[] = { + constexpr U32 types[] = { LLRenderPass::PASS_SIMPLE, LLRenderPass::PASS_FULLBRIGHT, LLRenderPass::PASS_SHINY @@ -1008,6 +1047,8 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) gPipeline.renderGeomDeferred(*LLViewerCamera::getInstance(), true); } + // =========== UNBIND TEXTURES ============= + { LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Texture Unbind"); for (S32 i = 0; i < gGLManager.mNumTextureImageUnits; i++) @@ -1020,11 +1061,15 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) } } + // =========== FLUSH ============= + LLAppViewer::instance()->pingMainloopTimeout("Display:RenderFlush"); LLRenderTarget &rt = (gPipeline.sRenderDeferred ? gPipeline.mRT->deferredScreen : gPipeline.mRT->screen); rt.flush(); + // =========== RENDER DEFERRED ============= + if (LLPipeline::sRenderDeferred) { gPipeline.renderDeferredLighting(); @@ -1037,10 +1082,14 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) LLSceneMonitor::getInstance()->capture(); } + // =========== RENDER UI ============= + LLAppViewer::instance()->pingMainloopTimeout("Display:RenderUI"); if (!for_snapshot) { + gGL.flush(); render_ui(); + gGL.flush(); swap(); } @@ -1051,8 +1100,6 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) LLAppViewer::instance()->pingMainloopTimeout("Display:FrameStats"); - stop_glerror(); - display_stats(); LLAppViewer::instance()->pingMainloopTimeout("Display:Done"); @@ -1201,8 +1248,8 @@ void display_cube_face() gGL.setColorMask(true, true); - glClearColor(0, 0, 0, 0); - gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); + glClearColor(0.f, 0.f, 0.f, 0.f); + //gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); glClear(GL_DEPTH_BUFFER_BIT); // | GL_STENCIL_BUFFER_BIT); @@ -1230,14 +1277,14 @@ void display_cube_face() gGL.setColorMask(true, true); - gPipeline.mRT->deferredScreen.bindTarget(); + gPipeline.mRT->deferredScreen.bindTarget("", 1); if (gUseWireframe) { glClearColor(0.5f, 0.5f, 0.5f, 1.f); } else { - glClearColor(1, 0, 1, 1); + glClearColor(1.f, 0.f, 1.f, 1.f); } gPipeline.mRT->deferredScreen.clear(); @@ -1278,11 +1325,12 @@ void render_hud_attachments() { LLPipeline::sRenderingHUDs = true; LLCamera hud_cam = *LLViewerCamera::getInstance(); - hud_cam.setOrigin(-1.f,0,0); - hud_cam.setAxes(LLVector3(1,0,0), LLVector3(0,1,0), LLVector3(0,0,1)); + hud_cam.setOrigin(-1.f, 0.f, 0.f); + hud_cam.setAxes(LLVector3(1.f, 0.f, 0.f), LLVector3(0.f, 1.f, 0.f), LLVector3(0.f, 0.f, 1.f)); LLViewerCamera::updateFrustumPlanes(hud_cam, true); - bool render_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) && gSavedSettings.getBOOL("RenderHUDParticles"); + static LLCachedControl<bool> render_hud_particles(gSavedSettings, "RenderHUDParticles", false); + bool render_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) && render_hud_particles; //only render hud objects gPipeline.pushRenderTypeMask(); @@ -1345,7 +1393,7 @@ void render_hud_attachments() gPipeline.stateSort(hud_cam, result); - gPipeline.renderGeomPostDeferred(hud_cam); + gPipeline.renderGeomPostDeferredOnlyHud(hud_cam); LLSpatialGroup::sNoDelete = false; //gPipeline.clearReferences(); @@ -1490,6 +1538,7 @@ void render_ui(F32 zoom_factor, int subfield) { LLGLState::checkStates(); + gPipeline.disableLights(); LL_PROFILE_ZONE_NAMED_CATEGORY_UI("HUD"); render_hud_elements(); @@ -1509,7 +1558,8 @@ void render_ui(F32 zoom_factor, int subfield) { if (!gDisconnected) { - LL_PROFILE_ZONE_NAMED_CATEGORY_UI("UI 3D"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_3D); + LL_PROFILE_ZONE_NAMED_CATEGORY_UI("UI 3D"); + LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_3D); LLGLState::checkStates(); render_ui_3d(); LLGLState::checkStates(); @@ -1519,10 +1569,16 @@ void render_ui(F32 zoom_factor, int subfield) render_disconnected_background(); } } + else + { + // Make sure particle effects disappear + LLHUDObject::renderAllForTimer(); + } if (render_ui) { - LL_PROFILE_ZONE_NAMED_CATEGORY_UI("UI 2D"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_2D); + LL_PROFILE_ZONE_NAMED_CATEGORY_UI("UI 2D"); + LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_2D); LLHUDObject::renderAll(); render_ui_2d(); } @@ -1642,10 +1698,11 @@ void render_ui_3d() stop_glerror(); gUIProgram.bind(); - gGL.color4f(1, 1, 1, 1); + gGL.color4f(1.f, 1.f, 1.f, 1.f); // Coordinate axes - if (gSavedSettings.getBOOL("ShowAxes")) + static LLCachedControl<bool> show_axes(gSavedSettings, "ShowAxes"); + if (show_axes()) { draw_axes(); } @@ -1665,7 +1722,7 @@ void render_ui_3d() LLHUDObject::renderAllForTimer(); } - stop_glerror(); + LOG_GLERROR("render_ui_3d()"); } void render_ui_2d() @@ -1707,7 +1764,7 @@ void render_ui_2d() gGL.pushMatrix(); S32 half_width = (gViewerWindow->getWorldViewWidthScaled() / 2); S32 half_height = (gViewerWindow->getWorldViewHeightScaled() / 2); - gGL.scalef(LLUI::getScaleFactor().mV[0], LLUI::getScaleFactor().mV[1], 1.f); + gGL.scalef(LLUI::getScaleFactor().mV[VX], LLUI::getScaleFactor().mV[VY], 1.f); gGL.translatef((F32)half_width, (F32)half_height, 0.f); F32 zoom = gAgentCamera.mHUDCurZoom; gGL.scalef(zoom,zoom,1.f); @@ -1715,7 +1772,7 @@ void render_ui_2d() gl_rect_2d(-half_width, half_height, half_width, -half_height, false); gGL.popMatrix(); gUIProgram.unbind(); - stop_glerror(); + LOG_GLERROR(""); } @@ -1726,10 +1783,10 @@ void render_ui_2d() LLView::sIsRectDirty = false; LLRect t_rect; - gPipeline.mUIScreen.bindTarget(); + gPipeline.mUIScreen.bindTarget("", 1); gGL.setColorMask(true, true); { - static const S32 pad = 8; + constexpr S32 pad = 8; LLView::sDirtyRect.mLeft -= pad; LLView::sDirtyRect.mRight += pad; @@ -1782,17 +1839,17 @@ void render_ui_2d() gViewerWindow->draw(); } - - // reset current origin for font rendering, in case of tiling render LLFontGL::sCurOrigin.set(0, 0); + + LOG_GLERROR("render_ui_2d()"); } void render_disconnected_background() { gUIProgram.bind(); - gGL.color4f(1,1,1,1); + gGL.color4f(1.f, 1.f, 1.f, 1.f); if (!gDisconnectedImagep && gDisconnected) { LL_INFOS() << "Loading last bitmap..." << LL_ENDL; @@ -1832,7 +1889,7 @@ void render_disconnected_background() raw->expandToPowerOfTwo(); - gDisconnectedImagep = LLViewerTextureManager::getLocalTexture(raw.get(), false ); + gDisconnectedImagep = LLViewerTextureManager::getLocalTexture(raw.get(), false); gStartTexture = gDisconnectedImagep; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } @@ -1867,6 +1924,5 @@ void render_disconnected_background() void display_cleanup() { - gDisconnectedImagep = NULL; + gDisconnectedImagep = nullptr; } - |
