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

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

Issue 282513003: gpu: Assert that FencedAllocator is empty in destructor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed 64 bit only test Created 6 years, 7 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
« no previous file with comments | « no previous file | gpu/command_buffer/client/gles2_implementation_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 FencedAllocator class. 5 // This file contains the implementation of the FencedAllocator class.
6 6
7 #include "gpu/command_buffer/client/fenced_allocator.h" 7 #include "gpu/command_buffer/client/fenced_allocator.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 blocks_.push_back(block); 43 blocks_.push_back(block);
44 } 44 }
45 45
46 FencedAllocator::~FencedAllocator() { 46 FencedAllocator::~FencedAllocator() {
47 // Free blocks pending tokens. 47 // Free blocks pending tokens.
48 for (unsigned int i = 0; i < blocks_.size(); ++i) { 48 for (unsigned int i = 0; i < blocks_.size(); ++i) {
49 if (blocks_[i].state == FREE_PENDING_TOKEN) { 49 if (blocks_[i].state == FREE_PENDING_TOKEN) {
50 i = WaitForTokenAndFreeBlock(i); 50 i = WaitForTokenAndFreeBlock(i);
51 } 51 }
52 } 52 }
53 // These checks are not valid if the service has crashed or lost the context. 53
54 // DCHECK_EQ(blocks_.size(), 1u); 54 DCHECK_EQ(blocks_.size(), 1u);
55 // DCHECK_EQ(blocks_[0].state, FREE); 55 DCHECK_EQ(blocks_[0].state, FREE);
56 } 56 }
57 57
58 // Looks for a non-allocated block that is big enough. Search in the FREE 58 // Looks for a non-allocated block that is big enough. Search in the FREE
59 // blocks first (for direct usage), first-fit, then in the FREE_PENDING_TOKEN 59 // blocks first (for direct usage), first-fit, then in the FREE_PENDING_TOKEN
60 // blocks, waiting for them. The current implementation isn't smart about 60 // blocks, waiting for them. The current implementation isn't smart about
61 // optimizing what to wait for, just looks inside the block in order (first-fit 61 // optimizing what to wait for, just looks inside the block in order (first-fit
62 // as well). 62 // as well).
63 FencedAllocator::Offset FencedAllocator::Alloc(unsigned int size) { 63 FencedAllocator::Offset FencedAllocator::Alloc(unsigned int size) {
64 // size of 0 is not allowed because it would be inconsistent to only sometimes 64 // size of 0 is not allowed because it would be inconsistent to only sometimes
65 // have it succeed. Example: Alloc(SizeOfBuffer), Alloc(0). 65 // have it succeed. Example: Alloc(SizeOfBuffer), Alloc(0).
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // The blocks are in offset order, so we can do a binary search. 244 // The blocks are in offset order, so we can do a binary search.
245 FencedAllocator::BlockIndex FencedAllocator::GetBlockByOffset(Offset offset) { 245 FencedAllocator::BlockIndex FencedAllocator::GetBlockByOffset(Offset offset) {
246 Block templ = { IN_USE, offset, 0, kUnusedToken }; 246 Block templ = { IN_USE, offset, 0, kUnusedToken };
247 Container::iterator it = std::lower_bound(blocks_.begin(), blocks_.end(), 247 Container::iterator it = std::lower_bound(blocks_.begin(), blocks_.end(),
248 templ, OffsetCmp()); 248 templ, OffsetCmp());
249 DCHECK(it != blocks_.end() && it->offset == offset); 249 DCHECK(it != blocks_.end() && it->offset == offset);
250 return it-blocks_.begin(); 250 return it-blocks_.begin();
251 } 251 }
252 252
253 } // namespace gpu 253 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/client/gles2_implementation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698