Skip to content

Performance improvements and cleanup in llviewerdisplay.cpp #3938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion indra/llui/lltextbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class LLTextBox :
bool mShowCursorHand;

protected:
virtual std::string _getSearchText() const override
std::string _getSearchText() const override
{
return LLTextBase::_getSearchText() + mText.getString();
}
Expand Down
65 changes: 33 additions & 32 deletions indra/newview/llviewerdisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -120,18 +120,16 @@ 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;
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();
Expand Down Expand Up @@ -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())

Expand All @@ -233,7 +232,7 @@ 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");
Expand All @@ -242,7 +241,7 @@ void display_stats()
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");
Expand All @@ -252,7 +251,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");
Expand Down Expand Up @@ -568,8 +567,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++;
Expand Down Expand Up @@ -792,7 +793,7 @@ 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();

Expand Down Expand Up @@ -960,12 +961,12 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot)
gPipeline.mRT->deferredScreen.bindTarget();
if (gUseWireframe)
{
F32 g = 0.5f;
constexpr F32 g = 0.5f;
glClearColor(g, g, g, 1.f);
}
else
{
glClearColor(1, 0, 1, 1);
glClearColor(1.f, 0.f, 1.f, 1.f);
}
gPipeline.mRT->deferredScreen.clear();

Expand All @@ -979,11 +980,12 @@ 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"))
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
Expand Down Expand Up @@ -1197,7 +1199,7 @@ void display_cube_face()

gGL.setColorMask(true, true);

glClearColor(0, 0, 0, 0);
glClearColor(0.f, 0.f, 0.f, 0.f);
gPipeline.generateSunShadow(*LLViewerCamera::getInstance());

glClear(GL_DEPTH_BUFFER_BIT); // | GL_STENCIL_BUFFER_BIT);
Expand Down Expand Up @@ -1233,7 +1235,7 @@ void display_cube_face()
}
else
{
glClearColor(1, 0, 1, 1);
glClearColor(1.f, 0.f, 1.f, 1.f);
}
gPipeline.mRT->deferredScreen.clear();

Expand Down Expand Up @@ -1274,11 +1276,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();
Expand Down Expand Up @@ -1638,10 +1641,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();
}
Expand Down Expand Up @@ -1701,7 +1705,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);
Expand All @@ -1723,7 +1727,7 @@ void render_ui_2d()
gPipeline.mUIScreen.bindTarget();
gGL.setColorMask(true, true);
{
static const S32 pad = 8;
constexpr S32 pad = 8;

LLView::sDirtyRect.mLeft -= pad;
LLView::sDirtyRect.mRight += pad;
Expand Down Expand Up @@ -1776,8 +1780,6 @@ void render_ui_2d()
gViewerWindow->draw();
}



// reset current origin for font rendering, in case of tiling render
LLFontGL::sCurOrigin.set(0, 0);
}
Expand All @@ -1786,7 +1788,7 @@ 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;
Expand Down Expand Up @@ -1826,7 +1828,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);
}
Expand Down Expand Up @@ -1861,6 +1863,5 @@ void render_disconnected_background()

void display_cleanup()
{
gDisconnectedImagep = NULL;
gDisconnectedImagep = nullptr;
}

Loading