History

Rebuild on a new branch after original stopped building.

Howard Stearns committed 10 years ago

Commit fee13d41 parent 9a651c69 files · +127 −5Browse files

Showing the changes to interface/src/Application.cpp (1 of 9 files). Show all

Unified · Split

interface/src/Application.cpp+18−1
@@ -1061,8 +1061,10 @@ void Application::paintGL() { · 1060 unmodified lines
10611061 uint64_t now = usecTimestampNow();
10621062 static uint64_t lastPaintBegin{ now };
10631063 uint64_t diff = now - lastPaintBegin;
1064+ float instantaneousFps = 0.0f;
10641065 if (diff != 0) {
1065− _framesPerSecond.updateAverage((float)USECS_PER_SECOND / (float)diff);
1066+ instantaneousFps = (float)USECS_PER_SECOND / (float)diff;
1067+ _framesPerSecond.updateAverage(_lastInstantaneousFps);
10661068 }
10671069
10681070 lastPaintBegin = now;
@@ -1326,6 +1328,7 @@ void Application::paintGL() { · 257 unmodified lines
13261328 // Ensure all operations from the previous context are complete before we try to read the fbo
13271329 glWaitSync(sync, 0, GL_TIMEOUT_IGNORED);
13281330 glDeleteSync(sync);
1331+ uint64_t displayStart = usecTimestampNow();
13291332
13301333 {
13311334 PROFILE_RANGE(__FUNCTION__ "/pluginDisplay");
@@ -1338,6 +1341,20 @@ void Application::paintGL() { · 6 unmodified lines
13381341 PerformanceTimer perfTimer("bufferSwap");
13391342 displayPlugin->finishFrame();
13401343 }
1344+ uint64_t displayEnd = usecTimestampNow();
1345+ // Store together, without Application::idle happening in between setting fps and period.
1346+ _lastInstantaneousFps = instantaneousFps;
1347+ const float displayPeriodUsec = (float)(displayEnd - displayStart); // usecs
1348+ _lastPaintWait = displayPeriodUsec / (float)USECS_PER_SECOND;
1349+ const float targetPeriod = isHMDMode() ? 1.0f/75.0f : 1.0f/60.0f;
1350+ const float actualPeriod = 1.0f / instantaneousFps;
1351+ const float nSyncsByFrameRate = round(actualPeriod / targetPeriod);
1352+ const float accuracyAllowance = 0.0005;
1353+ const float nSyncsByPaintWait = floor((_lastPaintWait + accuracyAllowance) / targetPeriod); // sometimes paint goes over and it isn't reflected in actualPeriod
1354+ const float modularPeriod = (nSyncsByFrameRate + nSyncsByPaintWait) * targetPeriod;
1355+ const float deducedNonVSyncPeriod = modularPeriod - _lastPaintWait;
1356+ _lastDeducedNonVSyncFps = 1.0f / deducedNonVSyncPeriod;
1357+
13411358 }
13421359
13431360 {