summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/client
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/command_buffer/client')
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc6
-rw-r--r--gpu/command_buffer/client/gles2_implementation.h6
2 files changed, 12 insertions, 0 deletions
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 64bcbe2..4e75be9 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -651,7 +651,13 @@ void GLES2Implementation::Finish() {
}
void GLES2Implementation::SwapBuffers() {
+ // Wait if this would add too many swap buffers.
+ if (swap_buffers_tokens_.size() == kMaxSwapBuffers) {
+ helper_->WaitForToken(swap_buffers_tokens_.front());
+ swap_buffers_tokens_.pop();
+ }
helper_->SwapBuffers();
+ swap_buffers_tokens_.push(helper_->InsertToken());
Flush();
}
diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h
index d56e32e..f3f202e 100644
--- a/gpu/command_buffer/client/gles2_implementation.h
+++ b/gpu/command_buffer/client/gles2_implementation.h
@@ -8,6 +8,7 @@
#include <GLES2/gl2.h>
#include <map>
+#include <queue>
#include <set>
#include <string>
#include <vector>
@@ -70,6 +71,9 @@ class GLES2Implementation {
static const GLuint kClientSideArrayId = 0xFEDCBA98u;
static const GLuint kClientSideElementArrayId = 0xFEDCBA99u;
+ // Number of swap buffers allowed before waiting.
+ static const size_t kMaxSwapBuffers = 2;
+
GLES2Implementation(
GLES2CmdHelper* helper,
size_t transfer_buffer_size,
@@ -347,6 +351,8 @@ class GLES2Implementation {
uint32 result_shm_offset_;
std::string last_error_;
+ std::queue<int32> swap_buffers_tokens_;
+
// pack alignment as last set by glPixelStorei
GLint pack_alignment_;