OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file contains the implementation of the command buffer helper class. | 5 // This file contains the implementation of the command buffer helper class. |
6 | 6 |
7 #include "gpu/command_buffer/client/cmd_buffer_helper.h" | 7 #include "gpu/command_buffer/client/cmd_buffer_helper.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "gpu/command_buffer/common/command_buffer.h" | 11 #include "gpu/command_buffer/common/command_buffer.h" |
12 #include "gpu/command_buffer/common/trace_event.h" | 12 #include "gpu/command_buffer/common/trace_event.h" |
13 | 13 |
14 namespace gpu { | 14 namespace gpu { |
15 | 15 |
16 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) | 16 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) |
17 : command_buffer_(command_buffer), | 17 : command_buffer_(command_buffer), |
18 ring_buffer_id_(-1), | 18 ring_buffer_id_(-1), |
19 ring_buffer_size_(0), | 19 ring_buffer_size_(0), |
20 entries_(NULL), | 20 entries_(NULL), |
21 total_entry_count_(0), | 21 total_entry_count_(0), |
22 immediate_entry_count_(0), | 22 immediate_entry_count_(0), |
23 token_(0), | 23 token_(0), |
24 put_(0), | 24 put_(0), |
25 last_put_sent_(0), | 25 last_put_sent_(0), |
| 26 last_shallow_put_sent_(0), |
26 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) | 27 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) |
27 commands_issued_(0), | 28 commands_issued_(0), |
28 #endif | 29 #endif |
29 usable_(true), | 30 usable_(true), |
30 context_lost_(false), | 31 context_lost_(false), |
31 flush_automatically_(true), | 32 flush_automatically_(true), |
32 flush_generation_(0) { | 33 flush_generation_(0) { |
33 } | 34 } |
34 | 35 |
35 void CommandBufferHelper::SetAutomaticFlushes(bool enabled) { | 36 void CommandBufferHelper::SetAutomaticFlushes(bool enabled) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 147 } |
147 | 148 |
148 void CommandBufferHelper::Flush() { | 149 void CommandBufferHelper::Flush() { |
149 // Wrap put_ before flush. | 150 // Wrap put_ before flush. |
150 if (put_ == total_entry_count_) | 151 if (put_ == total_entry_count_) |
151 put_ = 0; | 152 put_ = 0; |
152 | 153 |
153 if (usable() && last_put_sent_ != put_) { | 154 if (usable() && last_put_sent_ != put_) { |
154 last_flush_time_ = base::TimeTicks::Now(); | 155 last_flush_time_ = base::TimeTicks::Now(); |
155 last_put_sent_ = put_; | 156 last_put_sent_ = put_; |
| 157 last_shallow_put_sent_ = put_; |
156 command_buffer_->Flush(put_); | 158 command_buffer_->Flush(put_); |
157 ++flush_generation_; | 159 ++flush_generation_; |
158 CalcImmediateEntries(0); | 160 CalcImmediateEntries(0); |
159 } | 161 } |
160 } | 162 } |
161 | 163 |
| 164 void CommandBufferHelper::ShallowFlush() { |
| 165 // Wrap put_ before flush. |
| 166 if (put_ == total_entry_count_) |
| 167 put_ = 0; |
| 168 |
| 169 if (usable() && last_shallow_put_sent_ != put_) { |
| 170 last_shallow_put_sent_ = put_; |
| 171 command_buffer_->ShallowFlush(put_); |
| 172 ++flush_generation_; |
| 173 CalcImmediateEntries(0); |
| 174 } |
| 175 } |
| 176 |
162 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) | 177 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) |
163 void CommandBufferHelper::PeriodicFlushCheck() { | 178 void CommandBufferHelper::PeriodicFlushCheck() { |
164 base::TimeTicks current_time = base::TimeTicks::Now(); | 179 base::TimeTicks current_time = base::TimeTicks::Now(); |
165 if (current_time - last_flush_time_ > | 180 if (current_time - last_flush_time_ > |
166 base::TimeDelta::FromMicroseconds(kPeriodicFlushDelayInMicroseconds)) { | 181 base::TimeDelta::FromMicroseconds(kPeriodicFlushDelayInMicroseconds)) { |
167 Flush(); | 182 Flush(); |
168 } | 183 } |
169 } | 184 } |
170 #endif | 185 #endif |
171 | 186 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 if (!WaitForGetOffsetInRange(put_ + count + 1, put_)) | 299 if (!WaitForGetOffsetInRange(put_ + count + 1, put_)) |
285 return; | 300 return; |
286 CalcImmediateEntries(count); | 301 CalcImmediateEntries(count); |
287 DCHECK_GE(immediate_entry_count_, count); | 302 DCHECK_GE(immediate_entry_count_, count); |
288 } | 303 } |
289 } | 304 } |
290 } | 305 } |
291 | 306 |
292 | 307 |
293 } // namespace gpu | 308 } // namespace gpu |
OLD | NEW |