| OLD | NEW |
| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 #define O3D_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_FORMAT_H_ | 60 #define O3D_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_FORMAT_H_ |
| 61 | 61 |
| 62 #include "base/basictypes.h" | 62 #include "base/basictypes.h" |
| 63 #include "command_buffer/common/cross/types.h" | 63 #include "command_buffer/common/cross/types.h" |
| 64 #include "command_buffer/common/cross/bitfield_helpers.h" | 64 #include "command_buffer/common/cross/bitfield_helpers.h" |
| 65 #include "core/cross/packing.h" | 65 #include "core/cross/packing.h" |
| 66 | 66 |
| 67 namespace o3d { | 67 namespace o3d { |
| 68 namespace command_buffer { | 68 namespace command_buffer { |
| 69 | 69 |
| 70 namespace cmd { |
| 71 enum ArgFlags { |
| 72 kFixed = 0x0, |
| 73 kAtLeastN = 0x1, |
| 74 }; |
| 75 } // namespace cmd |
| 76 |
| 70 // Computes the number of command buffer entries needed for a certain size. In | 77 // Computes the number of command buffer entries needed for a certain size. In |
| 71 // other words it rounds up to a multiple of entries. | 78 // other words it rounds up to a multiple of entries. |
| 72 inline uint32 ComputeNumEntries(size_t size_in_bytes) { | 79 inline uint32 ComputeNumEntries(size_t size_in_bytes) { |
| 73 return static_cast<uint32>( | 80 return static_cast<uint32>( |
| 74 (size_in_bytes + sizeof(uint32) - 1) / sizeof(uint32)); // NOLINT | 81 (size_in_bytes + sizeof(uint32) - 1) / sizeof(uint32)); // NOLINT |
| 75 } | 82 } |
| 76 | 83 |
| 77 // Rounds up to a multiple of entries in bytes. | 84 // Rounds up to a multiple of entries in bytes. |
| 78 inline size_t RoundSizeToMultipleOfEntries(size_t size_in_bytes) { | 85 inline size_t RoundSizeToMultipleOfEntries(size_t size_in_bytes) { |
| 79 return ComputeNumEntries(size_in_bytes) * sizeof(uint32); // NOLINT | 86 return ComputeNumEntries(size_in_bytes) * sizeof(uint32); // NOLINT |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 // Parameters: | 457 // Parameters: |
| 451 // cmd: Address of command. | 458 // cmd: Address of command. |
| 452 // size_of_data_in_bytes: Size of the data for the command. | 459 // size_of_data_in_bytes: Size of the data for the command. |
| 453 template <typename T> | 460 template <typename T> |
| 454 void* NextImmediateCmdAddress(void* cmd, uint32 size_of_data_in_bytes) { | 461 void* NextImmediateCmdAddress(void* cmd, uint32 size_of_data_in_bytes) { |
| 455 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); | 462 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); |
| 456 return reinterpret_cast<char*>(cmd) + sizeof(T) + // NOLINT | 463 return reinterpret_cast<char*>(cmd) + sizeof(T) + // NOLINT |
| 457 RoundSizeToMultipleOfEntries(size_of_data_in_bytes); | 464 RoundSizeToMultipleOfEntries(size_of_data_in_bytes); |
| 458 } | 465 } |
| 459 | 466 |
| 460 enum ArgFlags { | |
| 461 kFixed = 0x0, | |
| 462 kAtLeastN = 0x1, | |
| 463 }; | |
| 464 | |
| 465 struct SharedMemory { | 467 struct SharedMemory { |
| 466 void Init(uint32 _id, uint32 _offset) { | 468 void Init(uint32 _id, uint32 _offset) { |
| 467 id = _id; | 469 id = _id; |
| 468 offset = _offset; | 470 offset = _offset; |
| 469 } | 471 } |
| 470 | 472 |
| 471 uint32 id; | 473 uint32 id; |
| 472 uint32 offset; | 474 uint32 offset; |
| 473 }; | 475 }; |
| 474 | 476 |
| (...skipping 2812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3287 OffsetOf_SetBackSurfaces_header_not_0); | 3289 OffsetOf_SetBackSurfaces_header_not_0); |
| 3288 | 3290 |
| 3289 O3D_POP_STRUCTURE_PACKING; | 3291 O3D_POP_STRUCTURE_PACKING; |
| 3290 | 3292 |
| 3291 } // namespace cmd | 3293 } // namespace cmd |
| 3292 | 3294 |
| 3293 } // namespace command_buffer | 3295 } // namespace command_buffer |
| 3294 } // namespace o3d | 3296 } // namespace o3d |
| 3295 | 3297 |
| 3296 #endif // O3D_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_FORMAT_H_ | 3298 #endif // O3D_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_FORMAT_H_ |
| OLD | NEW |