History

Repost missed Presents with low priority

Zach Pomerantz committed 10 years ago

Commit 25deaf51 parent 2d4fd781 file · +18 −3Browse files

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

Unified · Split

interface/src/Application.cpp+18−3
@@ -1786,14 +1786,29 @@ bool Application::event(QEvent* event) { · 1785 unmodified lines
17861786 return false;
17871787 }
17881788
1789+ static bool justPresented = false;
17891790 if ((int)event->type() == (int)Present) {
1791+ if (justPresented) {
1792+ justPresented = false;
1793+
1794+ // If presentation is hogging the main thread, repost as low priority to avoid hanging the GUI.
1795+ // This has the effect of allowing presentation to exceed the paint budget by X times and
1796+ // only dropping every (1/X) frames, instead of every ceil(X) frames.
1797+ // (e.g. at a 60FPS target, painting for 17us would fall to 58.82FPS instead of 30FPS).
1798+ removePostedEvents(this, Present);
1799+ postEvent(this, new QEvent(static_cast<QEvent::Type>(Present)), Qt::LowEventPriority);
1800+ return true;
1801+ }
1802+
17901803 idle();
1791− removePostedEvents(this, Present); // clear pending presents so we don't clog the pipes
17921804 return true;
17931805 } else if ((int)event->type() == (int)Paint) {
1806+ justPresented = true;
17941807 paintGL();
17951808 return true;
1796− } else if ((int)event->type() == (int)Lambda) {
1809+ }
1810+
1811+ if ((int)event->type() == (int)Lambda) {
17971812 static_cast<LambdaEvent*>(event)->call();
17981813 return true;
17991814 }
@@ -2605,7 +2620,7 @@ void Application::idle() { · 805 unmodified lines
26052620 _renderedFrameIndex = displayPlugin->presentCount();
26062621
26072622 // Request a paint ASAP
2608− postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority);
2623+ postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority + 1);
26092624
26102625 // Update the deadlock watchdog
26112626 updateHeartbeat();