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

Side by Side Diff: gpu/command_buffer/client/cmd_buffer_helper.cc

Issue 116863003: gpu: Reuse transfer buffers more aggresively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: [WIP] Introduced internal SetAsyncToken command buffer command Created 6 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 unified diff | Download patch
OLDNEW
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 "gpu/command_buffer/common/command_buffer.h" 10 #include "gpu/command_buffer/common/command_buffer.h"
11 #include "gpu/command_buffer/common/trace_event.h" 11 #include "gpu/command_buffer/common/trace_event.h"
12 12
13 namespace gpu { 13 namespace gpu {
14 14
15 const int kCommandsPerFlushCheck = 100; 15 const int kCommandsPerFlushCheck = 100;
16 16
17 #if !defined(OS_ANDROID) 17 #if !defined(OS_ANDROID)
18 const double kFlushDelay = 1.0 / (5.0 * 60.0); 18 const double kFlushDelay = 1.0 / (5.0 * 60.0);
19 #endif 19 #endif
20 20
21 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) 21 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer)
22 : command_buffer_(command_buffer), 22 : command_buffer_(command_buffer),
23 ring_buffer_id_(-1), 23 ring_buffer_id_(-1),
24 ring_buffer_size_(0), 24 ring_buffer_size_(0),
25 entries_(NULL), 25 entries_(NULL),
26 total_entry_count_(0), 26 total_entry_count_(0),
27 token_(0), 27 token_(0),
28 async_token_(0),
28 put_(0), 29 put_(0),
29 last_put_sent_(0), 30 last_put_sent_(0),
30 commands_issued_(0), 31 commands_issued_(0),
31 usable_(true), 32 usable_(true),
32 context_lost_(false), 33 context_lost_(false),
33 flush_automatically_(true), 34 flush_automatically_(true),
34 last_flush_time_(0) { 35 last_flush_time_(0) {
35 } 36 }
36 37
37 void CommandBufferHelper::SetAutomaticFlushes(bool enabled) { 38 void CommandBufferHelper::SetAutomaticFlushes(bool enabled) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 LOG(FATAL) << "Empty command buffer while waiting on a token."; 185 LOG(FATAL) << "Empty command buffer while waiting on a token.";
185 return; 186 return;
186 } 187 }
187 // Do not loop forever if the flush fails, meaning the command buffer reader 188 // Do not loop forever if the flush fails, meaning the command buffer reader
188 // has shutdown. 189 // has shutdown.
189 if (!FlushSync()) 190 if (!FlushSync())
190 return; 191 return;
191 } 192 }
192 } 193 }
193 194
195 uint32 CommandBufferHelper::InsertAsyncToken() {
epenner 2014/01/23 02:52:44 Perhaps async token is meant to be more generic, b
196 AllocateRingBuffer();
197 if (!usable()) {
198 return async_token_;
199 }
200 DCHECK(HaveRingBuffer());
201
202 async_token_++;
203 if (async_token_ == 0)
204 async_token_++;
205
206 cmd::SetAsyncToken* cmd = GetCmdSpace<cmd::SetAsyncToken>();
207 if (cmd) {
208 cmd->Init(async_token_);
209 }
210 return async_token_;
211 }
212
194 // Waits for available entries, basically waiting until get >= put + count + 1. 213 // Waits for available entries, basically waiting until get >= put + count + 1.
195 // It actually waits for contiguous entries, so it may need to wrap the buffer 214 // It actually waits for contiguous entries, so it may need to wrap the buffer
196 // around, adding a noops. Thus this function may change the value of put_. The 215 // around, adding a noops. Thus this function may change the value of put_. The
197 // function will return early if an error occurs, in which case the available 216 // function will return early if an error occurs, in which case the available
198 // space may not be available. 217 // space may not be available.
199 void CommandBufferHelper::WaitForAvailableEntries(int32 count) { 218 void CommandBufferHelper::WaitForAvailableEntries(int32 count) {
200 AllocateRingBuffer(); 219 AllocateRingBuffer();
201 if (!usable()) { 220 if (!usable()) {
202 return; 221 return;
203 } 222 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 CommandBufferEntry* space = &entries_[put_]; 289 CommandBufferEntry* space = &entries_[put_];
271 put_ += entries; 290 put_ += entries;
272 DCHECK_LE(put_, total_entry_count_); 291 DCHECK_LE(put_, total_entry_count_);
273 if (put_ == total_entry_count_) { 292 if (put_ == total_entry_count_) {
274 put_ = 0; 293 put_ = 0;
275 } 294 }
276 return space; 295 return space;
277 } 296 }
278 297
279 } // namespace gpu 298 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698