 Chromium Code Reviews
 Chromium Code Reviews 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/
    
  
    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/| 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, | 
| +// because otherwise the renderer process produces frames that do not | 
| +// actually reach the screen. | 
| 
Nico
2010/11/24 23:43:29
True, but the browser process would show the lates
 
Ken Russell (switch to Gerrit)
2010/11/25 01:02:08
Correct.
 | 
| +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; | 
| } |