Skip to content

Commit b81be8e

Browse files
Ansarielakleshchev
authored andcommitted
Performance improvements and cleanup in llviewerdisplay.cpp
# Conflicts: # indra/newview/llviewerdisplay.cpp
1 parent ea96f7a commit b81be8e

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

indra/newview/llviewerdisplay.cpp

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@
100100
extern LLPointer<LLViewerTexture> gStartTexture;
101101
extern bool gShiftFrame;
102102

103-
LLPointer<LLViewerTexture> gDisconnectedImagep = NULL;
103+
LLPointer<LLViewerTexture> gDisconnectedImagep = nullptr;
104104

105105
// used to toggle renderer back on after teleport
106106
bool gTeleportDisplay = false;
107107
LLFrameTimer gTeleportDisplayTimer;
108108
LLFrameTimer gTeleportArrivalTimer;
109-
const F32 RESTORE_GL_TIME = 5.f; // Wait this long while reloading textures before we raise the curtain
109+
constexpr F32 RESTORE_GL_TIME = 5.f; // Wait this long while reloading textures before we raise the curtain
110110

111111
bool gForceRenderLandFence = false;
112112
bool gDisplaySwapBuffers = false;
@@ -120,18 +120,16 @@ bool gSnapshotNoPost = false;
120120
bool gShaderProfileFrame = false;
121121

122122
// This is how long the sim will try to teleport you before giving up.
123-
const F32 TELEPORT_EXPIRY = 15.0f;
123+
constexpr F32 TELEPORT_EXPIRY = 15.0f;
124124
// Additional time (in seconds) to wait per attachment
125-
const F32 TELEPORT_EXPIRY_PER_ATTACHMENT = 3.f;
125+
constexpr F32 TELEPORT_EXPIRY_PER_ATTACHMENT = 3.f;
126126

127127
U32 gRecentFrameCount = 0; // number of 'recent' frames
128128
LLFrameTimer gRecentFPSTime;
129129
LLFrameTimer gRecentMemoryTime;
130130
LLFrameTimer gAssetStorageLogTime;
131131

132132
// Rendering stuff
133-
void pre_show_depth_buffer();
134-
void post_show_depth_buffer();
135133
void render_ui(F32 zoom_factor = 1.f, int subfield = 0);
136134
void swap();
137135
void render_hud_attachments();
@@ -212,7 +210,8 @@ void display_update_camera()
212210
F32 final_far = gAgentCamera.mDrawDistance;
213211
if (gCubeSnapshot)
214212
{
215-
final_far = gSavedSettings.getF32("RenderReflectionProbeDrawDistance");
213+
static LLCachedControl<F32> reflection_probe_draw_distance(gSavedSettings, "RenderReflectionProbeDrawDistance", 64.f);
214+
final_far = reflection_probe_draw_distance();
216215
}
217216
else if (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode())
218217

