OLD | NEW |
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> |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 OP(Noop) /* 0 */ \ | 151 OP(Noop) /* 0 */ \ |
152 OP(SetToken) /* 1 */ \ | 152 OP(SetToken) /* 1 */ \ |
153 OP(Jump) /* 2 */ \ | 153 OP(Jump) /* 2 */ \ |
154 OP(JumpRelative) /* 3 */ \ | 154 OP(JumpRelative) /* 3 */ \ |
155 OP(Call) /* 4 */ \ | 155 OP(Call) /* 4 */ \ |
156 OP(CallRelative) /* 5 */ \ | 156 OP(CallRelative) /* 5 */ \ |
157 OP(Return) /* 6 */ \ | 157 OP(Return) /* 6 */ \ |
158 OP(SetBucketSize) /* 7 */ \ | 158 OP(SetBucketSize) /* 7 */ \ |
159 OP(SetBucketData) /* 8 */ \ | 159 OP(SetBucketData) /* 8 */ \ |
160 OP(SetBucketDataImmediate) /* 9 */ \ | 160 OP(SetBucketDataImmediate) /* 9 */ \ |
161 OP(GetBucketSize) /* 10 */ \ | 161 OP(GetBucketStart) /* 10 */ \ |
162 OP(GetBucketData) /* 11 */ \ | 162 OP(GetBucketData) /* 11 */ \ |
163 | 163 |
164 // Common commands. | 164 // Common commands. |
165 enum CommandId { | 165 enum CommandId { |
166 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name, | 166 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name, |
167 | 167 |
168 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) | 168 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) |
169 | 169 |
170 #undef COMMON_COMMAND_BUFFER_CMD_OP | 170 #undef COMMON_COMMAND_BUFFER_CMD_OP |
171 | 171 |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 Sizeof_SetBucketDataImmediate_is_not_24); | 526 Sizeof_SetBucketDataImmediate_is_not_24); |
527 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, header) == 0, | 527 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, header) == 0, |
528 Offsetof_SetBucketDataImmediate_header_not_0); | 528 Offsetof_SetBucketDataImmediate_header_not_0); |
529 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, bucket_id) == 4, | 529 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, bucket_id) == 4, |
530 Offsetof_SetBucketDataImmediate_bucket_id_not_4); | 530 Offsetof_SetBucketDataImmediate_bucket_id_not_4); |
531 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, offset) == 8, | 531 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, offset) == 8, |
532 Offsetof_SetBucketDataImmediate_offset_not_8); | 532 Offsetof_SetBucketDataImmediate_offset_not_8); |
533 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, size) == 12, | 533 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, size) == 12, |
534 Offsetof_SetBucketDataImmediate_size_not_12); | 534 Offsetof_SetBucketDataImmediate_size_not_12); |
535 | 535 |
536 // Gets the size of a bucket the service has available. Sending a variable size | 536 // Gets the start of a bucket the service has available. Sending a variable size |
537 // result back to the client, for example any API that returns a string, is | 537 // result back to the client and the portion of that result that fits in the |
538 // problematic since the largest thing you can send back is the size of your | 538 // supplied shared memory. If the size of the result is larger than the supplied |
539 // shared memory. This command along with GetBucketData implements a way to get | 539 // shared memory the rest of the bucket's contents can be retrieved with |
540 // a result a piece at a time to help solve that problem in a generic way. | 540 // GetBucketData. |
541 struct GetBucketSize { | 541 // |
542 typedef GetBucketSize ValueType; | 542 // This is used for example for any API that returns a string. The problem is |
543 static const CommandId kCmdId = kGetBucketSize; | 543 // the largest thing you can send back in 1 command is the size of your shared |
| 544 // memory. This command along with GetBucketData implements a way to get a |
| 545 // result a piece at a time to help solve that problem in a generic way. |
| 546 struct GetBucketStart { |
| 547 typedef GetBucketStart ValueType; |
| 548 static const CommandId kCmdId = kGetBucketStart; |
544 static const cmd::ArgFlags kArgFlags = cmd::kFixed; | 549 static const cmd::ArgFlags kArgFlags = cmd::kFixed; |
545 | 550 |
546 typedef uint32 Result; | 551 typedef uint32 Result; |
547 | 552 |
548 void SetHeader() { | 553 void SetHeader() { |
549 header.SetCmd<ValueType>(); | 554 header.SetCmd<ValueType>(); |
550 } | 555 } |
551 | 556 |
552 void Init(uint32 _bucket_id, | 557 void Init(uint32 _bucket_id, |
553 uint32 _shared_memory_id, | 558 uint32 _result_memory_id, |
554 uint32 _shared_memory_offset) { | 559 uint32 _result_memory_offset, |
| 560 uint32 _data_memory_size, |
| 561 uint32 _data_memory_id, |
| 562 uint32 _data_memory_offset) { |
555 SetHeader(); | 563 SetHeader(); |
556 bucket_id = _bucket_id; | 564 bucket_id = _bucket_id; |
557 shared_memory_id = _shared_memory_id; | 565 result_memory_id = _result_memory_id; |
558 shared_memory_offset = _shared_memory_offset; | 566 result_memory_offset = _result_memory_offset; |
| 567 data_memory_size = _data_memory_size; |
| 568 data_memory_id = _data_memory_id; |
| 569 data_memory_offset = _data_memory_offset; |
559 } | 570 } |
560 static void* Set(void* cmd, | 571 static void* Set(void* cmd, |
561 uint32 _bucket_id, | 572 uint32 _bucket_id, |
562 uint32 _shared_memory_id, | 573 uint32 _result_memory_id, |
563 uint32 _shared_memory_offset) { | 574 uint32 _result_memory_offset, |
| 575 uint32 _data_memory_size, |
| 576 uint32 _data_memory_id, |
| 577 uint32 _data_memory_offset) { |
564 static_cast<ValueType*>(cmd)->Init( | 578 static_cast<ValueType*>(cmd)->Init( |
565 _bucket_id, | 579 _bucket_id, |
566 _shared_memory_id, | 580 _result_memory_id, |
567 _shared_memory_offset); | 581 _result_memory_offset, |
| 582 _data_memory_size, |
| 583 _data_memory_id, |
| 584 _data_memory_offset); |
568 return NextCmdAddress<ValueType>(cmd); | 585 return NextCmdAddress<ValueType>(cmd); |
569 } | 586 } |
570 | 587 |
571 CommandHeader header; | 588 CommandHeader header; |
572 uint32 bucket_id; | 589 uint32 bucket_id; |
573 uint32 shared_memory_id; | 590 uint32 result_memory_id; |
574 uint32 shared_memory_offset; | 591 uint32 result_memory_offset; |
| 592 uint32 data_memory_size; |
| 593 uint32 data_memory_id; |
| 594 uint32 data_memory_offset; |
575 }; | 595 }; |
576 | 596 |
577 COMPILE_ASSERT(sizeof(GetBucketSize) == 16, Sizeof_GetBucketSize_is_not_16); | 597 COMPILE_ASSERT(sizeof(GetBucketStart) == 28, Sizeof_GetBucketStart_is_not_28); |
578 COMPILE_ASSERT(offsetof(GetBucketSize, header) == 0, | 598 COMPILE_ASSERT(offsetof(GetBucketStart, header) == 0, |
579 Offsetof_GetBucketSize_header_not_0); | 599 Offsetof_GetBucketStart_header_not_0); |
580 COMPILE_ASSERT(offsetof(GetBucketSize, bucket_id) == 4, | 600 COMPILE_ASSERT(offsetof(GetBucketStart, bucket_id) == 4, |
581 Offsetof_GetBucketSize_bucket_id_not_4); | 601 Offsetof_GetBucketStart_bucket_id_not_4); |
582 COMPILE_ASSERT(offsetof(GetBucketSize, shared_memory_id) == 8, | 602 COMPILE_ASSERT(offsetof(GetBucketStart, result_memory_id) == 8, |
583 Offsetof_GetBucketSize_shared_memory_id_not_8); | 603 Offsetof_GetBucketStart_result_memory_id_not_8); |
584 COMPILE_ASSERT(offsetof(GetBucketSize, shared_memory_offset) == 12, | 604 COMPILE_ASSERT(offsetof(GetBucketStart, result_memory_offset) == 12, |
585 Offsetof_GetBucketSize_shared_memory_offset_not_12); | 605 Offsetof_GetBucketStart_result_memory_offset_not_12); |
| 606 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_size) == 16, |
| 607 Offsetof_GetBucketStart_data_memory_size_not_16); |
| 608 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_id) == 20, |
| 609 Offsetof_GetBucketStart_data_memory_id_not_20); |
| 610 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_offset) == 24, |
| 611 Offsetof_GetBucketStart_data_memory_offset_not_24); |
586 | 612 |
587 // Gets a piece of a result the service as available. | 613 // Gets a piece of a result the service as available. |
588 // See GetBucketSize. | 614 // See GetBucketSize. |
589 struct GetBucketData { | 615 struct GetBucketData { |
590 typedef GetBucketData ValueType; | 616 typedef GetBucketData ValueType; |
591 static const CommandId kCmdId = kGetBucketData; | 617 static const CommandId kCmdId = kGetBucketData; |
592 static const cmd::ArgFlags kArgFlags = cmd::kFixed; | 618 static const cmd::ArgFlags kArgFlags = cmd::kFixed; |
593 | 619 |
594 void SetHeader() { | 620 void SetHeader() { |
595 header.SetCmd<ValueType>(); | 621 header.SetCmd<ValueType>(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 Offsetof_GetBucketData_shared_memory_offset_not_20); | 671 Offsetof_GetBucketData_shared_memory_offset_not_20); |
646 | 672 |
647 } // namespace cmd | 673 } // namespace cmd |
648 | 674 |
649 #pragma pack(pop) | 675 #pragma pack(pop) |
650 | 676 |
651 } // namespace gpu | 677 } // namespace gpu |
652 | 678 |
653 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ | 679 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ |
654 | 680 |
OLD | NEW |