diff options
author | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-08 00:27:07 +0000 |
---|---|---|
committer | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-08 00:27:07 +0000 |
commit | 14eb04bc8bcd8fbfbdf50b50bcc3c453384b83a7 (patch) | |
tree | 9fcfd81b3b865a77721ffba42541817690ff95b7 /gpu | |
parent | 703901aef7daa1e92b2a715b2add66a63d37d01d (diff) | |
download | chromium_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')
-rw-r--r-- | gpu/command_buffer/client/cmd_buffer_helper.cc | 22 | ||||
-rw-r--r-- | gpu/command_buffer/client/cmd_buffer_helper.h | 2 |
2 files changed, 16 insertions, 8 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(); } } diff --git a/gpu/command_buffer/client/cmd_buffer_helper.h b/gpu/command_buffer/client/cmd_buffer_helper.h index a7c17ef..b6f45e2 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper.h +++ b/gpu/command_buffer/client/cmd_buffer_helper.h @@ -235,7 +235,7 @@ class CommandBufferHelper { int commands_issued_; // Using C runtime instead of base because this file cannot depend on base. - time_t last_flush_time_; + clock_t last_flush_time_; friend class CommandBufferHelperTest; DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |