This commit is contained in:
Inusaito Sayori
2014-09-07 18:25:25 -04:00

View File

@@ -3702,37 +3702,55 @@ static LLFastTimer::DeclareTimer FTM_VLMANAGER("VL Manager");
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
void LLAppViewer::idle() void LLAppViewer::idle()
{ {
//LAZY_FT is just temporary.
#define LAZY_FT(str) static LLFastTimer::DeclareTimer ftm(str); LLFastTimer t(ftm)
pingMainloopTimeout("Main:Idle"); pingMainloopTimeout("Main:Idle");
// Update frame timers // Update frame timers
static LLTimer idle_timer; static LLTimer idle_timer;
LLFrameTimer::updateFrameTimeAndCount();
LLEventTimer::updateClass();
LLCriticalDamp::updateInterpolants();
LLMortician::updateClass();
F32 dt_raw = idle_timer.getElapsedTimeAndResetF32();
// Cap out-of-control frame times
// Too low because in menus, swapping, debugger, etc.
// Too high because idle called with no objects in view, etc.
const F32 MIN_FRAME_RATE = 1.f;
const F32 MAX_FRAME_RATE = 200.f;
F32 frame_rate_clamped = 1.f / dt_raw;
frame_rate_clamped = llclamp(frame_rate_clamped, MIN_FRAME_RATE, MAX_FRAME_RATE);
gFrameDTClamped = 1.f / frame_rate_clamped;
// Global frame timer
// Smoothly weight toward current frame
gFPSClamped = (frame_rate_clamped + (4.f * gFPSClamped)) / 5.f;
F32 qas = gSavedSettings.getF32("QuitAfterSeconds");
if (qas > 0.f)
{ {
if (gRenderStartTime.getElapsedTimeF32() > qas) LAZY_FT("updateFrameTimeAndCount");
LLFrameTimer::updateFrameTimeAndCount();
}
{
LAZY_FT("LLEventTimer::updateClass");
LLEventTimer::updateClass();
}
{
LAZY_FT("LLCriticalDamp::updateInterpolants");
LLCriticalDamp::updateInterpolants();
}
{
LAZY_FT("LLMortician::updateClass");
LLMortician::updateClass();
}
F32 dt_raw;
{
LAZY_FT("UpdateGlobalTimers");
dt_raw = idle_timer.getElapsedTimeAndResetF32();
// Cap out-of-control frame times
// Too low because in menus, swapping, debugger, etc.
// Too high because idle called with no objects in view, etc.
const F32 MIN_FRAME_RATE = 1.f;
const F32 MAX_FRAME_RATE = 200.f;
F32 frame_rate_clamped = 1.f / dt_raw;
frame_rate_clamped = llclamp(frame_rate_clamped, MIN_FRAME_RATE, MAX_FRAME_RATE);
gFrameDTClamped = 1.f / frame_rate_clamped;
// Global frame timer
// Smoothly weight toward current frame
gFPSClamped = (frame_rate_clamped + (4.f * gFPSClamped)) / 5.f;
F32 qas = gSavedSettings.getF32("QuitAfterSeconds");
if (qas > 0.f)
{ {
LLAppViewer::instance()->forceQuit(); if (gRenderStartTime.getElapsedTimeF32() > qas)
{
LLAppViewer::instance()->forceQuit();
}
} }
} }
@@ -3748,38 +3766,44 @@ void LLAppViewer::idle()
// Must wait until both have avatar object and mute list, so poll // Must wait until both have avatar object and mute list, so poll
// here. // here.
request_initial_instant_messages(); {
LAZY_FT("request_initial_instant_messages");
request_initial_instant_messages();
}
/////////////////////////////////// ///////////////////////////////////
// //
// Special case idle if still starting up // Special case idle if still starting up
// //
if (LLStartUp::getStartupState() < STATE_STARTED)
{ {
// Skip rest if idle startup returns false (essentially, no world yet) LAZY_FT("idle_startup");
gGLActive = TRUE; if (LLStartUp::getStartupState() < STATE_STARTED)
if (!idle_startup())
{ {
// Skip rest if idle startup returns false (essentially, no world yet)
gGLActive = TRUE;
if (!idle_startup())
{
gGLActive = FALSE;
return;
}
gGLActive = FALSE; gGLActive = FALSE;
return;
} }
gGLActive = FALSE;
} }
F32 yaw = 0.f; // radians F32 yaw = 0.f; // radians
if (!gDisconnected) if (!gDisconnected)
{ {
LLFastTimer t(FTM_NETWORK); LLFastTimer t(FTM_NETWORK);
// Update spaceserver timeinfo // Update spaceserver timeinfo
LLWorld::getInstance()->setSpaceTimeUSec(LLWorld::getInstance()->getSpaceTimeUSec() + (U32)(dt_raw * SEC_TO_MICROSEC)); LLWorld::getInstance()->setSpaceTimeUSec(LLWorld::getInstance()->getSpaceTimeUSec() + (U32)(dt_raw * SEC_TO_MICROSEC));
////////////////////////////////////// //////////////////////////////////////
// //
// Update simulator agent state // Update simulator agent state
// //
if (gSavedSettings.getBOOL("RotateRight")) if (gSavedSettings.getBOOL("RotateRight"))
{ {
@@ -3792,22 +3816,22 @@ void LLAppViewer::idle()
gAgentPilot.updateTarget(); gAgentPilot.updateTarget();
gAgent.autoPilot(&yaw); gAgent.autoPilot(&yaw);
} }
static LLFrameTimer agent_update_timer; static LLFrameTimer agent_update_timer;
static U32 last_control_flags; static U32 last_control_flags;
// When appropriate, update agent location to the simulator. // When appropriate, update agent location to the simulator.
F32 agent_update_time = agent_update_timer.getElapsedTimeF32(); F32 agent_update_time = agent_update_timer.getElapsedTimeF32();
BOOL flags_changed = gAgent.controlFlagsDirty() || (last_control_flags != gAgent.getControlFlags()); BOOL flags_changed = gAgent.controlFlagsDirty() || (last_control_flags != gAgent.getControlFlags());
if (flags_changed || (agent_update_time > (1.0f / (F32) AGENT_UPDATES_PER_SECOND))) if (flags_changed || (agent_update_time > (1.0f / (F32)AGENT_UPDATES_PER_SECOND)))
{ {
LLFastTimer t(FTM_AGENT_UPDATE); LLFastTimer t(FTM_AGENT_UPDATE);
// Send avatar and camera info // Send avatar and camera info
last_control_flags = gAgent.getControlFlags(); last_control_flags = gAgent.getControlFlags();
send_agent_update(TRUE); send_agent_update(TRUE);
agent_update_timer.reset(); agent_update_timer.reset();
} }
} }
////////////////////////////////////// //////////////////////////////////////
@@ -3816,6 +3840,7 @@ void LLAppViewer::idle()
// //
// //
{ {
LAZY_FT("Frame Stats");
// Initialize the viewer_stats_timer with an already elapsed time // Initialize the viewer_stats_timer with an already elapsed time
// of SEND_STATS_PERIOD so that the initial stats report will // of SEND_STATS_PERIOD so that the initial stats report will
// be sent immediately. // be sent immediately.
@@ -3859,26 +3884,26 @@ void LLAppViewer::idle()
} }
gFrameStats.addFrameData(); gFrameStats.addFrameData();
} }
if (!gDisconnected) if (!gDisconnected)
{ {
LLFastTimer t(FTM_NETWORK); LLFastTimer t(FTM_NETWORK);
//////////////////////////////////////////////// ////////////////////////////////////////////////
// //
// Network processing // Network processing
// //
// NOTE: Starting at this point, we may still have pointers to "dead" objects // NOTE: Starting at this point, we may still have pointers to "dead" objects
// floating throughout the various object lists. // floating throughout the various object lists.
// //
idleNameCache(); idleNameCache();
gFrameStats.start(LLFrameStats::IDLE_NETWORK); gFrameStats.start(LLFrameStats::IDLE_NETWORK);
stop_glerror(); stop_glerror();
idleNetwork(); idleNetwork();
stop_glerror(); stop_glerror();
gFrameStats.start(LLFrameStats::AGENT_MISC); gFrameStats.start(LLFrameStats::AGENT_MISC);
// Check for away from keyboard, kick idle agents. // Check for away from keyboard, kick idle agents.
idle_afk_check(); idle_afk_check();
@@ -3894,15 +3919,15 @@ void LLAppViewer::idle()
// //
{ {
// LLFastTimer t(FTM_IDLE_CB); LLFastTimer t(FTM_IDLE_CB);
// Do event notifications if necessary. Yes, we may want to move this elsewhere. // Do event notifications if necessary. Yes, we may want to move this elsewhere.
gEventNotifier.update(); gEventNotifier.update();
gIdleCallbacks.callFunctions(); gIdleCallbacks.callFunctions();
gInventory.idleNotifyObservers(); gInventory.idleNotifyObservers();
} }
// Metrics logging (LLViewerAssetStats, etc.) // Metrics logging (LLViewerAssetStats, etc.)
{ {
static LLTimer report_interval; static LLTimer report_interval;
@@ -3911,22 +3936,23 @@ void LLAppViewer::idle()
F32 seconds = report_interval.getElapsedTimeF32(); F32 seconds = report_interval.getElapsedTimeF32();
if (seconds >= app_metrics_interval) if (seconds >= app_metrics_interval)
{ {
metricsSend(! gDisconnected); LAZY_FT("metricsSend");
metricsSend(!gDisconnected);
report_interval.reset(); report_interval.reset();
} }
} }
if (gDisconnected) if (gDisconnected)
{ {
return; return;
} }
static const LLCachedControl<bool> hide_tp_screen("AscentDisableTeleportScreens",false); static const LLCachedControl<bool> hide_tp_screen("AscentDisableTeleportScreens", false);
LLAgent::ETeleportState tp_state = gAgent.getTeleportState(); LLAgent::ETeleportState tp_state = gAgent.getTeleportState();
if (!hide_tp_screen && tp_state != LLAgent::TELEPORT_NONE && tp_state != LLAgent::TELEPORT_LOCAL && tp_state != LLAgent::TELEPORT_PENDING) if (!hide_tp_screen && tp_state != LLAgent::TELEPORT_NONE && tp_state != LLAgent::TELEPORT_LOCAL && tp_state != LLAgent::TELEPORT_PENDING)
{ {
return; return;
} }
gViewerWindow->updateUI(); gViewerWindow->updateUI();
@@ -3936,11 +3962,12 @@ void LLAppViewer::idle()
/////////////////////////////////////// ///////////////////////////////////////
// Agent and camera movement // Agent and camera movement
// //
LLCoordGL current_mouse = gViewerWindow->getCurrentMouse(); LLCoordGL current_mouse = gViewerWindow->getCurrentMouse();
{ {
// After agent and camera moved, figure out if we need to // After agent and camera moved, figure out if we need to
// deselect objects. // deselect objects.
LAZY_FT("deselectAllIfTooFar");
LLSelectMgr::getInstance()->deselectAllIfTooFar(); LLSelectMgr::getInstance()->deselectAllIfTooFar();
} }
@@ -3955,15 +3982,15 @@ void LLAppViewer::idle()
} }
{ {
LLFastTimer t(FTM_OBJECTLIST_UPDATE); LLFastTimer t(FTM_OBJECTLIST_UPDATE);
gFrameStats.start(LLFrameStats::OBJECT_UPDATE); gFrameStats.start(LLFrameStats::OBJECT_UPDATE);
if (!(logoutRequestSent() && hasSavedFinalSnapshot())) if (!(logoutRequestSent() && hasSavedFinalSnapshot()))
{ {
gObjectList.update(gAgent, *LLWorld::getInstance()); gObjectList.update(gAgent, *LLWorld::getInstance());
} }
} }
////////////////////////////////////// //////////////////////////////////////
// //
// Deletes objects... // Deletes objects...
@@ -3982,7 +4009,7 @@ void LLAppViewer::idle()
LLDrawable::cleanupDeadDrawables(); LLDrawable::cleanupDeadDrawables();
} }
} }
// //
// After this point, in theory we should never see a dead object // After this point, in theory we should never see a dead object
// in the various object/drawable lists. // in the various object/drawable lists.
@@ -4016,25 +4043,29 @@ void LLAppViewer::idle()
LLFastTimer t(FTM_NETWORK); LLFastTimer t(FTM_NETWORK);
gVLManager.unpackData(); gVLManager.unpackData();
} }
///////////////////////// /////////////////////////
// //
// Update surfaces, and surface textures as well. // Update surfaces, and surface textures as well.
// //
LLWorld::getInstance()->updateVisibilities(); {
LAZY_FT("updateVisibilities");
LLWorld::getInstance()->updateVisibilities();
}
{ {
const F32 max_region_update_time = .001f; // 1ms const F32 max_region_update_time = .001f; // 1ms
LLFastTimer t(FTM_REGION_UPDATE); LLFastTimer t(FTM_REGION_UPDATE);
LLWorld::getInstance()->updateRegions(max_region_update_time); LLWorld::getInstance()->updateRegions(max_region_update_time);
} }
///////////////////////// /////////////////////////
// //
// Update weather effects // Update weather effects
// //
if (!gNoRender) if (!gNoRender)
{ {
LAZY_FT("Weather");
#if ENABLE_CLASSIC_CLOUDS #if ENABLE_CLASSIC_CLOUDS
LLWorld::getInstance()->updateClouds(gFrameDTClamped); LLWorld::getInstance()->updateClouds(gFrameDTClamped);
#endif #endif
@@ -4051,7 +4082,7 @@ void LLAppViewer::idle()
gWindVec = regionp->mWind.getVelocity(wind_position_region); gWindVec = regionp->mWind.getVelocity(wind_position_region);
// Compute average wind and use to drive motion of water // Compute average wind and use to drive motion of water
average_wind = regionp->mWind.getAverage(); average_wind = regionp->mWind.getAverage();
#if ENABLE_CLASSIC_CLOUDS #if ENABLE_CLASSIC_CLOUDS
F32 cloud_density = regionp->mCloudLayer.getDensityRegion(wind_position_region); F32 cloud_density = regionp->mCloudLayer.getDensityRegion(wind_position_region);
@@ -4066,13 +4097,13 @@ void LLAppViewer::idle()
} }
} }
stop_glerror(); stop_glerror();
////////////////////////////////////// //////////////////////////////////////
// //
// Sort and cull in the new renderer are moved to pipeline.cpp // Sort and cull in the new renderer are moved to pipeline.cpp
// Here, particles are updated and drawables are moved. // Here, particles are updated and drawables are moved.
// //
if (!gNoRender) if (!gNoRender)
{ {
LLFastTimer t(FTM_WORLD_UPDATE); LLFastTimer t(FTM_WORLD_UPDATE);
@@ -4084,26 +4115,38 @@ void LLAppViewer::idle()
} }
stop_glerror(); stop_glerror();
if (LLViewerJoystick::getInstance()->getOverrideCamera())
{ {
LLViewerJoystick::getInstance()->moveFlycam(); LAZY_FT("Move*");
} if (LLViewerJoystick::getInstance()->getOverrideCamera())
else
{
if (LLToolMgr::getInstance()->inBuildMode())
{ {
LLViewerJoystick::getInstance()->moveObjects(); LLViewerJoystick::getInstance()->moveFlycam();
} }
else
{
if (LLToolMgr::getInstance()->inBuildMode())
{
LLViewerJoystick::getInstance()->moveObjects();
}
gAgentCamera.updateCamera(); gAgentCamera.updateCamera();
}
} }
// update media focus // update media focus
LLViewerMediaFocus::getInstance()->update(); {
LAZY_FT("Media Focus");
LLViewerMediaFocus::getInstance()->update();
}
// Update marketplace // Update marketplace
LLMarketplaceInventoryImporter::update(); {
LLMarketplaceInventoryNotifications::update(); LAZY_FT("MPII::update");
LLMarketplaceInventoryImporter::update();
}
{
LAZY_FT("MPIN::update");
LLMarketplaceInventoryNotifications::update();
}
// objects and camera should be in sync, do LOD calculations now // objects and camera should be in sync, do LOD calculations now
{ {
@@ -4112,7 +4155,10 @@ void LLAppViewer::idle()
} }
// Execute deferred tasks. // Execute deferred tasks.
LLDeferredTaskList::instance().run(); {
LAZY_FT("DeferredTaskRun");
LLDeferredTaskList::instance().run();
}
// Handle shutdown process, for example, // Handle shutdown process, for example,
// wait for floaters to close, send quit message, // wait for floaters to close, send quit message,