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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // buffer commands in to various lists and never have them get out of sync. To | 144 // buffer commands in to various lists and never have them get out of sync. To |
145 // add a new command, add it this list, create the corresponding structure below | 145 // add a new command, add it this list, create the corresponding structure below |
146 // and then add a function in gapi_decoder.cc called Handle_COMMAND_NAME where | 146 // and then add a function in gapi_decoder.cc called Handle_COMMAND_NAME where |
147 // COMMAND_NAME is the name of your command structure. | 147 // COMMAND_NAME is the name of your command structure. |
148 // | 148 // |
149 // NOTE: THE ORDER OF THESE MUST NOT CHANGE (their id is derived by order) | 149 // NOTE: THE ORDER OF THESE MUST NOT CHANGE (their id is derived by order) |
150 #define COMMON_COMMAND_BUFFER_CMDS(OP) \ | 150 #define COMMON_COMMAND_BUFFER_CMDS(OP) \ |
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(SetBucketSize) /* 3 */ \ |
155 OP(Call) /* 4 */ \ | 155 OP(SetBucketData) /* 4 */ \ |
156 OP(CallRelative) /* 5 */ \ | 156 OP(SetBucketDataImmediate) /* 5 */ \ |
157 OP(Return) /* 6 */ \ | 157 OP(GetBucketStart) /* 6 */ \ |
158 OP(SetBucketSize) /* 7 */ \ | 158 OP(GetBucketData) /* 7 */ \ |
159 OP(SetBucketData) /* 8 */ \ | |
160 OP(SetBucketDataImmediate) /* 9 */ \ | |
161 OP(GetBucketStart) /* 10 */ \ | |
162 OP(GetBucketData) /* 11 */ \ | |
163 | 159 |
164 // Common commands. | 160 // Common commands. |
165 enum CommandId { | 161 enum CommandId { |
166 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name, | 162 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name, |
167 | 163 |
168 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) | 164 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) |
169 | 165 |
170 #undef COMMON_COMMAND_BUFFER_CMD_OP | 166 #undef COMMON_COMMAND_BUFFER_CMD_OP |
171 | 167 |
172 kNumCommands, | 168 kNumCommands, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 CommandHeader header; | 253 CommandHeader header; |
258 uint32 offset; | 254 uint32 offset; |
259 }; | 255 }; |
260 | 256 |
261 COMPILE_ASSERT(sizeof(Jump) == 8, Sizeof_Jump_is_not_8); | 257 COMPILE_ASSERT(sizeof(Jump) == 8, Sizeof_Jump_is_not_8); |
262 COMPILE_ASSERT(offsetof(Jump, header) == 0, | 258 COMPILE_ASSERT(offsetof(Jump, header) == 0, |
263 Offsetof_Jump_header_not_0); | 259 Offsetof_Jump_header_not_0); |
264 COMPILE_ASSERT(offsetof(Jump, offset) == 4, | 260 COMPILE_ASSERT(offsetof(Jump, offset) == 4, |
265 Offsetof_Jump_offset_not_4); | 261 Offsetof_Jump_offset_not_4); |
266 | 262 |
267 // The JumpRelative command jumps to another place in the command buffer | |
268 // relative to the end of this command. In other words. JumpRelative with an | |
269 // offset of zero is effectively a noop. | |
270 struct JumpRelative { | |
271 typedef JumpRelative ValueType; | |
272 static const CommandId kCmdId = kJumpRelative; | |
273 static const cmd::ArgFlags kArgFlags = cmd::kFixed; | |
274 | |
275 void SetHeader() { | |
276 header.SetCmd<ValueType>(); | |
277 } | |
278 | |
279 void Init(int32 _offset) { | |
280 SetHeader(); | |
281 offset = _offset; | |
282 } | |
283 static void* Set(void* cmd, int32 _offset) { | |
284 static_cast<ValueType*>(cmd)->Init(_offset); | |
285 return NextCmdAddress<ValueType>(cmd); | |
286 } | |
287 | |
288 CommandHeader header; | |
289 int32 offset; | |
290 }; | |
291 | |
292 COMPILE_ASSERT(sizeof(JumpRelative) == 8, Sizeof_JumpRelative_is_not_8); | |
293 COMPILE_ASSERT(offsetof(JumpRelative, header) == 0, | |
294 Offsetof_JumpRelative_header_not_0); | |
295 COMPILE_ASSERT(offsetof(JumpRelative, offset) == 4, | |
296 Offsetof_JumpRelative_offset_4); | |
297 | |
298 // The Call command jumps to a subroutine which can be returned from with the | |
299 // Return command. | |
300 struct Call { | |
301 typedef Call ValueType; | |
302 static const CommandId kCmdId = kCall; | |
303 static const cmd::ArgFlags kArgFlags = cmd::kFixed; | |
304 | |
305 void SetHeader() { | |
306 header.SetCmd<ValueType>(); | |
307 } | |
308 | |
309 void Init(uint32 _offset) { | |
310 SetHeader(); | |
311 offset = _offset; | |
312 } | |
313 static void* Set(void* cmd, uint32 _offset) { | |
314 static_cast<ValueType*>(cmd)->Init(_offset); | |
315 return NextCmdAddress<ValueType>(cmd); | |
316 } | |
317 | |
318 CommandHeader header; | |
319 uint32 offset; | |
320 }; | |
321 | |
322 COMPILE_ASSERT(sizeof(Call) == 8, Sizeof_Call_is_not_8); | |
323 COMPILE_ASSERT(offsetof(Call, header) == 0, | |
324 Offsetof_Call_header_not_0); | |
325 COMPILE_ASSERT(offsetof(Call, offset) == 4, | |
326 Offsetof_Call_offset_not_4); | |
327 | |
328 // The CallRelative command jumps to a subroutine using a relative offset. The | |
329 // offset is relative to the end of this command.. | |
330 struct CallRelative { | |
331 typedef CallRelative ValueType; | |
332 static const CommandId kCmdId = kCallRelative; | |
333 static const cmd::ArgFlags kArgFlags = cmd::kFixed; | |
334 | |
335 void SetHeader() { | |
336 header.SetCmd<ValueType>(); | |
337 } | |
338 | |
339 void Init(int32 _offset) { | |
340 SetHeader(); | |
341 offset = _offset; | |
342 } | |
343 static void* Set(void* cmd, int32 _offset) { | |
344 static_cast<ValueType*>(cmd)->Init(_offset); | |
345 return NextCmdAddress<ValueType>(cmd); | |
346 } | |
347 | |
348 CommandHeader header; | |
349 int32 offset; | |
350 }; | |
351 | |
352 COMPILE_ASSERT(sizeof(CallRelative) == 8, Sizeof_CallRelative_is_not_8); | |
353 COMPILE_ASSERT(offsetof(CallRelative, header) == 0, | |
354 Offsetof_CallRelative_header_not_0); | |
355 COMPILE_ASSERT(offsetof(CallRelative, offset) == 4, | |
356 Offsetof_CallRelative_offset_4); | |
357 | |
358 // Returns from a subroutine called by the Call or CallRelative commands. | |
359 struct Return { | |
360 typedef Return ValueType; | |
361 static const CommandId kCmdId = kReturn; | |
362 static const cmd::ArgFlags kArgFlags = cmd::kFixed; | |
363 | |
364 void SetHeader() { | |
365 header.SetCmd<ValueType>(); | |
366 } | |
367 | |
368 void Init() { | |
369 SetHeader(); | |
370 } | |
371 static void* Set(void* cmd) { | |
372 static_cast<ValueType*>(cmd)->Init(); | |
373 return NextCmdAddress<ValueType>(cmd); | |
374 } | |
375 | |
376 CommandHeader header; | |
377 }; | |
378 | |
379 COMPILE_ASSERT(sizeof(Return) == 4, Sizeof_Return_is_not_4); | |
380 COMPILE_ASSERT(offsetof(Return, header) == 0, | |
381 Offsetof_Return_header_not_0); | |
382 | |
383 // Sets the size of a bucket for collecting data on the service side. | 263 // Sets the size of a bucket for collecting data on the service side. |
384 // This is a utility for gathering data on the service side so it can be used | 264 // This is a utility for gathering data on the service side so it can be used |
385 // all at once when some service side API is called. It removes the need to add | 265 // all at once when some service side API is called. It removes the need to add |
386 // special commands just to support a particular API. For example, any API | 266 // special commands just to support a particular API. For example, any API |
387 // command that needs a string needs a way to send that string to the API over | 267 // command that needs a string needs a way to send that string to the API over |
388 // the command buffers. While you can require that the command buffer or | 268 // the command buffers. While you can require that the command buffer or |
389 // transfer buffer be large enough to hold the largest string you can send, | 269 // transfer buffer be large enough to hold the largest string you can send, |
390 // using this command removes that restriction by letting you send smaller | 270 // using this command removes that restriction by letting you send smaller |
391 // pieces over and build up the data on the service side. | 271 // pieces over and build up the data on the service side. |
392 // | 272 // |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 Offsetof_GetBucketData_shared_memory_offset_not_20); | 551 Offsetof_GetBucketData_shared_memory_offset_not_20); |
672 | 552 |
673 } // namespace cmd | 553 } // namespace cmd |
674 | 554 |
675 #pragma pack(pop) | 555 #pragma pack(pop) |
676 | 556 |
677 } // namespace gpu | 557 } // namespace gpu |
678 | 558 |
679 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ | 559 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ |
680 | 560 |
OLD | NEW |