@@ -233,7 +232,7 @@ void display_update_camera()
233232
void display_stats()
234233
{
235234
LL_PROFILE_ZONE_SCOPED;
236-
const F32 FPS_LOG_FREQUENCY = 10.f;
235+
constexpr F32 FPS_LOG_FREQUENCY = 10.f;
237236
if (gRecentFPSTime.getElapsedTimeF32() >= FPS_LOG_FREQUENCY)
238237
{
239238
LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("DS - FPS");
@@ -242,7 +241,7 @@ void display_stats()
242241
gRecentFrameCount = 0;
243242
gRecentFPSTime.reset();
244243
}
245-
F32 mem_log_freq = gSavedSettings.getF32("MemoryLogFrequency");
244+
static LLCachedControl<F32> mem_log_freq(gSavedSettings, "MemoryLogFrequency", 600.f);
246245
if (mem_log_freq > 0.f && gRecentMemoryTime.getElapsedTimeF32() >= mem_log_freq)
247246
{
248247
LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("DS - Memory");
@@ -252,7 +251,7 @@ void display_stats()
252251
LLMemory::logMemoryInfo(true) ;
253252
gRecentMemoryTime.reset();
254253
}
255-
const F32 ASSET_STORAGE_LOG_FREQUENCY = 60.f;
254+
constexpr F32 ASSET_STORAGE_LOG_FREQUENCY = 60.f;
256255
if (gAssetStorageLogTime.getElapsedTimeF32() >= ASSET_STORAGE_LOG_FREQUENCY)
257256
{
258257
LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("DS - Asset Storage");
@@ -568,8 +567,10 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot)
568567

569568
LLImageGL::updateStats(gFrameTimeSeconds);
570569

571-
LLVOAvatar::sRenderName = gSavedSettings.getS32("AvatarNameTagMode");
572-
LLVOAvatar::sRenderGroupTitles = (gSavedSettings.getBOOL("NameTagShowGroupTitles") && gSavedSettings.getS32("AvatarNameTagMode"));
570+
static LLCachedControl<S32> avatar_name_tag_mode(gSavedSettings, "AvatarNameTagMode", 1);
571+
static LLCachedControl<bool> name_tag_show_group_titles(gSavedSettings, "NameTagShowGroupTitles", true);
572+
LLVOAvatar::sRenderName = avatar_name_tag_mode;
573+
LLVOAvatar::sRenderGroupTitles = name_tag_show_group_titles && avatar_name_tag_mode > 0;
573574

574575
gPipeline.mBackfaceCull = true;
575576
gFrameCount++;
@@ -792,7 +793,7 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot)
792793
}
793794

794795
gGL.setColorMask(true, true);
795-
glClearColor(0,0,0,0);
796+
glClearColor(0.f, 0.f, 0.f, 0.f);
796797

797798
LLGLState::checkStates();
798799

@@ -960,7 +961,7 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot)
960961
gPipeline.mRT->deferredScreen.bindTarget();
961962
if (gUseWireframe)
962963
{
963-
F32 g = 0.5f;
964+
constexpr F32 g = 0.5f;
964965
glClearColor(g, g, g, 1.f);
965966
}
966967
else
@@ -979,11 +980,12 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot)
979980
LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("display - 5")
980981
LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
981982

