diff options
| author | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2023-01-13 15:34:59 +0200 | 
|---|---|---|
| committer | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2023-01-13 15:43:37 +0200 | 
| commit | 1ecb7186fb33e8cf2d9598e5c3c3d0a8041ab1d2 (patch) | |
| tree | 7f661d27aaafa167d9b17c8e747f7408704eb96c /indra | |
| parent | 005b29b89f7a3cbe54d37b53c0061ee36c80d871 (diff) | |
SL-18973 Wait a bit after viewer regains focus before engaging the Preferred frame rate
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/newview/llperfstats.cpp | 24 | ||||
| -rw-r--r-- | indra/newview/llperfstats.h | 2 | ||||
| -rw-r--r-- | indra/newview/llviewercontrol.cpp | 1 | 
3 files changed, 26 insertions, 1 deletions
| diff --git a/indra/newview/llperfstats.cpp b/indra/newview/llperfstats.cpp index f3d433a622..334fdbbb6e 100644 --- a/indra/newview/llperfstats.cpp +++ b/indra/newview/llperfstats.cpp @@ -29,7 +29,9 @@  #include "llcontrol.h"  #include "pipeline.h"  #include "llagentcamera.h" +#include "llviewerwindow.h"  #include "llvoavatar.h" +#include "llwindow.h"  #include "llworld.h"  #include <llthread.h> @@ -41,9 +43,11 @@ namespace LLPerfStats      std::atomic<U64> renderAvatarMaxART_ns{(U64)(ART_UNLIMITED_NANOS)}; // highest render time we'll allow without culling features      bool belowTargetFPS{false};      U32 lastGlobalPrefChange{0};  +    U32 lastSleepedFrame{0};      std::mutex bufferToggleLock{};      F64 cpu_hertz{0.0}; +    U32 vsync_max_fps{60};      Tunables tunables; @@ -115,6 +119,7 @@ namespace LLPerfStats          LLPerfStats::tunables.userImpostorDistanceTuningEnabled = gSavedSettings.getBOOL("AutoTuneImpostorByDistEnabled");          LLPerfStats::tunables.userFPSTuningStrategy = gSavedSettings.getU32("TuningFPSStrategy");          LLPerfStats::tunables.userTargetFPS = gSavedSettings.getU32("TargetFPS"); +        LLPerfStats::tunables.vsyncEnabled = gSavedSettings.getBOOL("RenderVSyncEnable");          LLPerfStats::tunables.userTargetReflections = gSavedSettings.getS32("UserTargetReflections");          LLPerfStats::tunables.userAutoTuneEnabled = gSavedSettings.getBOOL("AutoTuneFPS");          LLPerfStats::tunables.userAutoTuneLock = gSavedSettings.getBOOL("AutoTuneLock"); @@ -129,7 +134,7 @@ namespace LLPerfStats          // create a thread to consume from the queue          tunables.initialiseFromSettings();          LLPerfStats::cpu_hertz = (F64)LLTrace::BlockTimer::countsPerSecond(); - +        LLPerfStats::vsync_max_fps = gViewerWindow->getWindow()->getRefreshRate();          t.detach();      } @@ -332,9 +337,26 @@ namespace LLPerfStats              // if at some point we need to, the averaging will need to take this into account or               // we forever think we're in the background due to residuals.              LL_DEBUGS() << "No tuning when not in focus" << LL_ENDL; +            LLPerfStats::lastSleepedFrame = gFrameCount;              return;          } +        U32 target_fps = tunables.vsyncEnabled ? std::min(LLPerfStats::vsync_max_fps, tunables.userTargetFPS) : tunables.userTargetFPS; + +        if(LLPerfStats::lastSleepedFrame != 0) +        { +            // wait a short time after viewer regains focus +            if((gFrameCount - LLPerfStats::lastSleepedFrame) > target_fps * 5) +            { +                LLPerfStats::lastSleepedFrame = 0; +            } +            else +            { +                return; +            } +        } +         +          // The frametime budget we have based on the target FPS selected          auto target_frame_time_raw = (U64)llround(LLPerfStats::cpu_hertz/(tunables.userTargetFPS==0?1:tunables.userTargetFPS));          // LL_INFOS() << "Effective FPS(raw):" << tot_frame_time_raw << " Target:" << target_frame_time_raw << LL_ENDL; diff --git a/indra/newview/llperfstats.h b/indra/newview/llperfstats.h index 7aa3e1491c..f00a28703c 100644 --- a/indra/newview/llperfstats.h +++ b/indra/newview/llperfstats.h @@ -61,6 +61,7 @@ namespace LLPerfStats      extern std::atomic<U64> renderAvatarMaxART_ns;      extern bool belowTargetFPS;      extern U32 lastGlobalPrefChange; +    extern U32 lastSleepedFrame;      extern std::mutex bufferToggleLock;      enum class ObjType_t{ @@ -133,6 +134,7 @@ namespace LLPerfStats          U32 userTargetFPS{0};          F32 userARTCutoffSliderValue{0};          S32 userTargetReflections{0}; +        bool vsyncEnabled{true};          void updateNonImposters(U32 nv){nonImpostors=nv; tuningFlag |= NonImpostors;};          void updateReflectionDetail(S32 nv){reflectionDetail=nv; tuningFlag |= ReflectionDetail;}; diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 407aacdd99..0bade93c45 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -267,6 +267,7 @@ static bool handleAnisotropicChanged(const LLSD& newvalue)  static bool handleVSyncChanged(const LLSD& newvalue)  { +    LLPerfStats::tunables.vsyncEnabled = newvalue.asBoolean();      gViewerWindow->getWindow()->toggleVSync(newvalue.asBoolean());      return true; | 
