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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // add a new command, add it this list, create the corresponding structure below | 164 // add a new command, add it this list, create the corresponding structure below |
165 // and then add a function in gapi_decoder.cc called Handle_COMMAND_NAME where | 165 // and then add a function in gapi_decoder.cc called Handle_COMMAND_NAME where |
166 // COMMAND_NAME is the name of your command structure. | 166 // COMMAND_NAME is the name of your command structure. |
167 // | 167 // |
168 // NOTE: THE ORDER OF THESE MUST NOT CHANGE (their id is derived by order) | 168 // NOTE: THE ORDER OF THESE MUST NOT CHANGE (their id is derived by order) |
169 #define COMMON_COMMAND_BUFFER_CMDS(OP) \ | 169 #define COMMON_COMMAND_BUFFER_CMDS(OP) \ |
170 OP(Noop) /* 0 */ \ | 170 OP(Noop) /* 0 */ \ |
171 OP(SetToken) /* 1 */ \ | 171 OP(SetToken) /* 1 */ \ |
172 | 172 |
173 // Common commands. | 173 // Common commands. |
174 enum CommonCommandId { | 174 enum CommandId { |
175 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name, | 175 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name, |
176 | 176 |
177 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) | 177 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) |
178 | 178 |
179 #undef COMMON_COMMAND_BUFFER_CMD_OP | 179 #undef COMMON_COMMAND_BUFFER_CMD_OP |
180 | 180 |
181 kNumCommands, | 181 kNumCommands, |
182 kLastCommonId = 1023, // reserver 1024 spaces for common commands | 182 kLastCommonId = 1023, // reserve 1024 spaces for common commands. |
183 }; | 183 }; |
184 | 184 |
185 COMPILE_ASSERT(kNumCommands - 1 <= kLastCommonId, Too_many_common_commands); | 185 COMPILE_ASSERT(kNumCommands - 1 <= kLastCommonId, Too_many_common_commands); |
186 | 186 |
| 187 const char* GetCommandName(CommandId id); |
| 188 |
| 189 struct Noop { |
| 190 typedef Noop ValueType; |
| 191 static const CommandId kCmdId = kNoop; |
| 192 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; |
| 193 |
| 194 void SetHeader(uint32 skip_count) { |
| 195 header.Init(kCmdId, skip_count + 1); |
| 196 } |
| 197 |
| 198 void Init(uint32 skip_count) { |
| 199 SetHeader(skip_count); |
| 200 } |
| 201 |
| 202 static void* Set(void* cmd, uint32 skip_count) { |
| 203 static_cast<ValueType*>(cmd)->Init(skip_count); |
| 204 return NextImmediateCmdAddress<ValueType>( |
| 205 cmd, skip_count * sizeof(CommandBufferEntry)); // NOLINT |
| 206 } |
| 207 |
| 208 CommandHeader header; |
| 209 }; |
| 210 |
| 211 COMPILE_ASSERT(sizeof(Noop) == 4, Sizeof_Noop_is_not_4); |
| 212 COMPILE_ASSERT(offsetof(Noop, header) == 0, Offsetof_Noop_header_not_0); |
| 213 |
| 214 struct SetToken { |
| 215 typedef SetToken ValueType; |
| 216 static const CommandId kCmdId = kSetToken; |
| 217 static const cmd::ArgFlags kArgFlags = cmd::kFixed; |
| 218 |
| 219 void SetHeader() { |
| 220 header.SetCmd<ValueType>(); |
| 221 } |
| 222 |
| 223 void Init(uint32 _token) { |
| 224 SetHeader(); |
| 225 token = _token; |
| 226 } |
| 227 static void* Set(void* cmd, uint32 token) { |
| 228 static_cast<ValueType*>(cmd)->Init(token); |
| 229 return NextCmdAddress<ValueType>(cmd); |
| 230 } |
| 231 |
| 232 CommandHeader header; |
| 233 uint32 token; |
| 234 }; |
| 235 |
| 236 COMPILE_ASSERT(sizeof(SetToken) == 8, Sizeof_SetToken_is_not_8); |
| 237 COMPILE_ASSERT(offsetof(SetToken, header) == 0, |
| 238 Offsetof_SetToken_header_not_0); |
| 239 COMPILE_ASSERT(offsetof(SetToken, token) == 4, |
| 240 Offsetof_SetToken_token_not_4); |
| 241 |
187 } // namespace cmd | 242 } // namespace cmd |
188 | 243 |
189 O3D_POP_STRUCTURE_PACKING; | 244 O3D_POP_STRUCTURE_PACKING; |
190 | 245 |
191 } // namespace command_buffer | 246 } // namespace command_buffer |
192 } // namespace o3d | 247 } // namespace o3d |
193 | 248 |
194 #endif // O3D_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_COMMON_H_ | 249 #endif // O3D_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_COMMON_H_ |
195 | 250 |
OLD | NEW |