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

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

Issue 869433003: (not for commit) Simplified multi-threaded Ganesh with lock on Flush only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 11 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') | gpu/command_buffer/client/gles2_implementation.h » ('j') | 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
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc
index a99201e4b36164ef01ef218d7651f6fe55e851b9..da458c19c8020486e3498501c3527873c21b9ed8 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.cc
+++ b/gpu/command_buffer/client/cmd_buffer_helper.cc
@@ -23,6 +23,7 @@ CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer)
token_(0),
put_(0),
last_put_sent_(0),
+ safe_put_point_(0),
#if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK)
commands_issued_(0),
#endif
@@ -64,12 +65,14 @@ void CommandBufferHelper::CalcImmediateEntries(int waiting_count) {
// Limit entry count to force early flushing.
if (flush_automatically_) {
+ // Cache last_put_sent, as it may change via SafeFlush().
+ int32 last_put_sent = last_put_sent_;
int32 limit =
total_entry_count_ /
- ((curr_get == last_put_sent_) ? kAutoFlushSmall : kAutoFlushBig);
+ ((curr_get == last_put_sent) ? kAutoFlushSmall : kAutoFlushBig);
int32 pending =
- (put_ + total_entry_count_ - last_put_sent_) % total_entry_count_;
+ (put_ + total_entry_count_ - last_put_sent) % total_entry_count_;
if (pending > 0 && pending >= limit) {
// Time to force flush.
@@ -146,6 +149,7 @@ bool CommandBufferHelper::WaitForGetOffsetInRange(int32 start, int32 end) {
}
void CommandBufferHelper::Flush() {
+ base::AutoLock scoped_lock(flush_lock_);
// Wrap put_ before flush.
if (put_ == total_entry_count_)
put_ = 0;
@@ -153,12 +157,30 @@ void CommandBufferHelper::Flush() {
if (usable() && last_put_sent_ != put_) {
last_flush_time_ = base::TimeTicks::Now();
last_put_sent_ = put_;
+ safe_put_point_ = put_;
command_buffer_->Flush(put_);
++flush_generation_;
CalcImmediateEntries(0);
}
}
+void CommandBufferHelper::SetSafeFlushPoint() {
+ base::AutoLock scoped_lock(flush_lock_);
+ safe_put_point_ = put_;
+ if (safe_put_point_ == total_entry_count_)
+ safe_put_point_ = 0;
+}
+
+void CommandBufferHelper::SafeFlush() {
+ base::AutoLock scoped_lock(flush_lock_);
+ if (usable() && last_put_sent_ != safe_put_point_) {
+ last_flush_time_ = base::TimeTicks::Now();
+ last_put_sent_ = safe_put_point_;
+ command_buffer_->Flush(safe_put_point_);
+ //++flush_generation_;
+ }
+}
+
#if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK)
void CommandBufferHelper::PeriodicFlushCheck() {
base::TimeTicks current_time = base::TimeTicks::Now();
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper.h ('k') | gpu/command_buffer/client/gles2_implementation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698