OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2009, Google Inc. | |
3 * All rights reserved. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions are | |
7 * met: | |
8 * | |
9 * * Redistributions of source code must retain the above copyright | |
10 * notice, this list of conditions and the following disclaimer. | |
11 * * Redistributions in binary form must reproduce the above | |
12 * copyright notice, this list of conditions and the following disclaimer | |
13 * in the documentation and/or other materials provided with the | |
14 * distribution. | |
15 * * Neither the name of Google Inc. nor the names of its | |
16 * contributors may be used to endorse or promote products derived from | |
17 * this software without specific prior written permission. | |
18 * | |
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 */ | |
31 | |
32 | |
33 // This file contains the binary format definition of the command buffer and | |
34 // command buffer commands. | |
35 // It is recommended you use the CommandBufferHelper object to create commands | |
36 // but if you want to go lower level you can use the structures here to help. | |
37 // | |
38 // A few ways to use them: | |
39 // | |
40 // Fill out a structure in place: | |
41 // | |
42 // cmd::SetViewport::Set(ptrToSomeSharedMemory, | |
43 // left, right, width, height, z_min, z_max); | |
44 // | |
45 // Fill out consecutive commands: | |
46 // | |
47 // Note that each cmd::XXX::Set function returns a pointer to the place | |
48 // the next command should go. | |
49 // | |
50 // void* dest = ptrToSomeSharedMemory; | |
51 // dest = cmd::SetViewport::Set(dest, left, right, width, height, min, max); | |
52 // dest = cmd::Clear::Set(dest, buffers, r, g, b, a, depth, stencil); | |
53 // dest = cmd::Draw::Set(dest, primitive_type, first, count); | |
54 // | |
55 // NOTE: The types in this file must be POD types. That means they can not have | |
56 // constructors, destructors, virtual functions or inheritance and they can only | |
57 // use other POD types or intrinsics as members. | |
58 | |
59 #ifndef O3D_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_FORMAT_H_ | |
60 #define O3D_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_FORMAT_H_ | |
61 | |
62 #include "command_buffer/common/cross/cmd_buffer_common.h" | |
63 #include "command_buffer/common/cross/resource.h" | |
64 | |
65 namespace o3d { | |
66 namespace command_buffer { | |
67 | |
68 // This macro is used to safely and convienently expand the list of commnad | |
69 // buffer commands in to various lists and never have them get out of sync. To | |
70 // add a new command, add it this list, create the corresponding structure below | |
71 // and then add a function in gapi_decoder.cc called Handle_COMMAND_NAME where | |
72 // COMMAND_NAME is the name of your command structure. | |
73 // | |
74 // NOTE: THE ORDER OF THESE MUST NOT CHANGE (their id is derived by order) | |
75 #define O3D_COMMAND_BUFFER_CMDS(OP) \ | |
76 OP(Noop) /* 1024 */ \ | |
77 OP(SetToken) /* 1025 */ \ | |
78 OP(BeginFrame) /* 1026 */ \ | |
79 OP(EndFrame) /* 1027 */ \ | |
80 OP(Clear) /* 1028 */ \ | |
81 OP(CreateVertexBuffer) /* 1029 */ \ | |
82 OP(DestroyVertexBuffer) /* 1030 */ \ | |
83 OP(SetVertexBufferData) /* 1031 */ \ | |
84 OP(SetVertexBufferDataImmediate) /* 1032 */ \ | |
85 OP(GetVertexBufferData) /* 1033 */ \ | |
86 OP(CreateIndexBuffer) /* 1034 */ \ | |
87 OP(DestroyIndexBuffer) /* 1035 */ \ | |
88 OP(SetIndexBufferData) /* 1036 */ \ | |
89 OP(SetIndexBufferDataImmediate) /* 1037 */ \ | |
90 OP(GetIndexBufferData) /* 1038 */ \ | |
91 OP(CreateVertexStruct) /* 1039 */ \ | |
92 OP(DestroyVertexStruct) /* 1040 */ \ | |
93 OP(SetVertexInput) /* 1041 */ \ | |
94 OP(SetVertexStruct) /* 1042 */ \ | |
95 OP(Draw) /* 1043 */ \ | |
96 OP(DrawIndexed) /* 1044 */ \ | |
97 OP(CreateEffect) /* 1045 */ \ | |
98 OP(CreateEffectImmediate) /* 1046 */ \ | |
99 OP(DestroyEffect) /* 1047 */ \ | |
100 OP(SetEffect) /* 1048 */ \ | |
101 OP(GetParamCount) /* 1049 */ \ | |
102 OP(CreateParam) /* 1050 */ \ | |
103 OP(CreateParamByName) /* 1051 */ \ | |
104 OP(CreateParamByNameImmediate) /* 1052 */ \ | |
105 OP(DestroyParam) /* 1053 */ \ | |
106 OP(SetParamData) /* 1054 */ \ | |
107 OP(SetParamDataImmediate) /* 1055 */ \ | |
108 OP(GetParamDesc) /* 1056 */ \ | |
109 OP(GetStreamCount) /* 1057 */ \ | |
110 OP(GetStreamDesc) /* 1058 */ \ | |
111 OP(DestroyTexture) /* 1059 */ \ | |
112 OP(CreateTexture2d) /* 1060 */ \ | |
113 OP(CreateTexture3d) /* 1061 */ \ | |
114 OP(CreateTextureCube) /* 1062 */ \ | |
115 OP(SetTextureData) /* 1063 */ \ | |
116 OP(SetTextureDataImmediate) /* 1064 */ \ | |
117 OP(GetTextureData) /* 1065 */ \ | |
118 OP(CreateSampler) /* 1066 */ \ | |
119 OP(DestroySampler) /* 1067 */ \ | |
120 OP(SetSamplerStates) /* 1068 */ \ | |
121 OP(SetSamplerBorderColor) /* 1069 */ \ | |
122 OP(SetSamplerTexture) /* 1070 */ \ | |
123 OP(SetViewport) /* 1071 */ \ | |
124 OP(SetScissor) /* 1072 */ \ | |
125 OP(SetPointLineRaster) /* 1073 */ \ | |
126 OP(SetPolygonRaster) /* 1074 */ \ | |
127 OP(SetPolygonOffset) /* 1075 */ \ | |
128 OP(SetAlphaTest) /* 1076 */ \ | |
129 OP(SetDepthTest) /* 1077 */ \ | |
130 OP(SetStencilTest) /* 1078 */ \ | |
131 OP(SetBlending) /* 1079 */ \ | |
132 OP(SetBlendingColor) /* 1080 */ \ | |
133 OP(SetColorWrite) /* 1081 */ \ | |
134 OP(CreateRenderSurface) /* 1082 */ \ | |
135 OP(DestroyRenderSurface) /* 1083 */ \ | |
136 OP(CreateDepthSurface) /* 1084 */ \ | |
137 OP(DestroyDepthSurface) /* 1085 */ \ | |
138 OP(SetRenderSurface) /* 1086 */ \ | |
139 OP(SetBackSurfaces) /* 1087 */ \ | |
140 | |
141 | |
142 // GAPI commands. | |
143 enum CommandId { | |
144 // kStartPoint = cmd::kLastCommonId, // All O3D commands start after this. | |
145 #define O3D_COMMAND_BUFFER_CMD_OP(name) k ## name, | |
146 | |
147 O3D_COMMAND_BUFFER_CMDS(O3D_COMMAND_BUFFER_CMD_OP) | |
148 | |
149 #undef O3D_COMMAND_BUFFER_CMD_OP | |
150 | |
151 kNumCommands, | |
152 }; | |
153 | |
154 // Bit definitions for buffers to clear. | |
155 enum ClearBuffer { | |
156 kColor = 0x1, | |
157 kDepth = 0x2, | |
158 kStencil = 0x4, | |
159 kAllBuffers = kColor | kDepth | kStencil | |
160 }; | |
161 | |
162 // Polygon mode for SetPolygonRaster | |
163 enum PolygonMode { | |
164 kPolygonModePoints, | |
165 kPolygonModeLines, | |
166 kPolygonModeFill, | |
167 kNumPolygonMode | |
168 }; | |
169 | |
170 // Face culling mode for SetPolygonRaster | |
171 enum FaceCullMode { | |
172 kCullNone, | |
173 kCullCW, | |
174 kCullCCW, | |
175 kNumFaceCullMode | |
176 }; | |
177 | |
178 // Primitive type for Draw and DrawIndexed. | |
179 enum PrimitiveType { | |
180 kPoints, | |
181 kLines, | |
182 kLineStrips, | |
183 kTriangles, | |
184 kTriangleStrips, | |
185 kTriangleFans, | |
186 kMaxPrimitiveType | |
187 }; | |
188 | |
189 // Comparison function for alpha or depth test | |
190 enum Comparison { | |
191 kNever, | |
192 kLess, | |
193 kEqual, | |
194 kLEqual, | |
195 kGreater, | |
196 kNotEqual, | |
197 kGEqual, | |
198 kAlways, | |
199 kNumComparison | |
200 }; | |
201 | |
202 // Stencil operation | |
203 enum StencilOp { | |
204 kKeep, | |
205 kZero, | |
206 kReplace, | |
207 kIncNoWrap, | |
208 kDecNoWrap, | |
209 kInvert, | |
210 kIncWrap, | |
211 kDecWrap, | |
212 kNumStencilOp | |
213 }; | |
214 | |
215 // Blend Equation | |
216 enum BlendEq { | |
217 kBlendEqAdd, | |
218 kBlendEqSub, | |
219 kBlendEqRevSub, | |
220 kBlendEqMin, | |
221 kBlendEqMax, | |
222 kNumBlendEq | |
223 }; | |
224 | |
225 // Blend Funtion | |
226 enum BlendFunc { | |
227 kBlendFuncZero, | |
228 kBlendFuncOne, | |
229 kBlendFuncSrcColor, | |
230 kBlendFuncInvSrcColor, | |
231 kBlendFuncSrcAlpha, | |
232 kBlendFuncInvSrcAlpha, | |
233 kBlendFuncDstAlpha, | |
234 kBlendFuncInvDstAlpha, | |
235 kBlendFuncDstColor, | |
236 kBlendFuncInvDstColor, | |
237 kBlendFuncSrcAlphaSaturate, | |
238 kBlendFuncBlendColor, | |
239 kBlendFuncInvBlendColor, | |
240 kNumBlendFunc | |
241 }; | |
242 | |
243 namespace cmd { | |
244 | |
245 const char* GetCommandName(CommandId id); | |
246 | |
247 // Make sure the compiler does not add extra padding to any of the command | |
248 // structures. | |
249 O3D_PUSH_STRUCTURE_PACKING_1; | |
250 | |
251 struct Noop { | |
252 typedef Noop ValueType; | |
253 static const CommandId kCmdId = command_buffer::kNoop; | |
254 static const ArgFlags kArgFlags = kAtLeastN; | |
255 | |
256 void SetHeader(uint32 skip_count) { | |
257 header.Init(kCmdId, skip_count + 1); | |
258 } | |
259 | |
260 void Init(uint32 skip_count) { | |
261 SetHeader(skip_count); | |
262 } | |
263 | |
264 static void* Set(void* cmd, uint32 skip_count) { | |
265 static_cast<ValueType*>(cmd)->Init(skip_count); | |
266 return NextImmediateCmdAddress<ValueType>( | |
267 cmd, skip_count * sizeof(CommandBufferEntry)); // NOLINT | |
268 } | |
269 | |
270 CommandHeader header; | |
271 }; | |
272 | |
273 COMPILE_ASSERT(sizeof(Noop) == 4, Sizeof_Noop_is_not_4); | |
274 COMPILE_ASSERT(offsetof(Noop, header) == 0, Offsetof_Noop_header_not_0); | |
275 | |
276 struct SetToken { | |
277 typedef SetToken ValueType; | |
278 static const CommandId kCmdId = command_buffer::kSetToken; | |
279 static const ArgFlags kArgFlags = kFixed; | |
280 | |
281 void SetHeader() { | |
282 header.SetCmd<ValueType>(); | |
283 } | |
284 | |
285 void Init(uint32 _token) { | |
286 SetHeader(); | |
287 token = _token; | |
288 } | |
289 static void* Set(void* cmd, uint32 token) { | |
290 static_cast<ValueType*>(cmd)->Init(token); | |
291 return NextCmdAddress<ValueType>(cmd); | |
292 } | |
293 | |
294 CommandHeader header; | |
295 uint32 token; | |
296 }; | |
297 | |
298 COMPILE_ASSERT(sizeof(SetToken) == 8, Sizeof_SetToken_is_not_8); | |
299 COMPILE_ASSERT(offsetof(SetToken, header) == 0, | |
300 Offsetof_SetToken_header_not_0); | |
301 COMPILE_ASSERT(offsetof(SetToken, token) == 4, | |
302 Offsetof_SetToken_token_not_4); | |
303 | |
304 struct BeginFrame { | |
305 typedef BeginFrame ValueType; | |
306 static const CommandId kCmdId = command_buffer::kBeginFrame; | |
307 static const ArgFlags kArgFlags = kFixed; | |
308 | |
309 void SetHeader() { | |
310 header.SetCmd<ValueType>(); | |
311 } | |
312 | |
313 void Init() { | |
314 SetHeader(); | |
315 } | |
316 static void* Set(void* cmd) { | |
317 static_cast<ValueType*>(cmd)->Init(); | |
318 return NextCmdAddress<ValueType>(cmd); | |
319 } | |
320 | |
321 CommandHeader header; | |
322 }; | |
323 | |
324 COMPILE_ASSERT(sizeof(BeginFrame) == 4, Sizeof_BeginFrame_is_not_4); | |
325 COMPILE_ASSERT(offsetof(BeginFrame, header) == 0, | |
326 OffsetOf_BeginFrame_header_not_0); | |
327 | |
328 struct EndFrame { | |
329 typedef EndFrame ValueType; | |
330 static const CommandId kCmdId = command_buffer::kEndFrame; | |
331 static const ArgFlags kArgFlags = kFixed; | |
332 | |
333 void SetHeader() { | |
334 header.SetCmd<ValueType>(); | |
335 } | |
336 | |
337 void Init() { | |
338 SetHeader(); | |
339 } | |
340 static void* Set(void* cmd) { | |
341 static_cast<ValueType*>(cmd)->Init(); | |
342 return NextCmdAddress<ValueType>(cmd); | |
343 } | |
344 | |
345 CommandHeader header; | |
346 }; | |
347 | |
348 COMPILE_ASSERT(sizeof(EndFrame) == 4, Sizeof_EndFrame_is_not_4); | |
349 COMPILE_ASSERT(offsetof(EndFrame, header) == 0, | |
350 OffsetOf_EndFrame_header_not_0); | |
351 | |
352 struct Clear { | |
353 typedef Clear ValueType; | |
354 static const CommandId kCmdId = command_buffer::kClear; | |
355 static const ArgFlags kArgFlags = kFixed; | |
356 | |
357 void SetHeader() { | |
358 header.SetCmd<ValueType>(); | |
359 } | |
360 | |
361 void Init(uint32 _buffers, float _red, float _green, float _blue, | |
362 float _alpha, float _depth, uint32 _stencil) { | |
363 SetHeader(); | |
364 buffers = _buffers; | |
365 red = _red; | |
366 green = _green; | |
367 blue = _blue; | |
368 alpha = _alpha; | |
369 depth = _depth; | |
370 stencil = _stencil; | |
371 } | |
372 | |
373 static void* Set(void* cmd, uint32 buffers, | |
374 float red, float green, float blue, float alpha, | |
375 float depth, | |
376 uint32 stencil) { | |
377 static_cast<ValueType*>(cmd)->Init( | |
378 buffers, red, green, blue, alpha, depth, stencil); | |
379 return NextCmdAddress<ValueType>(cmd); | |
380 } | |
381 | |
382 CommandHeader header; | |
383 uint32 buffers; | |
384 float red; | |
385 float green; | |
386 float blue; | |
387 float alpha; | |
388 float depth; | |
389 uint32 stencil; | |
390 }; | |
391 | |
392 COMPILE_ASSERT(sizeof(Clear) == 32, Sizeof_Clear_is_not_32); | |
393 COMPILE_ASSERT(offsetof(Clear, header) == 0, | |
394 OffsetOf_Clear_header_not_0); | |
395 COMPILE_ASSERT(offsetof(Clear, buffers) == 4, | |
396 OffsetOf_Clear_buffers_not_4); | |
397 COMPILE_ASSERT(offsetof(Clear, red) == 8, | |
398 OffsetOf_Clear_red_not_8); | |
399 COMPILE_ASSERT(offsetof(Clear, green) == 12, | |
400 OffsetOf_Clear_green_not_12); | |
401 COMPILE_ASSERT(offsetof(Clear, blue) == 16, | |
402 OffsetOf_Clear_blue_not_16); | |
403 COMPILE_ASSERT(offsetof(Clear, alpha) == 20, | |
404 OffsetOf_Clear_alpha_not_20); | |
405 COMPILE_ASSERT(offsetof(Clear, depth) == 24, | |
406 OffsetOf_Clear_depth_not_24); | |
407 COMPILE_ASSERT(offsetof(Clear, stencil) == 28, | |
408 OffsetOf_Clear_stencil_not_28); | |
409 | |
410 struct SetViewport { | |
411 typedef SetViewport ValueType; | |
412 static const CommandId kCmdId = command_buffer::kSetViewport; | |
413 static const ArgFlags kArgFlags = kFixed; | |
414 | |
415 void SetHeader() { | |
416 header.SetCmd<ValueType>(); | |
417 } | |
418 | |
419 void Init( | |
420 uint32 _left, | |
421 uint32 _top, | |
422 uint32 _width, | |
423 uint32 _height, | |
424 float _z_min, | |
425 float _z_max) { | |
426 SetHeader(); | |
427 left = _left; | |
428 top = _top; | |
429 width = _width; | |
430 height = _height; | |
431 z_min = _z_min; | |
432 z_max = _z_max; | |
433 } | |
434 | |
435 static void* Set(void* cmd, | |
436 uint32 left, | |
437 uint32 top, | |
438 uint32 width, | |
439 uint32 height, | |
440 float z_min, | |
441 float z_max) { | |
442 static_cast<ValueType*>(cmd)->Init( | |
443 left, | |
444 top, | |
445 width, | |
446 height, | |
447 z_min, | |
448 z_max); | |
449 return NextCmdAddress<ValueType>(cmd); | |
450 } | |
451 | |
452 CommandHeader header; | |
453 uint32 left; | |
454 uint32 top; | |
455 uint32 width; | |
456 uint32 height; | |
457 float z_min; | |
458 float z_max; | |
459 }; | |
460 | |
461 COMPILE_ASSERT(sizeof(SetViewport) == 28, Sizeof_SetViewport_is_not_28); | |
462 COMPILE_ASSERT(offsetof(SetViewport, header) == 0, | |
463 OffsetOf_SetViewport_header_not_0); | |
464 COMPILE_ASSERT(offsetof(SetViewport, left) == 4, | |
465 OffsetOf_SetViewport_left_not_4); | |
466 COMPILE_ASSERT(offsetof(SetViewport, top) == 8, | |
467 OffsetOf_SetViewport_top_not_8); | |
468 COMPILE_ASSERT(offsetof(SetViewport, width) == 12, | |
469 OffsetOf_SetViewport_width_not_12); | |
470 COMPILE_ASSERT(offsetof(SetViewport, height) == 16, | |
471 OffsetOf_SetViewport_height_not_16); | |
472 COMPILE_ASSERT(offsetof(SetViewport, z_min) == 20, | |
473 OffsetOf_SetViewport_z_min_not_20); | |
474 COMPILE_ASSERT(offsetof(SetViewport, z_max) == 24, | |
475 OffsetOf_SetViewport_z_max_not_24); | |
476 | |
477 struct CreateVertexBuffer { | |
478 typedef CreateVertexBuffer ValueType; | |
479 static const CommandId kCmdId = command_buffer::kCreateVertexBuffer; | |
480 static const ArgFlags kArgFlags = kFixed; | |
481 | |
482 void SetHeader() { | |
483 header.SetCmd<ValueType>(); | |
484 } | |
485 | |
486 void Init(ResourceId _vertex_buffer_id, uint32 _size, | |
487 vertex_buffer::Flags _flags) { | |
488 SetHeader(); | |
489 vertex_buffer_id = _vertex_buffer_id; | |
490 size = _size; | |
491 flags = static_cast<uint32>(_flags); | |
492 } | |
493 | |
494 static void* Set(void* cmd, ResourceId vertex_buffer_id, | |
495 uint32 size, vertex_buffer::Flags flags) { | |
496 static_cast<ValueType*>(cmd)->Init(vertex_buffer_id, size, flags); | |
497 return NextCmdAddress<ValueType>(cmd); | |
498 } | |
499 | |
500 CommandHeader header; | |
501 ResourceId vertex_buffer_id; | |
502 uint32 size; | |
503 uint32 flags; | |
504 }; | |
505 | |
506 COMPILE_ASSERT(sizeof(CreateVertexBuffer) == 16, | |
507 Sizeof_CreateVertexBuffer_is_not_16); | |
508 COMPILE_ASSERT(offsetof(CreateVertexBuffer, header) == 0, | |
509 OffsetOf_CreateVertexBuffer_header_not_0); | |
510 COMPILE_ASSERT(offsetof(CreateVertexBuffer, vertex_buffer_id) == 4, | |
511 OffsetOf_CreateVertexBuffer_vertex_buffer_id_not_4); | |
512 COMPILE_ASSERT(offsetof(CreateVertexBuffer, size) == 8, | |
513 OffsetOf_CreateVertexBuffer_size_not_8); | |
514 COMPILE_ASSERT(offsetof(CreateVertexBuffer, flags) == 12, | |
515 OffsetOf_CreateVertexBuffer_flags_not_12); | |
516 | |
517 struct DestroyVertexBuffer { | |
518 typedef DestroyVertexBuffer ValueType; | |
519 static const CommandId kCmdId = command_buffer::kDestroyVertexBuffer; | |
520 static const ArgFlags kArgFlags = kFixed; | |
521 | |
522 void SetHeader() { | |
523 header.SetCmd<ValueType>(); | |
524 } | |
525 | |
526 void Init(ResourceId _vertex_buffer_id) { | |
527 SetHeader(); | |
528 vertex_buffer_id = _vertex_buffer_id; | |
529 } | |
530 | |
531 static void* Set(void* cmd, ResourceId vertex_buffer_id) { | |
532 static_cast<ValueType*>(cmd)->Init(vertex_buffer_id); | |
533 return NextCmdAddress<ValueType>(cmd); | |
534 } | |
535 | |
536 CommandHeader header; | |
537 ResourceId vertex_buffer_id; | |
538 }; | |
539 | |
540 COMPILE_ASSERT(sizeof(DestroyVertexBuffer) == 8, | |
541 Sizeof_DestroyVertexBuffer_is_not_8); | |
542 COMPILE_ASSERT(offsetof(DestroyVertexBuffer, header) == 0, | |
543 OffsetOf_DestroyVertexBuffer_header_not_0); | |
544 COMPILE_ASSERT(offsetof(DestroyVertexBuffer, vertex_buffer_id) == 4, | |
545 OffsetOf_DestroyVertexBuffer_vertex_buffer_id_not_4); | |
546 | |
547 struct SetVertexBufferDataImmediate { | |
548 typedef SetVertexBufferDataImmediate ValueType; | |
549 static const CommandId kCmdId = command_buffer::kSetVertexBufferDataImmediate; | |
550 static const ArgFlags kArgFlags = kAtLeastN; | |
551 | |
552 void SetHeader(uint32 size) { | |
553 header.SetCmdBySize<ValueType>(size); | |
554 } | |
555 | |
556 void Init(ResourceId _vertex_buffer_id, uint32 _offset, | |
557 const void* data, uint32 size) { | |
558 SetHeader(size); | |
559 vertex_buffer_id = _vertex_buffer_id; | |
560 offset = _offset; | |
561 memcpy(ImmediateDataAddress(this), data, size); | |
562 } | |
563 | |
564 static void* Set(void* cmd, ResourceId vertex_buffer_id, uint32 offset, | |
565 const void* data, uint32 size) { | |
566 static_cast<ValueType*>(cmd)->Init(vertex_buffer_id, offset, data, size); | |
567 return NextImmediateCmdAddress<ValueType>(cmd, size); | |
568 } | |
569 | |
570 CommandHeader header; | |
571 ResourceId vertex_buffer_id; | |
572 uint32 offset; | |
573 }; | |
574 | |
575 COMPILE_ASSERT(sizeof(SetVertexBufferDataImmediate) == 12, | |
576 Sizeof_SetVertexBufferDataImmediate_is_not_12); | |
577 COMPILE_ASSERT(offsetof(SetVertexBufferDataImmediate, header) == 0, | |
578 OffsetOf_SetVertexBufferDataImmediate_header_not_0); | |
579 COMPILE_ASSERT(offsetof(SetVertexBufferDataImmediate, vertex_buffer_id) == 4, | |
580 OffsetOf_SetVertexBufferDataImmediate_vertex_buffer_id_not_4); | |
581 COMPILE_ASSERT(offsetof(SetVertexBufferDataImmediate, offset) == 8, | |
582 OffsetOf_SetVertexBufferDataImmediate_offset_not_8); | |
583 | |
584 struct SetVertexBufferData { | |
585 typedef SetVertexBufferData ValueType; | |
586 static const CommandId kCmdId = command_buffer::kSetVertexBufferData; | |
587 static const ArgFlags kArgFlags = kFixed; | |
588 | |
589 void SetHeader() { | |
590 header.SetCmd<ValueType>(); | |
591 } | |
592 | |
593 void Init(ResourceId _vertex_buffer_id, uint32 _offset, uint32 _size, | |
594 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
595 SetHeader(); | |
596 vertex_buffer_id = _vertex_buffer_id; | |
597 offset = _offset; | |
598 size = _size; | |
599 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
600 } | |
601 | |
602 static void* Set(void* cmd, ResourceId vertex_buffer_id, | |
603 uint32 offset, uint32 size, | |
604 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
605 static_cast<ValueType*>(cmd)->Init(vertex_buffer_id, offset, size, | |
606 shared_memory_id, shared_memory_offset); | |
607 return NextCmdAddress<ValueType>(cmd); | |
608 } | |
609 | |
610 CommandHeader header; | |
611 ResourceId vertex_buffer_id; | |
612 uint32 offset; | |
613 uint32 size; | |
614 SharedMemory shared_memory; | |
615 }; | |
616 | |
617 COMPILE_ASSERT(sizeof(SetVertexBufferData) == 24, | |
618 Sizeof_SetVertexBufferData_is_not_24); | |
619 COMPILE_ASSERT(offsetof(SetVertexBufferData, header) == 0, | |
620 OffsetOf_SetVertexBufferData_header_not_0); | |
621 COMPILE_ASSERT(offsetof(SetVertexBufferData, vertex_buffer_id) == 4, | |
622 OffsetOf_SetVertexBufferData_vertex_buffer_id_not_4); | |
623 COMPILE_ASSERT(offsetof(SetVertexBufferData, offset) == 8, | |
624 OffsetOf_SetVertexBufferData_offset_not_8); | |
625 COMPILE_ASSERT(offsetof(SetVertexBufferData, size) == 12, | |
626 OffsetOf_SetVertexBufferData_size_not_12); | |
627 COMPILE_ASSERT(offsetof(SetVertexBufferData, shared_memory) == 16, | |
628 OffsetOf_SetVertexBufferData_shared_memory_not_16); | |
629 | |
630 struct GetVertexBufferData { | |
631 typedef GetVertexBufferData ValueType; | |
632 static const CommandId kCmdId = command_buffer::kGetVertexBufferData; | |
633 static const ArgFlags kArgFlags = kFixed; | |
634 | |
635 void SetHeader() { | |
636 header.SetCmd<ValueType>(); | |
637 } | |
638 | |
639 void Init(ResourceId _vertex_buffer_id, uint32 _offset, uint32 _size, | |
640 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
641 SetHeader(); | |
642 vertex_buffer_id = _vertex_buffer_id; | |
643 offset = _offset; | |
644 size = _size; | |
645 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
646 } | |
647 | |
648 static void* Set(void* cmd, ResourceId vertex_buffer_id, | |
649 uint32 offset, uint32 size, | |
650 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
651 static_cast<ValueType*>(cmd)->Init(vertex_buffer_id, offset, size, | |
652 shared_memory_id, shared_memory_offset); | |
653 return NextCmdAddress<ValueType>(cmd); | |
654 } | |
655 | |
656 CommandHeader header; | |
657 ResourceId vertex_buffer_id; | |
658 uint32 offset; | |
659 uint32 size; | |
660 SharedMemory shared_memory; | |
661 }; | |
662 | |
663 COMPILE_ASSERT(sizeof(GetVertexBufferData) == 24, | |
664 Sizeof_GetVertexBufferData_is_not_24); | |
665 COMPILE_ASSERT(offsetof(GetVertexBufferData, header) == 0, | |
666 OffsetOf_GetVertexBufferData_header_not_0); | |
667 COMPILE_ASSERT(offsetof(GetVertexBufferData, vertex_buffer_id) == 4, | |
668 OffsetOf_GetVertexBufferData_vertex_buffer_id_not_4); | |
669 COMPILE_ASSERT(offsetof(GetVertexBufferData, offset) == 8, | |
670 OffsetOf_GetVertexBufferData_offset_not_8); | |
671 COMPILE_ASSERT(offsetof(GetVertexBufferData, size) == 12, | |
672 OffsetOf_GetVertexBufferData_size_not_12); | |
673 COMPILE_ASSERT(offsetof(GetVertexBufferData, shared_memory) == 16, | |
674 OffsetOf_GetVertexBufferData_shared_memory_not_16); | |
675 | |
676 struct CreateIndexBuffer { | |
677 typedef CreateIndexBuffer ValueType; | |
678 static const CommandId kCmdId = command_buffer::kCreateIndexBuffer; | |
679 static const ArgFlags kArgFlags = kFixed; | |
680 | |
681 void SetHeader() { | |
682 header.SetCmd<ValueType>(); | |
683 } | |
684 | |
685 void Init(ResourceId _index_buffer_id, uint32 _size, | |
686 index_buffer::Flags _flags) { | |
687 SetHeader(); | |
688 index_buffer_id = _index_buffer_id; | |
689 size = _size; | |
690 flags = static_cast<uint32>(_flags); | |
691 } | |
692 | |
693 static void* Set(void* cmd, ResourceId index_buffer_id, | |
694 uint32 size, index_buffer::Flags flags) { | |
695 static_cast<ValueType*>(cmd)->Init(index_buffer_id, size, flags); | |
696 return NextCmdAddress<ValueType>(cmd); | |
697 } | |
698 | |
699 CommandHeader header; | |
700 ResourceId index_buffer_id; | |
701 uint32 size; | |
702 uint32 flags; | |
703 }; | |
704 | |
705 COMPILE_ASSERT(sizeof(CreateIndexBuffer) == 16, | |
706 Sizeof_CreateIndexBuffer_is_not_16); | |
707 COMPILE_ASSERT(offsetof(CreateIndexBuffer, header) == 0, | |
708 OffsetOf_CreateIndexBuffer_header_not_0); | |
709 COMPILE_ASSERT(offsetof(CreateIndexBuffer, index_buffer_id) == 4, | |
710 OffsetOf_CreateIndexBuffer_index_buffer_id_not_4); | |
711 COMPILE_ASSERT(offsetof(CreateIndexBuffer, size) == 8, | |
712 OffsetOf_CreateIndexBuffer_size_not_8); | |
713 COMPILE_ASSERT(offsetof(CreateIndexBuffer, flags) == 12, | |
714 OffsetOf_CreateIndexBuffer_flags_not_12); | |
715 | |
716 struct DestroyIndexBuffer { | |
717 typedef DestroyIndexBuffer ValueType; | |
718 static const CommandId kCmdId = command_buffer::kDestroyIndexBuffer; | |
719 static const ArgFlags kArgFlags = kFixed; | |
720 | |
721 void SetHeader() { | |
722 header.SetCmd<ValueType>(); | |
723 } | |
724 | |
725 void Init(ResourceId _index_buffer_id) { | |
726 SetHeader(); | |
727 index_buffer_id = _index_buffer_id; | |
728 } | |
729 | |
730 static void* Set(void* cmd, ResourceId index_buffer_id) { | |
731 static_cast<ValueType*>(cmd)->Init(index_buffer_id); | |
732 return NextCmdAddress<ValueType>(cmd); | |
733 } | |
734 | |
735 CommandHeader header; | |
736 ResourceId index_buffer_id; | |
737 }; | |
738 | |
739 COMPILE_ASSERT(sizeof(DestroyIndexBuffer) == 8, | |
740 Sizeof_DestroyIndexBuffer_is_not_8); | |
741 COMPILE_ASSERT(offsetof(DestroyIndexBuffer, header) == 0, | |
742 OffsetOf_DestroyIndexBuffer_header_not_0); | |
743 COMPILE_ASSERT(offsetof(DestroyIndexBuffer, index_buffer_id) == 4, | |
744 OffsetOf_DestroyIndexBuffer_index_buffer_id_not_4); | |
745 | |
746 struct SetIndexBufferDataImmediate { | |
747 typedef SetIndexBufferDataImmediate ValueType; | |
748 static const CommandId kCmdId = command_buffer::kSetIndexBufferDataImmediate; | |
749 static const ArgFlags kArgFlags = kAtLeastN; | |
750 | |
751 void SetHeader(uint32 size) { | |
752 header.SetCmdBySize<ValueType>(size); | |
753 } | |
754 | |
755 void Init(ResourceId _index_buffer_id, uint32 _offset, | |
756 const void* data, uint32 size) { | |
757 SetHeader(size); | |
758 index_buffer_id = _index_buffer_id; | |
759 offset = _offset; | |
760 memcpy(ImmediateDataAddress(this), data, size); | |
761 } | |
762 | |
763 static void* Set(void* cmd, ResourceId index_buffer_id, uint32 offset, | |
764 const void* data, uint32 size) { | |
765 static_cast<ValueType*>(cmd)->Init(index_buffer_id, offset, data, size); | |
766 return NextImmediateCmdAddress<ValueType>(cmd, size); | |
767 } | |
768 | |
769 CommandHeader header; | |
770 ResourceId index_buffer_id; | |
771 uint32 offset; | |
772 }; | |
773 | |
774 COMPILE_ASSERT(sizeof(SetIndexBufferDataImmediate) == 12, | |
775 Sizeof_SetIndexBufferDataImmediate_is_not_12); | |
776 COMPILE_ASSERT(offsetof(SetIndexBufferDataImmediate, header) == 0, | |
777 OffsetOf_SetIndexBufferDataImmediate_header_not_0); | |
778 COMPILE_ASSERT(offsetof(SetIndexBufferDataImmediate, index_buffer_id) == 4, | |
779 OffsetOf_SetIndexBufferDataImmediate_index_buffer_id_not_4); | |
780 COMPILE_ASSERT(offsetof(SetIndexBufferDataImmediate, offset) == 8, | |
781 OffsetOf_SetIndexBufferDataImmediate_offset_not_8); | |
782 | |
783 struct SetIndexBufferData { | |
784 typedef SetIndexBufferData ValueType; | |
785 static const CommandId kCmdId = command_buffer::kSetIndexBufferData; | |
786 static const ArgFlags kArgFlags = kFixed; | |
787 | |
788 void SetHeader() { | |
789 header.SetCmd<ValueType>(); | |
790 } | |
791 | |
792 void Init(ResourceId _index_buffer_id, uint32 _offset, uint32 _size, | |
793 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
794 SetHeader(); | |
795 index_buffer_id = _index_buffer_id; | |
796 offset = _offset; | |
797 size = _size; | |
798 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
799 } | |
800 | |
801 static void* Set(void* cmd, | |
802 ResourceId index_buffer_id, uint32 offset, uint32 size, | |
803 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
804 static_cast<ValueType*>(cmd)->Init(index_buffer_id, offset, size, | |
805 shared_memory_id, shared_memory_offset); | |
806 return NextCmdAddress<ValueType>(cmd); | |
807 } | |
808 | |
809 CommandHeader header; | |
810 ResourceId index_buffer_id; | |
811 uint32 offset; | |
812 uint32 size; | |
813 SharedMemory shared_memory; | |
814 }; | |
815 | |
816 COMPILE_ASSERT(sizeof(SetIndexBufferData) == 24, | |
817 Sizeof_SetIndexBufferData_is_not_24); | |
818 COMPILE_ASSERT(offsetof(SetIndexBufferData, header) == 0, | |
819 OffsetOf_SetIndexBufferData_header_not_0); | |
820 COMPILE_ASSERT(offsetof(SetIndexBufferData, index_buffer_id) == 4, | |
821 OffsetOf_SetIndexBufferData_index_buffer_id_not_4); | |
822 COMPILE_ASSERT(offsetof(SetIndexBufferData, offset) == 8, | |
823 OffsetOf_SetIndexBufferData_offset_not_8); | |
824 COMPILE_ASSERT(offsetof(SetIndexBufferData, size) == 12, | |
825 OffsetOf_SetIndexBufferData_size_not_12); | |
826 COMPILE_ASSERT(offsetof(SetIndexBufferData, shared_memory) == 16, | |
827 OffsetOf_SetIndexBufferData_shared_memory_not_16); | |
828 | |
829 struct GetIndexBufferData { | |
830 typedef GetIndexBufferData ValueType; | |
831 static const CommandId kCmdId = command_buffer::kGetIndexBufferData; | |
832 static const ArgFlags kArgFlags = kFixed; | |
833 | |
834 void SetHeader() { | |
835 header.SetCmd<ValueType>(); | |
836 } | |
837 | |
838 void Init(ResourceId _index_buffer_id, uint32 _offset, uint32 _size, | |
839 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
840 SetHeader(); | |
841 index_buffer_id = _index_buffer_id; | |
842 offset = _offset; | |
843 size = _size; | |
844 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
845 } | |
846 | |
847 static void* Set(void* cmd, ResourceId index_buffer_id, | |
848 uint32 offset, uint32 size, | |
849 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
850 static_cast<ValueType*>(cmd)->Init(index_buffer_id, offset, size, | |
851 shared_memory_id, shared_memory_offset); | |
852 return NextCmdAddress<ValueType>(cmd); | |
853 } | |
854 | |
855 CommandHeader header; | |
856 ResourceId index_buffer_id; | |
857 uint32 offset; | |
858 uint32 size; | |
859 SharedMemory shared_memory; | |
860 }; | |
861 | |
862 COMPILE_ASSERT(sizeof(GetIndexBufferData) == 24, | |
863 Sizeof_GetIndexBufferData_is_not_24); | |
864 COMPILE_ASSERT(offsetof(GetIndexBufferData, header) == 0, | |
865 OffsetOf_GetIndexBufferData_header_not_0); | |
866 COMPILE_ASSERT(offsetof(GetIndexBufferData, index_buffer_id) == 4, | |
867 OffsetOf_GetIndexBufferData_index_buffer_id_not_4); | |
868 COMPILE_ASSERT(offsetof(GetIndexBufferData, offset) == 8, | |
869 OffsetOf_GetIndexBufferData_offset_not_8); | |
870 COMPILE_ASSERT(offsetof(GetIndexBufferData, size) == 12, | |
871 OffsetOf_GetIndexBufferData_size_not_12); | |
872 COMPILE_ASSERT(offsetof(GetIndexBufferData, shared_memory) == 16, | |
873 OffsetOf_GetIndexBufferData_shared_memory_not_16); | |
874 | |
875 struct CreateVertexStruct { | |
876 typedef CreateVertexStruct ValueType; | |
877 static const CommandId kCmdId = command_buffer::kCreateVertexStruct; | |
878 static const ArgFlags kArgFlags = kFixed; | |
879 | |
880 void SetHeader() { | |
881 header.SetCmd<ValueType>(); | |
882 } | |
883 | |
884 void Init(ResourceId _vertex_struct_id, uint32 _input_count) { | |
885 SetHeader(); | |
886 vertex_struct_id = _vertex_struct_id; | |
887 input_count = _input_count; | |
888 } | |
889 | |
890 static void* Set(void* cmd, ResourceId vertex_struct_id, uint32 input_count) { | |
891 static_cast<ValueType*>(cmd)->Init(vertex_struct_id, input_count); | |
892 return NextCmdAddress<ValueType>(cmd); | |
893 } | |
894 | |
895 CommandHeader header; | |
896 ResourceId vertex_struct_id; | |
897 uint32 input_count; | |
898 }; | |
899 | |
900 COMPILE_ASSERT(sizeof(CreateVertexStruct) == 12, | |
901 Sizeof_CreateVertexStruct_is_not_12); | |
902 COMPILE_ASSERT(offsetof(CreateVertexStruct, header) == 0, | |
903 OffsetOf_CreateVertexStruct_header_not_0); | |
904 COMPILE_ASSERT(offsetof(CreateVertexStruct, vertex_struct_id) == 4, | |
905 OffsetOf_CreateVertexStruct_vertex_struct_id_not_4); | |
906 COMPILE_ASSERT(offsetof(CreateVertexStruct, input_count) == 8, | |
907 OffsetOf_CreateVertexStruct_input_count_not_8); | |
908 | |
909 struct DestroyVertexStruct { | |
910 typedef DestroyVertexStruct ValueType; | |
911 static const CommandId kCmdId = command_buffer::kDestroyVertexStruct; | |
912 static const ArgFlags kArgFlags = kFixed; | |
913 | |
914 void SetHeader() { | |
915 header.SetCmd<ValueType>(); | |
916 } | |
917 | |
918 void Init(ResourceId _vertex_struct_id) { | |
919 SetHeader(); | |
920 vertex_struct_id = _vertex_struct_id; | |
921 } | |
922 | |
923 static void* Set(void* cmd, ResourceId vertex_struct_id) { | |
924 static_cast<ValueType*>(cmd)->Init(vertex_struct_id); | |
925 return NextCmdAddress<ValueType>(cmd); | |
926 } | |
927 | |
928 CommandHeader header; | |
929 ResourceId vertex_struct_id; | |
930 }; | |
931 | |
932 COMPILE_ASSERT(sizeof(DestroyVertexStruct) == 8, | |
933 Sizeof_DestroyVertexStruct_is_not_8); | |
934 COMPILE_ASSERT(offsetof(DestroyVertexStruct, header) == 0, | |
935 OffsetOf_DestroyVertexStruct_header_not_0); | |
936 COMPILE_ASSERT(offsetof(DestroyVertexStruct, vertex_struct_id) == 4, | |
937 OffsetOf_DestroyVertexStruct_vertex_struct_id_not_4); | |
938 | |
939 struct SetVertexInput { | |
940 typedef SetVertexInput ValueType; | |
941 static const CommandId kCmdId = command_buffer::kSetVertexInput; | |
942 static const ArgFlags kArgFlags = kFixed; | |
943 | |
944 // type_stride_semantic field. | |
945 typedef BitField<0, 4> SemanticIndex; | |
946 typedef BitField<4, 4> Semantic; | |
947 typedef BitField<8, 8> Type; | |
948 typedef BitField<16, 16> Stride; | |
949 | |
950 void SetHeader() { | |
951 header.SetCmd<ValueType>(); | |
952 } | |
953 | |
954 void Init(ResourceId _vertex_struct_id, | |
955 uint32 _input_index, | |
956 ResourceId _vertex_buffer_id, | |
957 uint32 _offset, | |
958 vertex_struct::Semantic _semantic, | |
959 uint32 _semantic_index, | |
960 vertex_struct::Type _type, | |
961 uint32 _stride) { | |
962 SetHeader(); | |
963 vertex_struct_id = _vertex_struct_id; | |
964 input_index = _input_index; | |
965 vertex_buffer_id = _vertex_buffer_id; | |
966 offset = _offset; | |
967 type_stride_semantic = | |
968 Semantic::MakeValue(_semantic) | | |
969 SemanticIndex::MakeValue(_semantic_index) | | |
970 Type::MakeValue(_type) | | |
971 Stride::MakeValue(_stride); | |
972 } | |
973 | |
974 static void* Set( | |
975 void* cmd, | |
976 ResourceId vertex_struct_id, | |
977 uint32 input_index, | |
978 ResourceId vertex_buffer_id, | |
979 uint32 offset, | |
980 vertex_struct::Semantic semantic, | |
981 uint32 semantic_index, | |
982 vertex_struct::Type type, | |
983 uint32 stride) { | |
984 static_cast<ValueType*>(cmd)->Init( | |
985 vertex_struct_id, | |
986 input_index, | |
987 vertex_buffer_id, | |
988 offset, | |
989 semantic, | |
990 semantic_index, | |
991 type, | |
992 stride); | |
993 return NextCmdAddress<ValueType>(cmd); | |
994 } | |
995 | |
996 CommandHeader header; | |
997 ResourceId vertex_struct_id; | |
998 uint32 input_index; | |
999 ResourceId vertex_buffer_id; | |
1000 uint32 offset; | |
1001 uint32 type_stride_semantic; | |
1002 }; | |
1003 | |
1004 COMPILE_ASSERT(sizeof(SetVertexInput) == 24, | |
1005 Sizeof_SetVertexInput_is_not_24); | |
1006 COMPILE_ASSERT(offsetof(SetVertexInput, header) == 0, | |
1007 OffsetOf_SetVertexInput_header_not_0); | |
1008 COMPILE_ASSERT(offsetof(SetVertexInput, vertex_struct_id) == 4, | |
1009 OffsetOf_SetVertexInput_vertex_struct_id_not_4); | |
1010 COMPILE_ASSERT(offsetof(SetVertexInput, input_index) == 8, | |
1011 OffsetOf_SetVertexInput_input_index_not_8); | |
1012 COMPILE_ASSERT(offsetof(SetVertexInput, vertex_buffer_id) == 12, | |
1013 OffsetOf_SetVertexInput_vertex_buffer_id_not_12); | |
1014 COMPILE_ASSERT(offsetof(SetVertexInput, offset) == 16, | |
1015 OffsetOf_SetVertexInput_offset_not_16); | |
1016 COMPILE_ASSERT(offsetof(SetVertexInput, type_stride_semantic) == 20, | |
1017 OffsetOf_SetVertexInput_type_stride_semantic_not_20); | |
1018 | |
1019 struct SetVertexStruct { | |
1020 typedef SetVertexStruct ValueType; | |
1021 static const CommandId kCmdId = command_buffer::kSetVertexStruct; | |
1022 static const ArgFlags kArgFlags = kFixed; | |
1023 | |
1024 void SetHeader() { | |
1025 header.SetCmd<ValueType>(); | |
1026 } | |
1027 | |
1028 void Init(ResourceId _vertex_struct_id) { | |
1029 SetHeader(); | |
1030 vertex_struct_id = _vertex_struct_id; | |
1031 } | |
1032 | |
1033 static void* Set(void* cmd, ResourceId vertex_struct_id) { | |
1034 static_cast<ValueType*>(cmd)->Init(vertex_struct_id); | |
1035 return NextCmdAddress<ValueType>(cmd); | |
1036 } | |
1037 | |
1038 CommandHeader header; | |
1039 ResourceId vertex_struct_id; | |
1040 }; | |
1041 | |
1042 COMPILE_ASSERT(sizeof(SetVertexStruct) == 8, | |
1043 Sizeof_SetVertexStruct_is_not_8); | |
1044 COMPILE_ASSERT(offsetof(SetVertexStruct, header) == 0, | |
1045 OffsetOf_SetVertexStruct_header_not_0); | |
1046 COMPILE_ASSERT(offsetof(SetVertexStruct, vertex_struct_id) == 4, | |
1047 OffsetOf_SetVertexStruct_vertex_struct_id_not_4); | |
1048 | |
1049 struct Draw { | |
1050 typedef Draw ValueType; | |
1051 static const CommandId kCmdId = command_buffer::kDraw; | |
1052 static const ArgFlags kArgFlags = kFixed; | |
1053 | |
1054 void SetHeader() { | |
1055 header.SetCmd<ValueType>(); | |
1056 } | |
1057 | |
1058 void Init(PrimitiveType _primitive_type, uint32 _first, uint32 _count) { | |
1059 SetHeader(); | |
1060 primitive_type = _primitive_type; | |
1061 first = _first; | |
1062 count = _count; | |
1063 } | |
1064 | |
1065 static void* Set(void* cmd, PrimitiveType primitive_type, uint32 first, | |
1066 uint32 count) { | |
1067 static_cast<ValueType*>(cmd)->Init(primitive_type, first, count); | |
1068 return NextCmdAddress<ValueType>(cmd); | |
1069 } | |
1070 | |
1071 CommandHeader header; | |
1072 uint32 primitive_type; | |
1073 uint32 first; | |
1074 uint32 count; | |
1075 }; | |
1076 | |
1077 COMPILE_ASSERT(sizeof(Draw) == 16, Sizeof_DRAW_is_not_16); | |
1078 COMPILE_ASSERT(offsetof(Draw, header) == 0, | |
1079 OffsetOf_Draw_header_not_0); | |
1080 COMPILE_ASSERT(offsetof(Draw, primitive_type) == 4, | |
1081 OffsetOf_Draw_primitive_type_not_4); | |
1082 COMPILE_ASSERT(offsetof(Draw, first) == 8, | |
1083 OffsetOf_Draw_first_not_8); | |
1084 COMPILE_ASSERT(offsetof(Draw, count) == 12, | |
1085 OffsetOf_Draw_count_not_12); | |
1086 | |
1087 struct DrawIndexed { | |
1088 typedef DrawIndexed ValueType; | |
1089 static const CommandId kCmdId = command_buffer::kDrawIndexed; | |
1090 static const ArgFlags kArgFlags = kFixed; | |
1091 | |
1092 void SetHeader() { | |
1093 header.SetCmd<ValueType>(); | |
1094 } | |
1095 | |
1096 void Init( | |
1097 PrimitiveType _primitive_type, | |
1098 ResourceId _index_buffer_id, | |
1099 uint32 _first, | |
1100 uint32 _count, | |
1101 uint32 _min_index, | |
1102 uint32 _max_index) { | |
1103 SetHeader(); | |
1104 primitive_type = _primitive_type; | |
1105 index_buffer_id = _index_buffer_id; | |
1106 first = _first; | |
1107 count = _count; | |
1108 min_index = _min_index; | |
1109 max_index = _max_index; | |
1110 } | |
1111 | |
1112 static void* Set(void* cmd, | |
1113 PrimitiveType primitive_type, | |
1114 ResourceId index_buffer_id, | |
1115 uint32 first, | |
1116 uint32 count, | |
1117 uint32 min_index, | |
1118 uint32 max_index) { | |
1119 static_cast<ValueType*>(cmd)->Init( | |
1120 primitive_type, | |
1121 index_buffer_id, | |
1122 first, | |
1123 count, | |
1124 min_index, | |
1125 max_index); | |
1126 return NextCmdAddress<ValueType>(cmd); | |
1127 } | |
1128 | |
1129 CommandHeader header; | |
1130 uint32 primitive_type; | |
1131 ResourceId index_buffer_id; | |
1132 uint32 first; | |
1133 uint32 count; | |
1134 uint32 min_index; | |
1135 uint32 max_index; | |
1136 }; | |
1137 | |
1138 COMPILE_ASSERT(sizeof(DrawIndexed) == 28, Sizeof_DrawIndexed_is_not_28); | |
1139 COMPILE_ASSERT(offsetof(DrawIndexed, header) == 0, | |
1140 OffsetOf_DrawIndexed_header_not_0); | |
1141 COMPILE_ASSERT(offsetof(DrawIndexed, primitive_type) == 4, | |
1142 OffsetOf_DrawIndexed_primitive_type_not_4); | |
1143 COMPILE_ASSERT(offsetof(DrawIndexed, index_buffer_id) == 8, | |
1144 OffsetOf_DrawIndexed_index_buffer_id_not_8); | |
1145 COMPILE_ASSERT(offsetof(DrawIndexed, first) == 12, | |
1146 OffsetOf_DrawIndexed_first_not_12); | |
1147 COMPILE_ASSERT(offsetof(DrawIndexed, count) == 16, | |
1148 OffsetOf_DrawIndexed_count_not_16); | |
1149 COMPILE_ASSERT(offsetof(DrawIndexed, min_index) == 20, | |
1150 OffsetOf_DrawIndexed_min_index_not_20); | |
1151 COMPILE_ASSERT(offsetof(DrawIndexed, max_index) == 24, | |
1152 OffsetOf_DrawIndexed_max_index_not_24); | |
1153 | |
1154 struct CreateEffect { | |
1155 typedef CreateEffect ValueType; | |
1156 static const CommandId kCmdId = command_buffer::kCreateEffect; | |
1157 static const ArgFlags kArgFlags = kFixed; | |
1158 | |
1159 void SetHeader() { | |
1160 header.SetCmd<ValueType>(); | |
1161 } | |
1162 | |
1163 void Init(ResourceId _effect_id, uint32 _size, | |
1164 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1165 SetHeader(); | |
1166 effect_id = _effect_id; | |
1167 size = _size; | |
1168 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
1169 } | |
1170 | |
1171 static void* Set(void* cmd, ResourceId effect_id, uint32 size, | |
1172 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1173 static_cast<ValueType*>(cmd)->Init(effect_id, size, | |
1174 shared_memory_id, shared_memory_offset); | |
1175 return NextCmdAddress<ValueType>(cmd); | |
1176 } | |
1177 | |
1178 CommandHeader header; | |
1179 ResourceId effect_id; | |
1180 uint32 size; | |
1181 SharedMemory shared_memory; | |
1182 }; | |
1183 | |
1184 COMPILE_ASSERT(sizeof(CreateEffect) == 20, Sizeof_CreateEffect_is_not_20); | |
1185 COMPILE_ASSERT(offsetof(CreateEffect, header) == 0, | |
1186 OffsetOf_CreateEffect_header_not_0); | |
1187 COMPILE_ASSERT(offsetof(CreateEffect, effect_id) == 4, | |
1188 OffsetOf_CreateEffect_effect_id_not_4); | |
1189 COMPILE_ASSERT(offsetof(CreateEffect, size) == 8, | |
1190 OffsetOf_CreateEffect_size_not_8); | |
1191 COMPILE_ASSERT(offsetof(CreateEffect, shared_memory) == 12, | |
1192 OffsetOf_CreateEffect_shared_memory_not_12); | |
1193 | |
1194 struct CreateEffectImmediate { | |
1195 typedef CreateEffectImmediate ValueType; | |
1196 static const CommandId kCmdId = command_buffer::kCreateEffectImmediate; | |
1197 static const ArgFlags kArgFlags = kAtLeastN; | |
1198 | |
1199 void SetHeader(uint32 size) { | |
1200 header.SetCmdBySize<ValueType>(size); | |
1201 } | |
1202 | |
1203 void Init(ResourceId _effect_id, uint32 _size, const void* data) { | |
1204 SetHeader(_size); | |
1205 effect_id = _effect_id; | |
1206 size = _size; | |
1207 } | |
1208 | |
1209 static void* Set(void* cmd, | |
1210 ResourceId effect_id, uint32 size, const void* data) { | |
1211 static_cast<ValueType*>(cmd)->Init(effect_id, size, data); | |
1212 return NextImmediateCmdAddress<ValueType>(cmd, size); | |
1213 } | |
1214 | |
1215 CommandHeader header; | |
1216 ResourceId effect_id; | |
1217 uint32 size; | |
1218 }; | |
1219 | |
1220 COMPILE_ASSERT(sizeof(CreateEffectImmediate) == 12, | |
1221 Sizeof_CreateEffectImmediate_is_not_12); | |
1222 COMPILE_ASSERT(offsetof(CreateEffectImmediate, header) == 0, | |
1223 OffsetOf_CreateEffectImmediate_header_not_0); | |
1224 COMPILE_ASSERT(offsetof(CreateEffectImmediate, effect_id) == 4, | |
1225 OffsetOf_CreateEffectImmediate_effect_id_not_4); | |
1226 COMPILE_ASSERT(offsetof(CreateEffectImmediate, size) == 8, | |
1227 OffsetOf_CreateEffectImmediate_size_not_8); | |
1228 | |
1229 struct DestroyEffect { | |
1230 typedef DestroyEffect ValueType; | |
1231 static const CommandId kCmdId = command_buffer::kDestroyEffect; | |
1232 static const ArgFlags kArgFlags = kFixed; | |
1233 | |
1234 void SetHeader() { | |
1235 header.SetCmd<ValueType>(); | |
1236 } | |
1237 | |
1238 void Init(ResourceId _effect_id) { | |
1239 SetHeader(); | |
1240 effect_id = _effect_id; | |
1241 } | |
1242 | |
1243 static void* Set(void* cmd, ResourceId effect_id) { | |
1244 static_cast<ValueType*>(cmd)->Init(effect_id); | |
1245 return NextCmdAddress<ValueType>(cmd); | |
1246 } | |
1247 | |
1248 CommandHeader header; | |
1249 ResourceId effect_id; | |
1250 }; | |
1251 | |
1252 COMPILE_ASSERT(sizeof(DestroyEffect) == 8, Sizeof_DestroyEffect_is_not_8); | |
1253 COMPILE_ASSERT(offsetof(DestroyEffect, header) == 0, | |
1254 OffsetOf_DestroyEffect_header_not_0); | |
1255 COMPILE_ASSERT(offsetof(DestroyEffect, effect_id) == 4, | |
1256 OffsetOf_DestroyEffect_effect_id_not_4); | |
1257 | |
1258 struct SetEffect { | |
1259 typedef SetEffect ValueType; | |
1260 static const CommandId kCmdId = command_buffer::kSetEffect; | |
1261 static const ArgFlags kArgFlags = kFixed; | |
1262 | |
1263 void SetHeader() { | |
1264 header.SetCmd<ValueType>(); | |
1265 } | |
1266 | |
1267 void Init(ResourceId _effect_id) { | |
1268 SetHeader(); | |
1269 effect_id = _effect_id; | |
1270 } | |
1271 | |
1272 static void* Set(void* cmd, ResourceId effect_id) { | |
1273 static_cast<ValueType*>(cmd)->Init(effect_id); | |
1274 return NextCmdAddress<ValueType>(cmd); | |
1275 } | |
1276 | |
1277 CommandHeader header; | |
1278 ResourceId effect_id; | |
1279 }; | |
1280 | |
1281 COMPILE_ASSERT(sizeof(SetEffect) == 8, Sizeof_SetEffect_is_not_8); | |
1282 COMPILE_ASSERT(offsetof(SetEffect, header) == 0, | |
1283 OffsetOf_SetEffect_header_not_0); | |
1284 COMPILE_ASSERT(offsetof(SetEffect, effect_id) == 4, | |
1285 OffsetOf_SetEffect_effect_id_not_4); | |
1286 | |
1287 struct GetParamCount { | |
1288 typedef GetParamCount ValueType; | |
1289 static const CommandId kCmdId = command_buffer::kGetParamCount; | |
1290 static const ArgFlags kArgFlags = kFixed; | |
1291 | |
1292 void SetHeader() { | |
1293 header.SetCmd<ValueType>(); | |
1294 } | |
1295 | |
1296 void Init(ResourceId _effect_id, uint32 _size, | |
1297 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1298 SetHeader(); | |
1299 effect_id = _effect_id; | |
1300 size = _size; | |
1301 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
1302 } | |
1303 | |
1304 static void* Set(void* cmd, ResourceId effect_id, uint32 size, | |
1305 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1306 static_cast<ValueType*>(cmd)->Init(effect_id, size, | |
1307 shared_memory_id, shared_memory_offset); | |
1308 return NextCmdAddress<ValueType>(cmd); | |
1309 } | |
1310 | |
1311 CommandHeader header; | |
1312 ResourceId effect_id; | |
1313 uint32 size; | |
1314 SharedMemory shared_memory; | |
1315 }; | |
1316 | |
1317 COMPILE_ASSERT(sizeof(GetParamCount) == 20, Sizeof_GetParamCount_is_not_20); | |
1318 COMPILE_ASSERT(offsetof(GetParamCount, header) == 0, | |
1319 OffsetOf_GetParamCount_header_not_0); | |
1320 COMPILE_ASSERT(offsetof(GetParamCount, effect_id) == 4, | |
1321 OffsetOf_GetParamCount_effect_id_not_4); | |
1322 COMPILE_ASSERT(offsetof(GetParamCount, size) == 8, | |
1323 OffsetOf_GetParamCount_size_not_8); | |
1324 COMPILE_ASSERT(offsetof(GetParamCount, shared_memory) == 12, | |
1325 OffsetOf_GetParamCount_shared_memory_not_12); | |
1326 | |
1327 struct CreateParam { | |
1328 typedef CreateParam ValueType; | |
1329 static const CommandId kCmdId = command_buffer::kCreateParam; | |
1330 static const ArgFlags kArgFlags = kFixed; | |
1331 | |
1332 void SetHeader() { | |
1333 header.SetCmd<ValueType>(); | |
1334 } | |
1335 | |
1336 void Init(ResourceId _param_id, ResourceId _effect_id, uint32 _index) { | |
1337 SetHeader(); | |
1338 param_id = _param_id; | |
1339 effect_id = _effect_id; | |
1340 index = _index; | |
1341 } | |
1342 | |
1343 static void* Set(void* cmd, | |
1344 ResourceId param_id, ResourceId effect_id, uint32 index) { | |
1345 static_cast<ValueType*>(cmd)->Init(param_id, effect_id, index); | |
1346 return NextCmdAddress<ValueType>(cmd); | |
1347 } | |
1348 | |
1349 CommandHeader header; | |
1350 ResourceId param_id; | |
1351 ResourceId effect_id; | |
1352 uint32 index; | |
1353 }; | |
1354 | |
1355 COMPILE_ASSERT(sizeof(CreateParam) == 16, Sizeof_CreateParam_is_not_16); | |
1356 COMPILE_ASSERT(offsetof(CreateParam, header) == 0, | |
1357 OffsetOf_CreateParam_header_not_0); | |
1358 COMPILE_ASSERT(offsetof(CreateParam, param_id) == 4, | |
1359 OffsetOf_CreateParam_param_id_not_4); | |
1360 COMPILE_ASSERT(offsetof(CreateParam, effect_id) == 8, | |
1361 OffsetOf_CreateParam_effect_id_not_8); | |
1362 COMPILE_ASSERT(offsetof(CreateParam, index) == 12, | |
1363 OffsetOf_CreateParam_index_not_12); | |
1364 | |
1365 struct CreateParamByName { | |
1366 typedef CreateParamByName ValueType; | |
1367 static const CommandId kCmdId = command_buffer::kCreateParamByName; | |
1368 static const ArgFlags kArgFlags = kFixed; | |
1369 | |
1370 void SetHeader() { | |
1371 header.SetCmd<ValueType>(); | |
1372 } | |
1373 | |
1374 void Init(ResourceId _param_id, ResourceId _effect_id, uint32 _size, | |
1375 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1376 SetHeader(); | |
1377 param_id = _param_id; | |
1378 effect_id = _effect_id; | |
1379 size = _size; | |
1380 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
1381 } | |
1382 | |
1383 static void* Set(void* cmd, ResourceId param_id, ResourceId effect_id, | |
1384 uint32 size, | |
1385 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1386 static_cast<ValueType*>(cmd)->Init(param_id, effect_id, size, | |
1387 shared_memory_id, shared_memory_offset); | |
1388 return NextCmdAddress<ValueType>(cmd); | |
1389 } | |
1390 | |
1391 CommandHeader header; | |
1392 ResourceId param_id; | |
1393 ResourceId effect_id; | |
1394 uint32 size; | |
1395 SharedMemory shared_memory; | |
1396 }; | |
1397 | |
1398 COMPILE_ASSERT(sizeof(CreateParamByName) == 24, | |
1399 Sizeof_CreateParamByName_is_not_24); | |
1400 COMPILE_ASSERT(offsetof(CreateParamByName, header) == 0, | |
1401 OffsetOf_CreateParamByName_header_not_0); | |
1402 COMPILE_ASSERT(offsetof(CreateParamByName, param_id) == 4, | |
1403 OffsetOf_CreateParamByName_param_id_not_4); | |
1404 COMPILE_ASSERT(offsetof(CreateParamByName, effect_id) == 8, | |
1405 OffsetOf_CreateParamByName_effect_id_not_8); | |
1406 COMPILE_ASSERT(offsetof(CreateParamByName, size) == 12, | |
1407 OffsetOf_CreateParamByName_size_not_12); | |
1408 COMPILE_ASSERT(offsetof(CreateParamByName, shared_memory) == 16, | |
1409 OffsetOf_CreateParamByName_shared_memory_not_16); | |
1410 | |
1411 struct CreateParamByNameImmediate { | |
1412 typedef CreateParamByNameImmediate ValueType; | |
1413 static const CommandId kCmdId = command_buffer::kCreateParamByNameImmediate; | |
1414 static const ArgFlags kArgFlags = kAtLeastN; | |
1415 | |
1416 void SetHeader(uint32 size) { | |
1417 header.SetCmdBySize<ValueType>(size); | |
1418 } | |
1419 | |
1420 void Init(ResourceId _param_id, ResourceId _effect_id, uint32 _size, | |
1421 const void* data) { | |
1422 SetHeader(_size); | |
1423 param_id = _param_id; | |
1424 effect_id = _effect_id; | |
1425 size = _size; | |
1426 memcpy(ImmediateDataAddress(this), data, _size); | |
1427 } | |
1428 | |
1429 static void* Set(void* cmd, ResourceId param_id, ResourceId effect_id, | |
1430 uint32 size, const void* data) { | |
1431 static_cast<ValueType*>(cmd)->Init(param_id, effect_id, size, data); | |
1432 return NextImmediateCmdAddress<ValueType>(cmd, size); | |
1433 } | |
1434 | |
1435 CommandHeader header; | |
1436 ResourceId param_id; | |
1437 ResourceId effect_id; | |
1438 uint32 size; | |
1439 }; | |
1440 | |
1441 COMPILE_ASSERT(sizeof(CreateParamByNameImmediate) == 16, | |
1442 Sizeof_CreateParamByNameImmediate_is_not_16); | |
1443 COMPILE_ASSERT(offsetof(CreateParamByNameImmediate, header) == 0, | |
1444 OffsetOf_CreateParamByNameImmediate_header_not_0); | |
1445 COMPILE_ASSERT(offsetof(CreateParamByNameImmediate, param_id) == 4, | |
1446 OffsetOf_CreateParamByNameImmediate_param_id_not_4); | |
1447 COMPILE_ASSERT(offsetof(CreateParamByNameImmediate, effect_id) == 8, | |
1448 OffsetOf_CreateParamByNameImmediate_effect_id_not_8); | |
1449 COMPILE_ASSERT(offsetof(CreateParamByNameImmediate, size) == 12, | |
1450 OffsetOf_CreateParamByNameImmediate_size_not_12); | |
1451 | |
1452 struct DestroyParam { | |
1453 typedef DestroyParam ValueType; | |
1454 static const CommandId kCmdId = command_buffer::kDestroyParam; | |
1455 static const ArgFlags kArgFlags = kFixed; | |
1456 | |
1457 void SetHeader() { | |
1458 header.SetCmd<ValueType>(); | |
1459 } | |
1460 | |
1461 void Init(ResourceId _param_id) { | |
1462 SetHeader(); | |
1463 param_id = _param_id; | |
1464 } | |
1465 | |
1466 static void* Set(void* cmd, ResourceId param_id) { | |
1467 static_cast<ValueType*>(cmd)->Init(param_id); | |
1468 return NextCmdAddress<ValueType>(cmd); | |
1469 } | |
1470 | |
1471 CommandHeader header; | |
1472 ResourceId param_id; | |
1473 }; | |
1474 | |
1475 COMPILE_ASSERT(sizeof(DestroyParam) == 8, Sizeof_DestroyParam_is_not_8); | |
1476 COMPILE_ASSERT(offsetof(DestroyParam, header) == 0, | |
1477 OffsetOf_DestroyParam_header_not_0); | |
1478 COMPILE_ASSERT(offsetof(DestroyParam, param_id) == 4, | |
1479 OffsetOf_DestroyParam_param_id_not_4); | |
1480 | |
1481 struct SetParamData { | |
1482 typedef SetParamData ValueType; | |
1483 static const CommandId kCmdId = command_buffer::kSetParamData; | |
1484 static const ArgFlags kArgFlags = kFixed; | |
1485 | |
1486 void SetHeader() { | |
1487 header.SetCmd<ValueType>(); | |
1488 } | |
1489 | |
1490 void Init(ResourceId _param_id, uint32 _size, | |
1491 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1492 SetHeader(); | |
1493 param_id = _param_id; | |
1494 size = _size; | |
1495 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
1496 } | |
1497 | |
1498 static void* Set(void* cmd, ResourceId param_id, uint32 size, | |
1499 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1500 static_cast<ValueType*>(cmd)->Init(param_id, size, | |
1501 shared_memory_id, shared_memory_offset); | |
1502 return NextCmdAddress<ValueType>(cmd); | |
1503 } | |
1504 | |
1505 CommandHeader header; | |
1506 ResourceId param_id; | |
1507 uint32 size; | |
1508 SharedMemory shared_memory; | |
1509 }; | |
1510 | |
1511 COMPILE_ASSERT(sizeof(SetParamData) == 20, Sizeof_SetParamData_is_not_20); | |
1512 COMPILE_ASSERT(offsetof(SetParamData, header) == 0, | |
1513 OffsetOf_SetParamData_header_not_0); | |
1514 COMPILE_ASSERT(offsetof(SetParamData, param_id) == 4, | |
1515 OffsetOf_SetParamData_param_id_not_4); | |
1516 COMPILE_ASSERT(offsetof(SetParamData, size) == 8, | |
1517 OffsetOf_SetParamData_size_not_8); | |
1518 COMPILE_ASSERT(offsetof(SetParamData, shared_memory) == 12, | |
1519 OffsetOf_SetParamData_shared_memory_not_12); | |
1520 | |
1521 struct SetParamDataImmediate { | |
1522 typedef SetParamDataImmediate ValueType; | |
1523 static const CommandId kCmdId = command_buffer::kSetParamDataImmediate; | |
1524 static const ArgFlags kArgFlags = kAtLeastN; | |
1525 | |
1526 void SetHeader(uint32 size) { | |
1527 header.SetCmdBySize<ValueType>(size); | |
1528 } | |
1529 | |
1530 void Init(ResourceId _param_id, uint32 _size, const void* data) { | |
1531 SetHeader(_size); | |
1532 param_id = _param_id; | |
1533 size = _size; | |
1534 memcpy(ImmediateDataAddress(this), data, _size); | |
1535 } | |
1536 | |
1537 static void* Set(void* cmd, ResourceId param_id, | |
1538 uint32 size, const void* data) { | |
1539 static_cast<ValueType*>(cmd)->Init(param_id, size, data); | |
1540 return NextImmediateCmdAddress<ValueType>(cmd, size); | |
1541 } | |
1542 | |
1543 CommandHeader header; | |
1544 ResourceId param_id; | |
1545 uint32 size; | |
1546 }; | |
1547 | |
1548 COMPILE_ASSERT(sizeof(SetParamDataImmediate) == 12, | |
1549 Sizeof_SetParamDataImmediate_is_not_12); | |
1550 COMPILE_ASSERT(offsetof(SetParamDataImmediate, header) == 0, | |
1551 OffsetOf_SetParamDataImmediate_header_not_0); | |
1552 COMPILE_ASSERT(offsetof(SetParamDataImmediate, param_id) == 4, | |
1553 OffsetOf_SetParamDataImmediate_param_id_not_4); | |
1554 COMPILE_ASSERT(offsetof(SetParamDataImmediate, size) == 8, | |
1555 OffsetOf_SetParamDataImmediate_size_not_8); | |
1556 | |
1557 struct GetParamDesc { | |
1558 typedef GetParamDesc ValueType; | |
1559 static const CommandId kCmdId = command_buffer::kGetParamDesc; | |
1560 static const ArgFlags kArgFlags = kFixed; | |
1561 | |
1562 void SetHeader() { | |
1563 header.SetCmd<ValueType>(); | |
1564 } | |
1565 | |
1566 void Init(ResourceId _param_id, uint32 _size, | |
1567 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1568 SetHeader(); | |
1569 param_id = _param_id; | |
1570 size = _size; | |
1571 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
1572 } | |
1573 | |
1574 static void* Set(void* cmd, ResourceId param_id, uint32 size, | |
1575 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1576 static_cast<ValueType*>(cmd)->Init(param_id, size, | |
1577 shared_memory_id, shared_memory_offset); | |
1578 return NextCmdAddress<ValueType>(cmd); | |
1579 } | |
1580 | |
1581 CommandHeader header; | |
1582 ResourceId param_id; | |
1583 uint32 size; | |
1584 SharedMemory shared_memory; | |
1585 }; | |
1586 | |
1587 COMPILE_ASSERT(sizeof(GetParamDesc) == 20, Sizeof_GetParamDesc_is_not_20); | |
1588 COMPILE_ASSERT(offsetof(GetParamDesc, header) == 0, | |
1589 OffsetOf_GetParamDesc_header_not_0); | |
1590 COMPILE_ASSERT(offsetof(GetParamDesc, param_id) == 4, | |
1591 OffsetOf_GetParamDesc_id_not_4); | |
1592 COMPILE_ASSERT(offsetof(GetParamDesc, size) == 8, | |
1593 OffsetOf_GetParamDesc_size_not_8); | |
1594 COMPILE_ASSERT(offsetof(GetParamDesc, shared_memory) == 12, | |
1595 OffsetOf_GetParamDesc_shared_memory_not_12); | |
1596 | |
1597 struct GetStreamCount { | |
1598 typedef GetStreamCount ValueType; | |
1599 static const CommandId kCmdId = command_buffer::kGetStreamCount; | |
1600 static const ArgFlags kArgFlags = kFixed; | |
1601 | |
1602 void SetHeader() { | |
1603 header.SetCmd<ValueType>(); | |
1604 } | |
1605 | |
1606 void Init(ResourceId _effect_id, uint32 _size, | |
1607 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1608 SetHeader(); | |
1609 effect_id = _effect_id; | |
1610 size = _size; | |
1611 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
1612 } | |
1613 | |
1614 static void* Set(void* cmd, ResourceId effect_id, uint32 size, | |
1615 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1616 static_cast<ValueType*>(cmd)->Init(effect_id, size, | |
1617 shared_memory_id, shared_memory_offset); | |
1618 return NextCmdAddress<ValueType>(cmd); | |
1619 } | |
1620 | |
1621 CommandHeader header; | |
1622 ResourceId effect_id; | |
1623 uint32 size; | |
1624 SharedMemory shared_memory; | |
1625 }; | |
1626 | |
1627 COMPILE_ASSERT(sizeof(GetStreamCount) == 20, | |
1628 Sizeof_GetStreamCount_is_not_20); | |
1629 COMPILE_ASSERT(offsetof(GetStreamCount, header) == 0, | |
1630 OffsetOf_GetStreamCount_header_not_0); | |
1631 COMPILE_ASSERT(offsetof(GetStreamCount, effect_id) == 4, | |
1632 OffsetOf_GetStreamCount_effect_id_not_4); | |
1633 COMPILE_ASSERT(offsetof(GetStreamCount, size) == 8, | |
1634 OffsetOf_GetStreamCount_size_not_8); | |
1635 COMPILE_ASSERT(offsetof(GetStreamCount, shared_memory) == 12, | |
1636 OffsetOf_GetStreamCount_shared_memory_not_12); | |
1637 | |
1638 struct GetStreamDesc { | |
1639 typedef GetStreamDesc ValueType; | |
1640 static const CommandId kCmdId = command_buffer::kGetStreamDesc; | |
1641 static const ArgFlags kArgFlags = kFixed; | |
1642 | |
1643 void SetHeader() { | |
1644 header.SetCmd<ValueType>(); | |
1645 } | |
1646 | |
1647 void Init(ResourceId _effect_id, uint32 _index, uint32 _size, | |
1648 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1649 SetHeader(); | |
1650 effect_id = _effect_id; | |
1651 index = _index; | |
1652 size = _size; | |
1653 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
1654 } | |
1655 | |
1656 static void* Set(void* cmd, ResourceId effect_id, uint32 index, uint32 size, | |
1657 uint32 shared_memory_id, uint32 shared_memory_offset) { | |
1658 static_cast<ValueType*>(cmd)->Init(effect_id, index, size, | |
1659 shared_memory_id, shared_memory_offset); | |
1660 return NextCmdAddress<ValueType>(cmd); | |
1661 } | |
1662 | |
1663 CommandHeader header; | |
1664 ResourceId effect_id; | |
1665 uint32 index; | |
1666 uint32 size; | |
1667 SharedMemory shared_memory; | |
1668 }; | |
1669 | |
1670 COMPILE_ASSERT(sizeof(GetStreamDesc) == 24, Sizeof_GetStreamDesc_is_not_24); | |
1671 COMPILE_ASSERT(offsetof(GetStreamDesc, header) == 0, | |
1672 OffsetOf_GetStreamDesc_header_not_0); | |
1673 COMPILE_ASSERT(offsetof(GetStreamDesc, effect_id) ==4 , | |
1674 OffsetOf_GetStreamDesc_effect_id_not_4); | |
1675 COMPILE_ASSERT(offsetof(GetStreamDesc, index) == 8, | |
1676 OffsetOf_GetStreamDesc_index_not_8); | |
1677 COMPILE_ASSERT(offsetof(GetStreamDesc, size) == 12, | |
1678 OffsetOf_GetStreamDesc_size_not_12); | |
1679 COMPILE_ASSERT(offsetof(GetStreamDesc, shared_memory) == 16, | |
1680 OffsetOf_GetStreamDesc_shared_memory_not_16); | |
1681 | |
1682 struct DestroyTexture { | |
1683 typedef DestroyTexture ValueType; | |
1684 static const CommandId kCmdId = command_buffer::kDestroyTexture; | |
1685 static const ArgFlags kArgFlags = kFixed; | |
1686 | |
1687 void SetHeader() { | |
1688 header.SetCmd<ValueType>(); | |
1689 } | |
1690 | |
1691 void Init(ResourceId _texture_id) { | |
1692 SetHeader(); | |
1693 texture_id = _texture_id; | |
1694 } | |
1695 | |
1696 static void* Set(void* cmd, ResourceId texture_id) { | |
1697 static_cast<ValueType*>(cmd)->Init(texture_id); | |
1698 return NextCmdAddress<ValueType>(cmd); | |
1699 } | |
1700 | |
1701 CommandHeader header; | |
1702 ResourceId texture_id; | |
1703 }; | |
1704 | |
1705 COMPILE_ASSERT(sizeof(DestroyTexture) == 8, Sizeof_DestroyTexture_is_not_8); | |
1706 COMPILE_ASSERT(offsetof(DestroyTexture, header) == 0, | |
1707 OffsetOf_DestroyTexture_header_not_0); | |
1708 COMPILE_ASSERT(offsetof(DestroyTexture, texture_id) == 4, | |
1709 OffsetOf_DestroyTexture_texture_id_not_4); | |
1710 | |
1711 struct CreateTexture2d { | |
1712 typedef CreateTexture2d ValueType; | |
1713 static const CommandId kCmdId = command_buffer::kCreateTexture2d; | |
1714 static const ArgFlags kArgFlags = kFixed; | |
1715 | |
1716 // argument 1 | |
1717 typedef BitField<0, 16> Width; | |
1718 typedef BitField<16, 16> Height; | |
1719 // argument 2 | |
1720 typedef BitField<0, 4> Levels; | |
1721 typedef BitField<4, 4> Unused; | |
1722 typedef BitField<8, 8> Format; | |
1723 typedef BitField<16, 16> Flags; | |
1724 | |
1725 void SetHeader() { | |
1726 header.SetCmd<ValueType>(); | |
1727 } | |
1728 | |
1729 void Init(ResourceId _texture_id, | |
1730 uint32 _width, uint32 _height, uint32 _levels, | |
1731 texture::Format _format, | |
1732 bool _enable_render_surfaces) { | |
1733 SetHeader(); | |
1734 texture_id = _texture_id; | |
1735 width_height = Width::MakeValue(_width) | Height::MakeValue(_height); | |
1736 levels_format_flags = | |
1737 Levels::MakeValue(_levels) | | |
1738 Format::MakeValue(_format) | | |
1739 Flags::MakeValue(_enable_render_surfaces ? 1 : 0); | |
1740 } | |
1741 | |
1742 static void* Set(void* cmd, ResourceId texture_id, | |
1743 uint32 width, uint32 height, uint32 levels, | |
1744 texture::Format format, | |
1745 bool enable_render_surfaces) { | |
1746 static_cast<ValueType*>(cmd)->Init(texture_id, | |
1747 width, height, levels, format, | |
1748 enable_render_surfaces); | |
1749 return NextCmdAddress<ValueType>(cmd); | |
1750 } | |
1751 | |
1752 // TODO(gman): fix this to not use obfusticated fields. | |
1753 CommandHeader header; | |
1754 ResourceId texture_id; | |
1755 uint32 width_height; | |
1756 uint32 levels_format_flags; | |
1757 }; | |
1758 | |
1759 COMPILE_ASSERT(sizeof(CreateTexture2d) == 16, | |
1760 Sizeof_CreateTexture2d_is_not_16); | |
1761 COMPILE_ASSERT(offsetof(CreateTexture2d, header) == 0, | |
1762 OffsetOf_CreateTexture2d_header_not_0); | |
1763 COMPILE_ASSERT(offsetof(CreateTexture2d, texture_id) == 4, | |
1764 OffsetOf_CreateTexture2d_texture_id_not_4); | |
1765 COMPILE_ASSERT(offsetof(CreateTexture2d, width_height) == 8, | |
1766 OffsetOf_CreateTexture2d_width_height_not_8); | |
1767 COMPILE_ASSERT(offsetof(CreateTexture2d, levels_format_flags) == 12, | |
1768 OffsetOf_CreateTexture2d_levels_format_flags_not_12); | |
1769 | |
1770 struct CreateTexture3d { | |
1771 typedef CreateTexture3d ValueType; | |
1772 static const CommandId kCmdId = command_buffer::kCreateTexture3d; | |
1773 static const ArgFlags kArgFlags = kFixed; | |
1774 | |
1775 // argument 1 | |
1776 typedef BitField<0, 16> Width; | |
1777 typedef BitField<16, 16> Height; | |
1778 // argument 2 | |
1779 typedef BitField<0, 16> Depth; | |
1780 typedef BitField<16, 16> Unused1; | |
1781 // argument 3 | |
1782 typedef BitField<0, 4> Levels; | |
1783 typedef BitField<4, 4> Unused2; | |
1784 typedef BitField<8, 8> Format; | |
1785 typedef BitField<16, 16> Flags; | |
1786 | |
1787 void SetHeader() { | |
1788 header.SetCmd<ValueType>(); | |
1789 } | |
1790 | |
1791 void Init(ResourceId _texture_id, | |
1792 uint32 _width, uint32 _height, uint32 _depth, | |
1793 uint32 _levels, texture::Format _format, | |
1794 bool _enable_render_surfaces) { | |
1795 SetHeader(); | |
1796 texture_id = _texture_id; | |
1797 width_height = Width::MakeValue(_width) | Height::MakeValue(_height); | |
1798 depth_unused = Depth::MakeValue(_depth); | |
1799 levels_format_flags = | |
1800 Levels::MakeValue(_levels) | | |
1801 Format::MakeValue(_format) | | |
1802 Flags::MakeValue(_enable_render_surfaces ? 1 : 0); | |
1803 } | |
1804 | |
1805 static void* Set(void* cmd, ResourceId texture_id, | |
1806 uint32 width, uint32 height, uint32 depth, | |
1807 uint32 levels, texture::Format format, | |
1808 bool enable_render_surfaces) { | |
1809 static_cast<ValueType*>(cmd)->Init(texture_id, | |
1810 width, height, depth, | |
1811 levels, format, | |
1812 enable_render_surfaces); | |
1813 return NextCmdAddress<ValueType>(cmd); | |
1814 } | |
1815 | |
1816 // TODO(gman): fix this to not use obfusticated fields. | |
1817 CommandHeader header; | |
1818 ResourceId texture_id; | |
1819 uint32 width_height; | |
1820 uint32 depth_unused; | |
1821 uint32 levels_format_flags; | |
1822 }; | |
1823 | |
1824 COMPILE_ASSERT(sizeof(CreateTexture3d) == 20, | |
1825 Sizeof_CreateTexture3d_is_not_20); | |
1826 COMPILE_ASSERT(offsetof(CreateTexture3d, header) == 0, | |
1827 OffsetOf_CreateTexture3d_header_not_0); | |
1828 COMPILE_ASSERT(offsetof(CreateTexture3d, texture_id) == 4, | |
1829 OffsetOf_CreateTexture3d_texture_id_not_4); | |
1830 COMPILE_ASSERT(offsetof(CreateTexture3d, width_height) == 8, | |
1831 OffsetOf_CreateTexture3d_width_height_not_8); | |
1832 COMPILE_ASSERT(offsetof(CreateTexture3d, depth_unused) == 12, | |
1833 OffsetOf_CreateTexture3d_depth_unused_not_12); | |
1834 COMPILE_ASSERT(offsetof(CreateTexture3d, levels_format_flags) == 16, | |
1835 OffsetOf_CreateTexture3d_levels_format_flags_not_16); | |
1836 | |
1837 struct CreateTextureCube { | |
1838 typedef CreateTextureCube ValueType; | |
1839 static const CommandId kCmdId = command_buffer::kCreateTextureCube; | |
1840 static const ArgFlags kArgFlags = kFixed; | |
1841 | |
1842 // argument 1 | |
1843 typedef BitField<0, 16> Side; | |
1844 typedef BitField<16, 16> Unused1; | |
1845 // argument 2 | |
1846 typedef BitField<0, 4> Levels; | |
1847 typedef BitField<4, 4> Unused2; | |
1848 typedef BitField<8, 8> Format; | |
1849 typedef BitField<16, 16> Flags; | |
1850 | |
1851 void SetHeader() { | |
1852 header.SetCmd<ValueType>(); | |
1853 } | |
1854 | |
1855 void Init(ResourceId _texture_id, | |
1856 uint32 _edge_length, uint32 _levels, texture::Format _format, | |
1857 bool _enable_render_surfaces) { | |
1858 SetHeader(); | |
1859 texture_id = _texture_id; | |
1860 edge_length = _edge_length; | |
1861 levels_format_flags = | |
1862 Levels::MakeValue(_levels) | | |
1863 Format::MakeValue(_format) | | |
1864 Flags::MakeValue(_enable_render_surfaces ? 1 : 0); | |
1865 } | |
1866 | |
1867 static void* Set(void* cmd, ResourceId texture_id, | |
1868 uint32 edge_length, uint32 levels, texture::Format format, | |
1869 bool enable_render_surfaces) { | |
1870 static_cast<ValueType*>(cmd)->Init(texture_id, | |
1871 edge_length, levels, format, | |
1872 enable_render_surfaces); | |
1873 return NextCmdAddress<ValueType>(cmd); | |
1874 } | |
1875 | |
1876 // TODO(gman): fix this to not use obfusticated fields. | |
1877 CommandHeader header; | |
1878 ResourceId texture_id; | |
1879 uint32 edge_length; | |
1880 uint32 levels_format_flags; | |
1881 }; | |
1882 | |
1883 COMPILE_ASSERT(sizeof(CreateTextureCube) == 16, | |
1884 Sizeof_CreateTextureCube_is_not_16); | |
1885 COMPILE_ASSERT(offsetof(CreateTextureCube, header) == 0, | |
1886 OffsetOf_CreateTextureCube_header_not_0); | |
1887 COMPILE_ASSERT(offsetof(CreateTextureCube, texture_id) == 4, | |
1888 OffsetOf_CreateTextureCube_texture_id_not_4); | |
1889 COMPILE_ASSERT(offsetof(CreateTextureCube, edge_length) == 8, | |
1890 OffsetOf_CreateTextureCube_edge_length_not_8); | |
1891 COMPILE_ASSERT(offsetof(CreateTextureCube, levels_format_flags) == 12, | |
1892 OffsetOf_CreateTextureCube_levels_format_flags_not_12); | |
1893 | |
1894 struct SetTextureData { | |
1895 typedef SetTextureData ValueType; | |
1896 static const CommandId kCmdId = command_buffer::kSetTextureData; | |
1897 static const ArgFlags kArgFlags = kFixed; | |
1898 | |
1899 // argument 1 | |
1900 typedef BitField<0, 16> X; | |
1901 typedef BitField<16, 16> Y; | |
1902 // argument 2 | |
1903 typedef BitField<0, 16> Width; | |
1904 typedef BitField<16, 16> Height; | |
1905 // argument 3 | |
1906 typedef BitField<0, 16> Z; | |
1907 typedef BitField<16, 16> Depth; | |
1908 // argument 4 | |
1909 typedef BitField<0, 4> Level; | |
1910 typedef BitField<4, 3> Face; | |
1911 typedef BitField<7, 25> Unused; | |
1912 | |
1913 void SetHeader() { | |
1914 header.SetCmd<ValueType>(); | |
1915 } | |
1916 | |
1917 void Init( | |
1918 ResourceId _texture_id, | |
1919 uint32 _x, | |
1920 uint32 _y, | |
1921 uint32 _z, | |
1922 uint32 _width, | |
1923 uint32 _height, | |
1924 uint32 _depth, | |
1925 uint32 _level, | |
1926 texture::Face _face, | |
1927 uint32 _row_pitch, | |
1928 uint32 _slice_pitch, | |
1929 uint32 _size, | |
1930 uint32 shared_memory_id, | |
1931 uint32 shared_memory_offset) { | |
1932 SetHeader(); | |
1933 texture_id = _texture_id; | |
1934 x_y = X::MakeValue(_x) | Y::MakeValue(_y); | |
1935 width_height = Width::MakeValue(_width) | Height::MakeValue(_height); | |
1936 z_depth = Z::MakeValue(_z) | Depth::MakeValue(_depth); | |
1937 level_face = Level::MakeValue(_level) | Face::MakeValue(_face); | |
1938 row_pitch = _row_pitch; | |
1939 slice_pitch = _slice_pitch; | |
1940 size = _size; | |
1941 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
1942 } | |
1943 | |
1944 static void* Set( | |
1945 void* cmd, | |
1946 ResourceId texture_id, | |
1947 uint32 x, | |
1948 uint32 y, | |
1949 uint32 z, | |
1950 uint32 width, | |
1951 uint32 height, | |
1952 uint32 depth, | |
1953 uint32 level, | |
1954 texture::Face face, | |
1955 uint32 row_pitch, | |
1956 uint32 slice_pitch, | |
1957 uint32 size, | |
1958 uint32 shared_memory_id, | |
1959 uint32 shared_memory_offset) { | |
1960 static_cast<ValueType*>(cmd)->Init( | |
1961 texture_id, | |
1962 x, | |
1963 y, | |
1964 z, | |
1965 width, | |
1966 height, | |
1967 depth, | |
1968 level, | |
1969 face, | |
1970 row_pitch, | |
1971 slice_pitch, | |
1972 size, | |
1973 shared_memory_id, | |
1974 shared_memory_offset); | |
1975 return NextCmdAddress<ValueType>(cmd); | |
1976 } | |
1977 | |
1978 // TODO(gman): fix this to not use obfusticated fields. | |
1979 CommandHeader header; | |
1980 ResourceId texture_id; | |
1981 uint32 x_y; | |
1982 uint32 width_height; | |
1983 uint32 z_depth; | |
1984 uint32 level_face; | |
1985 uint32 row_pitch; | |
1986 uint32 slice_pitch; | |
1987 uint32 size; | |
1988 SharedMemory shared_memory; | |
1989 }; | |
1990 | |
1991 COMPILE_ASSERT(sizeof(SetTextureData) == 44, | |
1992 Sizeof_SetTextureData_is_not_44); | |
1993 COMPILE_ASSERT(offsetof(SetTextureData, header) == 0, | |
1994 OffsetOf_SetTextureData_header_not_0); | |
1995 COMPILE_ASSERT(offsetof(SetTextureData, texture_id) == 4, | |
1996 OffsetOf_SetTextureData_texture_id_not_4); | |
1997 COMPILE_ASSERT(offsetof(SetTextureData, x_y) == 8, | |
1998 OffsetOf_SetTextureData_x_y_not_8); | |
1999 COMPILE_ASSERT(offsetof(SetTextureData, width_height) == 12, | |
2000 OffsetOf_SetTextureData_width_height_not_12); | |
2001 COMPILE_ASSERT(offsetof(SetTextureData, z_depth) == 16, | |
2002 OffsetOf_SetTextureData_z_depth_not_16); | |
2003 COMPILE_ASSERT(offsetof(SetTextureData, level_face) == 20, | |
2004 OffsetOf_SetTextureData_level_face_not_20); | |
2005 COMPILE_ASSERT(offsetof(SetTextureData, row_pitch) == 24, | |
2006 OffsetOf_SetTextureData_row_pitch_not_24); | |
2007 COMPILE_ASSERT(offsetof(SetTextureData, slice_pitch) == 28, | |
2008 OffsetOf_SetTextureData_slice_pitch_not_28); | |
2009 COMPILE_ASSERT(offsetof(SetTextureData, size) == 32, | |
2010 OffsetOf_SetTextureData_size_not_32); | |
2011 COMPILE_ASSERT(offsetof(SetTextureData, shared_memory) == 36, | |
2012 OffsetOf_SetTextureData_shared_memory_not_36); | |
2013 | |
2014 struct SetTextureDataImmediate { | |
2015 typedef SetTextureDataImmediate ValueType; | |
2016 static const CommandId kCmdId = command_buffer::kSetTextureDataImmediate; | |
2017 static const ArgFlags kArgFlags = kAtLeastN; | |
2018 | |
2019 // argument 1 | |
2020 typedef BitField<0, 16> X; | |
2021 typedef BitField<16, 16> Y; | |
2022 // argument 2 | |
2023 typedef BitField<0, 16> Width; | |
2024 typedef BitField<16, 16> Height; | |
2025 // argument 3 | |
2026 typedef BitField<0, 16> Z; | |
2027 typedef BitField<16, 16> Depth; | |
2028 // argument 4 | |
2029 typedef BitField<0, 4> Level; | |
2030 typedef BitField<4, 3> Face; | |
2031 typedef BitField<7, 25> Unused; | |
2032 | |
2033 void SetHeader(uint32 size) { | |
2034 header.SetCmdBySize<ValueType>(size); | |
2035 } | |
2036 | |
2037 void Init( | |
2038 ResourceId _texture_id, | |
2039 uint32 _x, | |
2040 uint32 _y, | |
2041 uint32 _z, | |
2042 uint32 _width, | |
2043 uint32 _height, | |
2044 uint32 _depth, | |
2045 uint32 _level, | |
2046 texture::Face _face, | |
2047 uint32 _row_pitch, | |
2048 uint32 _slice_pitch, | |
2049 uint32 _size, | |
2050 const void* data) { | |
2051 SetHeader(_size); | |
2052 texture_id = _texture_id; | |
2053 x_y = X::MakeValue(_x) | Y::MakeValue(_y); | |
2054 width_height = Width::MakeValue(_width) | Height::MakeValue(_height); | |
2055 z_depth = Z::MakeValue(_z) | Depth::MakeValue(_depth); | |
2056 level_face = Level::MakeValue(_level) | Face::MakeValue(_face); | |
2057 row_pitch = _row_pitch; | |
2058 slice_pitch = _slice_pitch; | |
2059 size = _size; | |
2060 memcpy(ImmediateDataAddress(this), data, _size); | |
2061 } | |
2062 | |
2063 static void* Set( | |
2064 void* cmd, | |
2065 ResourceId texture_id, | |
2066 uint32 x, | |
2067 uint32 y, | |
2068 uint32 z, | |
2069 uint32 width, | |
2070 uint32 height, | |
2071 uint32 depth, | |
2072 uint32 level, | |
2073 texture::Face face, | |
2074 uint32 row_pitch, | |
2075 uint32 slice_pitch, | |
2076 uint32 size, | |
2077 const void* data) { | |
2078 static_cast<ValueType*>(cmd)->Init( | |
2079 texture_id, | |
2080 x, | |
2081 y, | |
2082 z, | |
2083 width, | |
2084 height, | |
2085 depth, | |
2086 level, | |
2087 face, | |
2088 row_pitch, | |
2089 slice_pitch, | |
2090 size, | |
2091 data); | |
2092 return NextImmediateCmdAddress<ValueType>(cmd, size); | |
2093 } | |
2094 | |
2095 // TODO(gman): fix this to not use obfusticated fields. | |
2096 CommandHeader header; | |
2097 ResourceId texture_id; | |
2098 uint32 x_y; | |
2099 uint32 width_height; | |
2100 uint32 z_depth; | |
2101 uint32 level_face; | |
2102 uint32 row_pitch; | |
2103 uint32 slice_pitch; | |
2104 uint32 size; | |
2105 }; | |
2106 | |
2107 COMPILE_ASSERT(sizeof(SetTextureDataImmediate) == 36, | |
2108 Sizeof_SetTextureDataImmediate_is_not_36); | |
2109 COMPILE_ASSERT(offsetof(SetTextureDataImmediate, header) == 0, | |
2110 OffsetOf_SetTextureDataImmediate_header_not_0); | |
2111 COMPILE_ASSERT(offsetof(SetTextureDataImmediate, texture_id) == 4, | |
2112 OffsetOf_SetTextureDataImmediate_texture_id_not_4); | |
2113 COMPILE_ASSERT(offsetof(SetTextureDataImmediate, x_y) == 8, | |
2114 OffsetOf_SetTextureDataImmediate_x_y_not_8); | |
2115 COMPILE_ASSERT(offsetof(SetTextureDataImmediate, width_height) == 12, | |
2116 OffsetOf_SetTextureDataImmediate_width_height_not_12); | |
2117 COMPILE_ASSERT(offsetof(SetTextureDataImmediate, z_depth) == 16, | |
2118 OffsetOf_SetTextureDataImmediate_z_depth_not_16); | |
2119 COMPILE_ASSERT(offsetof(SetTextureDataImmediate, level_face) == 20, | |
2120 OffsetOf_SetTextureDataImmediate_level_face_not_20); | |
2121 COMPILE_ASSERT(offsetof(SetTextureDataImmediate, row_pitch) == 24, | |
2122 OffsetOf_SetTextureDataImmediate_row_pitch_not_24); | |
2123 COMPILE_ASSERT(offsetof(SetTextureDataImmediate, slice_pitch) == 28, | |
2124 OffsetOf_SetTextureDataImmediate_slice_pitch_not_28); | |
2125 COMPILE_ASSERT(offsetof(SetTextureDataImmediate, size) == 32, | |
2126 OffsetOf_SetTextureDataImmediate_size_not_32); | |
2127 | |
2128 struct GetTextureData { | |
2129 typedef GetTextureData ValueType; | |
2130 static const CommandId kCmdId = command_buffer::kGetTextureData; | |
2131 static const ArgFlags kArgFlags = kFixed; | |
2132 | |
2133 // argument 1 | |
2134 typedef BitField<0, 16> X; | |
2135 typedef BitField<16, 16> Y; | |
2136 // argument 2 | |
2137 typedef BitField<0, 16> Width; | |
2138 typedef BitField<16, 16> Height; | |
2139 // argument 3 | |
2140 typedef BitField<0, 16> Z; | |
2141 typedef BitField<16, 16> Depth; | |
2142 // argument 4 | |
2143 typedef BitField<0, 4> Level; | |
2144 typedef BitField<4, 3> Face; | |
2145 typedef BitField<7, 25> Unused; | |
2146 | |
2147 void SetHeader() { | |
2148 header.SetCmd<ValueType>(); | |
2149 } | |
2150 | |
2151 void Init( | |
2152 ResourceId _texture_id, | |
2153 uint32 _x, | |
2154 uint32 _y, | |
2155 uint32 _z, | |
2156 uint32 _width, | |
2157 uint32 _height, | |
2158 uint32 _depth, | |
2159 uint32 _level, | |
2160 texture::Face _face, | |
2161 uint32 _row_pitch, | |
2162 uint32 _slice_pitch, | |
2163 uint32 _size, | |
2164 uint32 shared_memory_id, | |
2165 uint32 shared_memory_offset) { | |
2166 SetHeader(); | |
2167 texture_id = _texture_id; | |
2168 x_y = X::MakeValue(_x) | Y::MakeValue(_y); | |
2169 width_height = Width::MakeValue(_width) | Height::MakeValue(_height); | |
2170 z_depth = Z::MakeValue(_z) | Depth::MakeValue(_depth); | |
2171 level_face = Level::MakeValue(_level) | Face::MakeValue(_face); | |
2172 row_pitch = _row_pitch; | |
2173 slice_pitch = _slice_pitch; | |
2174 size = _size; | |
2175 shared_memory.Init(shared_memory_id, shared_memory_offset); | |
2176 } | |
2177 | |
2178 static void* Set( | |
2179 void* cmd, | |
2180 ResourceId texture_id, | |
2181 uint32 x, | |
2182 uint32 y, | |
2183 uint32 z, | |
2184 uint32 width, | |
2185 uint32 height, | |
2186 uint32 depth, | |
2187 uint32 level, | |
2188 texture::Face face, | |
2189 uint32 row_pitch, | |
2190 uint32 slice_pitch, | |
2191 uint32 size, | |
2192 uint32 shared_memory_id, | |
2193 uint32 shared_memory_offset) { | |
2194 static_cast<ValueType*>(cmd)->Init( | |
2195 texture_id, | |
2196 x, | |
2197 y, | |
2198 z, | |
2199 width, | |
2200 height, | |
2201 depth, | |
2202 level, | |
2203 face, | |
2204 row_pitch, | |
2205 slice_pitch, | |
2206 size, | |
2207 shared_memory_id, | |
2208 shared_memory_offset); | |
2209 return NextCmdAddress<ValueType>(cmd); | |
2210 } | |
2211 | |
2212 // TODO(gman): fix this to not use obfusticated fields. | |
2213 CommandHeader header; | |
2214 ResourceId texture_id; | |
2215 uint32 x_y; | |
2216 uint32 width_height; | |
2217 uint32 z_depth; | |
2218 uint32 level_face; | |
2219 uint32 row_pitch; | |
2220 uint32 slice_pitch; | |
2221 uint32 size; | |
2222 SharedMemory shared_memory; | |
2223 }; | |
2224 | |
2225 COMPILE_ASSERT(sizeof(GetTextureData) == 44, | |
2226 Sizeof_GetTextureData_is_not_44); | |
2227 COMPILE_ASSERT(offsetof(GetTextureData, header) == 0, | |
2228 OffsetOf_GetTextureData_header_not_0); | |
2229 COMPILE_ASSERT(offsetof(GetTextureData, texture_id) == 4, | |
2230 OffsetOf_GetTextureData_texture_id_not_4); | |
2231 COMPILE_ASSERT(offsetof(GetTextureData, x_y) == 8, | |
2232 OffsetOf_GetTextureData_x_y_not_8); | |
2233 COMPILE_ASSERT(offsetof(GetTextureData, width_height) == 12, | |
2234 OffsetOf_GetTextureData_width_height_not_12); | |
2235 COMPILE_ASSERT(offsetof(GetTextureData, z_depth) == 16, | |
2236 OffsetOf_GetTextureData_z_depth_not_16); | |
2237 COMPILE_ASSERT(offsetof(GetTextureData, level_face) == 20, | |
2238 OffsetOf_GetTextureData_level_face_not_20); | |
2239 COMPILE_ASSERT(offsetof(GetTextureData, row_pitch) == 24, | |
2240 OffsetOf_GetTextureData_row_pitch_not_24); | |
2241 COMPILE_ASSERT(offsetof(GetTextureData, slice_pitch) == 28, | |
2242 OffsetOf_GetTextureData_slice_pitch_not_28); | |
2243 COMPILE_ASSERT(offsetof(GetTextureData, size) == 32, | |
2244 OffsetOf_GetTextureData_size_not_32); | |
2245 COMPILE_ASSERT(offsetof(GetTextureData, shared_memory) == 36, | |
2246 OffsetOf_GetTextureData_shared_memory_not_36); | |
2247 | |
2248 struct CreateSampler { | |
2249 typedef CreateSampler ValueType; | |
2250 static const CommandId kCmdId = command_buffer::kCreateSampler; | |
2251 static const ArgFlags kArgFlags = kFixed; | |
2252 | |
2253 void SetHeader() { | |
2254 header.SetCmd<ValueType>(); | |
2255 } | |
2256 | |
2257 void Init(ResourceId _sampler_id) { | |
2258 SetHeader(); | |
2259 sampler_id = _sampler_id; | |
2260 } | |
2261 | |
2262 static void* Set(void* cmd, ResourceId sampler_id) { | |
2263 static_cast<ValueType*>(cmd)->Init(sampler_id); | |
2264 return NextCmdAddress<ValueType>(cmd); | |
2265 } | |
2266 | |
2267 CommandHeader header; | |
2268 ResourceId sampler_id; | |
2269 }; | |
2270 | |
2271 COMPILE_ASSERT(sizeof(CreateSampler) == 8, Sizeof_CreateSampler_is_not_8); | |
2272 COMPILE_ASSERT(offsetof(CreateSampler, header) == 0, | |
2273 OffsetOf_CreateSampler_header_not_0); | |
2274 COMPILE_ASSERT(offsetof(CreateSampler, sampler_id) == 4, | |
2275 OffsetOf_CreateSampler_sampler_id_not_4); | |
2276 | |
2277 struct DestroySampler { | |
2278 typedef DestroySampler ValueType; | |
2279 static const CommandId kCmdId = command_buffer::kDestroySampler; | |
2280 static const ArgFlags kArgFlags = kFixed; | |
2281 | |
2282 void SetHeader() { | |
2283 header.SetCmd<ValueType>(); | |
2284 } | |
2285 | |
2286 void Init(ResourceId _sampler_id) { | |
2287 SetHeader(); | |
2288 sampler_id = _sampler_id; | |
2289 } | |
2290 | |
2291 static void* Set(void* cmd, ResourceId sampler_id) { | |
2292 static_cast<ValueType*>(cmd)->Init(sampler_id); | |
2293 return NextCmdAddress<ValueType>(cmd); | |
2294 } | |
2295 | |
2296 CommandHeader header; | |
2297 ResourceId sampler_id; | |
2298 }; | |
2299 | |
2300 COMPILE_ASSERT(sizeof(DestroySampler) == 8, Sizeof_DestroySampler_is_not_8); | |
2301 COMPILE_ASSERT(offsetof(DestroySampler, header) == 0, | |
2302 OffsetOf_DestroySampler_header_not_0); | |
2303 COMPILE_ASSERT(offsetof(DestroySampler, sampler_id) == 4, | |
2304 OffsetOf_DestroySampler_sampler_id_not_4); | |
2305 | |
2306 struct SetSamplerStates { | |
2307 typedef SetSamplerStates ValueType; | |
2308 static const CommandId kCmdId = command_buffer::kSetSamplerStates; | |
2309 static const ArgFlags kArgFlags = kFixed; | |
2310 | |
2311 // argument 2 | |
2312 typedef BitField<0, 3> AddressingU; | |
2313 typedef BitField<3, 3> AddressingV; | |
2314 typedef BitField<6, 3> AddressingW; | |
2315 typedef BitField<9, 3> MagFilter; | |
2316 typedef BitField<12, 3> MinFilter; | |
2317 typedef BitField<15, 3> MipFilter; | |
2318 typedef BitField<18, 6> Unused; | |
2319 typedef BitField<24, 8> MaxAnisotropy; | |
2320 | |
2321 void SetHeader() { | |
2322 header.SetCmd<ValueType>(); | |
2323 } | |
2324 | |
2325 void Init( | |
2326 ResourceId _sampler_id, | |
2327 sampler::AddressingMode _address_u_value, | |
2328 sampler::AddressingMode _address_v_value, | |
2329 sampler::AddressingMode _address_w_value, | |
2330 sampler::FilteringMode _mag_filter_value, | |
2331 sampler::FilteringMode _min_filter_value, | |
2332 sampler::FilteringMode _mip_filter_value, | |
2333 uint8 _max_anisotropy) { | |
2334 SetHeader(); | |
2335 sampler_id = _sampler_id; | |
2336 sampler_states = | |
2337 AddressingU::MakeValue(_address_u_value) | | |
2338 AddressingV::MakeValue(_address_v_value) | | |
2339 AddressingW::MakeValue(_address_w_value) | | |
2340 MagFilter::MakeValue(_mag_filter_value) | | |
2341 MinFilter::MakeValue(_min_filter_value) | | |
2342 MipFilter::MakeValue(_mip_filter_value) | | |
2343 MaxAnisotropy::MakeValue(_max_anisotropy); | |
2344 } | |
2345 | |
2346 static void* Set(void* cmd, | |
2347 ResourceId sampler_id, | |
2348 sampler::AddressingMode address_u_value, | |
2349 sampler::AddressingMode address_v_value, | |
2350 sampler::AddressingMode address_w_value, | |
2351 sampler::FilteringMode mag_filter_value, | |
2352 sampler::FilteringMode min_filter_value, | |
2353 sampler::FilteringMode mip_filter_value, | |
2354 uint8 max_anisotropy) { | |
2355 static_cast<ValueType*>(cmd)->Init( | |
2356 sampler_id, | |
2357 address_u_value, | |
2358 address_v_value, | |
2359 address_w_value, | |
2360 mag_filter_value, | |
2361 min_filter_value, | |
2362 mip_filter_value, | |
2363 max_anisotropy); | |
2364 return NextCmdAddress<ValueType>(cmd); | |
2365 } | |
2366 | |
2367 // TODO(gman): fix this to not use obfusticated fields. | |
2368 CommandHeader header; | |
2369 ResourceId sampler_id; | |
2370 uint32 sampler_states; | |
2371 }; | |
2372 | |
2373 COMPILE_ASSERT(sizeof(SetSamplerStates) == 12, | |
2374 Sizeof_SetSamplerStates_is_not_12); | |
2375 COMPILE_ASSERT(offsetof(SetSamplerStates, header) == 0, | |
2376 OffsetOf_SetSamplerStates_header_not_0); | |
2377 COMPILE_ASSERT(offsetof(SetSamplerStates, sampler_id) == 4, | |
2378 OffsetOf_SetSamplerStates_sampler_id_not_4); | |
2379 COMPILE_ASSERT(offsetof(SetSamplerStates, sampler_states) == 8, | |
2380 OffsetOf_SetSamplerStates_sampler_states_not_8); | |
2381 | |
2382 struct SetSamplerBorderColor { | |
2383 typedef SetSamplerBorderColor ValueType; | |
2384 static const CommandId kCmdId = command_buffer::kSetSamplerBorderColor; | |
2385 static const ArgFlags kArgFlags = kFixed; | |
2386 | |
2387 void SetHeader() { | |
2388 header.SetCmd<ValueType>(); | |
2389 } | |
2390 | |
2391 void Init(ResourceId _sampler_id, | |
2392 float _red, float _green, float _blue, float _alpha) { | |
2393 SetHeader(); | |
2394 sampler_id = _sampler_id; | |
2395 red = _red; | |
2396 green = _green; | |
2397 blue = _blue; | |
2398 alpha = _alpha; | |
2399 } | |
2400 | |
2401 static void* Set(void* cmd, ResourceId sampler_id, | |
2402 float red, float green, float blue, float alpha) { | |
2403 static_cast<ValueType*>(cmd)->Init(sampler_id, red, green, blue, alpha); | |
2404 return NextCmdAddress<ValueType>(cmd); | |
2405 } | |
2406 | |
2407 CommandHeader header; | |
2408 ResourceId sampler_id; | |
2409 float red; | |
2410 float blue; | |
2411 float green; | |
2412 float alpha; | |
2413 }; | |
2414 | |
2415 COMPILE_ASSERT(sizeof(SetSamplerBorderColor) == 24, | |
2416 Sizeof_SetSamplerBorderColor_is_not_24); | |
2417 COMPILE_ASSERT(offsetof(SetSamplerBorderColor, header) == 0, | |
2418 OffsetOf_SetSamplerBorderColor_header_not_0); | |
2419 COMPILE_ASSERT(offsetof(SetSamplerBorderColor, sampler_id) == 4, | |
2420 OffsetOf_SetSamplerBorderColor_sampler_id_not_4); | |
2421 COMPILE_ASSERT(offsetof(SetSamplerBorderColor, red) == 8, | |
2422 OffsetOf_SetSamplerBorderColor_red_not_8); | |
2423 COMPILE_ASSERT(offsetof(SetSamplerBorderColor, blue) == 12, | |
2424 OffsetOf_SetSamplerBorderColor_blue_not_12); | |
2425 COMPILE_ASSERT(offsetof(SetSamplerBorderColor, green) == 16, | |
2426 OffsetOf_SetSamplerBorderColor_green_not_16); | |
2427 COMPILE_ASSERT(offsetof(SetSamplerBorderColor, alpha) == 20, | |
2428 OffsetOf_SetSamplerBorderColor_alpha_not_20); | |
2429 | |
2430 struct SetSamplerTexture { | |
2431 typedef SetSamplerTexture ValueType; | |
2432 static const CommandId kCmdId = command_buffer::kSetSamplerTexture; | |
2433 static const ArgFlags kArgFlags = kFixed; | |
2434 | |
2435 void SetHeader() { | |
2436 header.SetCmd<ValueType>(); | |
2437 } | |
2438 | |
2439 void Init(ResourceId _sampler_id, ResourceId _texture_id) { | |
2440 SetHeader(); | |
2441 sampler_id = _sampler_id; | |
2442 texture_id = _texture_id; | |
2443 } | |
2444 | |
2445 static void* Set(void* cmd, ResourceId sampler_id, ResourceId texture_id) { | |
2446 static_cast<ValueType*>(cmd)->Init(sampler_id, texture_id); | |
2447 return NextCmdAddress<ValueType>(cmd); | |
2448 } | |
2449 | |
2450 CommandHeader header; | |
2451 ResourceId sampler_id; | |
2452 ResourceId texture_id; | |
2453 }; | |
2454 | |
2455 COMPILE_ASSERT(sizeof(SetSamplerTexture) == 12, | |
2456 Sizeof_SetSamplerTexture_is_not_12); | |
2457 COMPILE_ASSERT(offsetof(SetSamplerTexture, header) == 0, | |
2458 OffsetOf_SetSamplerTexture_header_not_0); | |
2459 COMPILE_ASSERT(offsetof(SetSamplerTexture, sampler_id) == 4, | |
2460 OffsetOf_SetSamplerTexture_sampler_id_not_4); | |
2461 COMPILE_ASSERT(offsetof(SetSamplerTexture, texture_id) == 8, | |
2462 OffsetOf_SetSamplerTexture_texture_id_not_8); | |
2463 | |
2464 struct SetScissor { | |
2465 typedef SetScissor ValueType; | |
2466 static const CommandId kCmdId = command_buffer::kSetScissor; | |
2467 static const ArgFlags kArgFlags = kFixed; | |
2468 | |
2469 // argument 0 | |
2470 typedef BitField<0, 15> X; | |
2471 typedef BitField<15, 1> Unused; | |
2472 typedef BitField<16, 15> Y; | |
2473 typedef BitField<31, 1> Enable; | |
2474 // argument 1 | |
2475 typedef BitField<0, 16> Width; | |
2476 typedef BitField<16, 16> Height; | |
2477 | |
2478 void SetHeader() { | |
2479 header.SetCmd<ValueType>(); | |
2480 } | |
2481 | |
2482 void Init(uint32 _x, | |
2483 uint32 _y, | |
2484 uint32 _width, | |
2485 uint32 _height, | |
2486 bool _enable) { | |
2487 SetHeader(); | |
2488 x_y_enable = | |
2489 X::MakeValue(_x) | | |
2490 Y::MakeValue(_y) | | |
2491 Enable::MakeValue(_enable ? 1 : 0); | |
2492 width_height = Width::MakeValue(_width) | Height::MakeValue(_height); | |
2493 } | |
2494 | |
2495 static void* Set( | |
2496 void* cmd, | |
2497 uint32 x, | |
2498 uint32 y, | |
2499 uint32 width, | |
2500 uint32 height, | |
2501 bool enable) { | |
2502 static_cast<ValueType*>(cmd)->Init( | |
2503 x, | |
2504 y, | |
2505 width, | |
2506 height, | |
2507 enable); | |
2508 return NextCmdAddress<ValueType>(cmd); | |
2509 } | |
2510 | |
2511 // TODO(gman): fix this to not use obfusticated fields. | |
2512 CommandHeader header; | |
2513 uint32 x_y_enable; | |
2514 uint32 width_height; | |
2515 }; | |
2516 | |
2517 COMPILE_ASSERT(sizeof(SetScissor) == 12, Sizeof_SetScissor_is_not_12); | |
2518 COMPILE_ASSERT(offsetof(SetScissor, header) == 0, | |
2519 OffsetOf_SetScissor_header_not_0); | |
2520 COMPILE_ASSERT(offsetof(SetScissor, x_y_enable) == 4, | |
2521 OffsetOf_SetScissor_x_y_enable_not_4); | |
2522 COMPILE_ASSERT(offsetof(SetScissor, width_height) == 8, | |
2523 OffsetOf_SetScissor_width_height_not_8); | |
2524 | |
2525 struct SetPolygonOffset { | |
2526 typedef SetPolygonOffset ValueType; | |
2527 static const CommandId kCmdId = command_buffer::kSetPolygonOffset; | |
2528 static const ArgFlags kArgFlags = kFixed; | |
2529 | |
2530 void SetHeader() { | |
2531 header.SetCmd<ValueType>(); | |
2532 } | |
2533 | |
2534 void Init(float _slope_factor, float _units) { | |
2535 SetHeader(); | |
2536 slope_factor = _slope_factor; | |
2537 units = _units; | |
2538 } | |
2539 | |
2540 static void* Set(void* cmd, float slope_factor, float units) { | |
2541 static_cast<ValueType*>(cmd)->Init(slope_factor, units); | |
2542 return NextCmdAddress<ValueType>(cmd); | |
2543 } | |
2544 | |
2545 CommandHeader header; | |
2546 float slope_factor; | |
2547 float units; | |
2548 }; | |
2549 | |
2550 COMPILE_ASSERT(sizeof(SetPolygonOffset) == 12, | |
2551 Sizeof_SetPolygonOffset_is_not_12); | |
2552 COMPILE_ASSERT(offsetof(SetPolygonOffset, header) == 0, | |
2553 OffsetOf_SetPolygonOffset_header_not_0); | |
2554 COMPILE_ASSERT(offsetof(SetPolygonOffset, slope_factor) == 4, | |
2555 OffsetOf_SetPolygonOffset_slope_factor_not_4); | |
2556 COMPILE_ASSERT(offsetof(SetPolygonOffset, units) == 8, | |
2557 OffsetOf_SetPolygonOffset_units_not_8); | |
2558 | |
2559 struct SetPointLineRaster { | |
2560 typedef SetPointLineRaster ValueType; | |
2561 static const CommandId kCmdId = command_buffer::kSetPointLineRaster; | |
2562 static const ArgFlags kArgFlags = kFixed; | |
2563 | |
2564 // argument 0 | |
2565 typedef BitField<0, 1> LineSmoothEnable; | |
2566 typedef BitField<1, 1> PointSpriteEnable; | |
2567 typedef BitField<2, 30> Unused; | |
2568 | |
2569 void SetHeader() { | |
2570 header.SetCmd<ValueType>(); | |
2571 } | |
2572 | |
2573 void Init(bool _line_smooth_enable, bool _point_sprite_enable, | |
2574 float _point_size) { | |
2575 SetHeader(); | |
2576 enables = | |
2577 LineSmoothEnable::MakeValue(_line_smooth_enable ? 1 : 0) | | |
2578 PointSpriteEnable::MakeValue(_point_sprite_enable ? 1 : 0); | |
2579 point_size = _point_size; | |
2580 } | |
2581 | |
2582 static void* Set(void* cmd, bool line_smooth_enable, bool point_sprite_enable, | |
2583 float point_size) { | |
2584 static_cast<ValueType*>(cmd)->Init(line_smooth_enable, point_sprite_enable, | |
2585 point_size); | |
2586 return NextCmdAddress<ValueType>(cmd); | |
2587 } | |
2588 | |
2589 // TODO(gman): fix this to not use obfusticated fields. | |
2590 CommandHeader header; | |
2591 uint32 enables; | |
2592 float point_size; | |
2593 }; | |
2594 | |
2595 COMPILE_ASSERT(sizeof(SetPointLineRaster) == 12, | |
2596 Sizeof_SetPointLineRaster_is_not_12); | |
2597 COMPILE_ASSERT(offsetof(SetPointLineRaster, header) == 0, | |
2598 OffsetOf_SetPointLineRaster_header_not_0); | |
2599 COMPILE_ASSERT(offsetof(SetPointLineRaster, enables) == 4, | |
2600 OffsetOf_SetPointLineRaster_enables_not_4); | |
2601 COMPILE_ASSERT(offsetof(SetPointLineRaster, point_size) == 8, | |
2602 OffsetOf_SetPointLineRaster_point_size_not_8); | |
2603 | |
2604 struct SetPolygonRaster { | |
2605 typedef SetPolygonRaster ValueType; | |
2606 static const CommandId kCmdId = command_buffer::kSetPolygonRaster; | |
2607 static const ArgFlags kArgFlags = kFixed; | |
2608 | |
2609 // argument 0 | |
2610 typedef BitField<0, 2> FillMode; | |
2611 typedef BitField<2, 2> CullMode; | |
2612 typedef BitField<4, 28> Unused; | |
2613 | |
2614 void SetHeader() { | |
2615 header.SetCmd<ValueType>(); | |
2616 } | |
2617 | |
2618 void Init(PolygonMode _fill_mode, FaceCullMode _cull_mode) { | |
2619 SetHeader(); | |
2620 fill_cull = FillMode::MakeValue(_fill_mode) | | |
2621 CullMode::MakeValue(_cull_mode); | |
2622 } | |
2623 | |
2624 static void* Set(void* cmd, PolygonMode fill_mode, FaceCullMode cull_mode) { | |
2625 static_cast<ValueType*>(cmd)->Init(fill_mode, cull_mode); | |
2626 return NextCmdAddress<ValueType>(cmd); | |
2627 } | |
2628 | |
2629 // TODO(gman): fix this to not use obfusticated fields. | |
2630 CommandHeader header; | |
2631 uint32 fill_cull; | |
2632 }; | |
2633 | |
2634 COMPILE_ASSERT(sizeof(SetPolygonRaster) == 8, | |
2635 Sizeof_SetPolygonRaster_is_not_8); | |
2636 COMPILE_ASSERT(offsetof(SetPolygonRaster, header) == 0, | |
2637 OffsetOf_SetPolygonRaster_header_not_0); | |
2638 COMPILE_ASSERT(offsetof(SetPolygonRaster, fill_cull) == 4, | |
2639 OffsetOf_SetPolygonRaster_fill_cull_not_4); | |
2640 | |
2641 struct SetAlphaTest { | |
2642 typedef SetAlphaTest ValueType; | |
2643 static const CommandId kCmdId = command_buffer::kSetAlphaTest; | |
2644 static const ArgFlags kArgFlags = kFixed; | |
2645 | |
2646 // argument 0 | |
2647 typedef BitField<0, 3> Func; | |
2648 typedef BitField<3, 28> Unused; | |
2649 typedef BitField<31, 1> Enable; | |
2650 | |
2651 void SetHeader() { | |
2652 header.SetCmd<ValueType>(); | |
2653 } | |
2654 | |
2655 void Init(Comparison _func, bool _enable, float _value) { | |
2656 SetHeader(); | |
2657 func_enable = Func::MakeValue(_func) | Enable::MakeValue(_enable ? 1 : 0); | |
2658 value = _value; | |
2659 } | |
2660 | |
2661 static void* Set(void* cmd, Comparison func, bool enable, float value) { | |
2662 static_cast<ValueType*>(cmd)->Init(func, enable, value); | |
2663 return NextCmdAddress<ValueType>(cmd); | |
2664 } | |
2665 | |
2666 // TODO(gman): fix this to not use obfusticated fields. | |
2667 CommandHeader header; | |
2668 uint32 func_enable; | |
2669 float value; | |
2670 }; | |
2671 | |
2672 COMPILE_ASSERT(sizeof(SetAlphaTest) == 12, Sizeof_SetAlphaTest_is_not_12); | |
2673 COMPILE_ASSERT(offsetof(SetAlphaTest, header) == 0, | |
2674 OffsetOf_SetAlphaTest_header_not_0); | |
2675 COMPILE_ASSERT(offsetof(SetAlphaTest, func_enable) == 4, | |
2676 OffsetOf_SetAlphaTest_func_enable_not_4); | |
2677 COMPILE_ASSERT(offsetof(SetAlphaTest, value) == 8, | |
2678 OffsetOf_SetAlphaTest_value_not_8); | |
2679 | |
2680 struct SetDepthTest { | |
2681 typedef SetDepthTest ValueType; | |
2682 static const CommandId kCmdId = command_buffer::kSetDepthTest; | |
2683 static const ArgFlags kArgFlags = kFixed; | |
2684 | |
2685 // argument 0 | |
2686 typedef BitField<0, 3> Func; | |
2687 typedef BitField<3, 27> Unused; | |
2688 typedef BitField<30, 1> WriteEnable; | |
2689 typedef BitField<31, 1> Enable; | |
2690 | |
2691 void SetHeader() { | |
2692 header.SetCmd<ValueType>(); | |
2693 } | |
2694 | |
2695 void Init(Comparison _func, bool _write_enable, bool _enable) { | |
2696 SetHeader(); | |
2697 func_enable = | |
2698 Func::MakeValue(_func) | | |
2699 WriteEnable::MakeValue(_write_enable ? 1 : 0) | | |
2700 Enable::MakeValue(_enable ? 1 : 0); | |
2701 } | |
2702 | |
2703 static void* Set(void* cmd, | |
2704 Comparison func, bool write_enable, bool enable) { | |
2705 static_cast<ValueType*>(cmd)->Init(func, write_enable, enable); | |
2706 return NextCmdAddress<ValueType>(cmd); | |
2707 } | |
2708 | |
2709 // TODO(gman): fix this to not use obfusticated fields. | |
2710 CommandHeader header; | |
2711 uint32 func_enable; | |
2712 }; | |
2713 | |
2714 COMPILE_ASSERT(sizeof(SetDepthTest) == 8, Sizeof_SetDepthTest_is_not_8); | |
2715 COMPILE_ASSERT(offsetof(SetDepthTest, header) == 0, | |
2716 OffsetOf_SetDepthTest_header_not_0); | |
2717 COMPILE_ASSERT(offsetof(SetDepthTest, func_enable) == 4, | |
2718 OffsetOf_SetDepthTest_func_enable_not_4); | |
2719 | |
2720 struct SetStencilTest { | |
2721 typedef SetStencilTest ValueType; | |
2722 static const CommandId kCmdId = command_buffer::kSetStencilTest; | |
2723 static const ArgFlags kArgFlags = kFixed; | |
2724 | |
2725 // argument 0 | |
2726 typedef BitField<0, 8> WriteMask; | |
2727 typedef BitField<8, 8> CompareMask; | |
2728 typedef BitField<16, 8> ReferenceValue; | |
2729 typedef BitField<24, 6> Unused0; | |
2730 typedef BitField<30, 1> SeparateCCW; | |
2731 typedef BitField<31, 1> Enable; | |
2732 // argument 1 | |
2733 typedef BitField<0, 3> CWFunc; | |
2734 typedef BitField<3, 3> CWPassOp; | |
2735 typedef BitField<6, 3> CWFailOp; | |
2736 typedef BitField<9, 3> CWZFailOp; | |
2737 typedef BitField<12, 4> Unused1; | |
2738 typedef BitField<16, 3> CCWFunc; | |
2739 typedef BitField<19, 3> CCWPassOp; | |
2740 typedef BitField<22, 3> CCWFailOp; | |
2741 typedef BitField<25, 3> CCWZFailOp; | |
2742 typedef BitField<28, 4> Unused2; | |
2743 | |
2744 void SetHeader() { | |
2745 header.SetCmd<ValueType>(); | |
2746 } | |
2747 | |
2748 void Init(uint8 _write_mask, | |
2749 uint8 _compare_mask, | |
2750 uint8 _reference_value, | |
2751 bool _separate_ccw, | |
2752 bool _enable, | |
2753 Comparison _cw_func, | |
2754 StencilOp _cw_pass_op, | |
2755 StencilOp _cw_fail_op, | |
2756 StencilOp _cw_z_fail_op, | |
2757 Comparison _ccw_func, | |
2758 StencilOp _ccw_pass_op, | |
2759 StencilOp _ccw_fail_op, | |
2760 StencilOp _ccw_z_fail_op) { | |
2761 SetHeader(); | |
2762 stencil_args0 = | |
2763 WriteMask::MakeValue(_write_mask) | | |
2764 CompareMask::MakeValue(_compare_mask) | | |
2765 ReferenceValue::MakeValue(_reference_value) | | |
2766 SeparateCCW::MakeValue(_separate_ccw ? 1 : 0) | | |
2767 Enable::MakeValue(_enable ? 1 : 0); | |
2768 stencil_args1 = | |
2769 CWFunc::MakeValue(_cw_func) | | |
2770 CWPassOp::MakeValue(_cw_pass_op) | | |
2771 CWFailOp::MakeValue(_cw_fail_op) | | |
2772 CWZFailOp::MakeValue(_cw_z_fail_op) | | |
2773 CCWFunc::MakeValue(_ccw_func) | | |
2774 CCWPassOp::MakeValue(_ccw_pass_op) | | |
2775 CCWFailOp::MakeValue(_ccw_fail_op) | | |
2776 CCWZFailOp::MakeValue(_ccw_z_fail_op); | |
2777 } | |
2778 | |
2779 static void* Set( | |
2780 void* cmd, | |
2781 uint8 write_mask, | |
2782 uint8 compare_mask, | |
2783 uint8 reference_value, | |
2784 bool separate_ccw, | |
2785 bool enable, | |
2786 Comparison cw_func, | |
2787 StencilOp cw_pass_op, | |
2788 StencilOp cw_fail_op, | |
2789 StencilOp cw_z_fail_op, | |
2790 Comparison ccw_func, | |
2791 StencilOp ccw_pass_op, | |
2792 StencilOp ccw_fail_op, | |
2793 StencilOp ccw_z_fail_op) { | |
2794 static_cast<ValueType*>(cmd)->Init( | |
2795 write_mask, | |
2796 compare_mask, | |
2797 reference_value, | |
2798 separate_ccw, | |
2799 enable, | |
2800 cw_func, | |
2801 cw_pass_op, | |
2802 cw_fail_op, | |
2803 cw_z_fail_op, | |
2804 ccw_func, | |
2805 ccw_pass_op, | |
2806 ccw_fail_op, | |
2807 ccw_z_fail_op); | |
2808 return NextCmdAddress<ValueType>(cmd); | |
2809 } | |
2810 | |
2811 // TODO(gman): fix this to not use obfusticated fields. | |
2812 CommandHeader header; | |
2813 uint32 stencil_args0; | |
2814 uint32 stencil_args1; | |
2815 }; | |
2816 | |
2817 COMPILE_ASSERT(sizeof(SetStencilTest) == 12, | |
2818 Sizeof_SetStencilTest_is_not_12); | |
2819 COMPILE_ASSERT(offsetof(SetStencilTest, header) == 0, | |
2820 OffsetOf_SetStencilTest_header_not_0); | |
2821 COMPILE_ASSERT(offsetof(SetStencilTest, stencil_args0) == 4, | |
2822 OffsetOf_SetStencilTest_stencil_args0_not_4); | |
2823 COMPILE_ASSERT(offsetof(SetStencilTest, stencil_args1) == 8, | |
2824 OffsetOf_SetStencilTest_stencil_args1_not_8); | |
2825 | |
2826 struct SetColorWrite { | |
2827 typedef SetColorWrite ValueType; | |
2828 static const CommandId kCmdId = command_buffer::kSetColorWrite; | |
2829 static const ArgFlags kArgFlags = kFixed; | |
2830 | |
2831 // argument 0 | |
2832 typedef BitField<0, 1> RedMask; | |
2833 typedef BitField<1, 1> GreenMask; | |
2834 typedef BitField<2, 1> BlueMask; | |
2835 typedef BitField<3, 1> AlphaMask; | |
2836 typedef BitField<0, 4> AllColorsMask; // alias for RGBA | |
2837 typedef BitField<4, 27> Unused; | |
2838 typedef BitField<31, 1> DitherEnable; | |
2839 | |
2840 void SetHeader() { | |
2841 header.SetCmd<ValueType>(); | |
2842 } | |
2843 | |
2844 void Init(uint8 _mask, bool _dither_enable) { | |
2845 SetHeader(); | |
2846 flags = | |
2847 RedMask::MakeValue((_mask | 0x01) != 0 ? 1 : 0) | | |
2848 GreenMask::MakeValue((_mask | 0x02) != 0 ? 1 : 0) | | |
2849 BlueMask::MakeValue((_mask | 0x02) != 0 ? 1 : 0) | | |
2850 AlphaMask::MakeValue((_mask | 0x02) != 0 ? 1 : 0) | | |
2851 DitherEnable::MakeValue(_dither_enable ? 1 : 0); | |
2852 } | |
2853 | |
2854 static void* Set(void* cmd, uint8 mask, bool dither_enable) { | |
2855 static_cast<ValueType*>(cmd)->Init(mask, dither_enable); | |
2856 return NextCmdAddress<ValueType>(cmd); | |
2857 } | |
2858 | |
2859 CommandHeader header; | |
2860 uint32 flags; | |
2861 }; | |
2862 | |
2863 COMPILE_ASSERT(sizeof(SetColorWrite) == 8, Sizeof_SetColorWrite_is_not_8); | |
2864 COMPILE_ASSERT(offsetof(SetColorWrite, header) == 0, | |
2865 OffsetOf_SetColorWrite_header_not_0); | |
2866 COMPILE_ASSERT(offsetof(SetColorWrite, flags) == 4, | |
2867 OffsetOf_SetColorWrite_flags_not_4); | |
2868 | |
2869 struct SetBlending { | |
2870 typedef SetBlending ValueType; | |
2871 static const CommandId kCmdId = command_buffer::kSetBlending; | |
2872 static const ArgFlags kArgFlags = kFixed; | |
2873 | |
2874 // argument 0 | |
2875 typedef BitField<0, 4> ColorSrcFunc; | |
2876 typedef BitField<4, 4> ColorDstFunc; | |
2877 typedef BitField<8, 3> ColorEq; | |
2878 typedef BitField<11, 5> Unused0; | |
2879 typedef BitField<16, 4> AlphaSrcFunc; | |
2880 typedef BitField<20, 4> AlphaDstFunc; | |
2881 typedef BitField<24, 3> AlphaEq; | |
2882 typedef BitField<27, 3> Unused1; | |
2883 typedef BitField<30, 1> SeparateAlpha; | |
2884 typedef BitField<31, 1> Enable; | |
2885 | |
2886 void SetHeader() { | |
2887 header.SetCmd<ValueType>(); | |
2888 } | |
2889 | |
2890 void Init( | |
2891 BlendFunc _color_src_func, | |
2892 BlendFunc _color_dst_func, | |
2893 BlendEq _color_eq, | |
2894 BlendFunc _alpha_src_func, | |
2895 BlendFunc _alpha_dst_func, | |
2896 BlendEq _alpha_eq, | |
2897 bool _separate_alpha, | |
2898 bool _enable) { | |
2899 SetHeader(); | |
2900 blend_settings = | |
2901 ColorSrcFunc::MakeValue(_color_src_func) | | |
2902 ColorDstFunc::MakeValue(_color_dst_func) | | |
2903 ColorEq::MakeValue(_color_eq) | | |
2904 AlphaSrcFunc::MakeValue(_alpha_src_func) | | |
2905 AlphaDstFunc::MakeValue(_alpha_dst_func) | | |
2906 AlphaEq::MakeValue(_alpha_eq) | | |
2907 SeparateAlpha::MakeValue(_separate_alpha ? 1 : 0) | | |
2908 Enable::MakeValue(_enable ? 1 : 0); | |
2909 } | |
2910 | |
2911 static void* Set( | |
2912 void* cmd, | |
2913 BlendFunc color_src_func, | |
2914 BlendFunc color_dst_func, | |
2915 BlendEq color_eq, | |
2916 BlendFunc alpha_src_func, | |
2917 BlendFunc alpha_dst_func, | |
2918 BlendEq alpha_eq, | |
2919 bool separate_alpha, | |
2920 bool enable) { | |
2921 static_cast<ValueType*>(cmd)->Init( | |
2922 color_src_func, | |
2923 color_dst_func, | |
2924 color_eq, | |
2925 alpha_src_func, | |
2926 alpha_dst_func, | |
2927 alpha_eq, | |
2928 separate_alpha, | |
2929 enable); | |
2930 return NextCmdAddress<ValueType>(cmd); | |
2931 } | |
2932 | |
2933 // TODO(gman): fix this to not use obfusticated fields. | |
2934 CommandHeader header; | |
2935 uint32 blend_settings; | |
2936 }; | |
2937 | |
2938 COMPILE_ASSERT(sizeof(SetBlending) == 8, Sizeof_SetBlending_is_not_8); | |
2939 COMPILE_ASSERT(offsetof(SetBlending, header) == 0, | |
2940 OffsetOf_SetBlending_header_not_0); | |
2941 COMPILE_ASSERT(offsetof(SetBlending, blend_settings) == 4, | |
2942 OffsetOf_SetBlending_blend_settings_not_4); | |
2943 | |
2944 struct SetBlendingColor { | |
2945 typedef SetBlendingColor ValueType; | |
2946 static const CommandId kCmdId = command_buffer::kSetBlendingColor; | |
2947 static const ArgFlags kArgFlags = kFixed; | |
2948 | |
2949 void SetHeader() { | |
2950 header.SetCmd<ValueType>(); | |
2951 } | |
2952 | |
2953 void Init(float _red, float _green, float _blue, float _alpha) { | |
2954 SetHeader(); | |
2955 red = _red; | |
2956 green = _green; | |
2957 blue = _blue; | |
2958 alpha = _alpha; | |
2959 } | |
2960 | |
2961 static void* Set(void* cmd, | |
2962 float red, float green, float blue, float alpha) { | |
2963 static_cast<ValueType*>(cmd)->Init(red, green, blue, alpha); | |
2964 return NextCmdAddress<ValueType>(cmd); | |
2965 } | |
2966 | |
2967 CommandHeader header; | |
2968 float red; | |
2969 float blue; | |
2970 float green; | |
2971 float alpha; | |
2972 }; | |
2973 | |
2974 COMPILE_ASSERT(sizeof(SetBlendingColor) == 20, | |
2975 Sizeof_SetBlendingColor_is_not_20); | |
2976 COMPILE_ASSERT(offsetof(SetBlendingColor, header) == 0, | |
2977 OffsetOf_SetBlendingColor_header_not_0); | |
2978 COMPILE_ASSERT(offsetof(SetBlendingColor, red) == 4, | |
2979 OffsetOf_SetBlendingColor_red_not_4); | |
2980 COMPILE_ASSERT(offsetof(SetBlendingColor, blue) == 8, | |
2981 OffsetOf_SetBlendingColor_blue_not_8); | |
2982 COMPILE_ASSERT(offsetof(SetBlendingColor, green) == 12, | |
2983 OffsetOf_SetBlendingColor_green_not_12); | |
2984 COMPILE_ASSERT(offsetof(SetBlendingColor, alpha) == 16, | |
2985 OffsetOf_SetBlendingColor_alpha_not_16); | |
2986 | |
2987 struct CreateRenderSurface { | |
2988 typedef CreateRenderSurface ValueType; | |
2989 static const CommandId kCmdId = command_buffer::kCreateRenderSurface; | |
2990 static const ArgFlags kArgFlags = kFixed; | |
2991 | |
2992 // argument 1 | |
2993 typedef BitField<0, 16> Width; | |
2994 typedef BitField<16, 16> Height; | |
2995 // argument 2 may refer to side or depth | |
2996 typedef BitField<0, 16> Levels; | |
2997 typedef BitField<16, 16> Side; | |
2998 | |
2999 void SetHeader() { | |
3000 header.SetCmd<ValueType>(); | |
3001 } | |
3002 | |
3003 void Init(ResourceId _render_surface_id, | |
3004 ResourceId _texture_id, uint32 _width, uint32 _height, | |
3005 uint32 _level, uint32 _side) { | |
3006 SetHeader(); | |
3007 render_surface_id = _render_surface_id; | |
3008 // TODO(gman): Why does this need a width and height. It's inherited from | |
3009 // the texture isn't it? | |
3010 width_height = Width::MakeValue(_width) | Height::MakeValue(_height); | |
3011 levels_side = Levels::MakeValue(_level) | Side::MakeValue(_side); | |
3012 texture_id = _texture_id; | |
3013 } | |
3014 | |
3015 static void* Set(void* cmd, | |
3016 ResourceId render_surface_id, ResourceId texture_id, | |
3017 uint32 width, uint32 height, | |
3018 uint32 level, uint32 side) { | |
3019 static_cast<ValueType*>(cmd)->Init(render_surface_id, texture_id, | |
3020 width, height, | |
3021 level, side); | |
3022 return NextCmdAddress<ValueType>(cmd); | |
3023 } | |
3024 | |
3025 // TODO(gman): fix this to not use obfusticated fields. | |
3026 CommandHeader header; | |
3027 ResourceId render_surface_id; | |
3028 uint32 width_height; | |
3029 uint32 levels_side; | |
3030 ResourceId texture_id; | |
3031 }; | |
3032 | |
3033 COMPILE_ASSERT(sizeof(CreateRenderSurface) == 20, | |
3034 Sizeof_CreateRenderSurface_is_not_20); | |
3035 COMPILE_ASSERT(offsetof(CreateRenderSurface, header) == 0, | |
3036 OffsetOf_CreateRenderSurface_header_not_0); | |
3037 COMPILE_ASSERT(offsetof(CreateRenderSurface, render_surface_id) == 4, | |
3038 OffsetOf_CreateRenderSurface_render_surface_id_not_4); | |
3039 COMPILE_ASSERT(offsetof(CreateRenderSurface, width_height) == 8, | |
3040 OffsetOf_CreateRenderSurface_width_height_not_8); | |
3041 COMPILE_ASSERT(offsetof(CreateRenderSurface, levels_side) == 12, | |
3042 OffsetOf_CreateRenderSurface_levels_side_not_12); | |
3043 COMPILE_ASSERT(offsetof(CreateRenderSurface, texture_id) == 16, | |
3044 OffsetOf_CreateRenderSurface_texture_id_not_16); | |
3045 | |
3046 struct DestroyRenderSurface { | |
3047 typedef DestroyRenderSurface ValueType; | |
3048 static const CommandId kCmdId = command_buffer::kDestroyRenderSurface; | |
3049 static const ArgFlags kArgFlags = kFixed; | |
3050 | |
3051 void SetHeader() { | |
3052 header.SetCmd<ValueType>(); | |
3053 } | |
3054 | |
3055 void Init(ResourceId _render_surface_id) { | |
3056 SetHeader(); | |
3057 render_surface_id = _render_surface_id; | |
3058 } | |
3059 | |
3060 static void* Set(void* cmd, ResourceId render_surface_id) { | |
3061 static_cast<ValueType*>(cmd)->Init(render_surface_id); | |
3062 return NextCmdAddress<ValueType>(cmd); | |
3063 } | |
3064 | |
3065 CommandHeader header; | |
3066 ResourceId render_surface_id; | |
3067 }; | |
3068 | |
3069 COMPILE_ASSERT(sizeof(DestroyRenderSurface) == 8, | |
3070 Sizeof_DestroyRenderSurface_is_not_8); | |
3071 COMPILE_ASSERT(offsetof(DestroyRenderSurface, header) == 0, | |
3072 OffsetOf_DestroyRenderSurface_header_not_0); | |
3073 COMPILE_ASSERT(offsetof(DestroyRenderSurface, render_surface_id) == 4, | |
3074 OffsetOf_DestroyRenderSurface_render_surface_id_not_4); | |
3075 | |
3076 struct CreateDepthSurface { | |
3077 typedef CreateDepthSurface ValueType; | |
3078 static const CommandId kCmdId = command_buffer::kCreateDepthSurface; | |
3079 static const ArgFlags kArgFlags = kFixed; | |
3080 | |
3081 // argument 1 | |
3082 typedef BitField<0, 16> Width; | |
3083 typedef BitField<16, 16> Height; | |
3084 | |
3085 void SetHeader() { | |
3086 header.SetCmd<ValueType>(); | |
3087 } | |
3088 | |
3089 void Init(ResourceId _depth_surface_id, uint32 _width, uint32 _height) { | |
3090 SetHeader(); | |
3091 depth_surface_id = _depth_surface_id; | |
3092 width_height = Width::MakeValue(_width) | Height::MakeValue(_height); | |
3093 } | |
3094 | |
3095 static void* Set(void* cmd, ResourceId depth_surface_id, | |
3096 uint32 width, uint32 height) { | |
3097 static_cast<ValueType*>(cmd)->Init(depth_surface_id, width, height); | |
3098 return NextCmdAddress<ValueType>(cmd); | |
3099 } | |
3100 | |
3101 // TODO(gman): fix this to not use obfusticated fields. | |
3102 CommandHeader header; | |
3103 ResourceId depth_surface_id; | |
3104 uint32 width_height; | |
3105 }; | |
3106 | |
3107 COMPILE_ASSERT(sizeof(CreateDepthSurface) == 12, | |
3108 Sizeof_CreateDepthSurface_is_not_12); | |
3109 COMPILE_ASSERT(offsetof(CreateDepthSurface, header) == 0, | |
3110 OffsetOf_CreateDepthSurface_header_not_0); | |
3111 COMPILE_ASSERT(offsetof(CreateDepthSurface, depth_surface_id) == 4, | |
3112 OffsetOf_CreateDepthSurface_depth_surface_id_not_4); | |
3113 COMPILE_ASSERT(offsetof(CreateDepthSurface, width_height) == 8, | |
3114 OffsetOf_CreateDepthSurface_width_height_not_8); | |
3115 | |
3116 struct DestroyDepthSurface { | |
3117 typedef DestroyDepthSurface ValueType; | |
3118 static const CommandId kCmdId = command_buffer::kDestroyDepthSurface; | |
3119 static const ArgFlags kArgFlags = kFixed; | |
3120 | |
3121 void SetHeader() { | |
3122 header.SetCmd<ValueType>(); | |
3123 } | |
3124 | |
3125 void Init(ResourceId _depth_surface_id) { | |
3126 SetHeader(); | |
3127 depth_surface_id = _depth_surface_id; | |
3128 } | |
3129 | |
3130 static void* Set(void* cmd, ResourceId depth_surface_id) { | |
3131 static_cast<ValueType*>(cmd)->Init(depth_surface_id); | |
3132 return NextCmdAddress<ValueType>(cmd); | |
3133 } | |
3134 | |
3135 CommandHeader header; | |
3136 ResourceId depth_surface_id; | |
3137 }; | |
3138 | |
3139 COMPILE_ASSERT(sizeof(DestroyDepthSurface) == 8, | |
3140 Sizeof_DestroyDepthSurface_is_not_8); | |
3141 COMPILE_ASSERT(offsetof(DestroyDepthSurface, header) == 0, | |
3142 OffsetOf_DestroyDepthSurface_header_not_0); | |
3143 COMPILE_ASSERT(offsetof(DestroyDepthSurface, depth_surface_id) == 4, | |
3144 OffsetOf_DestroyDepthdepth_surface_id_not_4); | |
3145 | |
3146 struct SetRenderSurface { | |
3147 typedef SetRenderSurface ValueType; | |
3148 static const CommandId kCmdId = command_buffer::kSetRenderSurface; | |
3149 static const ArgFlags kArgFlags = kFixed; | |
3150 | |
3151 void SetHeader() { | |
3152 header.SetCmd<ValueType>(); | |
3153 } | |
3154 | |
3155 void Init(ResourceId _render_surface_id, ResourceId _depth_surface_id) { | |
3156 SetHeader(); | |
3157 render_surface_id = _render_surface_id; | |
3158 depth_surface_id = _depth_surface_id; | |
3159 } | |
3160 | |
3161 static void* Set(void* cmd, | |
3162 ResourceId render_surface_id, ResourceId depth_surface_id) { | |
3163 static_cast<ValueType*>(cmd)->Init(render_surface_id, depth_surface_id); | |
3164 return NextCmdAddress<ValueType>(cmd); | |
3165 } | |
3166 | |
3167 CommandHeader header; | |
3168 ResourceId render_surface_id; | |
3169 ResourceId depth_surface_id; | |
3170 }; | |
3171 | |
3172 COMPILE_ASSERT(sizeof(SetRenderSurface) == 12, | |
3173 Sizeof_SetRenderSurface_is_not_12); | |
3174 COMPILE_ASSERT(offsetof(SetRenderSurface, header) == 0, | |
3175 OffsetOf_SetRenderSurface_header_not_0); | |
3176 COMPILE_ASSERT(offsetof(SetRenderSurface, render_surface_id) == 4, | |
3177 OffsetOf_SetRenderSurface_render_surface_id_not_4); | |
3178 COMPILE_ASSERT(offsetof(SetRenderSurface, depth_surface_id) == 8, | |
3179 OffsetOf_SetRenderSurface_depth_surface_id_not_8); | |
3180 | |
3181 struct SetBackSurfaces { | |
3182 typedef SetBackSurfaces ValueType; | |
3183 static const CommandId kCmdId = command_buffer::kSetBackSurfaces; | |
3184 static const ArgFlags kArgFlags = kFixed; | |
3185 | |
3186 void SetHeader() { | |
3187 header.SetCmd<ValueType>(); | |
3188 } | |
3189 | |
3190 void Init() { | |
3191 SetHeader(); | |
3192 } | |
3193 | |
3194 static void* Set(void* cmd) { | |
3195 static_cast<ValueType*>(cmd)->Init(); | |
3196 return NextCmdAddress<ValueType>(cmd); | |
3197 } | |
3198 | |
3199 CommandHeader header; | |
3200 }; | |
3201 | |
3202 COMPILE_ASSERT(sizeof(SetBackSurfaces) == 4, | |
3203 Sizeof_SetBackSurfaces_is_not_4); | |
3204 COMPILE_ASSERT(offsetof(SetBackSurfaces, header) == 0, | |
3205 OffsetOf_SetBackSurfaces_header_not_0); | |
3206 | |
3207 O3D_POP_STRUCTURE_PACKING; | |
3208 | |
3209 } // namespace o3d | |
3210 } // namespace command_buffer | |
3211 } // namespace o3d | |
3212 | |
3213 #endif // O3D_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_FORMAT_H_ | |
OLD | NEW |