| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 void Init(uint32_t _command, int32_t _size) { | 50 void Init(uint32_t _command, int32_t _size) { |
| 51 DCHECK_LE(_size, kMaxSize); | 51 DCHECK_LE(_size, kMaxSize); |
| 52 command = _command; | 52 command = _command; |
| 53 size = _size; | 53 size = _size; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // 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 |
| 57 // variable sized commands like immediate commands or Noop. | 57 // variable sized commands like immediate commands or Noop. |
| 58 template <typename T> | 58 template <typename T> |
| 59 void SetCmd() { | 59 void SetCmd() { |
| 60 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); | 60 static_assert(T::kArgFlags == cmd::kFixed, |
| 61 "T::kArgFlags should equal cmd::kFixed"); |
| 61 Init(T::kCmdId, ComputeNumEntries(sizeof(T))); // NOLINT | 62 Init(T::kCmdId, ComputeNumEntries(sizeof(T))); // NOLINT |
| 62 } | 63 } |
| 63 | 64 |
| 64 // Sets the header by a size in bytes of the immediate data after the command. | 65 // Sets the header by a size in bytes of the immediate data after the command. |
| 65 template <typename T> | 66 template <typename T> |
| 66 void SetCmdBySize(uint32_t size_of_data_in_bytes) { | 67 void SetCmdBySize(uint32_t size_of_data_in_bytes) { |
| 67 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); | 68 static_assert(T::kArgFlags == cmd::kAtLeastN, |
| 69 "T::kArgFlags should equal cmd::kAtLeastN"); |
| 68 Init(T::kCmdId, | 70 Init(T::kCmdId, |
| 69 ComputeNumEntries(sizeof(T) + size_of_data_in_bytes)); // NOLINT | 71 ComputeNumEntries(sizeof(T) + size_of_data_in_bytes)); // NOLINT |
| 70 } | 72 } |
| 71 | 73 |
| 72 // Sets the header by a size in bytes. | 74 // Sets the header by a size in bytes. |
| 73 template <typename T> | 75 template <typename T> |
| 74 void SetCmdByTotalSize(uint32_t size_in_bytes) { | 76 void SetCmdByTotalSize(uint32_t size_in_bytes) { |
| 75 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); | 77 static_assert(T::kArgFlags == cmd::kAtLeastN, |
| 78 "T::kArgFlags should equal cmd::kAtLeastN"); |
| 76 DCHECK_GE(size_in_bytes, sizeof(T)); // NOLINT | 79 DCHECK_GE(size_in_bytes, sizeof(T)); // NOLINT |
| 77 Init(T::kCmdId, ComputeNumEntries(size_in_bytes)); | 80 Init(T::kCmdId, ComputeNumEntries(size_in_bytes)); |
| 78 } | 81 } |
| 79 }; | 82 }; |
| 80 | 83 |
| 81 COMPILE_ASSERT(sizeof(CommandHeader) == 4, Sizeof_CommandHeader_is_not_4); | 84 static_assert(sizeof(CommandHeader) == 4, |
| 85 "size of CommandHeader should equal 4"); |
| 82 | 86 |
| 83 // Union that defines possible command buffer entries. | 87 // Union that defines possible command buffer entries. |
| 84 union CommandBufferEntry { | 88 union CommandBufferEntry { |
| 85 CommandHeader value_header; | 89 CommandHeader value_header; |
| 86 uint32_t value_uint32; | 90 uint32_t value_uint32; |
| 87 int32_t value_int32; | 91 int32_t value_int32; |
| 88 float value_float; | 92 float value_float; |
| 89 }; | 93 }; |
| 90 | 94 |
| 91 #define GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT 4 | 95 #define GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT 4 |
| 92 const size_t kCommandBufferEntrySize = GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT; | 96 const size_t kCommandBufferEntrySize = GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT; |
| 93 | 97 |
| 94 COMPILE_ASSERT(sizeof(CommandBufferEntry) == kCommandBufferEntrySize, | 98 static_assert(sizeof(CommandBufferEntry) == kCommandBufferEntrySize, |
| 95 Sizeof_CommandBufferEntry_is_not_4); | 99 "size of CommandBufferEntry should equal " |
| 100 "kCommandBufferEntrySize"); |
| 96 | 101 |
| 97 // Command buffer is GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT byte aligned. | 102 // Command buffer is GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT byte aligned. |
| 98 #pragma pack(push, GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT) | 103 #pragma pack(push, GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT) |
| 99 | 104 |
| 100 // Gets the address of memory just after a structure in a typesafe way. This is | 105 // Gets the address of memory just after a structure in a typesafe way. This is |
| 101 // used for IMMEDIATE commands to get the address of the place to put the data. | 106 // used for IMMEDIATE commands to get the address of the place to put the data. |
| 102 // Immediate command put their data direclty in the command buffer. | 107 // Immediate command put their data direclty in the command buffer. |
| 103 // Parameters: | 108 // Parameters: |
| 104 // cmd: Address of command. | 109 // cmd: Address of command. |
| 105 template <typename T> | 110 template <typename T> |
| 106 void* ImmediateDataAddress(T* cmd) { | 111 void* ImmediateDataAddress(T* cmd) { |
| 107 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); | 112 static_assert(T::kArgFlags == cmd::kAtLeastN, |
| 113 "T::kArgFlags should equal cmd::kAtLeastN"); |
| 108 return reinterpret_cast<char*>(cmd) + sizeof(*cmd); | 114 return reinterpret_cast<char*>(cmd) + sizeof(*cmd); |
| 109 } | 115 } |
| 110 | 116 |
| 111 // Gets the address of the place to put the next command in a typesafe way. | 117 // Gets the address of the place to put the next command in a typesafe way. |
| 112 // This can only be used for fixed sized commands. | 118 // This can only be used for fixed sized commands. |
| 113 template <typename T> | 119 template <typename T> |
| 114 // Parameters: | 120 // Parameters: |
| 115 // cmd: Address of command. | 121 // cmd: Address of command. |
| 116 void* NextCmdAddress(void* cmd) { | 122 void* NextCmdAddress(void* cmd) { |
| 117 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); | 123 static_assert(T::kArgFlags == cmd::kFixed, |
| 124 "T::kArgFlags should equal cmd::kFixed"); |
| 118 return reinterpret_cast<char*>(cmd) + sizeof(T); | 125 return reinterpret_cast<char*>(cmd) + sizeof(T); |
| 119 } | 126 } |
| 120 | 127 |
| 121 // Gets the address of the place to put the next command in a typesafe way. | 128 // Gets the address of the place to put the next command in a typesafe way. |
| 122 // This can only be used for variable sized command like IMMEDIATE commands. | 129 // This can only be used for variable sized command like IMMEDIATE commands. |
| 123 // Parameters: | 130 // Parameters: |
| 124 // cmd: Address of command. | 131 // cmd: Address of command. |
| 125 // size_of_data_in_bytes: Size of the data for the command. | 132 // size_of_data_in_bytes: Size of the data for the command. |
| 126 template <typename T> | 133 template <typename T> |
| 127 void* NextImmediateCmdAddress(void* cmd, uint32_t size_of_data_in_bytes) { | 134 void* NextImmediateCmdAddress(void* cmd, uint32_t size_of_data_in_bytes) { |
| 128 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); | 135 static_assert(T::kArgFlags == cmd::kAtLeastN, |
| 136 "T::kArgFlags should equal cmd::kAtLeastN"); |
| 129 return reinterpret_cast<char*>(cmd) + sizeof(T) + // NOLINT | 137 return reinterpret_cast<char*>(cmd) + sizeof(T) + // NOLINT |
| 130 RoundSizeToMultipleOfEntries(size_of_data_in_bytes); | 138 RoundSizeToMultipleOfEntries(size_of_data_in_bytes); |
| 131 } | 139 } |
| 132 | 140 |
| 133 // Gets the address of the place to put the next command in a typesafe way. | 141 // Gets the address of the place to put the next command in a typesafe way. |
| 134 // This can only be used for variable sized command like IMMEDIATE commands. | 142 // This can only be used for variable sized command like IMMEDIATE commands. |
| 135 // Parameters: | 143 // Parameters: |
| 136 // cmd: Address of command. | 144 // cmd: Address of command. |
| 137 // size_of_cmd_in_bytes: Size of the cmd and data. | 145 // size_of_cmd_in_bytes: Size of the cmd and data. |
| 138 template <typename T> | 146 template <typename T> |
| 139 void* NextImmediateCmdAddressTotalSize(void* cmd, | 147 void* NextImmediateCmdAddressTotalSize(void* cmd, |
| 140 uint32_t total_size_in_bytes) { | 148 uint32_t total_size_in_bytes) { |
| 141 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); | 149 static_assert(T::kArgFlags == cmd::kAtLeastN, |
| 150 "T::kArgFlags should equal cmd::kAtLeastN"); |
| 142 DCHECK_GE(total_size_in_bytes, sizeof(T)); // NOLINT | 151 DCHECK_GE(total_size_in_bytes, sizeof(T)); // NOLINT |
| 143 return reinterpret_cast<char*>(cmd) + | 152 return reinterpret_cast<char*>(cmd) + |
| 144 RoundSizeToMultipleOfEntries(total_size_in_bytes); | 153 RoundSizeToMultipleOfEntries(total_size_in_bytes); |
| 145 } | 154 } |
| 146 | 155 |
| 147 namespace cmd { | 156 namespace cmd { |
| 148 | 157 |
| 149 // This macro is used to safely and convienently expand the list of commnad | 158 // This macro is used to safely and convienently expand the list of commnad |
| 150 // buffer commands in to various lists and never have them get out of sync. To | 159 // buffer commands in to various lists and never have them get out of sync. To |
| 151 // add a new command, add it this list, create the corresponding structure below | 160 // add a new command, add it this list, create the corresponding structure below |
| (...skipping 15 matching lines...) Expand all Loading... |
| 167 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name, | 176 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name, |
| 168 | 177 |
| 169 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) | 178 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) |
| 170 | 179 |
| 171 #undef COMMON_COMMAND_BUFFER_CMD_OP | 180 #undef COMMON_COMMAND_BUFFER_CMD_OP |
| 172 | 181 |
| 173 kNumCommands, | 182 kNumCommands, |
| 174 kLastCommonId = 255 // reserve 256 spaces for common commands. | 183 kLastCommonId = 255 // reserve 256 spaces for common commands. |
| 175 }; | 184 }; |
| 176 | 185 |
| 177 COMPILE_ASSERT(kNumCommands - 1 <= kLastCommonId, Too_many_common_commands); | 186 static_assert(kNumCommands - 1 <= kLastCommonId, "too many commands"); |
| 178 | 187 |
| 179 const char* GetCommandName(CommandId id); | 188 const char* GetCommandName(CommandId id); |
| 180 | 189 |
| 181 // A Noop command. | 190 // A Noop command. |
| 182 struct Noop { | 191 struct Noop { |
| 183 typedef Noop ValueType; | 192 typedef Noop ValueType; |
| 184 static const CommandId kCmdId = kNoop; | 193 static const CommandId kCmdId = kNoop; |
| 185 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; | 194 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; |
| 186 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); | 195 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); |
| 187 | 196 |
| 188 void SetHeader(uint32_t skip_count) { | 197 void SetHeader(uint32_t skip_count) { |
| 189 DCHECK_GT(skip_count, 0u); | 198 DCHECK_GT(skip_count, 0u); |
| 190 header.Init(kCmdId, skip_count); | 199 header.Init(kCmdId, skip_count); |
| 191 } | 200 } |
| 192 | 201 |
| 193 void Init(uint32_t skip_count) { | 202 void Init(uint32_t skip_count) { |
| 194 SetHeader(skip_count); | 203 SetHeader(skip_count); |
| 195 } | 204 } |
| 196 | 205 |
| 197 static void* Set(void* cmd, uint32_t skip_count) { | 206 static void* Set(void* cmd, uint32_t skip_count) { |
| 198 static_cast<ValueType*>(cmd)->Init(skip_count); | 207 static_cast<ValueType*>(cmd)->Init(skip_count); |
| 199 return NextImmediateCmdAddress<ValueType>( | 208 return NextImmediateCmdAddress<ValueType>( |
| 200 cmd, skip_count * sizeof(CommandBufferEntry)); // NOLINT | 209 cmd, skip_count * sizeof(CommandBufferEntry)); // NOLINT |
| 201 } | 210 } |
| 202 | 211 |
| 203 CommandHeader header; | 212 CommandHeader header; |
| 204 }; | 213 }; |
| 205 | 214 |
| 206 COMPILE_ASSERT(sizeof(Noop) == 4, Sizeof_Noop_is_not_4); | 215 static_assert(sizeof(Noop) == 4, "size of Noop should equal 4"); |
| 207 COMPILE_ASSERT(offsetof(Noop, header) == 0, Offsetof_Noop_header_not_0); | 216 static_assert(offsetof(Noop, header) == 0, |
| 217 "offset of Noop.header should equal 0"); |
| 208 | 218 |
| 209 // The SetToken command puts a token in the command stream that you can | 219 // The SetToken command puts a token in the command stream that you can |
| 210 // use to check if that token has been passed in the command stream. | 220 // use to check if that token has been passed in the command stream. |
| 211 struct SetToken { | 221 struct SetToken { |
| 212 typedef SetToken ValueType; | 222 typedef SetToken ValueType; |
| 213 static const CommandId kCmdId = kSetToken; | 223 static const CommandId kCmdId = kSetToken; |
| 214 static const cmd::ArgFlags kArgFlags = cmd::kFixed; | 224 static const cmd::ArgFlags kArgFlags = cmd::kFixed; |
| 215 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); | 225 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); |
| 216 | 226 |
| 217 void SetHeader() { | 227 void SetHeader() { |
| 218 header.SetCmd<ValueType>(); | 228 header.SetCmd<ValueType>(); |
| 219 } | 229 } |
| 220 | 230 |
| 221 void Init(uint32_t _token) { | 231 void Init(uint32_t _token) { |
| 222 SetHeader(); | 232 SetHeader(); |
| 223 token = _token; | 233 token = _token; |
| 224 } | 234 } |
| 225 static void* Set(void* cmd, uint32_t token) { | 235 static void* Set(void* cmd, uint32_t token) { |
| 226 static_cast<ValueType*>(cmd)->Init(token); | 236 static_cast<ValueType*>(cmd)->Init(token); |
| 227 return NextCmdAddress<ValueType>(cmd); | 237 return NextCmdAddress<ValueType>(cmd); |
| 228 } | 238 } |
| 229 | 239 |
| 230 CommandHeader header; | 240 CommandHeader header; |
| 231 uint32_t token; | 241 uint32_t token; |
| 232 }; | 242 }; |
| 233 | 243 |
| 234 COMPILE_ASSERT(sizeof(SetToken) == 8, Sizeof_SetToken_is_not_8); | 244 static_assert(sizeof(SetToken) == 8, "size of SetToken should equal 8"); |
| 235 COMPILE_ASSERT(offsetof(SetToken, header) == 0, | 245 static_assert(offsetof(SetToken, header) == 0, |
| 236 Offsetof_SetToken_header_not_0); | 246 "offset of SetToken.header should equal 0"); |
| 237 COMPILE_ASSERT(offsetof(SetToken, token) == 4, | 247 static_assert(offsetof(SetToken, token) == 4, |
| 238 Offsetof_SetToken_token_not_4); | 248 "offset of SetToken.token should equal 4"); |
| 239 | 249 |
| 240 // Sets the size of a bucket for collecting data on the service side. | 250 // Sets the size of a bucket for collecting data on the service side. |
| 241 // This is a utility for gathering data on the service side so it can be used | 251 // This is a utility for gathering data on the service side so it can be used |
| 242 // all at once when some service side API is called. It removes the need to add | 252 // all at once when some service side API is called. It removes the need to add |
| 243 // special commands just to support a particular API. For example, any API | 253 // special commands just to support a particular API. For example, any API |
| 244 // command that needs a string needs a way to send that string to the API over | 254 // command that needs a string needs a way to send that string to the API over |
| 245 // the command buffers. While you can require that the command buffer or | 255 // the command buffers. While you can require that the command buffer or |
| 246 // transfer buffer be large enough to hold the largest string you can send, | 256 // transfer buffer be large enough to hold the largest string you can send, |
| 247 // using this command removes that restriction by letting you send smaller | 257 // using this command removes that restriction by letting you send smaller |
| 248 // pieces over and build up the data on the service side. | 258 // pieces over and build up the data on the service side. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 267 static void* Set(void* cmd, uint32_t _bucket_id, uint32_t _size) { | 277 static void* Set(void* cmd, uint32_t _bucket_id, uint32_t _size) { |
| 268 static_cast<ValueType*>(cmd)->Init(_bucket_id, _size); | 278 static_cast<ValueType*>(cmd)->Init(_bucket_id, _size); |
| 269 return NextCmdAddress<ValueType>(cmd); | 279 return NextCmdAddress<ValueType>(cmd); |
| 270 } | 280 } |
| 271 | 281 |
| 272 CommandHeader header; | 282 CommandHeader header; |
| 273 uint32_t bucket_id; | 283 uint32_t bucket_id; |
| 274 uint32_t size; | 284 uint32_t size; |
| 275 }; | 285 }; |
| 276 | 286 |
| 277 COMPILE_ASSERT(sizeof(SetBucketSize) == 12, Sizeof_SetBucketSize_is_not_8); | 287 static_assert(sizeof(SetBucketSize) == 12, |
| 278 COMPILE_ASSERT(offsetof(SetBucketSize, header) == 0, | 288 "size of SetBucketSize should equal 12"); |
| 279 Offsetof_SetBucketSize_header_not_0); | 289 static_assert(offsetof(SetBucketSize, header) == 0, |
| 280 COMPILE_ASSERT(offsetof(SetBucketSize, bucket_id) == 4, | 290 "offset of SetBucketSize.header should equal 0"); |
| 281 Offsetof_SetBucketSize_bucket_id_4); | 291 static_assert(offsetof(SetBucketSize, bucket_id) == 4, |
| 282 COMPILE_ASSERT(offsetof(SetBucketSize, size) == 8, | 292 "offset of SetBucketSize.bucket_id should equal 4"); |
| 283 Offsetof_SetBucketSize_size_8); | 293 static_assert(offsetof(SetBucketSize, size) == 8, |
| 294 "offset of SetBucketSize.size should equal 8"); |
| 284 | 295 |
| 285 // Sets the contents of a portion of a bucket on the service side from data in | 296 // Sets the contents of a portion of a bucket on the service side from data in |
| 286 // shared memory. | 297 // shared memory. |
| 287 // See SetBucketSize. | 298 // See SetBucketSize. |
| 288 struct SetBucketData { | 299 struct SetBucketData { |
| 289 typedef SetBucketData ValueType; | 300 typedef SetBucketData ValueType; |
| 290 static const CommandId kCmdId = kSetBucketData; | 301 static const CommandId kCmdId = kSetBucketData; |
| 291 static const cmd::ArgFlags kArgFlags = cmd::kFixed; | 302 static const cmd::ArgFlags kArgFlags = cmd::kFixed; |
| 292 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); | 303 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); |
| 293 | 304 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 323 } | 334 } |
| 324 | 335 |
| 325 CommandHeader header; | 336 CommandHeader header; |
| 326 uint32_t bucket_id; | 337 uint32_t bucket_id; |
| 327 uint32_t offset; | 338 uint32_t offset; |
| 328 uint32_t size; | 339 uint32_t size; |
| 329 uint32_t shared_memory_id; | 340 uint32_t shared_memory_id; |
| 330 uint32_t shared_memory_offset; | 341 uint32_t shared_memory_offset; |
| 331 }; | 342 }; |
| 332 | 343 |
| 333 COMPILE_ASSERT(sizeof(SetBucketData) == 24, Sizeof_SetBucketData_is_not_24); | 344 static_assert(sizeof(SetBucketData) == 24, |
| 334 COMPILE_ASSERT(offsetof(SetBucketData, header) == 0, | 345 "size of SetBucketData should be 24"); |
| 335 Offsetof_SetBucketData_header_not_0); | 346 static_assert(offsetof(SetBucketData, header) == 0, |
| 336 COMPILE_ASSERT(offsetof(SetBucketData, bucket_id) == 4, | 347 "offset of SetBucketData.header should be 0"); |
| 337 Offsetof_SetBucketData_bucket_id_not_4); | 348 static_assert(offsetof(SetBucketData, bucket_id) == 4, |
| 338 COMPILE_ASSERT(offsetof(SetBucketData, offset) == 8, | 349 "offset of SetBucketData.bucket_id should be 4"); |
| 339 Offsetof_SetBucketData_offset_not_8); | 350 static_assert(offsetof(SetBucketData, offset) == 8, |
| 340 COMPILE_ASSERT(offsetof(SetBucketData, size) == 12, | 351 "offset of SetBucketData.offset should be 8"); |
| 341 Offsetof_SetBucketData_size_not_12); | 352 static_assert(offsetof(SetBucketData, size) == 12, |
| 342 COMPILE_ASSERT(offsetof(SetBucketData, shared_memory_id) == 16, | 353 "offset of SetBucketData.size should be 12"); |
| 343 Offsetof_SetBucketData_shared_memory_id_not_16); | 354 static_assert(offsetof(SetBucketData, shared_memory_id) == 16, |
| 344 COMPILE_ASSERT(offsetof(SetBucketData, shared_memory_offset) == 20, | 355 "offset of SetBucketData.shared_memory_id should be 16"); |
| 345 Offsetof_SetBucketData_shared_memory_offset_not_20); | 356 static_assert(offsetof(SetBucketData, shared_memory_offset) == 20, |
| 357 "offset of SetBucketData.shared_memory_offset should be 20"); |
| 346 | 358 |
| 347 // Sets the contents of a portion of a bucket on the service side from data in | 359 // Sets the contents of a portion of a bucket on the service side from data in |
| 348 // the command buffer. | 360 // the command buffer. |
| 349 // See SetBucketSize. | 361 // See SetBucketSize. |
| 350 struct SetBucketDataImmediate { | 362 struct SetBucketDataImmediate { |
| 351 typedef SetBucketDataImmediate ValueType; | 363 typedef SetBucketDataImmediate ValueType; |
| 352 static const CommandId kCmdId = kSetBucketDataImmediate; | 364 static const CommandId kCmdId = kSetBucketDataImmediate; |
| 353 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; | 365 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; |
| 354 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); | 366 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); |
| 355 | 367 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 375 _size); | 387 _size); |
| 376 return NextImmediateCmdAddress<ValueType>(cmd, _size); | 388 return NextImmediateCmdAddress<ValueType>(cmd, _size); |
| 377 } | 389 } |
| 378 | 390 |
| 379 CommandHeader header; | 391 CommandHeader header; |
| 380 uint32_t bucket_id; | 392 uint32_t bucket_id; |
| 381 uint32_t offset; | 393 uint32_t offset; |
| 382 uint32_t size; | 394 uint32_t size; |
| 383 }; | 395 }; |
| 384 | 396 |
| 385 COMPILE_ASSERT(sizeof(SetBucketDataImmediate) == 16, | 397 static_assert(sizeof(SetBucketDataImmediate) == 16, |
| 386 Sizeof_SetBucketDataImmediate_is_not_24); | 398 "size of SetBucketDataImmediate should be 16"); |
| 387 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, header) == 0, | 399 static_assert(offsetof(SetBucketDataImmediate, header) == 0, |
| 388 Offsetof_SetBucketDataImmediate_header_not_0); | 400 "offset of SetBucketDataImmediate.header should be 0"); |
| 389 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, bucket_id) == 4, | 401 static_assert(offsetof(SetBucketDataImmediate, bucket_id) == 4, |
| 390 Offsetof_SetBucketDataImmediate_bucket_id_not_4); | 402 "offset of SetBucketDataImmediate.bucket_id should be 4"); |
| 391 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, offset) == 8, | 403 static_assert(offsetof(SetBucketDataImmediate, offset) == 8, |
| 392 Offsetof_SetBucketDataImmediate_offset_not_8); | 404 "offset of SetBucketDataImmediate.offset should be 8"); |
| 393 COMPILE_ASSERT(offsetof(SetBucketDataImmediate, size) == 12, | 405 static_assert(offsetof(SetBucketDataImmediate, size) == 12, |
| 394 Offsetof_SetBucketDataImmediate_size_not_12); | 406 "offset of SetBucketDataImmediate.size should be 12"); |
| 395 | 407 |
| 396 // Gets the start of a bucket the service has available. Sending a variable size | 408 // Gets the start of a bucket the service has available. Sending a variable size |
| 397 // result back to the client and the portion of that result that fits in the | 409 // result back to the client and the portion of that result that fits in the |
| 398 // supplied shared memory. If the size of the result is larger than the supplied | 410 // supplied shared memory. If the size of the result is larger than the supplied |
| 399 // shared memory the rest of the bucket's contents can be retrieved with | 411 // shared memory the rest of the bucket's contents can be retrieved with |
| 400 // GetBucketData. | 412 // GetBucketData. |
| 401 // | 413 // |
| 402 // This is used for example for any API that returns a string. The problem is | 414 // This is used for example for any API that returns a string. The problem is |
| 403 // the largest thing you can send back in 1 command is the size of your shared | 415 // the largest thing you can send back in 1 command is the size of your shared |
| 404 // memory. This command along with GetBucketData implements a way to get a | 416 // memory. This command along with GetBucketData implements a way to get a |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 460 |
| 449 CommandHeader header; | 461 CommandHeader header; |
| 450 uint32_t bucket_id; | 462 uint32_t bucket_id; |
| 451 uint32_t result_memory_id; | 463 uint32_t result_memory_id; |
| 452 uint32_t result_memory_offset; | 464 uint32_t result_memory_offset; |
| 453 uint32_t data_memory_size; | 465 uint32_t data_memory_size; |
| 454 uint32_t data_memory_id; | 466 uint32_t data_memory_id; |
| 455 uint32_t data_memory_offset; | 467 uint32_t data_memory_offset; |
| 456 }; | 468 }; |
| 457 | 469 |
| 458 COMPILE_ASSERT(sizeof(GetBucketStart) == 28, Sizeof_GetBucketStart_is_not_28); | 470 static_assert(sizeof(GetBucketStart) == 28, |
| 459 COMPILE_ASSERT(offsetof(GetBucketStart, header) == 0, | 471 "size of GetBucketStart should be 28"); |
| 460 Offsetof_GetBucketStart_header_not_0); | 472 static_assert(offsetof(GetBucketStart, header) == 0, |
| 461 COMPILE_ASSERT(offsetof(GetBucketStart, bucket_id) == 4, | 473 "offset of GetBucketStart.header should be 0"); |
| 462 Offsetof_GetBucketStart_bucket_id_not_4); | 474 static_assert(offsetof(GetBucketStart, bucket_id) == 4, |
| 463 COMPILE_ASSERT(offsetof(GetBucketStart, result_memory_id) == 8, | 475 "offset of GetBucketStart.bucket_id should be 4"); |
| 464 Offsetof_GetBucketStart_result_memory_id_not_8); | 476 static_assert(offsetof(GetBucketStart, result_memory_id) == 8, |
| 465 COMPILE_ASSERT(offsetof(GetBucketStart, result_memory_offset) == 12, | 477 "offset of GetBucketStart.result_memory_id should be 8"); |
| 466 Offsetof_GetBucketStart_result_memory_offset_not_12); | 478 static_assert(offsetof(GetBucketStart, result_memory_offset) == 12, |
| 467 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_size) == 16, | 479 "offset of GetBucketStart.result_memory_offset should be 12"); |
| 468 Offsetof_GetBucketStart_data_memory_size_not_16); | 480 static_assert(offsetof(GetBucketStart, data_memory_size) == 16, |
| 469 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_id) == 20, | 481 "offset of GetBucketStart.data_memory_size should be 16"); |
| 470 Offsetof_GetBucketStart_data_memory_id_not_20); | 482 static_assert(offsetof(GetBucketStart, data_memory_id) == 20, |
| 471 COMPILE_ASSERT(offsetof(GetBucketStart, data_memory_offset) == 24, | 483 "offset of GetBucketStart.data_memory_id should be 20"); |
| 472 Offsetof_GetBucketStart_data_memory_offset_not_24); | 484 static_assert(offsetof(GetBucketStart, data_memory_offset) == 24, |
| 485 "offset of GetBucketStart.data_memory_offset should be 24"); |
| 473 | 486 |
| 474 // Gets a piece of a result the service as available. | 487 // Gets a piece of a result the service as available. |
| 475 // See GetBucketSize. | 488 // See GetBucketSize. |
| 476 struct GetBucketData { | 489 struct GetBucketData { |
| 477 typedef GetBucketData ValueType; | 490 typedef GetBucketData ValueType; |
| 478 static const CommandId kCmdId = kGetBucketData; | 491 static const CommandId kCmdId = kGetBucketData; |
| 479 static const cmd::ArgFlags kArgFlags = cmd::kFixed; | 492 static const cmd::ArgFlags kArgFlags = cmd::kFixed; |
| 480 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); | 493 static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); |
| 481 | 494 |
| 482 void SetHeader() { | 495 void SetHeader() { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 511 } | 524 } |
| 512 | 525 |
| 513 CommandHeader header; | 526 CommandHeader header; |
| 514 uint32_t bucket_id; | 527 uint32_t bucket_id; |
| 515 uint32_t offset; | 528 uint32_t offset; |
| 516 uint32_t size; | 529 uint32_t size; |
| 517 uint32_t shared_memory_id; | 530 uint32_t shared_memory_id; |
| 518 uint32_t shared_memory_offset; | 531 uint32_t shared_memory_offset; |
| 519 }; | 532 }; |
| 520 | 533 |
| 521 COMPILE_ASSERT(sizeof(GetBucketData) == 24, Sizeof_GetBucketData_is_not_20); | 534 static_assert(sizeof(GetBucketData) == 24, |
| 522 COMPILE_ASSERT(offsetof(GetBucketData, header) == 0, | 535 "size of GetBucketData should be 24"); |
| 523 Offsetof_GetBucketData_header_not_0); | 536 static_assert(offsetof(GetBucketData, header) == 0, |
| 524 COMPILE_ASSERT(offsetof(GetBucketData, bucket_id) == 4, | 537 "offset of GetBucketData.header should be 0"); |
| 525 Offsetof_GetBucketData_bucket_id_not_4); | 538 static_assert(offsetof(GetBucketData, bucket_id) == 4, |
| 526 COMPILE_ASSERT(offsetof(GetBucketData, offset) == 8, | 539 "offset of GetBucketData.bucket_id should be 4"); |
| 527 Offsetof_GetBucketData_offset_not_8); | 540 static_assert(offsetof(GetBucketData, offset) == 8, |
| 528 COMPILE_ASSERT(offsetof(GetBucketData, size) == 12, | 541 "offset of GetBucketData.offset should be 8"); |
| 529 Offsetof_GetBucketData_size_not_12); | 542 static_assert(offsetof(GetBucketData, size) == 12, |
| 530 COMPILE_ASSERT(offsetof(GetBucketData, shared_memory_id) == 16, | 543 "offset of GetBucketData.size should be 12"); |
| 531 Offsetof_GetBucketData_shared_memory_id_not_16); | 544 static_assert(offsetof(GetBucketData, shared_memory_id) == 16, |
| 532 COMPILE_ASSERT(offsetof(GetBucketData, shared_memory_offset) == 20, | 545 "offset of GetBucketData.shared_memory_id should be 16"); |
| 533 Offsetof_GetBucketData_shared_memory_offset_not_20); | 546 static_assert(offsetof(GetBucketData, shared_memory_offset) == 20, |
| 547 "offset of GetBucketData.shared_memory_offset should be 20"); |
| 534 | 548 |
| 535 } // namespace cmd | 549 } // namespace cmd |
| 536 | 550 |
| 537 #pragma pack(pop) | 551 #pragma pack(pop) |
| 538 | 552 |
| 539 } // namespace gpu | 553 } // namespace gpu |
| 540 | 554 |
| 541 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ | 555 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ |
| 542 | 556 |
| OLD | NEW |