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

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

Issue 2550583002: gpu: Thread-safe command buffer state lookup. (Closed)
Patch Set: move cmd buffer helper memory dump to context provider Created 4 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 RingBuffer class. 5 // This file contains the implementation of the RingBuffer class.
6 6
7 #include "gpu/command_buffer/client/ring_buffer.h" 7 #include "gpu/command_buffer/client/ring_buffer.h"
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 in_use_offset_ = 0; 139 in_use_offset_ = 0;
140 free_offset_ = 0; 140 free_offset_ = 0;
141 } 141 }
142 return; 142 return;
143 } 143 }
144 } 144 }
145 NOTREACHED() << "attempt to discard non-existant block"; 145 NOTREACHED() << "attempt to discard non-existant block";
146 } 146 }
147 147
148 unsigned int RingBuffer::GetLargestFreeSizeNoWaiting() { 148 unsigned int RingBuffer::GetLargestFreeSizeNoWaiting() {
149 unsigned int last_token_read = helper_->last_token_read();
150 while (!blocks_.empty()) { 149 while (!blocks_.empty()) {
151 Block& block = blocks_.front(); 150 Block& block = blocks_.front();
152 if (block.token > last_token_read || block.state == IN_USE) break; 151 if (!helper_->HasTokenPassed(block.token) || block.state == IN_USE) break;
jbauman 2016/12/09 03:16:03 This will most likely hit the lock at least once p
sunnyps 2016/12/09 04:09:37 I didn't expose token from the helper directly bec
153 FreeOldestBlock(); 152 FreeOldestBlock();
154 } 153 }
155 if (free_offset_ == in_use_offset_) { 154 if (free_offset_ == in_use_offset_) {
156 if (blocks_.empty()) { 155 if (blocks_.empty()) {
157 // The entire buffer is free. 156 // The entire buffer is free.
158 DCHECK_EQ(free_offset_, 0u); 157 DCHECK_EQ(free_offset_, 0u);
159 return size_; 158 return size_;
160 } else { 159 } else {
161 // The entire buffer is in use. 160 // The entire buffer is in use.
162 return 0; 161 return 0;
(...skipping 11 matching lines...) Expand all
174 unsigned int largest_free_size = GetLargestFreeSizeNoWaiting(); 173 unsigned int largest_free_size = GetLargestFreeSizeNoWaiting();
175 if (free_offset_ > in_use_offset_) { 174 if (free_offset_ > in_use_offset_) {
176 // It's free from free_offset_ to size_ and from 0 to in_use_offset_. 175 // It's free from free_offset_ to size_ and from 0 to in_use_offset_.
177 return size_ - free_offset_ + in_use_offset_; 176 return size_ - free_offset_ + in_use_offset_;
178 } else { 177 } else {
179 return largest_free_size; 178 return largest_free_size;
180 } 179 }
181 } 180 }
182 181
183 } // namespace gpu 182 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698