Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Unified Diff: ui/ozone/platform/dri/gbm_surfaceless.cc

Issue 781683005: Ozone: Avoid blocking in Swapbuffer Call. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/ozone/platform/dri/gbm_surfaceless.cc
diff --git a/ui/ozone/platform/dri/gbm_surfaceless.cc b/ui/ozone/platform/dri/gbm_surfaceless.cc
index b3748445a369b53d97866b759da0455c26cc4c0d..4a995002cd27ba75dc82a64bf6a60960abeab09a 100644
--- a/ui/ozone/platform/dri/gbm_surfaceless.cc
+++ b/ui/ozone/platform/dri/gbm_surfaceless.cc
@@ -32,8 +32,20 @@ bool GbmSurfaceless::OnSwapBuffers() {
if (!controller)
return true;
- bool success = controller->SchedulePageFlip();
+ // Ensure any previous PageFlip events are handled. Doing this here also makes
+ // sure we don't throttle GPU in case it's still handling previous PageFlip
+ // request. This also makes sure we have at most two frames "in flight". Let's
+ // say we submitted all the commands for render buffer A to GPU and then
+ // requested the driver to display it. GPU might still be rendering buffer A,
+ // so the flip is still pending. However, we might already be busy at work
+ // submitting commands for render buffer B. Once done submitting commands for
+ // buffer B, we queue B for page flip, and continue render for frame C. If we
+ // try page flipping B without handling the events, the driver might return
+ // EBusy(in case it's still handling previous flip) here, and also we don't
+ // want to use any more than triple buffering. Thus, we sleep waiting for A
+ // to show up on the screen, before issuing a flip request for B.
controller->WaitForPageFlipEvent();
+ bool success = controller->SchedulePageFlip();
return success;
}

Powered by Google App Engine
This is Rietveld 408576698