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

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

Issue 268063002: Remove command_buffer/common/types.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix 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 | Annotate | Revision Log
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 // This file contains the common parts of command buffer formats. 5 // This file contains the common parts of command buffer formats.
6 6
7 #ifndef GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ 7 #ifndef GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_
8 #define GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ 8 #define GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_
9 9
10 #include <stddef.h> 10 #include <stddef.h>
11 #include <stdint.h>
11 12
12 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h"
13 #include "gpu/command_buffer/common/bitfield_helpers.h" 15 #include "gpu/command_buffer/common/bitfield_helpers.h"
14 #include "gpu/command_buffer/common/types.h"
15 #include "gpu/gpu_export.h" 16 #include "gpu/gpu_export.h"
16 17
17 namespace gpu { 18 namespace gpu {
18 19
19 namespace cmd { 20 namespace cmd {
20 enum ArgFlags { 21 enum ArgFlags {
21 kFixed = 0x0, 22 kFixed = 0x0,
22 kAtLeastN = 0x1 23 kAtLeastN = 0x1
23 }; 24 };
24 } // namespace cmd 25 } // namespace cmd
25 26
26 // Pack & unpack Command cmd_flags 27 // Pack & unpack Command cmd_flags
27 #define CMD_FLAG_SET_TRACE_LEVEL(level) ((level & 3) << 0) 28 #define CMD_FLAG_SET_TRACE_LEVEL(level) ((level & 3) << 0)
28 #define CMD_FLAG_GET_TRACE_LEVEL(cmd_flags) ((cmd_flags >> 0) & 3) 29 #define CMD_FLAG_GET_TRACE_LEVEL(cmd_flags) ((cmd_flags >> 0) & 3)
29 30
30 // Computes the number of command buffer entries needed for a certain size. In 31 // Computes the number of command buffer entries needed for a certain size. In
31 // other words it rounds up to a multiple of entries. 32 // other words it rounds up to a multiple of entries.
32 inline uint32 ComputeNumEntries(size_t size_in_bytes) { 33 inline uint32_t ComputeNumEntries(size_t size_in_bytes) {
33 return static_cast<uint32>( 34 return static_cast<uint32_t>(
34 (size_in_bytes + sizeof(uint32) - 1) / sizeof(uint32)); // NOLINT 35 (size_in_bytes + sizeof(uint32_t) - 1) / sizeof(uint32_t)); // NOLINT
35 } 36 }
36 37
37 // Rounds up to a multiple of entries in bytes. 38 // Rounds up to a multiple of entries in bytes.
38 inline size_t RoundSizeToMultipleOfEntries(size_t size_in_bytes) { 39 inline size_t RoundSizeToMultipleOfEntries(size_t size_in_bytes) {
39 return ComputeNumEntries(size_in_bytes) * sizeof(uint32); // NOLINT 40 return ComputeNumEntries(size_in_bytes) * sizeof(uint32_t); // NOLINT
40 } 41 }
41 42
42 // Struct that defines the command header in the command buffer. 43 // Struct that defines the command header in the command buffer.
43 struct CommandHeader { 44 struct CommandHeader {
44 uint32 size:21; 45 uint32_t size:21;
45 uint32 command:11; 46 uint32_t command:11;
46 47
47 GPU_EXPORT static const int32 kMaxSize = (1 << 21) - 1; 48 GPU_EXPORT static const int32_t kMaxSize = (1 << 21) - 1;
48 49
49 void Init(uint32 _command, int32 _size) { 50 void Init(uint32_t _command, int32_t _size) {
50 DCHECK_LE(_size, kMaxSize); 51 DCHECK_LE(_size, kMaxSize);
51 command = _command; 52 command = _command;
52 size = _size; 53 size = _size;
53 } 54 }
54 55
55 // Sets the header based on the passed in command. Can not be used for 56 // Sets the header based on the passed in command. Can not be used for
56 // variable sized commands like immediate commands or Noop. 57 // variable sized commands like immediate commands or Noop.
57 template <typename T> 58 template <typename T>
58 void SetCmd() { 59 void SetCmd() {
59 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); 60 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed);
60 Init(T::kCmdId, ComputeNumEntries(sizeof(T))); // NOLINT 61 Init(T::kCmdId, ComputeNumEntries(sizeof(T))); // NOLINT
61 } 62 }
62 63
63 // Sets the header by a size in bytes of the immediate data after the command. 64 // Sets the header by a size in bytes of the immediate data after the command.
64 template <typename T> 65 template <typename T>
65 void SetCmdBySize(uint32 size_of_data_in_bytes) { 66 void SetCmdBySize(uint32_t size_of_data_in_bytes) {
66 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); 67 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN);
67 Init(T::kCmdId, 68 Init(T::kCmdId,
68 ComputeNumEntries(sizeof(T) + size_of_data_in_bytes)); // NOLINT 69 ComputeNumEntries(sizeof(T) + size_of_data_in_bytes)); // NOLINT
69 } 70 }
70 71
71 // Sets the header by a size in bytes. 72 // Sets the header by a size in bytes.
72 template <typename T> 73 template <typename T>
73 void SetCmdByTotalSize(uint32 size_in_bytes) { 74 void SetCmdByTotalSize(uint32_t size_in_bytes) {
74 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); 75 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN);
75 DCHECK_GE(size_in_bytes, sizeof(T)); // NOLINT 76 DCHECK_GE(size_in_bytes, sizeof(T)); // NOLINT
76 Init(T::kCmdId, ComputeNumEntries(size_in_bytes)); 77 Init(T::kCmdId, ComputeNumEntries(size_in_bytes));
77 } 78 }
78 }; 79 };
79 80
80 COMPILE_ASSERT(sizeof(CommandHeader) == 4, Sizeof_CommandHeader_is_not_4); 81 COMPILE_ASSERT(sizeof(CommandHeader) == 4, Sizeof_CommandHeader_is_not_4);
81 82
82 // Union that defines possible command buffer entries. 83 // Union that defines possible command buffer entries.
83 union CommandBufferEntry { 84 union CommandBufferEntry {
84 CommandHeader value_header; 85 CommandHeader value_header;
85 uint32 value_uint32; 86 uint32_t value_uint32;
86 int32 value_int32; 87 int32_t value_int32;
87 float value_float; 88 float value_float;
88 }; 89 };
89 90
90 #define GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT 4 91 #define GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT 4
91 const size_t kCommandBufferEntrySize = GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT; 92 const size_t kCommandBufferEntrySize = GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT;
92 93
93 COMPILE_ASSERT(sizeof(CommandBufferEntry) == kCommandBufferEntrySize, 94 COMPILE_ASSERT(sizeof(CommandBufferEntry) == kCommandBufferEntrySize,
94 Sizeof_CommandBufferEntry_is_not_4); 95 Sizeof_CommandBufferEntry_is_not_4);
95 96
96 // Command buffer is GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT byte aligned. 97 // Command buffer is GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT byte aligned.
(...skipping 19 matching lines...) Expand all
116 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); 117 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed);
117 return reinterpret_cast<char*>(cmd) + sizeof(T); 118 return reinterpret_cast<char*>(cmd) + sizeof(T);
118 } 119 }
119 120
120 // Gets the address of the place to put the next command in a typesafe way. 121 // Gets the address of the place to put the next command in a typesafe way.
121 // This can only be used for variable sized command like IMMEDIATE commands. 122 // This can only be used for variable sized command like IMMEDIATE commands.
122 // Parameters: 123 // Parameters:
123 // cmd: Address of command. 124 // cmd: Address of command.
124 // size_of_data_in_bytes: Size of the data for the command. 125 // size_of_data_in_bytes: Size of the data for the command.
125 template <typename T> 126 template <typename T>
126 void* NextImmediateCmdAddress(void* cmd, uint32 size_of_data_in_bytes) { 127 void* NextImmediateCmdAddress(void* cmd, uint32_t size_of_data_in_bytes) {
127 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); 128 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN);
128 return reinterpret_cast<char*>(cmd) + sizeof(T) + // NOLINT 129 return reinterpret_cast<char*>(cmd) + sizeof(T) + // NOLINT
129 RoundSizeToMultipleOfEntries(size_of_data_in_bytes); 130 RoundSizeToMultipleOfEntries(size_of_data_in_bytes);
130 } 131 }
131 132
132 // Gets the address of the place to put the next command in a typesafe way. 133 // Gets the address of the place to put the next command in a typesafe way.
133 // This can only be used for variable sized command like IMMEDIATE commands. 134 // This can only be used for variable sized command like IMMEDIATE commands.
134 // Parameters: 135 // Parameters:
135 // cmd: Address of command. 136 // cmd: Address of command.
136 // size_of_cmd_in_bytes: Size of the cmd and data. 137 // size_of_cmd_in_bytes: Size of the cmd and data.
137 template <typename T> 138 template <typename T>
138 void* NextImmediateCmdAddressTotalSize(void* cmd, uint32 total_size_in_bytes) { 139 void* NextImmediateCmdAddressTotalSize(void* cmd,
140 uint32_t total_size_in_bytes) {
139 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); 141 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN);
140 DCHECK_GE(total_size_in_bytes, sizeof(T)); // NOLINT 142 DCHECK_GE(total_size_in_bytes, sizeof(T)); // NOLINT
141 return reinterpret_cast<char*>(cmd) + 143 return reinterpret_cast<char*>(cmd) +
142 RoundSizeToMultipleOfEntries(total_size_in_bytes); 144 RoundSizeToMultipleOfEntries(total_size_in_bytes);
143 } 145 }
144 146
145 namespace cmd { 147 namespace cmd {
146 148
147 // This macro is used to safely and convienently expand the list of commnad 149 // This macro is used to safely and convienently expand the list of commnad
148 // buffer commands in to various lists and never have them get out of sync. To 150 // buffer commands in to various lists and never have them get out of sync. To
(...skipping 25 matching lines...) Expand all
174 176
175 COMPILE_ASSERT(kNumCommands - 1 <= kLastCommonId, Too_many_common_commands); 177 COMPILE_ASSERT(kNumCommands - 1 <= kLastCommonId, Too_many_common_commands);
176 178
177 const char* GetCommandName(CommandId id); 179 const char* GetCommandName(CommandId id);
178 180
179 // A Noop command. 181 // A Noop command.
180 struct Noop { 182 struct Noop {
181 typedef Noop ValueType; 183 typedef Noop ValueType;
182 static const CommandId kCmdId = kNoop; 184 static const CommandId kCmdId = kNoop;
183 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; 185 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN;
184 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); 186 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
185 187
186 void SetHeader(uint32 skip_count) { 188 void SetHeader(uint32_t skip_count) {
187 DCHECK_GT(skip_count, 0u); 189 DCHECK_GT(skip_count, 0u);
188 header.Init(kCmdId, skip_count); 190 header.Init(kCmdId, skip_count);
189 } 191 }
190 192
191 void Init(uint32 skip_count) { 193 void Init(uint32_t skip_count) {
192 SetHeader(skip_count); 194 SetHeader(skip_count);
193 } 195 }
194 196
195 static void* Set(void* cmd, uint32 skip_count) { 197 static void* Set(void* cmd, uint32_t skip_count) {
196 static_cast<ValueType*>(cmd)->Init(skip_count); 198 static_cast<ValueType*>(cmd)->Init(skip_count);
197 return NextImmediateCmdAddress<ValueType>( 199 return NextImmediateCmdAddress<ValueType>(
198 cmd, skip_count * sizeof(CommandBufferEntry)); // NOLINT 200 cmd, skip_count * sizeof(CommandBufferEntry)); // NOLINT
199 } 201 }
200 202
201 CommandHeader header; 203 CommandHeader header;
202 }; 204 };
203 205
204 COMPILE_ASSERT(sizeof(Noop) == 4, Sizeof_Noop_is_not_4); 206 COMPILE_ASSERT(sizeof(Noop) == 4, Sizeof_Noop_is_not_4);
205 COMPILE_ASSERT(offsetof(Noop, header) == 0, Offsetof_Noop_header_not_0); 207 COMPILE_ASSERT(offsetof(Noop, header) == 0, Offsetof_Noop_header_not_0);
206 208
207 // The SetToken command puts a token in the command stream that you can 209 // The SetToken command puts a token in the command stream that you can
208 // use to check if that token has been passed in the command stream. 210 // use to check if that token has been passed in the command stream.
209 struct SetToken { 211 struct SetToken {
210 typedef SetToken ValueType; 212 typedef SetToken ValueType;
211 static const CommandId kCmdId = kSetToken; 213 static const CommandId kCmdId = kSetToken;
212 static const cmd::ArgFlags kArgFlags = cmd::kFixed; 214 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
213 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); 215 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
214 216
215 void SetHeader() { 217 void SetHeader() {
216 header.SetCmd<ValueType>(); 218 header.SetCmd<ValueType>();
217 } 219 }
218 220
219 void Init(uint32 _token) { 221 void Init(uint32_t _token) {
220 SetHeader(); 222 SetHeader();
221 token = _token; 223 token = _token;
222 } 224 }
223 static void* Set(void* cmd, uint32 token) { 225 static void* Set(void* cmd, uint32_t token) {
224 static_cast<ValueType*>(cmd)->Init(token); 226 static_cast<ValueType*>(cmd)->Init(token);
225 return NextCmdAddress<ValueType>(cmd); 227 return NextCmdAddress<ValueType>(cmd);
226 } 228 }
227 229
228 CommandHeader header; 230 CommandHeader header;
229 uint32 token; 231 uint32_t token;
230 }; 232 };
231 233
232 COMPILE_ASSERT(sizeof(SetToken) == 8, Sizeof_SetToken_is_not_8); 234 COMPILE_ASSERT(sizeof(SetToken) == 8, Sizeof_SetToken_is_not_8);
233 COMPILE_ASSERT(offsetof(SetToken, header) == 0, 235 COMPILE_ASSERT(offsetof(SetToken, header) == 0,
234 Offsetof_SetToken_header_not_0); 236 Offsetof_SetToken_header_not_0);
235 COMPILE_ASSERT(offsetof(SetToken, token) == 4, 237 COMPILE_ASSERT(offsetof(SetToken, token) == 4,
236 Offsetof_SetToken_token_not_4); 238 Offsetof_SetToken_token_not_4);
237 239
238 // Sets the size of a bucket for collecting data on the service side. 240 // Sets the size of a bucket for collecting data on the service side.
239 // This is a utility for gathering data on the service side so it can be used 241 // This is a utility for gathering data on the service side so it can be used
240 // all at once when some service side API is called. It removes the need to add 242 // all at once when some service side API is called. It removes the need to add
241 // special commands just to support a particular API. For example, any API 243 // special commands just to support a particular API. For example, any API
242 // command that needs a string needs a way to send that string to the API over 244 // command that needs a string needs a way to send that string to the API over
243 // the command buffers. While you can require that the command buffer or 245 // the command buffers. While you can require that the command buffer or
244 // transfer buffer be large enough to hold the largest string you can send, 246 // transfer buffer be large enough to hold the largest string you can send,
245 // using this command removes that restriction by letting you send smaller 247 // using this command removes that restriction by letting you send smaller
246 // pieces over and build up the data on the service side. 248 // pieces over and build up the data on the service side.
247 // 249 //
248 // You can clear a bucket on the service side and thereby free memory by sending 250 // You can clear a bucket on the service side and thereby free memory by sending
249 // a size of 0. 251 // a size of 0.
250 struct SetBucketSize { 252 struct SetBucketSize {
251 typedef SetBucketSize ValueType; 253 typedef SetBucketSize ValueType;
252 static const CommandId kCmdId = kSetBucketSize; 254 static const CommandId kCmdId = kSetBucketSize;
253 static const cmd::ArgFlags kArgFlags = cmd::kFixed; 255 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
254 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); 256 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
255 257
256 void SetHeader() { 258 void SetHeader() {
257 header.SetCmd<ValueType>(); 259 header.SetCmd<ValueType>();
258 } 260 }
259 261
260 void Init(uint32 _bucket_id, uint32 _size) { 262 void Init(uint32_t _bucket_id, uint32_t _size) {
261 SetHeader(); 263 SetHeader();
262 bucket_id = _bucket_id; 264 bucket_id = _bucket_id;
263 size = _size; 265 size = _size;
264 } 266 }
265 static void* Set(void* cmd, uint32 _bucket_id, uint32 _size) { 267 static void* Set(void* cmd, uint32_t _bucket_id, uint32_t _size) {
266 static_cast<ValueType*>(cmd)->Init(_bucket_id, _size); 268 static_cast<ValueType*>(cmd)->Init(_bucket_id, _size);
267 return NextCmdAddress<ValueType>(cmd); 269 return NextCmdAddress<ValueType>(cmd);
268 } 270 }
269 271
270 CommandHeader header; 272 CommandHeader header;
271 uint32 bucket_id; 273 uint32_t bucket_id;
272 uint32 size; 274 uint32_t size;
273 }; 275 };
274 276
275 COMPILE_ASSERT(sizeof(SetBucketSize) == 12, Sizeof_SetBucketSize_is_not_8); 277 COMPILE_ASSERT(sizeof(SetBucketSize) == 12, Sizeof_SetBucketSize_is_not_8);
276 COMPILE_ASSERT(offsetof(SetBucketSize, header) == 0, 278 COMPILE_ASSERT(offsetof(SetBucketSize, header) == 0,
277 Offsetof_SetBucketSize_header_not_0); 279 Offsetof_SetBucketSize_header_not_0);
278 COMPILE_ASSERT(offsetof(SetBucketSize, bucket_id) == 4, 280 COMPILE_ASSERT(offsetof(SetBucketSize, bucket_id) == 4,
279 Offsetof_SetBucketSize_bucket_id_4); 281 Offsetof_SetBucketSize_bucket_id_4);
280 COMPILE_ASSERT(offsetof(SetBucketSize, size) == 8, 282 COMPILE_ASSERT(offsetof(SetBucketSize, size) == 8,
281 Offsetof_SetBucketSize_size_8); 283 Offsetof_SetBucketSize_size_8);
282 284
283 // Sets the contents of a portion of a bucket on the service side from data in 285 // Sets the contents of a portion of a bucket on the service side from data in
284 // shared memory. 286 // shared memory.
285 // See SetBucketSize. 287 // See SetBucketSize.
286 struct SetBucketData { 288 struct SetBucketData {
287 typedef SetBucketData ValueType; 289 typedef SetBucketData ValueType;
288 static const CommandId kCmdId = kSetBucketData; 290 static const CommandId kCmdId = kSetBucketData;
289 static const cmd::ArgFlags kArgFlags = cmd::kFixed; 291 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
290 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); 292 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
291 293
292 void SetHeader() { 294 void SetHeader() {
293 header.SetCmd<ValueType>(); 295 header.SetCmd<ValueType>();
294 } 296 }
295 297
296 void Init(uint32 _bucket_id, 298 void Init(uint32_t _bucket_id,
297 uint32 _offset, 299 uint32_t _offset,
298 uint32 _size, 300 uint32_t _size,
299 uint32 _shared_memory_id, 301 uint32_t _shared_memory_id,
300 uint32 _shared_memory_offset) { 302 uint32_t _shared_memory_offset) {
301 SetHeader(); 303 SetHeader();
302 bucket_id = _bucket_id; 304 bucket_id = _bucket_id;
303 offset = _offset; 305 offset = _offset;
304 size = _size; 306 size = _size;
305 shared_memory_id = _shared_memory_id; 307 shared_memory_id = _shared_memory_id;
306 shared_memory_offset = _shared_memory_offset; 308 shared_memory_offset = _shared_memory_offset;
307 } 309 }
308 static void* Set(void* cmd, 310 static void* Set(void* cmd,
309 uint32 _bucket_id, 311 uint32_t _bucket_id,
310 uint32 _offset, 312 uint32_t _offset,
311 uint32 _size, 313 uint32_t _size,
312 uint32 _shared_memory_id, 314 uint32_t _shared_memory_id,
313 uint32 _shared_memory_offset) { 315 uint32_t _shared_memory_offset) {
314 static_cast<ValueType*>(cmd)->Init( 316 static_cast<ValueType*>(cmd)->Init(
315 _bucket_id, 317 _bucket_id,
316 _offset, 318 _offset,
317 _size, 319 _size,
318 _shared_memory_id, 320 _shared_memory_id,
319 _shared_memory_offset); 321 _shared_memory_offset);
320 return NextCmdAddress<ValueType>(cmd); 322 return NextCmdAddress<ValueType>(cmd);
321 } 323 }
322 324
323 CommandHeader header; 325 CommandHeader header;
324 uint32 bucket_id; 326 uint32_t bucket_id;
325 uint32 offset; 327 uint32_t offset;
326 uint32 size; 328 uint32_t size;
327 uint32 shared_memory_id; 329 uint32_t shared_memory_id;
328 uint32 shared_memory_offset; 330 uint32_t shared_memory_offset;
329 }; 331 };
330 332
331 COMPILE_ASSERT(sizeof(SetBucketData) == 24, Sizeof_SetBucketData_is_not_24); 333 COMPILE_ASSERT(sizeof(SetBucketData) == 24, Sizeof_SetBucketData_is_not_24);
332 COMPILE_ASSERT(offsetof(SetBucketData, header) == 0, 334 COMPILE_ASSERT(offsetof(SetBucketData, header) == 0,
333 Offsetof_SetBucketData_header_not_0); 335 Offsetof_SetBucketData_header_not_0);
334 COMPILE_ASSERT(offsetof(SetBucketData, bucket_id) == 4, 336 COMPILE_ASSERT(offsetof(SetBucketData, bucket_id) == 4,
335 Offsetof_SetBucketData_bucket_id_not_4); 337 Offsetof_SetBucketData_bucket_id_not_4);
336 COMPILE_ASSERT(offsetof(SetBucketData, offset) == 8, 338 COMPILE_ASSERT(offsetof(SetBucketData, offset) == 8,
337 Offsetof_SetBucketData_offset_not_8); 339 Offsetof_SetBucketData_offset_not_8);
338 COMPILE_ASSERT(offsetof(SetBucketData, size) == 12, 340 COMPILE_ASSERT(offsetof(SetBucketData, size) == 12,
339 Offsetof_SetBucketData_size_not_12); 341 Offsetof_SetBucketData_size_not_12);
340 COMPILE_ASSERT(offsetof(SetBucketData, shared_memory_id) == 16, 342 COMPILE_ASSERT(offsetof(SetBucketData, shared_memory_id) == 16,
341 Offsetof_SetBucketData_shared_memory_id_not_16); 343 Offsetof_SetBucketData_shared_memory_id_not_16);
342 COMPILE_ASSERT(offsetof(SetBucketData, shared_memory_offset) == 20, 344 COMPILE_ASSERT(offsetof(SetBucketData, shared_memory_offset) == 20,
343 Offsetof_SetBucketData_shared_memory_offset_not_20); 345 Offsetof_SetBucketData_shared_memory_offset_not_20);
344 346
345 // Sets the contents of a portion of a bucket on the service side from data in 347 // Sets the contents of a portion of a bucket on the service side from data in
346 // the command buffer. 348 // the command buffer.
347 // See SetBucketSize. 349 // See SetBucketSize.
348 struct SetBucketDataImmediate { 350 struct SetBucketDataImmediate {
349 typedef SetBucketDataImmediate ValueType; 351 typedef SetBucketDataImmediate ValueType;
350 static const CommandId kCmdId = kSetBucketDataImmediate; 352 static const CommandId kCmdId = kSetBucketDataImmediate;
351 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; 353 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN;
352 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); 354 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
353 355
354 void SetHeader(uint32 size) { 356 void SetHeader(uint32_t size) {
355 header.SetCmdBySize<ValueType>(size); 357 header.SetCmdBySize<ValueType>(size);
356 } 358 }
357 359
358 void Init(uint32 _bucket_id, 360 void Init(uint32_t _bucket_id,
359 uint32 _offset, 361 uint32_t _offset,
360 uint32 _size) { 362 uint32_t _size) {
361 SetHeader(_size); 363 SetHeader(_size);
362 bucket_id = _bucket_id; 364 bucket_id = _bucket_id;
363 offset = _offset; 365 offset = _offset;
364 size = _size; 366 size = _size;
365 } 367 }
366 static void* Set(void* cmd, 368 static void* Set(void* cmd,
367 uint32 _bucket_id, 369 uint32_t _bucket_id,
368 uint32 _offset, 370 uint32_t _offset,
369 uint32 _size) { 371 uint32_t _size) {
370 static_cast<ValueType*>(cmd)->Init( 372 static_cast<ValueType*>(cmd)->Init(
371 _bucket_id, 373 _bucket_id,
372 _offset, 374 _offset,
373 _size); 375 _size);
374 return NextImmediateCmdAddress<ValueType>(cmd, _size); 376 return NextImmediateCmdAddress<ValueType>(cmd, _size);
375 } 377 }
376 378
377 CommandHeader header; 379 CommandHeader header;
378 uint32 bucket_id; 380 uint32_t bucket_id;
379 uint32 offset; 381 uint32_t offset;
380 uint32 size; 382 uint32_t size;
381 }; 383 };
382 384
383 COMPILE_ASSERT(sizeof(SetBucketDataImmediate) == 16, 385 COMPILE_ASSERT(sizeof(SetBucketDataImmediate) == 16,
384 Sizeof_SetBucketDataImmediate_is_not_24); 386 Sizeof_SetBucketDataImmediate_is_not_24);
385 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, header) == 0, 387 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, header) == 0,
386 Offsetof_SetBucketDataImmediate_header_not_0); 388 Offsetof_SetBucketDataImmediate_header_not_0);
387 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, bucket_id) == 4, 389 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, bucket_id) == 4,
388 Offsetof_SetBucketDataImmediate_bucket_id_not_4); 390 Offsetof_SetBucketDataImmediate_bucket_id_not_4);
389 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, offset) == 8, 391 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, offset) == 8,
390 Offsetof_SetBucketDataImmediate_offset_not_8); 392 Offsetof_SetBucketDataImmediate_offset_not_8);
391 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, size) == 12, 393 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, size) == 12,
392 Offsetof_SetBucketDataImmediate_size_not_12); 394 Offsetof_SetBucketDataImmediate_size_not_12);
393 395
394 // Gets the start of a bucket the service has available. Sending a variable size 396 // Gets the start of a bucket the service has available. Sending a variable size
395 // result back to the client and the portion of that result that fits in the 397 // result back to the client and the portion of that result that fits in the
396 // supplied shared memory. If the size of the result is larger than the supplied 398 // supplied shared memory. If the size of the result is larger than the supplied
397 // shared memory the rest of the bucket's contents can be retrieved with 399 // shared memory the rest of the bucket's contents can be retrieved with
398 // GetBucketData. 400 // GetBucketData.
399 // 401 //
400 // This is used for example for any API that returns a string. The problem is 402 // This is used for example for any API that returns a string. The problem is
401 // the largest thing you can send back in 1 command is the size of your shared 403 // the largest thing you can send back in 1 command is the size of your shared
402 // memory. This command along with GetBucketData implements a way to get a 404 // memory. This command along with GetBucketData implements a way to get a
403 // result a piece at a time to help solve that problem in a generic way. 405 // result a piece at a time to help solve that problem in a generic way.
404 struct GetBucketStart { 406 struct GetBucketStart {
405 typedef GetBucketStart ValueType; 407 typedef GetBucketStart ValueType;
406 static const CommandId kCmdId = kGetBucketStart; 408 static const CommandId kCmdId = kGetBucketStart;
407 static const cmd::ArgFlags kArgFlags = cmd::kFixed; 409 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
408 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); 410 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
409 411
410 typedef uint32 Result; 412 typedef uint32_t Result;
411 413
412 void SetHeader() { 414 void SetHeader() {
413 header.SetCmd<ValueType>(); 415 header.SetCmd<ValueType>();
414 } 416 }
415 417
416 void Init(uint32 _bucket_id, 418 void Init(uint32_t _bucket_id,
417 uint32 _result_memory_id, 419 uint32_t _result_memory_id,
418 uint32 _result_memory_offset, 420 uint32_t _result_memory_offset,
419 uint32 _data_memory_size, 421 uint32_t _data_memory_size,
420 uint32 _data_memory_id, 422 uint32_t _data_memory_id,
421 uint32 _data_memory_offset) { 423 uint32_t _data_memory_offset) {
422 SetHeader(); 424 SetHeader();
423 bucket_id = _bucket_id; 425 bucket_id = _bucket_id;
424 result_memory_id = _result_memory_id; 426 result_memory_id = _result_memory_id;
425 result_memory_offset = _result_memory_offset; 427 result_memory_offset = _result_memory_offset;
426 data_memory_size = _data_memory_size; 428 data_memory_size = _data_memory_size;
427 data_memory_id = _data_memory_id; 429 data_memory_id = _data_memory_id;
428 data_memory_offset = _data_memory_offset; 430 data_memory_offset = _data_memory_offset;
429 } 431 }
430 static void* Set(void* cmd, 432 static void* Set(void* cmd,
431 uint32 _bucket_id, 433 uint32_t _bucket_id,
432 uint32 _result_memory_id, 434 uint32_t _result_memory_id,
433 uint32 _result_memory_offset, 435 uint32_t _result_memory_offset,
434 uint32 _data_memory_size, 436 uint32_t _data_memory_size,
435 uint32 _data_memory_id, 437 uint32_t _data_memory_id,
436 uint32 _data_memory_offset) { 438 uint32_t _data_memory_offset) {
437 static_cast<ValueType*>(cmd)->Init( 439 static_cast<ValueType*>(cmd)->Init(
438 _bucket_id, 440 _bucket_id,
439 _result_memory_id, 441 _result_memory_id,
440 _result_memory_offset, 442 _result_memory_offset,
441 _data_memory_size, 443 _data_memory_size,
442 _data_memory_id, 444 _data_memory_id,
443 _data_memory_offset); 445 _data_memory_offset);
444 return NextCmdAddress<ValueType>(cmd); 446 return NextCmdAddress<ValueType>(cmd);
445 } 447 }
446 448
447 CommandHeader header; 449 CommandHeader header;
448 uint32 bucket_id; 450 uint32_t bucket_id;
449 uint32 result_memory_id; 451 uint32_t result_memory_id;
450 uint32 result_memory_offset; 452 uint32_t result_memory_offset;
451 uint32 data_memory_size; 453 uint32_t data_memory_size;
452 uint32 data_memory_id; 454 uint32_t data_memory_id;
453 uint32 data_memory_offset; 455 uint32_t data_memory_offset;
454 }; 456 };
455 457
456 COMPILE_ASSERT(sizeof(GetBucketStart) == 28, Sizeof_GetBucketStart_is_not_28); 458 COMPILE_ASSERT(sizeof(GetBucketStart) == 28, Sizeof_GetBucketStart_is_not_28);
457 COMPILE_ASSERT(offsetof(GetBucketStart, header) == 0, 459 COMPILE_ASSERT(offsetof(GetBucketStart, header) == 0,
458 Offsetof_GetBucketStart_header_not_0); 460 Offsetof_GetBucketStart_header_not_0);
459 COMPILE_ASSERT(offsetof(GetBucketStart, bucket_id) == 4, 461 COMPILE_ASSERT(offsetof(GetBucketStart, bucket_id) == 4,
460 Offsetof_GetBucketStart_bucket_id_not_4); 462 Offsetof_GetBucketStart_bucket_id_not_4);
461 COMPILE_ASSERT(offsetof(GetBucketStart, result_memory_id) == 8, 463 COMPILE_ASSERT(offsetof(GetBucketStart, result_memory_id) == 8,
462 Offsetof_GetBucketStart_result_memory_id_not_8); 464 Offsetof_GetBucketStart_result_memory_id_not_8);
463 COMPILE_ASSERT(offsetof(GetBucketStart, result_memory_offset) == 12, 465 COMPILE_ASSERT(offsetof(GetBucketStart, result_memory_offset) == 12,
464 Offsetof_GetBucketStart_result_memory_offset_not_12); 466 Offsetof_GetBucketStart_result_memory_offset_not_12);
465 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_size) == 16, 467 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_size) == 16,
466 Offsetof_GetBucketStart_data_memory_size_not_16); 468 Offsetof_GetBucketStart_data_memory_size_not_16);
467 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_id) == 20, 469 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_id) == 20,
468 Offsetof_GetBucketStart_data_memory_id_not_20); 470 Offsetof_GetBucketStart_data_memory_id_not_20);
469 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_offset) == 24, 471 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_offset) == 24,
470 Offsetof_GetBucketStart_data_memory_offset_not_24); 472 Offsetof_GetBucketStart_data_memory_offset_not_24);
471 473
472 // Gets a piece of a result the service as available. 474 // Gets a piece of a result the service as available.
473 // See GetBucketSize. 475 // See GetBucketSize.
474 struct GetBucketData { 476 struct GetBucketData {
475 typedef GetBucketData ValueType; 477 typedef GetBucketData ValueType;
476 static const CommandId kCmdId = kGetBucketData; 478 static const CommandId kCmdId = kGetBucketData;
477 static const cmd::ArgFlags kArgFlags = cmd::kFixed; 479 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
478 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); 480 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
479 481
480 void SetHeader() { 482 void SetHeader() {
481 header.SetCmd<ValueType>(); 483 header.SetCmd<ValueType>();
482 } 484 }
483 485
484 void Init(uint32 _bucket_id, 486 void Init(uint32_t _bucket_id,
485 uint32 _offset, 487 uint32_t _offset,
486 uint32 _size, 488 uint32_t _size,
487 uint32 _shared_memory_id, 489 uint32_t _shared_memory_id,
488 uint32 _shared_memory_offset) { 490 uint32_t _shared_memory_offset) {
489 SetHeader(); 491 SetHeader();
490 bucket_id = _bucket_id; 492 bucket_id = _bucket_id;
491 offset = _offset; 493 offset = _offset;
492 size = _size; 494 size = _size;
493 shared_memory_id = _shared_memory_id; 495 shared_memory_id = _shared_memory_id;
494 shared_memory_offset = _shared_memory_offset; 496 shared_memory_offset = _shared_memory_offset;
495 } 497 }
496 static void* Set(void* cmd, 498 static void* Set(void* cmd,
497 uint32 _bucket_id, 499 uint32_t _bucket_id,
498 uint32 _offset, 500 uint32_t _offset,
499 uint32 _size, 501 uint32_t _size,
500 uint32 _shared_memory_id, 502 uint32_t _shared_memory_id,
501 uint32 _shared_memory_offset) { 503 uint32_t _shared_memory_offset) {
502 static_cast<ValueType*>(cmd)->Init( 504 static_cast<ValueType*>(cmd)->Init(
503 _bucket_id, 505 _bucket_id,
504 _offset, 506 _offset,
505 _size, 507 _size,
506 _shared_memory_id, 508 _shared_memory_id,
507 _shared_memory_offset); 509 _shared_memory_offset);
508 return NextCmdAddress<ValueType>(cmd); 510 return NextCmdAddress<ValueType>(cmd);
509 } 511 }
510 512
511 CommandHeader header; 513 CommandHeader header;
512 uint32 bucket_id; 514 uint32_t bucket_id;
513 uint32 offset; 515 uint32_t offset;
514 uint32 size; 516 uint32_t size;
515 uint32 shared_memory_id; 517 uint32_t shared_memory_id;
516 uint32 shared_memory_offset; 518 uint32_t shared_memory_offset;
517 }; 519 };
518 520
519 COMPILE_ASSERT(sizeof(GetBucketData) == 24, Sizeof_GetBucketData_is_not_20); 521 COMPILE_ASSERT(sizeof(GetBucketData) == 24, Sizeof_GetBucketData_is_not_20);
520 COMPILE_ASSERT(offsetof(GetBucketData, header) == 0, 522 COMPILE_ASSERT(offsetof(GetBucketData, header) == 0,
521 Offsetof_GetBucketData_header_not_0); 523 Offsetof_GetBucketData_header_not_0);
522 COMPILE_ASSERT(offsetof(GetBucketData, bucket_id) == 4, 524 COMPILE_ASSERT(offsetof(GetBucketData, bucket_id) == 4,
523 Offsetof_GetBucketData_bucket_id_not_4); 525 Offsetof_GetBucketData_bucket_id_not_4);
524 COMPILE_ASSERT(offsetof(GetBucketData, offset) == 8, 526 COMPILE_ASSERT(offsetof(GetBucketData, offset) == 8,
525 Offsetof_GetBucketData_offset_not_8); 527 Offsetof_GetBucketData_offset_not_8);
526 COMPILE_ASSERT(offsetof(GetBucketData, size) == 12, 528 COMPILE_ASSERT(offsetof(GetBucketData, size) == 12,
527 Offsetof_GetBucketData_size_not_12); 529 Offsetof_GetBucketData_size_not_12);
528 COMPILE_ASSERT(offsetof(GetBucketData, shared_memory_id) == 16, 530 COMPILE_ASSERT(offsetof(GetBucketData, shared_memory_id) == 16,
529 Offsetof_GetBucketData_shared_memory_id_not_16); 531 Offsetof_GetBucketData_shared_memory_id_not_16);
530 COMPILE_ASSERT(offsetof(GetBucketData, shared_memory_offset) == 20, 532 COMPILE_ASSERT(offsetof(GetBucketData, shared_memory_offset) == 20,
531 Offsetof_GetBucketData_shared_memory_offset_not_20); 533 Offsetof_GetBucketData_shared_memory_offset_not_20);
532 534
533 } // namespace cmd 535 } // namespace cmd
534 536
535 #pragma pack(pop) 537 #pragma pack(pop)
536 538
537 } // namespace gpu 539 } // namespace gpu
538 540
539 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ 541 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_
540 542
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698