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
10411041 }
10421042
10431043 void Application::paintGL() {
1044+ _frameCount++;
10441045
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);
10461063
10471064 PROFILE_RANGE(__FUNCTION__);
10481065 PerformanceTimer perfTimer("paintGL");
@@ -1318,24 +1335,6 @@ void Application::paintGL() { · 269 unmodified lines
13181335 batch.resetStages();
13191336 });
13201337 }
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− }
13391338 }
13401339
13411340 void Application::runTests() {
@@ -2107,7 +2106,7 @@ void Application::ping() { · 765 unmodified lines
21072106 }
21082107 }
21092108
2110−void Application::idle() {
2109+void Application::idle(uint64_t now) {
21112110 if (_aboutToQuit) {
21122111 return; // bail early, nothing to do here.
21132112 }
@@ -2130,7 +2129,6 @@ void Application::idle() { · 16 unmodified lines
21302129
21312130 {
21322131 PROFILE_RANGE(__FUNCTION__);
2133− uint64_t now = usecTimestampNow();
21342132 static uint64_t lastIdleStart{ now };
21352133 uint64_t idleStartToStartDuration = now - lastIdleStart;
21362134 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