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 23 matching lines...) Expand all Loading... |
34 (size_in_bytes + sizeof(uint32) - 1) / sizeof(uint32)); // NOLINT | 34 (size_in_bytes + sizeof(uint32) - 1) / sizeof(uint32)); // NOLINT |
35 } | 35 } |
36 | 36 |
37 // Rounds up to a multiple of entries in bytes. | 37 // Rounds up to a multiple of entries in bytes. |
38 inline size_t RoundSizeToMultipleOfEntries(size_t size_in_bytes) { | 38 inline size_t RoundSizeToMultipleOfEntries(size_t size_in_bytes) { |
39 return ComputeNumEntries(size_in_bytes) * sizeof(uint32); // NOLINT | 39 return ComputeNumEntries(size_in_bytes) * sizeof(uint32); // NOLINT |
40 } | 40 } |
41 | 41 |
42 // Struct that defines the command header in the command buffer. | 42 // Struct that defines the command header in the command buffer. |
43 struct CommandHeader { | 43 struct CommandHeader { |
44 Uint32 size:21; | 44 uint32 size:21; |
45 Uint32 command:11; | 45 uint32 command:11; |
46 | 46 |
47 GPU_EXPORT static const int32 kMaxSize = (1 << 21) - 1; | 47 GPU_EXPORT static const int32 kMaxSize = (1 << 21) - 1; |
48 | 48 |
49 void Init(uint32 _command, int32 _size) { | 49 void Init(uint32 _command, int32 _size) { |
50 DCHECK_LE(_size, kMaxSize); | 50 DCHECK_LE(_size, kMaxSize); |
51 command = _command; | 51 command = _command; |
52 size = _size; | 52 size = _size; |
53 } | 53 } |
54 | 54 |
55 // Sets the header based on the passed in command. Can not be used for | 55 // Sets the header based on the passed in command. Can not be used for |
(...skipping 19 matching lines...) Expand all Loading... |
75 DCHECK_GE(size_in_bytes, sizeof(T)); // NOLINT | 75 DCHECK_GE(size_in_bytes, sizeof(T)); // NOLINT |
76 Init(T::kCmdId, ComputeNumEntries(size_in_bytes)); | 76 Init(T::kCmdId, ComputeNumEntries(size_in_bytes)); |
77 } | 77 } |
78 }; | 78 }; |
79 | 79 |
80 COMPILE_ASSERT(sizeof(CommandHeader) == 4, Sizeof_CommandHeader_is_not_4); | 80 COMPILE_ASSERT(sizeof(CommandHeader) == 4, Sizeof_CommandHeader_is_not_4); |
81 | 81 |
82 // Union that defines possible command buffer entries. | 82 // Union that defines possible command buffer entries. |
83 union CommandBufferEntry { | 83 union CommandBufferEntry { |
84 CommandHeader value_header; | 84 CommandHeader value_header; |
85 Uint32 value_uint32; | 85 uint32 value_uint32; |
86 Int32 value_int32; | 86 int32 value_int32; |
87 float value_float; | 87 float value_float; |
88 }; | 88 }; |
89 | 89 |
90 #define GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT 4 | 90 #define GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT 4 |
91 const size_t kCommandBufferEntrySize = GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT; | 91 const size_t kCommandBufferEntrySize = GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT; |
92 | 92 |
93 COMPILE_ASSERT(sizeof(CommandBufferEntry) == kCommandBufferEntrySize, | 93 COMPILE_ASSERT(sizeof(CommandBufferEntry) == kCommandBufferEntrySize, |
94 Sizeof_CommandBufferEntry_is_not_4); | 94 Sizeof_CommandBufferEntry_is_not_4); |
95 | 95 |
96 // Command buffer is GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT byte aligned. | 96 // Command buffer is GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT byte aligned. |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 Offsetof_GetBucketData_shared_memory_offset_not_20); | 531 Offsetof_GetBucketData_shared_memory_offset_not_20); |
532 | 532 |
533 } // namespace cmd | 533 } // namespace cmd |
534 | 534 |
535 #pragma pack(pop) | 535 #pragma pack(pop) |
536 | 536 |
537 } // namespace gpu | 537 } // namespace gpu |
538 | 538 |
539 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ | 539 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ |
540 | 540 |
OLD | NEW |