OLD | NEW |
1 // Copyright (c) 2012 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 definition of the FencedAllocator class. | 5 // This file contains the definition of the FencedAllocator class. |
6 | 6 |
7 #ifndef GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
8 #define GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 8 #define GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | |
12 #include "../../gpu_export.h" | |
13 #include "../common/logging.h" | 11 #include "../common/logging.h" |
14 #include "../common/types.h" | 12 #include "../common/types.h" |
15 | 13 |
16 namespace gpu { | 14 namespace gpu { |
17 class CommandBufferHelper; | 15 class CommandBufferHelper; |
18 | 16 |
19 // FencedAllocator provides a mechanism to manage allocations within a fixed | 17 // FencedAllocator provides a mechanism to manage allocations within a fixed |
20 // block of memory (storing the book-keeping externally). Furthermore this | 18 // block of memory (storing the book-keeping externally). Furthermore this |
21 // class allows to free data "pending" the passage of a command buffer token, | 19 // class allows to free data "pending" the passage of a command buffer token, |
22 // that is, the memory won't be reused until the command buffer has processed | 20 // that is, the memory won't be reused until the command buffer has processed |
23 // that token. | 21 // that token. |
24 // | 22 // |
25 // NOTE: Although this class is intended to be used in the command buffer | 23 // NOTE: Although this class is intended to be used in the command buffer |
26 // environment which is multi-process, this class isn't "thread safe", because | 24 // environment which is multi-process, this class isn't "thread safe", because |
27 // it isn't meant to be shared across modules. It is thread-compatible though | 25 // it isn't meant to be shared across modules. It is thread-compatible though |
28 // (see http://www.corp.google.com/eng/doc/cpp_primer.html#thread_safety). | 26 // (see http://www.corp.google.com/eng/doc/cpp_primer.html#thread_safety). |
29 class GPU_EXPORT FencedAllocator { | 27 class FencedAllocator { |
30 public: | 28 public: |
31 typedef unsigned int Offset; | 29 typedef unsigned int Offset; |
32 // Invalid offset, returned by Alloc in case of failure. | 30 // Invalid offset, returned by Alloc in case of failure. |
33 static const Offset kInvalidOffset = 0xffffffffU; | 31 static const Offset kInvalidOffset = 0xffffffffU; |
34 | 32 |
35 // Creates a FencedAllocator. Note that the size of the buffer is passed, but | 33 // Creates a FencedAllocator. Note that the size of the buffer is passed, but |
36 // not its base address: everything is handled as offsets into the buffer. | 34 // not its base address: everything is handled as offsets into the buffer. |
37 FencedAllocator(unsigned int size, | 35 FencedAllocator(unsigned int size, |
38 CommandBufferHelper *helper); | 36 CommandBufferHelper *helper); |
39 | 37 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 243 |
246 private: | 244 private: |
247 FencedAllocator allocator_; | 245 FencedAllocator allocator_; |
248 void* base_; | 246 void* base_; |
249 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); | 247 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); |
250 }; | 248 }; |
251 | 249 |
252 } // namespace gpu | 250 } // namespace gpu |
253 | 251 |
254 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 252 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
OLD | NEW |