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

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

Issue 465013: TBR=apatrick@chromium.org... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years 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 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 (size_in_bytes + sizeof(uint32) - 1) / sizeof(uint32)); // NOLINT 56 (size_in_bytes + sizeof(uint32) - 1) / sizeof(uint32)); // NOLINT
57 } 57 }
58 58
59 // Rounds up to a multiple of entries in bytes. 59 // Rounds up to a multiple of entries in bytes.
60 inline size_t RoundSizeToMultipleOfEntries(size_t size_in_bytes) { 60 inline size_t RoundSizeToMultipleOfEntries(size_t size_in_bytes) {
61 return ComputeNumEntries(size_in_bytes) * sizeof(uint32); // NOLINT 61 return ComputeNumEntries(size_in_bytes) * sizeof(uint32); // NOLINT
62 } 62 }
63 63
64 // Struct that defines the command header in the command buffer. 64 // Struct that defines the command header in the command buffer.
65 struct CommandHeader { 65 struct CommandHeader {
66 Uint32 size:8; 66 Uint32 size:21;
67 Uint32 command:24; 67 Uint32 command:11;
68 68
69 void Init(uint32 _command, uint32 _size) { 69 void Init(uint32 _command, uint32 _size) {
70 DCHECK_LT(_size, 256u); 70 DCHECK_LE(_size, 1u << 22);
71 command = _command; 71 command = _command;
72 size = _size; 72 size = _size;
73 } 73 }
74 74
75 // Sets the header based on the passed in command. Can not be used for 75 // Sets the header based on the passed in command. Can not be used for
76 // variable sized commands like immediate commands or Noop. 76 // variable sized commands like immediate commands or Noop.
77 template <typename T> 77 template <typename T>
78 void SetCmd() { 78 void SetCmd() {
79 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); 79 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed);
80 Init(T::kCmdId, ComputeNumEntries(sizeof(T))); // NOLINT 80 Init(T::kCmdId, ComputeNumEntries(sizeof(T))); // NOLINT
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // cmd: Address of command. 154 // cmd: Address of command.
155 // size_of_cmd_in_bytes: Size of the cmd and data. 155 // size_of_cmd_in_bytes: Size of the cmd and data.
156 template <typename T> 156 template <typename T>
157 void* NextImmediateCmdAddressTotalSize(void* cmd, uint32 total_size_in_bytes) { 157 void* NextImmediateCmdAddressTotalSize(void* cmd, uint32 total_size_in_bytes) {
158 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); 158 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN);
159 DCHECK_GE(total_size_in_bytes, sizeof(T)); // NOLINT 159 DCHECK_GE(total_size_in_bytes, sizeof(T)); // NOLINT
160 return reinterpret_cast<char*>(cmd) + 160 return reinterpret_cast<char*>(cmd) +
161 RoundSizeToMultipleOfEntries(total_size_in_bytes); 161 RoundSizeToMultipleOfEntries(total_size_in_bytes);
162 } 162 }
163 163
164 struct SharedMemory {
165 void Init(uint32 _id, uint32 _offset) {
166 id = _id;
167 offset = _offset;
168 }
169
170 uint32 id;
171 uint32 offset;
172 };
173
174 COMPILE_ASSERT(offsetof(SharedMemory, id) == 0,
175 Offsetof_SharedMemory_id_not_0);
176 COMPILE_ASSERT(offsetof(SharedMemory, offset) == 4,
177 Offsetof_SharedMemory_offset_not_4);
178
179
180 namespace cmd { 164 namespace cmd {
181 165
182 // This macro is used to safely and convienently expand the list of commnad 166 // This macro is used to safely and convienently expand the list of commnad
183 // buffer commands in to various lists and never have them get out of sync. To 167 // buffer commands in to various lists and never have them get out of sync. To
184 // add a new command, add it this list, create the corresponding structure below 168 // add a new command, add it this list, create the corresponding structure below
185 // and then add a function in gapi_decoder.cc called Handle_COMMAND_NAME where 169 // and then add a function in gapi_decoder.cc called Handle_COMMAND_NAME where
186 // COMMAND_NAME is the name of your command structure. 170 // COMMAND_NAME is the name of your command structure.
187 // 171 //
188 // NOTE: THE ORDER OF THESE MUST NOT CHANGE (their id is derived by order) 172 // NOTE: THE ORDER OF THESE MUST NOT CHANGE (their id is derived by order)
189 #define COMMON_COMMAND_BUFFER_CMDS(OP) \ 173 #define COMMON_COMMAND_BUFFER_CMDS(OP) \
190 OP(Noop) /* 0 */ \ 174 OP(Noop) /* 0 */ \
191 OP(SetToken) /* 1 */ \ 175 OP(SetToken) /* 1 */ \
176 OP(Jump) /* 2 */ \
177 OP(JumpRelative) /* 3 */ \
178 OP(Call) /* 4 */ \
179 OP(CallRelative) /* 5 */ \
180 OP(Return) /* 6 */ \
181 OP(SetBucketSize) /* 7 */ \
182 OP(SetBucketData) /* 8 */ \
183 OP(SetBucketDataImmediate) /* 9 */ \
184 OP(GetResultSize) /* 10 */ \
185 OP(GetResultData) /* 11 */ \
192 186
193 // Common commands. 187 // Common commands.
194 enum CommandId { 188 enum CommandId {
195 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name, 189 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name,
196 190
197 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) 191 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP)
198 192
199 #undef COMMON_COMMAND_BUFFER_CMD_OP 193 #undef COMMON_COMMAND_BUFFER_CMD_OP
200 194
201 kNumCommands, 195 kNumCommands,
202 kLastCommonId = 1023, // reserve 1024 spaces for common commands. 196 kLastCommonId = 255, // reserve 256 spaces for common commands.
203 }; 197 };
204 198
205 COMPILE_ASSERT(kNumCommands - 1 <= kLastCommonId, Too_many_common_commands); 199 COMPILE_ASSERT(kNumCommands - 1 <= kLastCommonId, Too_many_common_commands);
206 200
207 const char* GetCommandName(CommandId id); 201 const char* GetCommandName(CommandId id);
208 202
203 // A Noop command.
209 struct Noop { 204 struct Noop {
210 typedef Noop ValueType; 205 typedef Noop ValueType;
211 static const CommandId kCmdId = kNoop; 206 static const CommandId kCmdId = kNoop;
212 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; 207 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN;
213 208
214 void SetHeader(uint32 skip_count) { 209 void SetHeader(uint32 skip_count) {
215 header.Init(kCmdId, skip_count + 1); 210 header.Init(kCmdId, skip_count + 1);
216 } 211 }
217 212
218 void Init(uint32 skip_count) { 213 void Init(uint32 skip_count) {
219 SetHeader(skip_count); 214 SetHeader(skip_count);
220 } 215 }
221 216
222 static void* Set(void* cmd, uint32 skip_count) { 217 static void* Set(void* cmd, uint32 skip_count) {
223 static_cast<ValueType*>(cmd)->Init(skip_count); 218 static_cast<ValueType*>(cmd)->Init(skip_count);
224 return NextImmediateCmdAddress<ValueType>( 219 return NextImmediateCmdAddress<ValueType>(
225 cmd, skip_count * sizeof(CommandBufferEntry)); // NOLINT 220 cmd, skip_count * sizeof(CommandBufferEntry)); // NOLINT
226 } 221 }
227 222
228 CommandHeader header; 223 CommandHeader header;
229 }; 224 };
230 225
231 COMPILE_ASSERT(sizeof(Noop) == 4, Sizeof_Noop_is_not_4); 226 COMPILE_ASSERT(sizeof(Noop) == 4, Sizeof_Noop_is_not_4);
232 COMPILE_ASSERT(offsetof(Noop, header) == 0, Offsetof_Noop_header_not_0); 227 COMPILE_ASSERT(offsetof(Noop, header) == 0, Offsetof_Noop_header_not_0);
233 228
229 // The SetToken command puts a token in the command stream that you can
230 // use to check if that token has been passed in the command stream.
234 struct SetToken { 231 struct SetToken {
235 typedef SetToken ValueType; 232 typedef SetToken ValueType;
236 static const CommandId kCmdId = kSetToken; 233 static const CommandId kCmdId = kSetToken;
237 static const cmd::ArgFlags kArgFlags = cmd::kFixed; 234 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
238 235
239 void SetHeader() { 236 void SetHeader() {
240 header.SetCmd<ValueType>(); 237 header.SetCmd<ValueType>();
241 } 238 }
242 239
243 void Init(uint32 _token) { 240 void Init(uint32 _token) {
244 SetHeader(); 241 SetHeader();
245 token = _token; 242 token = _token;
246 } 243 }
247 static void* Set(void* cmd, uint32 token) { 244 static void* Set(void* cmd, uint32 token) {
248 static_cast<ValueType*>(cmd)->Init(token); 245 static_cast<ValueType*>(cmd)->Init(token);
249 return NextCmdAddress<ValueType>(cmd); 246 return NextCmdAddress<ValueType>(cmd);
250 } 247 }
251 248
252 CommandHeader header; 249 CommandHeader header;
253 uint32 token; 250 uint32 token;
254 }; 251 };
255 252
256 COMPILE_ASSERT(sizeof(SetToken) == 8, Sizeof_SetToken_is_not_8); 253 COMPILE_ASSERT(sizeof(SetToken) == 8, Sizeof_SetToken_is_not_8);
257 COMPILE_ASSERT(offsetof(SetToken, header) == 0, 254 COMPILE_ASSERT(offsetof(SetToken, header) == 0,
258 Offsetof_SetToken_header_not_0); 255 Offsetof_SetToken_header_not_0);
259 COMPILE_ASSERT(offsetof(SetToken, token) == 4, 256 COMPILE_ASSERT(offsetof(SetToken, token) == 4,
260 Offsetof_SetToken_token_not_4); 257 Offsetof_SetToken_token_not_4);
261 258
259 // The Jump command jumps to another place in the command buffer.
260 struct Jump {
261 typedef Jump ValueType;
262 static const CommandId kCmdId = kJump;
263 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
264
265 void SetHeader() {
266 header.SetCmd<ValueType>();
267 }
268
269 void Init(uint32 _shared_memory_id, uint32 _shared_memory_offset) {
270 SetHeader();
271 shared_memory_id = _shared_memory_id;
272 shared_memory_offset = _shared_memory_offset;
273 }
274 static void* Set(
275 void* cmd, uint32 _shared_memory_id, uint32 _shared_memory_offset) {
276 static_cast<ValueType*>(cmd)->Init(
277 _shared_memory_id, _shared_memory_offset);
278 return NextCmdAddress<ValueType>(cmd);
279 }
280
281 CommandHeader header;
282 uint32 shared_memory_id;
283 uint32 shared_memory_offset;
284 };
285
286 COMPILE_ASSERT(sizeof(Jump) == 12, Sizeof_Jump_is_not_12);
287 COMPILE_ASSERT(offsetof(Jump, header) == 0,
288 Offsetof_Jump_header_not_0);
289 COMPILE_ASSERT(offsetof(Jump, shared_memory_id) == 4,
290 Offsetof_Jump_shared_memory_id_not_4);
291 COMPILE_ASSERT(offsetof(Jump, shared_memory_offset) == 8,
292 Offsetof_Jump_shared_memory_offset_not_8);
293
294 // The JumpRelative command jumps to another place in the command buffer
295 // relative to the end of this command. In other words. JumpRelative with an
296 // offset of zero is effectively a noop.
297 struct JumpRelative {
298 typedef JumpRelative ValueType;
299 static const CommandId kCmdId = kJumpRelative;
300 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
301
302 void SetHeader() {
303 header.SetCmd<ValueType>();
304 }
305
306 void Init(int32 _offset) {
307 SetHeader();
308 offset = _offset;
309 }
310 static void* Set(void* cmd, int32 _offset) {
311 static_cast<ValueType*>(cmd)->Init(_offset);
312 return NextCmdAddress<ValueType>(cmd);
313 }
314
315 CommandHeader header;
316 int32 offset;
317 };
318
319 COMPILE_ASSERT(sizeof(JumpRelative) == 8, Sizeof_JumpRelative_is_not_8);
320 COMPILE_ASSERT(offsetof(JumpRelative, header) == 0,
321 Offsetof_JumpRelative_header_not_0);
322 COMPILE_ASSERT(offsetof(JumpRelative, offset) == 4,
323 Offsetof_JumpRelative_offset_4);
324
325 // The Call command jumps to a subroutine which can be returned from with the
326 // Return command.
327 struct Call {
328 typedef Call ValueType;
329 static const CommandId kCmdId = kCall;
330 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
331
332 void SetHeader() {
333 header.SetCmd<ValueType>();
334 }
335
336 void Init(uint32 _shared_memory_id, uint32 _shared_memory_offset) {
337 SetHeader();
338 shared_memory_id = _shared_memory_id;
339 shared_memory_offset = _shared_memory_offset;
340 }
341 static void* Set(
342 void* cmd, uint32 _shared_memory_id, uint32 _shared_memory_offset) {
343 static_cast<ValueType*>(cmd)->Init(
344 _shared_memory_id, _shared_memory_offset);
345 return NextCmdAddress<ValueType>(cmd);
346 }
347
348 CommandHeader header;
349 uint32 shared_memory_id;
350 uint32 shared_memory_offset;
351 };
352
353 COMPILE_ASSERT(sizeof(Call) == 12, Sizeof_Call_is_not_12);
354 COMPILE_ASSERT(offsetof(Call, header) == 0,
355 Offsetof_Call_header_not_0);
356 COMPILE_ASSERT(offsetof(Call, shared_memory_id) == 4,
357 Offsetof_Call_shared_memory_id_not_4);
358 COMPILE_ASSERT(offsetof(Call, shared_memory_offset) == 8,
359 Offsetof_Call_shared_memory_offset_not_8);
360
361 // The CallRelative command jumps to a subroutine using a relative offset. The
362 // offset is relative to the end of this command..
363 struct CallRelative {
364 typedef CallRelative ValueType;
365 static const CommandId kCmdId = kCallRelative;
366 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
367
368 void SetHeader() {
369 header.SetCmd<ValueType>();
370 }
371
372 void Init(int32 _offset) {
373 SetHeader();
374 offset = _offset;
375 }
376 static void* Set(void* cmd, int32 _offset) {
377 static_cast<ValueType*>(cmd)->Init(_offset);
378 return NextCmdAddress<ValueType>(cmd);
379 }
380
381 CommandHeader header;
382 int32 offset;
383 };
384
385 COMPILE_ASSERT(sizeof(CallRelative) == 8, Sizeof_CallRelative_is_not_8);
386 COMPILE_ASSERT(offsetof(CallRelative, header) == 0,
387 Offsetof_CallRelative_header_not_0);
388 COMPILE_ASSERT(offsetof(CallRelative, offset) == 4,
389 Offsetof_CallRelative_offset_4);
390
391 // Returns from a subroutine called by the Call or CallRelative commands.
392 struct Return {
393 typedef Return ValueType;
394 static const CommandId kCmdId = kReturn;
395 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
396
397 void SetHeader() {
398 header.SetCmd<ValueType>();
399 }
400
401 void Init() {
402 SetHeader();
403 }
404 static void* Set(void* cmd) {
405 static_cast<ValueType*>(cmd)->Init();
406 return NextCmdAddress<ValueType>(cmd);
407 }
408
409 CommandHeader header;
410 };
411
412 COMPILE_ASSERT(sizeof(Return) == 4, Sizeof_Return_is_not_4);
413 COMPILE_ASSERT(offsetof(Return, header) == 0,
414 Offsetof_Return_header_not_0);
415
416 // Sets the size of a bucket for collecting data on the service side.
417 // This is a utility for gathering data on the service side so it can be used
418 // all at once when some service side API is called. It removes the need to add
419 // special commands just to support a particular API. For example, any API
420 // command that needs a string needs a way to send that string to the API over
421 // the command buffers. While you can require that the command buffer or
422 // transfer buffer be large enough to hold the largest string you can send,
423 // using this command removes that restriction by letting you send smaller
424 // pieces over and build up the data on the service side.
425 //
426 // You can clear a bucket on the service side and thereby free memory by sending
427 // a size of 0.
428 struct SetBucketSize {
429 typedef SetBucketSize ValueType;
430 static const CommandId kCmdId = kSetBucketSize;
431 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
432
433 void SetHeader() {
434 header.SetCmd<ValueType>();
435 }
436
437 void Init(uint32 _bucket_id, uint32 _size) {
438 SetHeader();
439 bucket_id = _bucket_id;
440 size = _size;
441 }
442 static void* Set(void* cmd, uint32 _bucket_id, uint32 _size) {
443 static_cast<ValueType*>(cmd)->Init(_bucket_id, _size);
444 return NextCmdAddress<ValueType>(cmd);
445 }
446
447 CommandHeader header;
448 utin32 bucket_id;
449 uint32 size;
450 };
451
452 COMPILE_ASSERT(sizeof(SetBucketSize) == 12, Sizeof_SetBucketSize_is_not_8);
453 COMPILE_ASSERT(offsetof(SetBucketSize, header) == 0,
454 Offsetof_SetBucketSize_header_not_0);
455 COMPILE_ASSERT(offsetof(SetBucketSize, bucket_id) == 4,
456 Offsetof_SetBucketSize_bucket_id_4);
457 COMPILE_ASSERT(offsetof(SetBucketSize, size) == 8,
458 Offsetof_SetBucketSize_size_8);
459
460 // Sets the contents of a portion of a bucket on the service side from data in
461 // shared memory.
462 // See SetBucketSize.
463 struct SetBucketData {
464 typedef SetBucketData ValueType;
465 static const CommandId kCmdId = kSetBucketData;
466 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
467
468 void SetHeader() {
469 header.SetCmd<ValueType>();
470 }
471
472 void Init(uint32 _bucket_id,
473 uint32 _offset,
474 uint32 _size,
475 uint32 _shared_memory_id,
476 uint32 _shared_memory_offset) {
477 SetHeader();
478 bucket_id = _bucket_id;
479 offset = _offset;
480 size = _size;
481 shared_memory_id = _shared_memory_id;
482 shared_memory_offset = _shared_memory_offset;
483 }
484 static void* Set(void* cmd,
485 uint32 _bucket_id,
486 uint32 _offset,
487 uint32 _size,
488 uint32 _shared_memory_id,
489 uint32 _shared_memory_offset) {
490 static_cast<ValueType*>(cmd)->Init(
491 _bucket_id,
492 _offset,
493 _size,
494 _shared_memory_id,
495 _shared_memory_offset);
496 return NextCmdAddress<ValueType>(cmd);
497 }
498
499 CommandHeader header;
500 uint32 bucket_id;
501 uint32 offset;
502 uint32 size;
503 uint32 shared_memory_id;
504 uint32 shared_memory_offset;
505 };
506
507 COMPILE_ASSERT(sizeof(SetBucketData) == 24, Sizeof_SetBucketData_is_not_24);
508 COMPILE_ASSERT(offsetof(SetBucketData, header) == 0,
509 Offsetof_SetBucketData_header_not_0);
510 COMPILE_ASSERT(offsetof(SetBucketData, bucket_id) == 4,
511 Offsetof_SetBucketData_bucket_id_not_4);
512 COMPILE_ASSERT(offsetof(SetBucketData, offset) == 8,
513 Offsetof_SetBucketData_offset_not_8);
514 COMPILE_ASSERT(offsetof(SetBucketData, size) == 12,
515 Offsetof_SetBucketData_size_not_12);
516 COMPILE_ASSERT(offsetof(SetBucketData, shared_memory_id) == 16,
517 Offsetof_SetBucketData_shared_memory_id_not_16);
518 COMPILE_ASSERT(offsetof(SetBucketData, shared_memory_offset) == 20,
519 Offsetof_SetBucketData_shared_memory_offset_not_20);
520
521 // Sets the contents of a portion of a bucket on the service side from data in
522 // the command buffer.
523 // See SetBucketSize.
524 struct SetBucketDataImmediate {
525 typedef SetBucketDataImmediate ValueType;
526 static const CommandId kCmdId = kSetBucketDataImmediate;
527 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN;
528
529 void SetHeader(uint32 size) {
530 header.SetCmdBySize<ValueType>(size);
531 }
532
533 void Init(uint32 _bucket_id,
534 uint32 _offset,
535 uint32 _size) {
536 SetHeader(_size);
537 bucket_id = _bucket_id;
538 offset = _offset;
539 size = _size;
540 }
541 static void* Set(void* cmd,
542 uint32 _bucket_id,
543 uint32 _offset,
544 uint32 _size) {
545 static_cast<ValueType*>(cmd)->Init(
546 _bucket_id,
547 _offset,
548 _size);
549 return NextImmediateCmdAddress<ValueType>(cmd, _size);
550 }
551
552 CommandHeader header;
553 uint32 bucket_id;
554 uint32 offset;
555 uint32 size;
556 };
557
558 COMPILE_ASSERT(sizeof(SetBucketDataImmediate) == 16,
559 Sizeof_SetBucketDataImmediate_is_not_24);
560 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, header) == 0,
561 Offsetof_SetBucketDataImmediate_header_not_0);
562 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, bucket_id) == 4,
563 Offsetof_SetBucketDataImmediate_bucket_id_not_4);
564 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, offset) == 8,
565 Offsetof_SetBucketDataImmediate_offset_not_8);
566 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, size) == 12,
567 Offsetof_SetBucketDataImmediate_size_not_12);
568
569 // Gets the size of a result the service has available.
570 // Sending a variable size result back to the client, for example any API that
571 // returns a string, is problematic since the largest thing you can send back is
572 // the size of your shared memory. This command along with GetResultData
573 // implement a way to get a result a piece at a time to help solve that problem
574 // in a generic way.
575 struct GetResultSize {
576 typedef GetResultSize ValueType;
577 static const CommandId kCmdId = kGetResultSize;
578 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
579
580 void SetHeader() {
581 header.SetCmd<ValueType>();
582 }
583
584 void Init(uint32 _shared_memory_id,
585 uint32 _shared_memory_offset) {
586 SetHeader();
587 shared_memory_id = _shared_memory_id;
588 shared_memory_offset = _shared_memory_offset;
589 }
590 static void* Set(void* cmd,
591 uint32 _shared_memory_id,
592 uint32 _shared_memory_offset) {
593 static_cast<ValueType*>(cmd)->Init(
594 _shared_memory_id,
595 _shared_memory_offset);
596 return NextCmdAddress<ValueType>(cmd);
597 }
598
599 CommandHeader header;
600 uint32 shared_memory_id;
601 uint32 shared_memory_offset;
602 };
603
604 COMPILE_ASSERT(sizeof(GetResultSize) == 12, Sizeof_GetResultSize_is_not_12);
605 COMPILE_ASSERT(offsetof(GetResultSize, header) == 0,
606 Offsetof_GetResultSize_header_not_0);
607 COMPILE_ASSERT(offsetof(GetResultSize, shared_memory_id) == 4,
608 Offsetof_GetResultSize_shared_memory_id_not_4);
609 COMPILE_ASSERT(offsetof(GetResultSize, shared_memory_offset) == 8,
610 Offsetof_GetResultSize_shared_memory_offset_not_8);
611
612 // Gets a piece of a result the service as available.
613 // See GetResultSize.
614 struct GetResultData {
615 typedef GetResultData ValueType;
616 static const CommandId kCmdId = kGetResultData;
617 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
618
619 void SetHeader() {
620 header.SetCmd<ValueType>();
621 }
622
623 void Init(uint32 _offset,
624 uint32 _size,
625 uint32 _shared_memory_id,
626 uint32 _shared_memory_offset) {
627 SetHeader();
628 offset = _offset;
629 size = _size;
630 shared_memory_id = _shared_memory_id;
631 shared_memory_offset = _shared_memory_offset;
632 }
633 static void* Set(void* cmd,
634 uint32 _offset,
635 uint32 _size,
636 uint32 _shared_memory_id,
637 uint32 _shared_memory_offset) {
638 static_cast<ValueType*>(cmd)->Init(
639 _offset,
640 _size,
641 _shared_memory_id,
642 _shared_memory_offset);
643 return NextCmdAddress<ValueType>(cmd);
644 }
645
646 CommandHeader header;
647 uint32 offset;
648 uint32 size;
649 uint32 shared_memory_id;
650 uint32 shared_memory_offset;
651 };
652
653 COMPILE_ASSERT(sizeof(GetResultData) == 20, Sizeof_GetResultData_is_not_20);
654 COMPILE_ASSERT(offsetof(GetResultData, header) == 0,
655 Offsetof_GetResultData_header_not_0);
656 COMPILE_ASSERT(offsetof(GetResultData, offset) == 4,
657 Offsetof_GetResultData_offset_not_4);
658 COMPILE_ASSERT(offsetof(GetResultData, size) == 8,
659 Offsetof_GetResultData_size_not_8);
660 COMPILE_ASSERT(offsetof(GetResultData, shared_memory_id) == 12,
661 Offsetof_GetResultData_shared_memory_id_not_12);
662 COMPILE_ASSERT(offsetof(GetResultData, shared_memory_offset) == 16,
663 Offsetof_GetResultData_shared_memory_offset_not_16);
664
262 } // namespace cmd 665 } // namespace cmd
263 666
264 #pragma pack(pop) 667 #pragma pack(pop)
265 668
266 } // namespace command_buffer 669 } // namespace command_buffer
267 670
268 #endif // GPU_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_COMMON_H_ 671 #endif // GPU_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_COMMON_H_
269 672
OLDNEW
« no previous file with comments | « gpu/command_buffer/build_gles2_cmd_buffer.py ('k') | gpu/command_buffer/common/gles2_cmd_id_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698