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
1061 uint64_t now = usecTimestampNow();1061 uint64_t now = usecTimestampNow();
1062 static uint64_t lastPaintBegin{ now };1062 static uint64_t lastPaintBegin{ now };
1063 uint64_t diff = now - lastPaintBegin;1063 uint64_t diff = now - lastPaintBegin;
1064 float instantaneousFps = 0.0f;
1064 if (diff != 0) {1065 if (diff != 0) {
1065 _framesPerSecond.updateAverage((float)USECS_PER_SECOND / (float)diff);1066 instantaneousFps = (float)USECS_PER_SECOND / (float)diff;
1067 _framesPerSecond.updateAverage(_lastInstantaneousFps);
1066 }1068 }
1067 1069
1068 lastPaintBegin = now;1070 lastPaintBegin = now;
@@ -1326,6 +1328,7 @@ void Application::paintGL() { · 257 unmodified lines
1326 // Ensure all operations from the previous context are complete before we try to read the fbo1328 // Ensure all operations from the previous context are complete before we try to read the fbo
1327 glWaitSync(sync, 0, GL_TIMEOUT_IGNORED);1329 glWaitSync(sync, 0, GL_TIMEOUT_IGNORED);
1328 glDeleteSync(sync);1330 glDeleteSync(sync);
1331 uint64_t displayStart = usecTimestampNow();
1329 1332
1330 {1333 {
1331 PROFILE_RANGE(__FUNCTION__ "/pluginDisplay");1334 PROFILE_RANGE(__FUNCTION__ "/pluginDisplay");
@@ -1338,6 +1341,20 @@ void Application::paintGL() { · 6 unmodified lines
1338 PerformanceTimer perfTimer("bufferSwap");1341 PerformanceTimer perfTimer("bufferSwap");
1339 displayPlugin->finishFrame();1342 displayPlugin->finishFrame();
1340 }1343 }
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
1341 }1358 }
1342 1359
1343 {1360 {