summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/client/cmd_buffer_helper.cc
diff options
context:
space:
mode:
authorjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-08 00:27:07 +0000
committerjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-08 00:27:07 +0000
commit14eb04bc8bcd8fbfbdf50b50bcc3c453384b83a7 (patch)
tree9fcfd81b3b865a77721ffba42541817690ff95b7 /gpu/command_buffer/client/cmd_buffer_helper.cc
parent703901aef7daa1e92b2a715b2add66a63d37d01d (diff)
downloadchromium_src-14eb04bc8bcd8fbfbdf50b50bcc3c453384b83a7.zip
chromium_src-14eb04bc8bcd8fbfbdf50b50bcc3c453384b83a7.tar.gz
chromium_src-14eb04bc8bcd8fbfbdf50b50bcc3c453384b83a7.tar.bz2
Fix early flush logic.
Use clock() instead of time() to determine how much time has passed, as that likely has a higher resolution. Also add back in the old flush logic, as a backup in case clock() doesn't have a high-enough resolution to cause it to flush before the entire command buffer is used up. BUG= TEST= Review URL: http://codereview.chromium.org/7789023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/client/cmd_buffer_helper.cc')
-rw-r--r--gpu/command_buffer/client/cmd_buffer_helper.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc
index bd44431..6328923 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.cc
+++ b/gpu/command_buffer/client/cmd_buffer_helper.cc
@@ -52,14 +52,14 @@ CommandBufferHelper::~CommandBufferHelper() {
}
bool CommandBufferHelper::FlushSync() {
- time(&last_flush_time_);
+ last_flush_time_ = clock();
last_put_sent_ = put_;
CommandBuffer::State state = command_buffer_->FlushSync(put_, get_offset());
return state.error == error::kNoError;
}
void CommandBufferHelper::Flush() {
- time(&last_flush_time_);
+ last_flush_time_ = clock();
last_put_sent_ = put_;
command_buffer_->Flush(put_);
}
@@ -152,11 +152,19 @@ void CommandBufferHelper::WaitForAvailableEntries(int32 count) {
return;
}
}
- // 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)
+ // 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_offset() == last_put_sent_) ? 16 : 2);
+ if (pending > limit) {
+ Flush();
+ } else if (commands_issued_ % kCommandsPerFlushCheck == 0) {
+ // Allow this command buffer to be pre-empted by another if a "reasonable"
+ // amount of work has been done.
+ clock_t current_time = clock();
+ if (current_time - last_flush_time_ > kFlushDelay * CLOCKS_PER_SEC)
Flush();
}
}