History

Moved fps timing to beginning of paintGL

This should improve accuracy. However the fps displayed can still sometimes be slightly greater then the vsync, this is either due to timer accuracy problems or QTimer delay within OpenGLDisplayPlugin.

Anthony J. Thibault committed 11 years ago

Commit 31f361d1 parent c139b622 files · +20 −22Browse files

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

Unified · Split

interface/src/Application.cpp+19−21
@@ -1041,8 +1041,25 @@ void Application::initializeUi() { · 1040 unmodified lines
1041}1041}
1042 1042
1043void Application::paintGL() {1043void Application::paintGL() {
1044 _frameCount++;
1044 1045
1045 idle();1046 // update fps moving average
1047 uint64_t now = usecTimestampNow();
1048 static uint64_t lastPaintBegin{ now };
1049 uint64_t diff = now - lastPaintBegin;
1050 if (diff != 0) {
1051 _framesPerSecond.updateAverage((float)USECS_PER_SECOND / (float)diff);
1052 }
1053
1054 lastPaintBegin = now;
1055
1056 // update fps once a second
1057 if (now - _lastFramesPerSecondUpdate > USECS_PER_SECOND) {
1058 _fps = _framesPerSecond.getAverage();
1059 _lastFramesPerSecondUpdate = now;
1060 }
1061
1062 idle(now);
1046 1063
1047 PROFILE_RANGE(__FUNCTION__);1064 PROFILE_RANGE(__FUNCTION__);
1048 PerformanceTimer perfTimer("paintGL");1065 PerformanceTimer perfTimer("paintGL");
@@ -1318,24 +1335,6 @@ void Application::paintGL() { · 269 unmodified lines
1318 batch.resetStages();1335 batch.resetStages();
1319 });1336 });
1320 }1337 }
1321
1322 // update fps moving average
1323 {
1324 uint64_t now = usecTimestampNow();
1325 static uint64_t lastPaintEnd{ now };
1326 uint64_t diff = now - lastPaintEnd;
1327 if (diff != 0) {
1328 _framesPerSecond.updateAverage((float)USECS_PER_SECOND / (float)diff);
1329 }
1330 lastPaintEnd = now;
1331
1332 // update fps once a second
1333 if (now - _lastFramesPerSecondUpdate > USECS_PER_SECOND) {
1334 _fps = _framesPerSecond.getAverage();
1335 _lastFramesPerSecondUpdate = now;
1336 }
1337 _frameCount++;
1338 }
1339}1338}
1340 1339
1341void Application::runTests() {1340void Application::runTests() {
@@ -2107,7 +2106,7 @@ void Application::ping() { · 765 unmodified lines
2107 }2106 }
2108}2107}
2109 2108
2110void Application::idle() {2109void Application::idle(uint64_t now) {
2111 if (_aboutToQuit) {2110 if (_aboutToQuit) {
2112 return; // bail early, nothing to do here.2111 return; // bail early, nothing to do here.
2113 }2112 }
@@ -2130,7 +2129,6 @@ void Application::idle() { · 16 unmodified lines
2130 2129
2131 {2130 {
2132 PROFILE_RANGE(__FUNCTION__);2131 PROFILE_RANGE(__FUNCTION__);
2133 uint64_t now = usecTimestampNow();
2134 static uint64_t lastIdleStart{ now };2132 static uint64_t lastIdleStart{ now };
2135 uint64_t idleStartToStartDuration = now - lastIdleStart;2133 uint64_t idleStartToStartDuration = now - lastIdleStart;
2136 if (idleStartToStartDuration != 0) {2134 if (idleStartToStartDuration != 0) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t