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

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] gpu: Reuse transfer buffers more aggresively 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 serial(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 serial. This used by the reader to synchronize with the
50 // writer that the action associated with the serial has been completed.
51 uint32 serial;
52
48 // Error status. 53 // Error status.
49 error::Error error; 54 error::Error error;
50 55
51 // Lost context detail information. 56 // Lost context detail information.
52 error::ContextLostReason context_lost_reason; 57 error::ContextLostReason context_lost_reason;
53 58
54 // Generation index of this state. The generation index is incremented every 59 // Generation index of this state. The generation index is incremented every
55 // time a new state is retrieved from the command processor, so that 60 // 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. 61 // consistency can be kept even if IPC messages are processed out-of-order.
57 uint32 generation; 62 uint32 generation;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // Destroy a transfer buffer. The ID must be positive. 116 // Destroy a transfer buffer. The ID must be positive.
112 virtual void DestroyTransferBuffer(int32 id) = 0; 117 virtual void DestroyTransferBuffer(int32 id) = 0;
113 118
114 // Get the transfer buffer associated with an ID. Returns a null buffer for 119 // Get the transfer buffer associated with an ID. Returns a null buffer for
115 // ID 0. 120 // ID 0.
116 virtual Buffer GetTransferBuffer(int32 id) = 0; 121 virtual Buffer GetTransferBuffer(int32 id) = 0;
117 122
118 // Allows the reader to update the current token value. 123 // Allows the reader to update the current token value.
119 virtual void SetToken(int32 token) = 0; 124 virtual void SetToken(int32 token) = 0;
120 125
126 // Allows the reader to update the current serial value.
127 virtual void SetSerial(uint32 serial) = 0;
128
121 // Allows the reader to set the current parse error. 129 // Allows the reader to set the current parse error.
122 virtual void SetParseError(error::Error) = 0; 130 virtual void SetParseError(error::Error) = 0;
123 131
124 // Allows the reader to set the current context lost reason. 132 // Allows the reader to set the current context lost reason.
125 // NOTE: if calling this in conjunction with SetParseError, 133 // NOTE: if calling this in conjunction with SetParseError,
126 // call this first. 134 // call this first.
127 virtual void SetContextLostReason(error::ContextLostReason) = 0; 135 virtual void SetContextLostReason(error::ContextLostReason) = 0;
128 136
129 // The NaCl Win64 build only really needs the struct definitions above; having 137 // 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 138 // GetLastError declared would mean we'd have to also define it, and pull more
131 // of gpu in to the NaCl Win64 build. 139 // of gpu in to the NaCl Win64 build.
132 #if !defined(NACL_WIN64) 140 #if !defined(NACL_WIN64)
133 // TODO(apatrick): this is a temporary optimization while skia is calling 141 // TODO(apatrick): this is a temporary optimization while skia is calling
134 // RendererGLContext::MakeCurrent prior to every GL call. It saves returning 6 142 // RendererGLContext::MakeCurrent prior to every GL call. It saves returning 6
135 // ints redundantly when only the error is needed for the CommandBufferProxy 143 // ints redundantly when only the error is needed for the CommandBufferProxy
136 // implementation. 144 // implementation.
137 virtual error::Error GetLastError(); 145 virtual error::Error GetLastError();
138 #endif 146 #endif
139 147
140 private: 148 private:
141 DISALLOW_COPY_AND_ASSIGN(CommandBuffer); 149 DISALLOW_COPY_AND_ASSIGN(CommandBuffer);
142 }; 150 };
143 151
144 } // namespace gpu 152 } // namespace gpu
145 153
146 #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ 154 #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698