summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-04 03:48:28 +0000
committerjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-04 03:48:28 +0000
commit9498e97cc3c1c4df7ad010e50d04191415f02a49 (patch)
tree59d0fbf3b600a75b489e2164745e1a0e7230f31d /gpu
parent2446ec6f42e485236553f60ecbf954bf57e20b6f (diff)
downloadchromium_src-9498e97cc3c1c4df7ad010e50d04191415f02a49.zip
chromium_src-9498e97cc3c1c4df7ad010e50d04191415f02a49.tar.gz
chromium_src-9498e97cc3c1c4df7ad010e50d04191415f02a49.tar.bz2
Add back in code to flush command buffer every 3 ms
Not having this code causes WebGL and NaCl apps to not flush as often as they should, and build up huge command buffers. BUG=152393 Review URL: https://chromiumcodereview.appspot.com/11031032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160070 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/client/cmd_buffer_helper.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc
index 3dcc318..d556b5e 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.cc
+++ b/gpu/command_buffer/client/cmd_buffer_helper.cc
@@ -10,6 +10,11 @@
namespace gpu {
+namespace {
+const int kCommandsPerFlushCheck = 100;
+const double kFlushDelay = 1.0 / (5.0 * 60.0);
+}
+
CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer)
: command_buffer_(command_buffer),
ring_buffer_id_(-1),
@@ -236,6 +241,16 @@ void CommandBufferHelper::WaitForAvailableEntries(int32 count) {
((get_offset() == last_put_sent_) ? 16 : 2);
if (pending > limit) {
Flush();
+ } else if (commands_issued_ % kCommandsPerFlushCheck == 0) {
+#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
+ // Allow this command buffer to be pre-empted by another if a "reasonable"
+ // amount of work has been done. On highend machines, this reduces the
+ // latency of GPU commands. However, on Android, this can cause the
+ // kernel to thrash between generating GPU commands and executing them.
+ clock_t current_time = clock();
+ if (current_time - last_flush_time_ > kFlushDelay * CLOCKS_PER_SEC)
+ Flush();
+#endif
}
}