Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: gpu/command_buffer/common/cmd_buffer_common.h

Issue 11613021: Removing the JumpRelative, Call, CallRelative and Return commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use Noops instead of Jump; Remove Jump command. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // This macro is used to safely and convienently expand the list of commnad 143 // This macro is used to safely and convienently expand the list of commnad
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(SetBucketSize) /* 2 */ \
154 OP(JumpRelative) /* 3 */ \ 154 OP(SetBucketData) /* 3 */ \
155 OP(Call) /* 4 */ \ 155 OP(SetBucketDataImmediate) /* 4 */ \
156 OP(CallRelative) /* 5 */ \ 156 OP(GetBucketStart) /* 5 */ \
157 OP(Return) /* 6 */ \ 157 OP(GetBucketData) /* 6 */ \
158 OP(SetBucketSize) /* 7 */ \
159 OP(SetBucketData) /* 8 */ \
160 OP(SetBucketDataImmediate) /* 9 */ \
161 OP(GetBucketStart) /* 10 */ \
162 OP(GetBucketData) /* 11 */ \
163 158
164 // Common commands. 159 // Common commands.
165 enum CommandId { 160 enum CommandId {
166 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name, 161 #define COMMON_COMMAND_BUFFER_CMD_OP(name) k ## name,
167 162
168 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) 163 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP)
169 164
170 #undef COMMON_COMMAND_BUFFER_CMD_OP 165 #undef COMMON_COMMAND_BUFFER_CMD_OP
171 166
172 kNumCommands, 167 kNumCommands,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 CommandHeader header; 222 CommandHeader header;
228 uint32 token; 223 uint32 token;
229 }; 224 };
230 225
231 COMPILE_ASSERT(sizeof(SetToken) == 8, Sizeof_SetToken_is_not_8); 226 COMPILE_ASSERT(sizeof(SetToken) == 8, Sizeof_SetToken_is_not_8);
232 COMPILE_ASSERT(offsetof(SetToken, header) == 0, 227 COMPILE_ASSERT(offsetof(SetToken, header) == 0,
233 Offsetof_SetToken_header_not_0); 228 Offsetof_SetToken_header_not_0);
234 COMPILE_ASSERT(offsetof(SetToken, token) == 4, 229 COMPILE_ASSERT(offsetof(SetToken, token) == 4,
235 Offsetof_SetToken_token_not_4); 230 Offsetof_SetToken_token_not_4);
236 231
237 // The Jump command jumps to another place in the command buffer.
238 struct Jump {
239 typedef Jump ValueType;
240 static const CommandId kCmdId = kJump;
241 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
242
243 void SetHeader() {
244 header.SetCmd<ValueType>();
245 }
246
247 void Init(uint32 _offset) {
248 SetHeader();
249 offset = _offset;
250 }
251 static void* Set(
252 void* cmd, uint32 _offset) {
253 static_cast<ValueType*>(cmd)->Init(_offset);
254 return NextCmdAddress<ValueType>(cmd);
255 }
256
257 CommandHeader header;
258 uint32 offset;
259 };
260
261 COMPILE_ASSERT(sizeof(Jump) == 8, Sizeof_Jump_is_not_8);
262 COMPILE_ASSERT(offsetof(Jump, header) == 0,
263 Offsetof_Jump_header_not_0);
264 COMPILE_ASSERT(offsetof(Jump, offset) == 4,
265 Offsetof_Jump_offset_not_4);
266
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. 232 // 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 233 // 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 234 // 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 235 // 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 236 // 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 237 // 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, 238 // 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 239 // using this command removes that restriction by letting you send smaller
391 // pieces over and build up the data on the service side. 240 // pieces over and build up the data on the service side.
392 // 241 //
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 Offsetof_GetBucketData_shared_memory_offset_not_20); 520 Offsetof_GetBucketData_shared_memory_offset_not_20);
672 521
673 } // namespace cmd 522 } // namespace cmd
674 523
675 #pragma pack(pop) 524 #pragma pack(pop)
676 525
677 } // namespace gpu 526 } // namespace gpu
678 527
679 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ 528 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_
680 529
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/ring_buffer_test.cc ('k') | gpu/command_buffer/service/common_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698