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

Unified Diff: chrome/renderer/ggl/ggl.cc

Issue 5317007: Add flow control between renderer and GPU processes, and, on Mac OS X,... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « chrome/gpu/gpu_thread.cc ('k') | gpu/command_buffer/service/gpu_processor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/ggl/ggl.cc
===================================================================
--- chrome/renderer/ggl/ggl.cc (revision 67289)
+++ chrome/renderer/ggl/ggl.cc (working copy)
@@ -34,6 +34,12 @@
// creation attributes.
const int32 kTransferBufferSize = 1024 * 1024;
+// TODO(kbr) / TODO(apatrick): determine the best number of pending frames
+// in the general case. On Mac OS X it seems we really want this to be 1,
nduca 2010/11/26 19:07:37 Just checking my understanding, the 1 is because t
Ken Russell (switch to Gerrit) 2010/11/26 20:23:10 No. It's because if we increase it to 2 then the r
+// because otherwise the renderer process produces frames that do not
+// actually reach the screen.
+const int kMaxFramesPending = 1;
+
// Singleton used to initialize and terminate the gles2 library.
class GLES2Initializer {
public:
@@ -132,6 +138,8 @@
gpu::gles2::GLES2Implementation* gles2_implementation_;
gfx::Size size_;
+ int32 swap_buffer_tokens_[kMaxFramesPending];
+
Error last_error_;
DISALLOW_COPY_AND_ASSIGN(Context);
@@ -147,6 +155,8 @@
gles2_implementation_(NULL),
last_error_(SUCCESS) {
DCHECK(channel);
+ for (int i = 0; i < kMaxFramesPending; ++i)
+ swap_buffer_tokens_[i] = -1;
}
Context::~Context() {
@@ -376,7 +386,18 @@
if (command_buffer_->GetLastState().error != gpu::error::kNoError)
return false;
+ // Throttle until there are not too many frames pending.
+ if (swap_buffer_tokens_[0] != -1) {
+ gles2_helper_->WaitForToken(swap_buffer_tokens_[0]);
+ }
+
gles2_implementation_->SwapBuffers();
+
+ // Insert a new token to throttle against for this frame.
+ for (int i = 0; i < kMaxFramesPending - 1; ++i)
+ swap_buffer_tokens_[i] = swap_buffer_tokens_[i + 1];
+ swap_buffer_tokens_[kMaxFramesPending - 1] = gles2_helper_->InsertToken();
+
return true;
}
« no previous file with comments | « chrome/gpu/gpu_thread.cc ('k') | gpu/command_buffer/service/gpu_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698