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

Side by Side Diff: gpu/command_buffer/common/command_buffer.h

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 #ifndef GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ 5 #ifndef GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_
6 #define GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ 6 #define GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_
7 7
8 #include "gpu/command_buffer/common/buffer.h" 8 #include "gpu/command_buffer/common/buffer.h"
9 #include "gpu/command_buffer/common/constants.h" 9 #include "gpu/command_buffer/common/constants.h"
10 #include "gpu/gpu_export.h" 10 #include "gpu/gpu_export.h"
11 11
12 namespace base { 12 namespace base {
13 class SharedMemory; 13 class SharedMemory;
14 } 14 }
15 15
16 namespace gpu { 16 namespace gpu {
17 17
18 // Common interface for CommandBuffer implementations. 18 // Common interface for CommandBuffer implementations.
19 class GPU_EXPORT CommandBuffer { 19 class GPU_EXPORT CommandBuffer {
20 public: 20 public:
21 struct State { 21 struct State {
22 State() 22 State()
23 : num_entries(0), 23 : num_entries(0),
24 get_offset(0), 24 get_offset(0),
25 put_offset(0), 25 put_offset(0),
26 token(-1), 26 token(-1),
27 async_token(0),
27 error(error::kNoError), 28 error(error::kNoError),
28 context_lost_reason(error::kUnknown), 29 context_lost_reason(error::kUnknown),
29 generation(0) { 30 generation(0) {
30 } 31 }
31 32
32 // Size of the command buffer in command buffer entries. 33 // Size of the command buffer in command buffer entries.
33 int32 num_entries; 34 int32 num_entries;
34 35
35 // The offset (in entries) from which the reader is reading. 36 // The offset (in entries) from which the reader is reading.
36 int32 get_offset; 37 int32 get_offset;
37 38
38 // The offset (in entries) at which the writer is writing. 39 // The offset (in entries) at which the writer is writing.
39 int32 put_offset; 40 int32 put_offset;
40 41
41 // The current token value. This is used by the writer to defer 42 // The current token value. This is used by the writer to defer
42 // changes to shared memory objects until the reader has reached a certain 43 // changes to shared memory objects until the reader has reached a certain
43 // point in the command buffer. The reader is responsible for updating the 44 // point in the command buffer. The reader is responsible for updating the
44 // token value, for example in response to an asynchronous set token command 45 // token value, for example in response to an asynchronous set token command
45 // embedded in the command buffer. The default token value is zero. 46 // embedded in the command buffer. The default token value is zero.
46 int32 token; 47 int32 token;
47 48
49 // The current async token. This used by the reader to synchronize with the
50 // writer that the action associated with the async token has been
51 // completed.
52 uint32 async_token;
reveman 2014/01/22 17:30:04 is there a good reason this is unsigned but |token
53
48 // Error status. 54 // Error status.
49 error::Error error; 55 error::Error error;
50 56
51 // Lost context detail information. 57 // Lost context detail information.
52 error::ContextLostReason context_lost_reason; 58 error::ContextLostReason context_lost_reason;
53 59
54 // Generation index of this state. The generation index is incremented every 60 // Generation index of this state. The generation index is incremented every
55 // time a new state is retrieved from the command processor, so that 61 // time a new state is retrieved from the command processor, so that
56 // consistency can be kept even if IPC messages are processed out-of-order. 62 // consistency can be kept even if IPC messages are processed out-of-order.
57 uint32 generation; 63 uint32 generation;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // Destroy a transfer buffer. The ID must be positive. 117 // Destroy a transfer buffer. The ID must be positive.
112 virtual void DestroyTransferBuffer(int32 id) = 0; 118 virtual void DestroyTransferBuffer(int32 id) = 0;
113 119
114 // Get the transfer buffer associated with an ID. Returns a null buffer for 120 // Get the transfer buffer associated with an ID. Returns a null buffer for
115 // ID 0. 121 // ID 0.
116 virtual Buffer GetTransferBuffer(int32 id) = 0; 122 virtual Buffer GetTransferBuffer(int32 id) = 0;
117 123
118 // Allows the reader to update the current token value. 124 // Allows the reader to update the current token value.
119 virtual void SetToken(int32 token) = 0; 125 virtual void SetToken(int32 token) = 0;
120 126
127 // Allows the reader to update the current async token value.
128 virtual void SetAsyncToken(uint32 token) = 0;
129
121 // Allows the reader to set the current parse error. 130 // Allows the reader to set the current parse error.
122 virtual void SetParseError(error::Error) = 0; 131 virtual void SetParseError(error::Error) = 0;
123 132
124 // Allows the reader to set the current context lost reason. 133 // Allows the reader to set the current context lost reason.
125 // NOTE: if calling this in conjunction with SetParseError, 134 // NOTE: if calling this in conjunction with SetParseError,
126 // call this first. 135 // call this first.
127 virtual void SetContextLostReason(error::ContextLostReason) = 0; 136 virtual void SetContextLostReason(error::ContextLostReason) = 0;
128 137
129 // The NaCl Win64 build only really needs the struct definitions above; having 138 // The NaCl Win64 build only really needs the struct definitions above; having
130 // GetLastError declared would mean we'd have to also define it, and pull more 139 // GetLastError declared would mean we'd have to also define it, and pull more
131 // of gpu in to the NaCl Win64 build. 140 // of gpu in to the NaCl Win64 build.
132 #if !defined(NACL_WIN64) 141 #if !defined(NACL_WIN64)
133 // TODO(apatrick): this is a temporary optimization while skia is calling 142 // TODO(apatrick): this is a temporary optimization while skia is calling
134 // RendererGLContext::MakeCurrent prior to every GL call. It saves returning 6 143 // RendererGLContext::MakeCurrent prior to every GL call. It saves returning 6
135 // ints redundantly when only the error is needed for the CommandBufferProxy 144 // ints redundantly when only the error is needed for the CommandBufferProxy
136 // implementation. 145 // implementation.
137 virtual error::Error GetLastError(); 146 virtual error::Error GetLastError();
138 #endif 147 #endif
139 148
140 private: 149 private:
141 DISALLOW_COPY_AND_ASSIGN(CommandBuffer); 150 DISALLOW_COPY_AND_ASSIGN(CommandBuffer);
142 }; 151 };
143 152
144 } // namespace gpu 153 } // namespace gpu
145 154
146 #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ 155 #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698