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

Unified Diff: gpu/command_buffer/client/cmd_buffer_helper.cc

Issue 7313032: Cooperatively round robin GPU command buffers. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months 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 | « gpu/command_buffer/client/cmd_buffer_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/client/cmd_buffer_helper.cc
===================================================================
--- gpu/command_buffer/client/cmd_buffer_helper.cc (revision 91787)
+++ gpu/command_buffer/client/cmd_buffer_helper.cc (working copy)
@@ -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),
entries_(NULL),
@@ -19,7 +24,9 @@
last_token_read_(-1),
get_(0),
put_(0),
- last_put_sent_(0) {
+ last_put_sent_(0),
+ commands_issued_(0),
+ last_flush_time_(0) {
}
bool CommandBufferHelper::Initialize(int32 ring_buffer_size) {
@@ -48,6 +55,7 @@
}
bool CommandBufferHelper::FlushSync() {
+ time(&last_flush_time_);
last_put_sent_ = put_;
CommandBuffer::State state = command_buffer_->FlushSync(put_, get_);
SynchronizeState(state);
@@ -55,6 +63,7 @@
}
void CommandBufferHelper::Flush() {
+ time(&last_flush_time_);
last_put_sent_ = put_;
command_buffer_->Flush(put_);
}
@@ -152,17 +161,17 @@
return;
}
}
- // Force a flush if the buffer is getting half full, or even earlier if the
- // reader is known to be idle.
- int32 pending =
- (put_ + usable_entry_count_ - last_put_sent_) % usable_entry_count_;
- int32 limit = usable_entry_count_ / ((get_ == last_put_sent_) ? 16 : 2);
- if (pending > limit) {
- Flush();
+ // Allow this command buffer to be pre-empted by another if a "reasonable"
+ // amount of work has been done.
+ if (commands_issued_ % kCommandsPerFlushCheck == 0) {
+ clock_t current_time = time(NULL);
+ if (difftime(current_time, last_flush_time_) > kFlushDelay)
+ Flush();
}
}
CommandBufferEntry* CommandBufferHelper::GetSpace(uint32 entries) {
+ ++commands_issued_;
WaitForAvailableEntries(entries);
CommandBufferEntry* space = &entries_[put_];
put_ += entries;
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698