982-
if (gSavedSettings.getBOOL("RenderDepthPrePass"))
983+
static LLCachedControl<bool> render_depth_pre_pass(gSavedSettings, "RenderDepthPrePass", false);
984+
if (render_depth_pre_pass)
983985
{
984986
gGL.setColorMask(false, false);
985987

986-
static const U32 types[] = {
988+
constexpr U32 types[] = {
987989
LLRenderPass::PASS_SIMPLE,
988990
LLRenderPass::PASS_FULLBRIGHT,
989991
LLRenderPass::PASS_SHINY
@@ -1197,7 +1199,7 @@ void display_cube_face()
11971199

11981200
gGL.setColorMask(true, true);
11991201

1200-
glClearColor(0, 0, 0, 0);
1202+
glClearColor(0.f, 0.f, 0.f, 0.f);
12011203
gPipeline.generateSunShadow(*LLViewerCamera::getInstance());
12021204

12031205
glClear(GL_DEPTH_BUFFER_BIT); // | GL_STENCIL_BUFFER_BIT);
@@ -1233,7 +1235,7 @@ void display_cube_face()
12331235
}
12341236
else
12351237
{
1236-
glClearColor(1, 0, 1, 1);
1238+
glClearColor(1.f, 0.f, 1.f, 1.f);
12371239
}
12381240
gPipeline.mRT->deferredScreen.clear();
12391241

@@ -1274,11 +1276,12 @@ void render_hud_attachments()
12741276
{
12751277
LLPipeline::sRenderingHUDs = true;
12761278
LLCamera hud_cam = *LLViewerCamera::getInstance();
1277-
hud_cam.setOrigin(-1.f,0,0);
1278-
hud_cam.setAxes(LLVector3(1,0,0), LLVector3(0,1,0), LLVector3(0,0,1));
1279+
hud_cam.setOrigin(-1.f, 0.f, 0.f);
1280+
hud_cam.setAxes(LLVector3(1.f, 0.f, 0.f), LLVector3(0.f, 1.f, 0.f), LLVector3(0.f, 0.f, 1.f));
12791281
LLViewerCamera::updateFrustumPlanes(hud_cam, true);
12801282

1281-
bool render_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) && gSavedSettings.getBOOL("RenderHUDParticles");
1283+
static LLCachedControl<bool> render_hud_particles(gSavedSettings, "RenderHUDParticles", false);
1284+
bool render_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) && render_hud_particles;
12821285

12831286
//only render hud objects
12841287
gPipeline.pushRenderTypeMask();
@@ -1638,10 +1641,11 @@ void render_ui_3d()
16381641
stop_glerror();
16391642

16401643
gUIProgram.bind();
1641-
gGL.color4f(1, 1, 1, 1);
1644+
gGL.color4f(1.f, 1.f, 1.f, 1.f);
16421645

16431646
// Coordinate axes
1644-
if (gSavedSettings.getBOOL("ShowAxes"))
1647+
static LLCachedControl<bool> show_axes(gSavedSettings, "ShowAxes");
1648+
if (show_axes())
16451649
{
16461650
draw_axes();
16471651
}
@@ -1701,7 +1705,7 @@ void render_ui_2d()
17011705
gGL.pushMatrix();
17021706
S32 half_width = (gViewerWindow->getWorldViewWidthScaled() / 2);
17031707
S32 half_height = (gViewerWindow->getWorldViewHeightScaled() / 2);
1704-
gGL.scalef(LLUI::getScaleFactor().mV[0], LLUI::getScaleFactor().mV[1], 1.f);
1708+
gGL.scalef(LLUI::getScaleFactor().mV[VX], LLUI::getScaleFactor().mV[VY], 1.f);
17051709
gGL.translatef((F32)half_width, (F32)half_height, 0.f);
17061710
F32 zoom = gAgentCamera.mHUDCurZoom;
17071711
gGL.scalef(zoom,zoom,1.f);
@@ -1723,7 +1727,7 @@ void render_ui_2d()
17231727
gPipeline.mUIScreen.bindTarget();
17241728
gGL.setColorMask(true, true);
17251729
{
1726-
static const S32 pad = 8;
1730+
constexpr S32 pad = 8;
17271731

17281732
LLView::sDirtyRect.mLeft -= pad;
17291733
LLView::sDirtyRect.mRight += pad;
@@ -1776,8 +1780,6 @@ void render_ui_2d()
17761780
gViewerWindow->draw();
17771781
}
17781782

1779-
1780-
17811783
// reset current origin for font rendering, in case of tiling render
17821784
LLFontGL::sCurOrigin.set(0, 0);
17831785
}
@@ -1786,7 +1788,7 @@ void render_disconnected_background()
17861788
{
17871789
gUIProgram.bind();
17881790

1789-
gGL.color4f(1,1,1,1);
1791+
gGL.color4f(1.f, 1.f, 1.f, 1.f);
17901792
if (!gDisconnectedImagep && gDisconnected)
17911793
{
17921794
LL_INFOS() << "Loading last bitmap..." << LL_ENDL;
@@ -1826,7 +1828,7 @@ void render_disconnected_background()
18261828

18271829

18281830
raw->expandToPowerOfTwo();
1829-
gDisconnectedImagep = LLViewerTextureManager::getLocalTexture(raw.get(), false );
1831+
gDisconnectedImagep = LLViewerTextureManager::getLocalTexture(raw.get(), false);
18301832
gStartTexture = gDisconnectedImagep;
18311833
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
18321834
}
@@ -1861,6 +1863,5 @@ void render_disconnected_background()
18611863

18621864
void display_cleanup()
18631865
{
1864-
gDisconnectedImagep = NULL;
1866+
gDisconnectedImagep = nullptr;
18651867
}
1866-

0 commit comments

Comments
 (0)