1/*
2 * Copyright (C) 2016 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24
25/* Instructions, enums and structures for SNB.
26 *
27 * This file has been generated, do not hand edit.
28 */
29
30#ifndef GFX6_PACK_H
31#define GFX6_PACK_H
32
33#include <stdio.h>
34#include <stdint.h>
35#include <stdbool.h>
36#include <assert.h>
37#include <math.h>
38
39#ifndef __gen_validate_value
40#define __gen_validate_value(x)
41#endif
42
43#ifndef __intel_field_functions
44#define __intel_field_functions
45
46#ifdef NDEBUG
47#define NDEBUG_UNUSED __attribute__((unused))
48#else
49#define NDEBUG_UNUSED
50#endif
51
52union __intel_value {
53   float f;
54   uint32_t dw;
55};
56
57static inline __attribute__((always_inline)) uint64_t
58__gen_mbo(uint32_t start, uint32_t end)
59{
60   return (~0ull >> (64 - (end - start + 1))) << start;
61}
62
63static inline __attribute__((always_inline)) uint64_t
64__gen_uint(uint64_t v, uint32_t start, NDEBUG_UNUSED uint32_t end)
65{
66   __gen_validate_value(v);
67
68#ifndef NDEBUG
69   const int width = end - start + 1;
70   if (width < 64) {
71      const uint64_t max = (1ull << width) - 1;
72      assert(v <= max);
73   }
74#endif
75
76   return v << start;
77}
78
79static inline __attribute__((always_inline)) uint64_t
80__gen_sint(int64_t v, uint32_t start, uint32_t end)
81{
82   const int width = end - start + 1;
83
84   __gen_validate_value(v);
85
86#ifndef NDEBUG
87   if (width < 64) {
88      const int64_t max = (1ll << (width - 1)) - 1;
89      const int64_t min = -(1ll << (width - 1));
90      assert(min <= v && v <= max);
91   }
92#endif
93
94   const uint64_t mask = ~0ull >> (64 - width);
95
96   return (v & mask) << start;
97}
98
99static inline __attribute__((always_inline)) uint64_t
100__gen_offset(uint64_t v, NDEBUG_UNUSED uint32_t start, NDEBUG_UNUSED uint32_t end)
101{
102   __gen_validate_value(v);
103#ifndef NDEBUG
104   uint64_t mask = (~0ull >> (64 - (end - start + 1))) << start;
105
106   assert((v & ~mask) == 0);
107#endif
108
109   return v;
110}
111
112static inline __attribute__((always_inline)) uint64_t
113__gen_address(__gen_user_data *data, void *location,
114              __gen_address_type address, uint32_t delta,
115              __attribute__((unused)) uint32_t start, uint32_t end)
116{
117   uint64_t addr_u64 = __gen_combine_address(data, location, address, delta);
118   if (end == 31) {
119      return addr_u64;
120   } else if (end < 63) {
121      const unsigned shift = 63 - end;
122      return (addr_u64 << shift) >> shift;
123   } else {
124      return addr_u64;
125   }
126}
127
128static inline __attribute__((always_inline)) uint32_t
129__gen_float(float v)
130{
131   __gen_validate_value(v);
132   return ((union __intel_value) { .f = (v) }).dw;
133}
134
135static inline __attribute__((always_inline)) uint64_t
136__gen_sfixed(float v, uint32_t start, uint32_t end, uint32_t fract_bits)
137{
138   __gen_validate_value(v);
139
140   const float factor = (1 << fract_bits);
141
142#ifndef NDEBUG
143   const float max = ((1 << (end - start)) - 1) / factor;
144   const float min = -(1 << (end - start)) / factor;
145   assert(min <= v && v <= max);
146#endif
147
148   const int64_t int_val = llroundf(v * factor);
149   const uint64_t mask = ~0ull >> (64 - (end - start + 1));
150
151   return (int_val & mask) << start;
152}
153
154static inline __attribute__((always_inline)) uint64_t
155__gen_ufixed(float v, uint32_t start, NDEBUG_UNUSED uint32_t end, uint32_t fract_bits)
156{
157   __gen_validate_value(v);
158
159   const float factor = (1 << fract_bits);
160
161#ifndef NDEBUG
162   const float max = ((1 << (end - start + 1)) - 1) / factor;
163   const float min = 0.0f;
164   assert(min <= v && v <= max);
165#endif
166
167   const uint64_t uint_val = llroundf(v * factor);
168
169   return uint_val << start;
170}
171
172#ifndef __gen_address_type
173#error #define __gen_address_type before including this file
174#endif
175
176#ifndef __gen_user_data
177#error #define __gen_combine_address before including this file
178#endif
179
180#undef NDEBUG_UNUSED
181
182#endif
183
184
185enum GFX6_3D_Color_Buffer_Blend_Factor {
186   BLENDFACTOR_ONE                      =      1,
187   BLENDFACTOR_SRC_COLOR                =      2,
188   BLENDFACTOR_SRC_ALPHA                =      3,
189   BLENDFACTOR_DST_ALPHA                =      4,
190   BLENDFACTOR_DST_COLOR                =      5,
191   BLENDFACTOR_SRC_ALPHA_SATURATE       =      6,
192   BLENDFACTOR_CONST_COLOR              =      7,
193   BLENDFACTOR_CONST_ALPHA              =      8,
194   BLENDFACTOR_SRC1_COLOR               =      9,
195   BLENDFACTOR_SRC1_ALPHA               =     10,
196   BLENDFACTOR_ZERO                     =     17,
197   BLENDFACTOR_INV_SRC_COLOR            =     18,
198   BLENDFACTOR_INV_SRC_ALPHA            =     19,
199   BLENDFACTOR_INV_DST_ALPHA            =     20,
200   BLENDFACTOR_INV_DST_COLOR            =     21,
201   BLENDFACTOR_INV_CONST_COLOR          =     23,
202   BLENDFACTOR_INV_CONST_ALPHA          =     24,
203   BLENDFACTOR_INV_SRC1_COLOR           =     25,
204   BLENDFACTOR_INV_SRC1_ALPHA           =     26,
205};
206
207enum GFX6_3D_Color_Buffer_Blend_Function {
208   BLENDFUNCTION_ADD                    =      0,
209   BLENDFUNCTION_SUBTRACT               =      1,
210   BLENDFUNCTION_REVERSE_SUBTRACT       =      2,
211   BLENDFUNCTION_MIN                    =      3,
212   BLENDFUNCTION_MAX                    =      4,
213};
214
215enum GFX6_3D_Compare_Function {
216   COMPAREFUNCTION_ALWAYS               =      0,
217   COMPAREFUNCTION_NEVER                =      1,
218   COMPAREFUNCTION_LESS                 =      2,
219   COMPAREFUNCTION_EQUAL                =      3,
220   COMPAREFUNCTION_LEQUAL               =      4,
221   COMPAREFUNCTION_GREATER              =      5,
222   COMPAREFUNCTION_NOTEQUAL             =      6,
223   COMPAREFUNCTION_GEQUAL               =      7,
224};
225
226enum GFX6_3D_Logic_Op_Function {
227   LOGICOP_CLEAR                        =      0,
228   LOGICOP_NOR                          =      1,
229   LOGICOP_AND_INVERTED                 =      2,
230   LOGICOP_COPY_INVERTED                =      3,
231   LOGICOP_AND_REVERSE                  =      4,
232   LOGICOP_INVERT                       =      5,
233   LOGICOP_XOR                          =      6,
234   LOGICOP_NAND                         =      7,
235   LOGICOP_AND                          =      8,
236   LOGICOP_EQUIV                        =      9,
237   LOGICOP_NOOP                         =     10,
238   LOGICOP_OR_INVERTED                  =     11,
239   LOGICOP_COPY                         =     12,
240   LOGICOP_OR_REVERSE                   =     13,
241   LOGICOP_OR                           =     14,
242   LOGICOP_SET                          =     15,
243};
244
245enum GFX6_3D_Prim_Topo_Type {
246   _3DPRIM_POINTLIST                    =      1,
247   _3DPRIM_LINELIST                     =      2,
248   _3DPRIM_LINESTRIP                    =      3,
249   _3DPRIM_TRILIST                      =      4,
250   _3DPRIM_TRISTRIP                     =      5,
251   _3DPRIM_TRIFAN                       =      6,
252   _3DPRIM_QUADLIST                     =      7,
253   _3DPRIM_QUADSTRIP                    =      8,
254   _3DPRIM_LINELIST_ADJ                 =      9,
255   _3DPRIM_LINESTRIP_ADJ                =     10,
256   _3DPRIM_TRILIST_ADJ                  =     11,
257   _3DPRIM_TRISTRIP_ADJ                 =     12,
258   _3DPRIM_TRISTRIP_REVERSE             =     13,
259   _3DPRIM_POLYGON                      =     14,
260   _3DPRIM_RECTLIST                     =     15,
261   _3DPRIM_LINELOOP                     =     16,
262   _3DPRIM_POINTLIST_BF                 =     17,
263   _3DPRIM_LINESTRIP_CONT               =     18,
264   _3DPRIM_LINESTRIP_BF                 =     19,
265   _3DPRIM_LINESTRIP_CONT_BF            =     20,
266   _3DPRIM_TRIFAN_NOSTIPPLE             =     22,
267};
268
269enum GFX6_3D_Stencil_Operation {
270   STENCILOP_KEEP                       =      0,
271   STENCILOP_ZERO                       =      1,
272   STENCILOP_REPLACE                    =      2,
273   STENCILOP_INCRSAT                    =      3,
274   STENCILOP_DECRSAT                    =      4,
275   STENCILOP_INCR                       =      5,
276   STENCILOP_DECR                       =      6,
277   STENCILOP_INVERT                     =      7,
278};
279
280enum GFX6_3D_Vertex_Component_Control {
281   VFCOMP_NOSTORE                       =      0,
282   VFCOMP_STORE_SRC                     =      1,
283   VFCOMP_STORE_0                       =      2,
284   VFCOMP_STORE_1_FP                    =      3,
285   VFCOMP_STORE_1_INT                   =      4,
286   VFCOMP_STORE_VID                     =      5,
287   VFCOMP_STORE_IID                     =      6,
288   VFCOMP_STORE_PID                     =      7,
289};
290
291enum GFX6_TextureCoordinateMode {
292   TCM_WRAP                             =      0,
293   TCM_MIRROR                           =      1,
294   TCM_CLAMP                            =      2,
295   TCM_CUBE                             =      3,
296   TCM_CLAMP_BORDER                     =      4,
297   TCM_MIRROR_ONCE                      =      5,
298};
299
300#define GFX6_3DSTATE_CONSTANT_BODY_length      4
301struct GFX6_3DSTATE_CONSTANT_BODY {
302   uint32_t                             ConstantBuffer0ReadLength;
303   uint64_t                             PointertoConstantBuffer0;
304   uint32_t                             ConstantBuffer1ReadLength;
305   __gen_address_type                   PointertoConstantBuffer1;
306   uint32_t                             ConstantBuffer2ReadLength;
307   __gen_address_type                   PointertoConstantBuffer2;
308   uint32_t                             ConstantBuffer3ReadLength;
309   __gen_address_type                   PointertoConstantBuffer3;
310};
311
312static inline __attribute__((always_inline)) void
313GFX6_3DSTATE_CONSTANT_BODY_pack(__attribute__((unused)) __gen_user_data *data,
314                                __attribute__((unused)) void * restrict dst,
315                                __attribute__((unused)) const struct GFX6_3DSTATE_CONSTANT_BODY * restrict values)
316{
317   uint32_t * restrict dw = (uint32_t * restrict) dst;
318
319   dw[0] =
320      __gen_uint(values->ConstantBuffer0ReadLength, 0, 4) |
321      __gen_offset(values->PointertoConstantBuffer0, 5, 31);
322
323   const uint32_t v1 =
324      __gen_uint(values->ConstantBuffer1ReadLength, 0, 4);
325   dw[1] = __gen_address(data, &dw[1], values->PointertoConstantBuffer1, v1, 5, 31);
326
327   const uint32_t v2 =
328      __gen_uint(values->ConstantBuffer2ReadLength, 0, 4);
329   dw[2] = __gen_address(data, &dw[2], values->PointertoConstantBuffer2, v2, 5, 31);
330
331   const uint32_t v3 =
332      __gen_uint(values->ConstantBuffer3ReadLength, 0, 4);
333   dw[3] = __gen_address(data, &dw[3], values->PointertoConstantBuffer3, v3, 5, 31);
334}
335
336#define GFX6_BINDING_TABLE_STATE_length        1
337struct GFX6_BINDING_TABLE_STATE {
338   uint64_t                             SurfaceStatePointer;
339};
340
341static inline __attribute__((always_inline)) void
342GFX6_BINDING_TABLE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
343                              __attribute__((unused)) void * restrict dst,
344                              __attribute__((unused)) const struct GFX6_BINDING_TABLE_STATE * restrict values)
345{
346   uint32_t * restrict dw = (uint32_t * restrict) dst;
347
348   dw[0] =
349      __gen_offset(values->SurfaceStatePointer, 5, 31);
350}
351
352#define GFX6_BLEND_STATE_ENTRY_length          2
353struct GFX6_BLEND_STATE_ENTRY {
354   enum GFX6_3D_Color_Buffer_Blend_Factor DestinationBlendFactor;
355   enum GFX6_3D_Color_Buffer_Blend_Factor SourceBlendFactor;
356   enum GFX6_3D_Color_Buffer_Blend_Function ColorBlendFunction;
357   enum GFX6_3D_Color_Buffer_Blend_Factor DestinationAlphaBlendFactor;
358   enum GFX6_3D_Color_Buffer_Blend_Factor SourceAlphaBlendFactor;
359   enum GFX6_3D_Color_Buffer_Blend_Function AlphaBlendFunction;
360   bool                                 IndependentAlphaBlendEnable;
361   bool                                 ColorBufferBlendEnable;
362   bool                                 PostBlendColorClampEnable;
363   bool                                 PreBlendColorClampEnable;
364   uint32_t                             ColorClampRange;
365#define COLORCLAMP_UNORM                         0
366#define COLORCLAMP_SNORM                         1
367#define COLORCLAMP_RTFORMAT                      2
368   uint32_t                             YDitherOffset;
369   uint32_t                             XDitherOffset;
370   bool                                 ColorDitherEnable;
371   enum GFX6_3D_Compare_Function        AlphaTestFunction;
372   bool                                 AlphaTestEnable;
373   enum GFX6_3D_Logic_Op_Function       LogicOpFunction;
374   bool                                 LogicOpEnable;
375   bool                                 WriteDisableBlue;
376   bool                                 WriteDisableGreen;
377   bool                                 WriteDisableRed;
378   bool                                 WriteDisableAlpha;
379   bool                                 AlphaToCoverageDitherEnable;
380   bool                                 AlphaToOneEnable;
381   bool                                 AlphaToCoverageEnable;
382};
383
384static inline __attribute__((always_inline)) void
385GFX6_BLEND_STATE_ENTRY_pack(__attribute__((unused)) __gen_user_data *data,
386                            __attribute__((unused)) void * restrict dst,
387                            __attribute__((unused)) const struct GFX6_BLEND_STATE_ENTRY * restrict values)
388{
389   uint32_t * restrict dw = (uint32_t * restrict) dst;
390
391   dw[0] =
392      __gen_uint(values->DestinationBlendFactor, 0, 4) |
393      __gen_uint(values->SourceBlendFactor, 5, 9) |
394      __gen_uint(values->ColorBlendFunction, 11, 13) |
395      __gen_uint(values->DestinationAlphaBlendFactor, 15, 19) |
396      __gen_uint(values->SourceAlphaBlendFactor, 20, 24) |
397      __gen_uint(values->AlphaBlendFunction, 26, 28) |
398      __gen_uint(values->IndependentAlphaBlendEnable, 30, 30) |
399      __gen_uint(values->ColorBufferBlendEnable, 31, 31);
400
401   dw[1] =
402      __gen_uint(values->PostBlendColorClampEnable, 0, 0) |
403      __gen_uint(values->PreBlendColorClampEnable, 1, 1) |
404      __gen_uint(values->ColorClampRange, 2, 3) |
405      __gen_uint(values->YDitherOffset, 8, 9) |
406      __gen_uint(values->XDitherOffset, 10, 11) |
407      __gen_uint(values->ColorDitherEnable, 12, 12) |
408      __gen_uint(values->AlphaTestFunction, 13, 15) |
409      __gen_uint(values->AlphaTestEnable, 16, 16) |
410      __gen_uint(values->LogicOpFunction, 18, 21) |
411      __gen_uint(values->LogicOpEnable, 22, 22) |
412      __gen_uint(values->WriteDisableBlue, 24, 24) |
413      __gen_uint(values->WriteDisableGreen, 25, 25) |
414      __gen_uint(values->WriteDisableRed, 26, 26) |
415      __gen_uint(values->WriteDisableAlpha, 27, 27) |
416      __gen_uint(values->AlphaToCoverageDitherEnable, 29, 29) |
417      __gen_uint(values->AlphaToOneEnable, 30, 30) |
418      __gen_uint(values->AlphaToCoverageEnable, 31, 31);
419}
420
421#define GFX6_BLEND_STATE_length                0
422struct GFX6_BLEND_STATE {
423   /* variable length fields follow */
424};
425
426static inline __attribute__((always_inline)) void
427GFX6_BLEND_STATE_pack(__attribute__((unused)) __gen_user_data *data,
428                      __attribute__((unused)) void * restrict dst,
429                      __attribute__((unused)) const struct GFX6_BLEND_STATE * restrict values)
430{
431}
432
433#define GFX6_CC_VIEWPORT_length                2
434struct GFX6_CC_VIEWPORT {
435   float                                MinimumDepth;
436   float                                MaximumDepth;
437};
438
439static inline __attribute__((always_inline)) void
440GFX6_CC_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
441                      __attribute__((unused)) void * restrict dst,
442                      __attribute__((unused)) const struct GFX6_CC_VIEWPORT * restrict values)
443{
444   uint32_t * restrict dw = (uint32_t * restrict) dst;
445
446   dw[0] =
447      __gen_float(values->MinimumDepth);
448
449   dw[1] =
450      __gen_float(values->MaximumDepth);
451}
452
453#define GFX6_CLIP_VIEWPORT_length              4
454struct GFX6_CLIP_VIEWPORT {
455   float                                XMinClipGuardband;
456   float                                XMaxClipGuardband;
457   float                                YMinClipGuardband;
458   float                                YMaxClipGuardband;
459};
460
461static inline __attribute__((always_inline)) void
462GFX6_CLIP_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
463                        __attribute__((unused)) void * restrict dst,
464                        __attribute__((unused)) const struct GFX6_CLIP_VIEWPORT * restrict values)
465{
466   uint32_t * restrict dw = (uint32_t * restrict) dst;
467
468   dw[0] =
469      __gen_float(values->XMinClipGuardband);
470
471   dw[1] =
472      __gen_float(values->XMaxClipGuardband);
473
474   dw[2] =
475      __gen_float(values->YMinClipGuardband);
476
477   dw[3] =
478      __gen_float(values->YMaxClipGuardband);
479}
480
481#define GFX6_COLOR_CALC_STATE_length           6
482struct GFX6_COLOR_CALC_STATE {
483   uint32_t                             AlphaTestFormat;
484#define ALPHATEST_UNORM8                         0
485#define ALPHATEST_FLOAT32                        1
486   bool                                 RoundDisableFunctionDisable;
487   uint32_t                             BackfaceStencilReferenceValue;
488   uint32_t                             StencilReferenceValue;
489   uint32_t                             AlphaReferenceValueAsUNORM8;
490   float                                AlphaReferenceValueAsFLOAT32;
491   float                                BlendConstantColorRed;
492   float                                BlendConstantColorGreen;
493   float                                BlendConstantColorBlue;
494   float                                BlendConstantColorAlpha;
495};
496
497static inline __attribute__((always_inline)) void
498GFX6_COLOR_CALC_STATE_pack(__attribute__((unused)) __gen_user_data *data,
499                           __attribute__((unused)) void * restrict dst,
500                           __attribute__((unused)) const struct GFX6_COLOR_CALC_STATE * restrict values)
501{
502   uint32_t * restrict dw = (uint32_t * restrict) dst;
503
504   dw[0] =
505      __gen_uint(values->AlphaTestFormat, 0, 0) |
506      __gen_uint(values->RoundDisableFunctionDisable, 15, 15) |
507      __gen_uint(values->BackfaceStencilReferenceValue, 16, 23) |
508      __gen_uint(values->StencilReferenceValue, 24, 31);
509
510   dw[1] =
511      __gen_uint(values->AlphaReferenceValueAsUNORM8, 0, 31) |
512      __gen_float(values->AlphaReferenceValueAsFLOAT32);
513
514   dw[2] =
515      __gen_float(values->BlendConstantColorRed);
516
517   dw[3] =
518      __gen_float(values->BlendConstantColorGreen);
519
520   dw[4] =
521      __gen_float(values->BlendConstantColorBlue);
522
523   dw[5] =
524      __gen_float(values->BlendConstantColorAlpha);
525}
526
527#define GFX6_DEPTH_STENCIL_STATE_length        3
528struct GFX6_DEPTH_STENCIL_STATE {
529   enum GFX6_3D_Stencil_Operation       BackfaceStencilPassDepthPassOp;
530   enum GFX6_3D_Stencil_Operation       BackfaceStencilPassDepthFailOp;
531   enum GFX6_3D_Stencil_Operation       BackfaceStencilFailOp;
532   enum GFX6_3D_Compare_Function        BackfaceStencilTestFunction;
533   bool                                 DoubleSidedStencilEnable;
534   bool                                 StencilBufferWriteEnable;
535   enum GFX6_3D_Stencil_Operation       StencilPassDepthPassOp;
536   enum GFX6_3D_Stencil_Operation       StencilPassDepthFailOp;
537   enum GFX6_3D_Stencil_Operation       StencilFailOp;
538   enum GFX6_3D_Compare_Function        StencilTestFunction;
539   bool                                 StencilTestEnable;
540   uint32_t                             BackfaceStencilWriteMask;
541   uint32_t                             BackfaceStencilTestMask;
542   uint32_t                             StencilWriteMask;
543   uint32_t                             StencilTestMask;
544   bool                                 DepthBufferWriteEnable;
545   enum GFX6_3D_Compare_Function        DepthTestFunction;
546   bool                                 DepthTestEnable;
547};
548
549static inline __attribute__((always_inline)) void
550GFX6_DEPTH_STENCIL_STATE_pack(__attribute__((unused)) __gen_user_data *data,
551                              __attribute__((unused)) void * restrict dst,
552                              __attribute__((unused)) const struct GFX6_DEPTH_STENCIL_STATE * restrict values)
553{
554   uint32_t * restrict dw = (uint32_t * restrict) dst;
555
556   dw[0] =
557      __gen_uint(values->BackfaceStencilPassDepthPassOp, 3, 5) |
558      __gen_uint(values->BackfaceStencilPassDepthFailOp, 6, 8) |
559      __gen_uint(values->BackfaceStencilFailOp, 9, 11) |
560      __gen_uint(values->BackfaceStencilTestFunction, 12, 14) |
561      __gen_uint(values->DoubleSidedStencilEnable, 15, 15) |
562      __gen_uint(values->StencilBufferWriteEnable, 18, 18) |
563      __gen_uint(values->StencilPassDepthPassOp, 19, 21) |
564      __gen_uint(values->StencilPassDepthFailOp, 22, 24) |
565      __gen_uint(values->StencilFailOp, 25, 27) |
566      __gen_uint(values->StencilTestFunction, 28, 30) |
567      __gen_uint(values->StencilTestEnable, 31, 31);
568
569   dw[1] =
570      __gen_uint(values->BackfaceStencilWriteMask, 0, 7) |
571      __gen_uint(values->BackfaceStencilTestMask, 8, 15) |
572      __gen_uint(values->StencilWriteMask, 16, 23) |
573      __gen_uint(values->StencilTestMask, 24, 31);
574
575   dw[2] =
576      __gen_uint(values->DepthBufferWriteEnable, 26, 26) |
577      __gen_uint(values->DepthTestFunction, 27, 29) |
578      __gen_uint(values->DepthTestEnable, 31, 31);
579}
580
581#define GFX6_INTERFACE_DESCRIPTOR_DATA_length      8
582struct GFX6_INTERFACE_DESCRIPTOR_DATA {
583   uint64_t                             KernelStartPointer;
584   bool                                 SoftwareExceptionEnable;
585   bool                                 MaskStackExceptionEnable;
586   bool                                 IllegalOpcodeExceptionEnable;
587   uint32_t                             FloatingPointMode;
588#define IEEE754                                  0
589#define Alternate                                1
590   uint32_t                             ThreadPriority;
591#define NormalPriority                           0
592#define HighPriority                             1
593   bool                                 SingleProgramFlow;
594   uint32_t                             SamplerCount;
595#define Nosamplersused                           0
596#define Between1and4samplersused                 1
597#define Between5and8samplersused                 2
598#define Between9and12samplersused                3
599#define Between13and16samplersused               4
600   uint64_t                             SamplerStatePointer;
601   uint32_t                             BindingTableEntryCount;
602   uint64_t                             BindingTablePointer;
603   uint32_t                             ConstantURBEntryReadOffset;
604   uint32_t                             ConstantURBEntryReadLength;
605   uint32_t                             BarrierID;
606   uint32_t                             BarrierReturnByte;
607   uint32_t                             BarrierReturnGRFOffset;
608};
609
610static inline __attribute__((always_inline)) void
611GFX6_INTERFACE_DESCRIPTOR_DATA_pack(__attribute__((unused)) __gen_user_data *data,
612                                    __attribute__((unused)) void * restrict dst,
613                                    __attribute__((unused)) const struct GFX6_INTERFACE_DESCRIPTOR_DATA * restrict values)
614{
615   uint32_t * restrict dw = (uint32_t * restrict) dst;
616
617   dw[0] =
618      __gen_offset(values->KernelStartPointer, 6, 31);
619
620   dw[1] =
621      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
622      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
623      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
624      __gen_uint(values->FloatingPointMode, 16, 16) |
625      __gen_uint(values->ThreadPriority, 17, 17) |
626      __gen_uint(values->SingleProgramFlow, 18, 18);
627
628   dw[2] =
629      __gen_uint(values->SamplerCount, 2, 4) |
630      __gen_offset(values->SamplerStatePointer, 5, 31);
631
632   dw[3] =
633      __gen_uint(values->BindingTableEntryCount, 0, 4) |
634      __gen_offset(values->BindingTablePointer, 5, 31);
635
636   dw[4] =
637      __gen_uint(values->ConstantURBEntryReadOffset, 0, 15) |
638      __gen_uint(values->ConstantURBEntryReadLength, 16, 31);
639
640   dw[5] =
641      __gen_uint(values->BarrierID, 0, 3) |
642      __gen_uint(values->BarrierReturnByte, 8, 15) |
643      __gen_uint(values->BarrierReturnGRFOffset, 24, 31);
644
645   dw[6] = 0;
646
647   dw[7] = 0;
648}
649
650#define GFX6_MEMORY_OBJECT_CONTROL_STATE_length      1
651struct GFX6_MEMORY_OBJECT_CONTROL_STATE {
652   uint32_t                             CacheabilityControl;
653   uint32_t                             GraphicsDataTypeGFDT;
654};
655
656static inline __attribute__((always_inline)) void
657GFX6_MEMORY_OBJECT_CONTROL_STATE_pack(__attribute__((unused)) __gen_user_data *data,
658                                      __attribute__((unused)) void * restrict dst,
659                                      __attribute__((unused)) const struct GFX6_MEMORY_OBJECT_CONTROL_STATE * restrict values)
660{
661   uint32_t * restrict dw = (uint32_t * restrict) dst;
662
663   dw[0] =
664      __gen_uint(values->CacheabilityControl, 0, 1) |
665      __gen_uint(values->GraphicsDataTypeGFDT, 2, 2);
666}
667
668#define GFX6_PALETTE_ENTRY_length              1
669struct GFX6_PALETTE_ENTRY {
670   uint32_t                             Blue;
671   uint32_t                             Green;
672   uint32_t                             Red;
673   uint32_t                             Alpha;
674};
675
676static inline __attribute__((always_inline)) void
677GFX6_PALETTE_ENTRY_pack(__attribute__((unused)) __gen_user_data *data,
678                        __attribute__((unused)) void * restrict dst,
679                        __attribute__((unused)) const struct GFX6_PALETTE_ENTRY * restrict values)
680{
681   uint32_t * restrict dw = (uint32_t * restrict) dst;
682
683   dw[0] =
684      __gen_uint(values->Blue, 0, 7) |
685      __gen_uint(values->Green, 8, 15) |
686      __gen_uint(values->Red, 16, 23) |
687      __gen_uint(values->Alpha, 24, 31);
688}
689
690#define GFX6_RENDER_SURFACE_STATE_length       6
691struct GFX6_RENDER_SURFACE_STATE {
692   bool                                 CubeFaceEnablePositiveZ;
693   bool                                 CubeFaceEnableNegativeZ;
694   bool                                 CubeFaceEnablePositiveY;
695   bool                                 CubeFaceEnableNegativeY;
696   bool                                 CubeFaceEnablePositiveX;
697   bool                                 CubeFaceEnableNegativeX;
698   uint32_t                             MediaBoundaryPixelMode;
699#define NORMAL_MODE                              0
700#define PROGRESSIVE_FRAME                        2
701#define INTERLACED_FRAME                         3
702   uint32_t                             RenderCacheReadWriteMode;
703#define WRITE_ONLY                               0
704#define READ_WRITE                               1
705   uint32_t                             CubeMapCornerMode;
706#define CUBE_REPLICATE                           0
707#define CUBE_AVERAGE                             1
708   uint32_t                             MIPMapLayoutMode;
709#define MIPLAYOUT_BELOW                          0
710#define MIPLAYOUT_RIGHT                          1
711   uint32_t                             VerticalLineStrideOffset;
712   uint32_t                             VerticalLineStride;
713   uint32_t                             SurfaceFormat;
714   uint32_t                             DataReturnFormat;
715#define DATA_RETURN_FLOAT32                      0
716   uint32_t                             SurfaceType;
717#define SURFTYPE_1D                              0
718#define SURFTYPE_2D                              1
719#define SURFTYPE_3D                              2
720#define SURFTYPE_CUBE                            3
721#define SURFTYPE_BUFFER                          4
722#define SURFTYPE_NULL                            7
723   __gen_address_type                   SurfaceBaseAddress;
724   uint32_t                             RenderTargetRotation;
725#define RTROTATE_0DEG                            0
726#define RTROTATE_90DEG                           1
727#define RTROTATE_270DEG                          3
728   uint32_t                             MIPCountLOD;
729   uint32_t                             Width;
730   uint32_t                             Height;
731   uint32_t                             TileWalk;
732#define TILEWALK_XMAJOR                          0
733#define TILEWALK_YMAJOR                          1
734   bool                                 TiledSurface;
735   uint32_t                             SurfacePitch;
736   uint32_t                             Depth;
737   uint32_t                             MultisamplePositionPaletteIndex;
738   uint32_t                             NumberofMultisamples;
739#define MULTISAMPLECOUNT_1                       0
740#define MULTISAMPLECOUNT_4                       2
741   uint32_t                             RenderTargetViewExtent;
742   uint32_t                             MinimumArrayElement;
743   uint32_t                             SurfaceMinLOD;
744   uint32_t                             MOCS;
745   uint32_t                             YOffset;
746   uint32_t                             SurfaceVerticalAlignment;
747#define VALIGN_2                                 0
748#define VALIGN_4                                 1
749   uint32_t                             XOffset;
750};
751
752static inline __attribute__((always_inline)) void
753GFX6_RENDER_SURFACE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
754                               __attribute__((unused)) void * restrict dst,
755                               __attribute__((unused)) const struct GFX6_RENDER_SURFACE_STATE * restrict values)
756{
757   uint32_t * restrict dw = (uint32_t * restrict) dst;
758
759   dw[0] =
760      __gen_uint(values->CubeFaceEnablePositiveZ, 0, 0) |
761      __gen_uint(values->CubeFaceEnableNegativeZ, 1, 1) |
762      __gen_uint(values->CubeFaceEnablePositiveY, 2, 2) |
763      __gen_uint(values->CubeFaceEnableNegativeY, 3, 3) |
764      __gen_uint(values->CubeFaceEnablePositiveX, 4, 4) |
765      __gen_uint(values->CubeFaceEnableNegativeX, 5, 5) |
766      __gen_uint(values->MediaBoundaryPixelMode, 6, 7) |
767      __gen_uint(values->RenderCacheReadWriteMode, 8, 8) |
768      __gen_uint(values->CubeMapCornerMode, 9, 9) |
769      __gen_uint(values->MIPMapLayoutMode, 10, 10) |
770      __gen_uint(values->VerticalLineStrideOffset, 11, 11) |
771      __gen_uint(values->VerticalLineStride, 12, 12) |
772      __gen_uint(values->SurfaceFormat, 18, 26) |
773      __gen_uint(values->DataReturnFormat, 27, 27) |
774      __gen_uint(values->SurfaceType, 29, 31);
775
776   dw[1] = __gen_address(data, &dw[1], values->SurfaceBaseAddress, 0, 0, 31);
777
778   dw[2] =
779      __gen_uint(values->RenderTargetRotation, 0, 1) |
780      __gen_uint(values->MIPCountLOD, 2, 5) |
781      __gen_uint(values->Width, 6, 18) |
782      __gen_uint(values->Height, 19, 31);
783
784   dw[3] =
785      __gen_uint(values->TileWalk, 0, 0) |
786      __gen_uint(values->TiledSurface, 1, 1) |
787      __gen_uint(values->SurfacePitch, 3, 19) |
788      __gen_uint(values->Depth, 21, 31);
789
790   dw[4] =
791      __gen_uint(values->MultisamplePositionPaletteIndex, 0, 2) |
792      __gen_uint(values->NumberofMultisamples, 4, 6) |
793      __gen_uint(values->RenderTargetViewExtent, 8, 16) |
794      __gen_uint(values->MinimumArrayElement, 17, 27) |
795      __gen_uint(values->SurfaceMinLOD, 28, 31);
796
797   dw[5] =
798      __gen_uint(values->MOCS, 16, 19) |
799      __gen_uint(values->YOffset, 20, 23) |
800      __gen_uint(values->SurfaceVerticalAlignment, 24, 24) |
801      __gen_uint(values->XOffset, 25, 31);
802}
803
804#define GFX6_SAMPLER_BORDER_COLOR_STATE_length     12
805struct GFX6_SAMPLER_BORDER_COLOR_STATE {
806   uint32_t                             BorderColorUnormRed;
807   uint32_t                             BorderColorUnormGreen;
808   uint32_t                             BorderColorUnormBlue;
809   uint32_t                             BorderColorUnormAlpha;
810   float                                BorderColorFloatRed;
811   float                                BorderColorFloatGreen;
812   float                                BorderColorFloatBlue;
813   float                                BorderColorFloatAlpha;
814   uint32_t                             BorderColorFloat16Red;
815   uint32_t                             BorderColorFloat16Green;
816   uint32_t                             BorderColorFloat16Blue;
817   uint32_t                             BorderColorFloat16Alpha;
818   uint32_t                             BorderColorUnorm16Red;
819   uint32_t                             BorderColorUnorm16Green;
820   uint32_t                             BorderColorUnorm16Blue;
821   uint32_t                             BorderColorUnorm16Alpha;
822   int32_t                              BorderColorSnorm16Red;
823   int32_t                              BorderColorSnorm16Green;
824   int32_t                              BorderColorSnorm16Blue;
825   int32_t                              BorderColorSnorm16Alpha;
826   int32_t                              BorderColorSnorm8Red;
827   int32_t                              BorderColorSnorm8Green;
828   int32_t                              BorderColorSnorm8Blue;
829   int32_t                              BorderColorSnorm8Alpha;
830};
831
832static inline __attribute__((always_inline)) void
833GFX6_SAMPLER_BORDER_COLOR_STATE_pack(__attribute__((unused)) __gen_user_data *data,
834                                     __attribute__((unused)) void * restrict dst,
835                                     __attribute__((unused)) const struct GFX6_SAMPLER_BORDER_COLOR_STATE * restrict values)
836{
837   uint32_t * restrict dw = (uint32_t * restrict) dst;
838
839   dw[0] =
840      __gen_uint(values->BorderColorUnormRed, 0, 7) |
841      __gen_uint(values->BorderColorUnormGreen, 8, 15) |
842      __gen_uint(values->BorderColorUnormBlue, 16, 23) |
843      __gen_uint(values->BorderColorUnormAlpha, 24, 31);
844
845   dw[1] =
846      __gen_float(values->BorderColorFloatRed);
847
848   dw[2] =
849      __gen_float(values->BorderColorFloatGreen);
850
851   dw[3] =
852      __gen_float(values->BorderColorFloatBlue);
853
854   dw[4] =
855      __gen_float(values->BorderColorFloatAlpha);
856
857   dw[5] =
858      __gen_uint(values->BorderColorFloat16Red, 0, 15) |
859      __gen_uint(values->BorderColorFloat16Green, 16, 31);
860
861   dw[6] =
862      __gen_uint(values->BorderColorFloat16Blue, 0, 15) |
863      __gen_uint(values->BorderColorFloat16Alpha, 16, 31);
864
865   dw[7] =
866      __gen_uint(values->BorderColorUnorm16Red, 0, 15) |
867      __gen_uint(values->BorderColorUnorm16Green, 16, 31);
868
869   dw[8] =
870      __gen_uint(values->BorderColorUnorm16Blue, 0, 15) |
871      __gen_uint(values->BorderColorUnorm16Alpha, 16, 31);
872
873   dw[9] =
874      __gen_sint(values->BorderColorSnorm16Red, 0, 15) |
875      __gen_sint(values->BorderColorSnorm16Green, 16, 31);
876
877   dw[10] =
878      __gen_sint(values->BorderColorSnorm16Blue, 0, 15) |
879      __gen_sint(values->BorderColorSnorm16Alpha, 16, 31);
880
881   dw[11] =
882      __gen_sint(values->BorderColorSnorm8Red, 0, 7) |
883      __gen_sint(values->BorderColorSnorm8Green, 8, 15) |
884      __gen_sint(values->BorderColorSnorm8Blue, 16, 23) |
885      __gen_sint(values->BorderColorSnorm8Alpha, 24, 31);
886}
887
888#define GFX6_SAMPLER_STATE_length              4
889struct GFX6_SAMPLER_STATE {
890   uint32_t                             ShadowFunction;
891#define PREFILTEROP_ALWAYS                       0
892#define PREFILTEROP_NEVER                        1
893#define PREFILTEROP_LESS                         2
894#define PREFILTEROP_EQUAL                        3
895#define PREFILTEROP_LEQUAL                       4
896#define PREFILTEROP_GREATER                      5
897#define PREFILTEROP_NOTEQUAL                     6
898#define PREFILTEROP_GEQUAL                       7
899   float                                TextureLODBias;
900   uint32_t                             MinModeFilter;
901   uint32_t                             MagModeFilter;
902#define MAPFILTER_NEAREST                        0
903#define MAPFILTER_LINEAR                         1
904#define MAPFILTER_ANISOTROPIC                    2
905#define MAPFILTER_MONO                           6
906   uint32_t                             MipModeFilter;
907#define MIPFILTER_NONE                           0
908#define MIPFILTER_NEAREST                        1
909#define MIPFILTER_LINEAR                         3
910   float                                BaseMipLevel;
911   uint32_t                             MinandMagStateNotEqual;
912#define MIN_MAG_EQ                               0
913#define MIN_MAG_NEQ                              1
914   uint32_t                             LODPreClampEnable;
915#define CLAMP_ENABLE_OGL                         1
916   uint32_t                             TextureBorderColorMode;
917#define DX10OGL                                  0
918#define DX9                                      1
919   bool                                 SamplerDisable;
920   enum GFX6_TextureCoordinateMode      TCZAddressControlMode;
921   enum GFX6_TextureCoordinateMode      TCYAddressControlMode;
922   enum GFX6_TextureCoordinateMode      TCXAddressControlMode;
923   uint32_t                             CubeSurfaceControlMode;
924#define CUBECTRLMODE_PROGRAMMED                  0
925#define CUBECTRLMODE_OVERRIDE                    1
926   float                                MaxLOD;
927   float                                MinLOD;
928   uint64_t                             BorderColorPointer;
929   bool                                 NonnormalizedCoordinateEnable;
930   bool                                 RAddressMinFilterRoundingEnable;
931   bool                                 RAddressMagFilterRoundingEnable;
932   bool                                 VAddressMinFilterRoundingEnable;
933   bool                                 VAddressMagFilterRoundingEnable;
934   bool                                 UAddressMinFilterRoundingEnable;
935   bool                                 UAddressMagFilterRoundingEnable;
936   uint32_t                             MaximumAnisotropy;
937#define RATIO21                                  0
938#define RATIO41                                  1
939#define RATIO61                                  2
940#define RATIO81                                  3
941#define RATIO101                                 4
942#define RATIO121                                 5
943#define RATIO141                                 6
944#define RATIO161                                 7
945   uint32_t                             ChromaKeyMode;
946#define KEYFILTER_KILL_ON_ANY_MATCH              0
947#define KEYFILTER_REPLACE_BLACK                  1
948   uint32_t                             ChromaKeyIndex;
949   bool                                 ChromaKeyEnable;
950   uint32_t                             MonochromeFilterWidth;
951   uint32_t                             MonochromeFilterHeightReserved;
952};
953
954static inline __attribute__((always_inline)) void
955GFX6_SAMPLER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
956                        __attribute__((unused)) void * restrict dst,
957                        __attribute__((unused)) const struct GFX6_SAMPLER_STATE * restrict values)
958{
959   uint32_t * restrict dw = (uint32_t * restrict) dst;
960
961   dw[0] =
962      __gen_uint(values->ShadowFunction, 0, 2) |
963      __gen_sfixed(values->TextureLODBias, 3, 13, 6) |
964      __gen_uint(values->MinModeFilter, 14, 16) |
965      __gen_uint(values->MagModeFilter, 17, 19) |
966      __gen_uint(values->MipModeFilter, 20, 21) |
967      __gen_ufixed(values->BaseMipLevel, 22, 26, 1) |
968      __gen_uint(values->MinandMagStateNotEqual, 27, 27) |
969      __gen_uint(values->LODPreClampEnable, 28, 28) |
970      __gen_uint(values->TextureBorderColorMode, 29, 29) |
971      __gen_uint(values->SamplerDisable, 31, 31);
972
973   dw[1] =
974      __gen_uint(values->TCZAddressControlMode, 0, 2) |
975      __gen_uint(values->TCYAddressControlMode, 3, 5) |
976      __gen_uint(values->TCXAddressControlMode, 6, 8) |
977      __gen_uint(values->CubeSurfaceControlMode, 9, 9) |
978      __gen_ufixed(values->MaxLOD, 12, 21, 6) |
979      __gen_ufixed(values->MinLOD, 22, 31, 6);
980
981   dw[2] =
982      __gen_offset(values->BorderColorPointer, 5, 31);
983
984   dw[3] =
985      __gen_uint(values->NonnormalizedCoordinateEnable, 0, 0) |
986      __gen_uint(values->RAddressMinFilterRoundingEnable, 13, 13) |
987      __gen_uint(values->RAddressMagFilterRoundingEnable, 14, 14) |
988      __gen_uint(values->VAddressMinFilterRoundingEnable, 15, 15) |
989      __gen_uint(values->VAddressMagFilterRoundingEnable, 16, 16) |
990      __gen_uint(values->UAddressMinFilterRoundingEnable, 17, 17) |
991      __gen_uint(values->UAddressMagFilterRoundingEnable, 18, 18) |
992      __gen_uint(values->MaximumAnisotropy, 19, 21) |
993      __gen_uint(values->ChromaKeyMode, 22, 22) |
994      __gen_uint(values->ChromaKeyIndex, 23, 24) |
995      __gen_uint(values->ChromaKeyEnable, 25, 25) |
996      __gen_uint(values->MonochromeFilterWidth, 26, 28) |
997      __gen_uint(values->MonochromeFilterHeightReserved, 29, 31);
998}
999
1000#define GFX6_SCISSOR_RECT_length               2
1001struct GFX6_SCISSOR_RECT {
1002   uint32_t                             ScissorRectangleXMin;
1003   uint32_t                             ScissorRectangleYMin;
1004   uint32_t                             ScissorRectangleXMax;
1005   uint32_t                             ScissorRectangleYMax;
1006};
1007
1008static inline __attribute__((always_inline)) void
1009GFX6_SCISSOR_RECT_pack(__attribute__((unused)) __gen_user_data *data,
1010                       __attribute__((unused)) void * restrict dst,
1011                       __attribute__((unused)) const struct GFX6_SCISSOR_RECT * restrict values)
1012{
1013   uint32_t * restrict dw = (uint32_t * restrict) dst;
1014
1015   dw[0] =
1016      __gen_uint(values->ScissorRectangleXMin, 0, 15) |
1017      __gen_uint(values->ScissorRectangleYMin, 16, 31);
1018
1019   dw[1] =
1020      __gen_uint(values->ScissorRectangleXMax, 0, 15) |
1021      __gen_uint(values->ScissorRectangleYMax, 16, 31);
1022}
1023
1024#define GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_length      1
1025struct GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL {
1026   uint32_t                             SourceAttribute;
1027   uint32_t                             SwizzleSelect;
1028#define INPUTATTR                                0
1029#define INPUTATTR_FACING                         1
1030#define INPUTATTR_W                              2
1031#define INPUTATTR_FACING_W                       3
1032   uint32_t                             ConstantSource;
1033#define CONST_0000                               0
1034#define CONST_0001_FLOAT                         1
1035#define CONST_1111_FLOAT                         2
1036#define PRIM_ID                                  3
1037   uint32_t                             SwizzleControlMode;
1038   bool                                 ComponentOverrideX;
1039   bool                                 ComponentOverrideY;
1040   bool                                 ComponentOverrideZ;
1041   bool                                 ComponentOverrideW;
1042};
1043
1044static inline __attribute__((always_inline)) void
1045GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(__attribute__((unused)) __gen_user_data *data,
1046                                     __attribute__((unused)) void * restrict dst,
1047                                     __attribute__((unused)) const struct GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL * restrict values)
1048{
1049   uint32_t * restrict dw = (uint32_t * restrict) dst;
1050
1051   dw[0] =
1052      __gen_uint(values->SourceAttribute, 0, 4) |
1053      __gen_uint(values->SwizzleSelect, 6, 7) |
1054      __gen_uint(values->ConstantSource, 9, 10) |
1055      __gen_uint(values->SwizzleControlMode, 11, 11) |
1056      __gen_uint(values->ComponentOverrideX, 12, 12) |
1057      __gen_uint(values->ComponentOverrideY, 13, 13) |
1058      __gen_uint(values->ComponentOverrideZ, 14, 14) |
1059      __gen_uint(values->ComponentOverrideW, 15, 15);
1060}
1061
1062#define GFX6_SF_VIEWPORT_length                8
1063struct GFX6_SF_VIEWPORT {
1064   float                                ViewportMatrixElementm00;
1065   float                                ViewportMatrixElementm11;
1066   float                                ViewportMatrixElementm22;
1067#define ExcludesDWord01                          0
1068   float                                ViewportMatrixElementm30;
1069   float                                ViewportMatrixElementm31;
1070   float                                ViewportMatrixElementm32;
1071};
1072
1073static inline __attribute__((always_inline)) void
1074GFX6_SF_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
1075                      __attribute__((unused)) void * restrict dst,
1076                      __attribute__((unused)) const struct GFX6_SF_VIEWPORT * restrict values)
1077{
1078   uint32_t * restrict dw = (uint32_t * restrict) dst;
1079
1080   dw[0] =
1081      __gen_float(values->ViewportMatrixElementm00);
1082
1083   dw[1] =
1084      __gen_float(values->ViewportMatrixElementm11);
1085
1086   dw[2] =
1087      __gen_float(values->ViewportMatrixElementm22);
1088
1089   dw[3] =
1090      __gen_float(values->ViewportMatrixElementm30);
1091
1092   dw[4] =
1093      __gen_float(values->ViewportMatrixElementm31);
1094
1095   dw[5] =
1096      __gen_float(values->ViewportMatrixElementm32);
1097
1098   dw[6] = 0;
1099
1100   dw[7] = 0;
1101}
1102
1103#define GFX6_VERTEX_BUFFER_STATE_length        4
1104struct GFX6_VERTEX_BUFFER_STATE {
1105   uint32_t                             BufferPitch;
1106   bool                                 VertexFetchInvalidate;
1107   bool                                 NullVertexBuffer;
1108   uint32_t                             MOCS;
1109   uint32_t                             BufferAccessType;
1110#define VERTEXDATA                               0
1111#define INSTANCEDATA                             1
1112   uint32_t                             VertexBufferIndex;
1113   __gen_address_type                   BufferStartingAddress;
1114   __gen_address_type                   EndAddress;
1115   uint32_t                             InstanceDataStepRate;
1116};
1117
1118static inline __attribute__((always_inline)) void
1119GFX6_VERTEX_BUFFER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1120                              __attribute__((unused)) void * restrict dst,
1121                              __attribute__((unused)) const struct GFX6_VERTEX_BUFFER_STATE * restrict values)
1122{
1123   uint32_t * restrict dw = (uint32_t * restrict) dst;
1124
1125   dw[0] =
1126      __gen_uint(values->BufferPitch, 0, 11) |
1127      __gen_uint(values->VertexFetchInvalidate, 12, 12) |
1128      __gen_uint(values->NullVertexBuffer, 13, 13) |
1129      __gen_uint(values->MOCS, 16, 19) |
1130      __gen_uint(values->BufferAccessType, 20, 20) |
1131      __gen_uint(values->VertexBufferIndex, 26, 31);
1132
1133   dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, 0, 0, 31);
1134
1135   dw[2] = __gen_address(data, &dw[2], values->EndAddress, 0, 0, 31);
1136
1137   dw[3] =
1138      __gen_uint(values->InstanceDataStepRate, 0, 31);
1139}
1140
1141#define GFX6_VERTEX_ELEMENT_STATE_length       2
1142struct GFX6_VERTEX_ELEMENT_STATE {
1143   uint32_t                             SourceElementOffset;
1144   bool                                 EdgeFlagEnable;
1145   uint32_t                             SourceElementFormat;
1146   bool                                 Valid;
1147   uint32_t                             VertexBufferIndex;
1148   enum GFX6_3D_Vertex_Component_Control Component3Control;
1149   enum GFX6_3D_Vertex_Component_Control Component2Control;
1150   enum GFX6_3D_Vertex_Component_Control Component1Control;
1151   enum GFX6_3D_Vertex_Component_Control Component0Control;
1152};
1153
1154static inline __attribute__((always_inline)) void
1155GFX6_VERTEX_ELEMENT_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1156                               __attribute__((unused)) void * restrict dst,
1157                               __attribute__((unused)) const struct GFX6_VERTEX_ELEMENT_STATE * restrict values)
1158{
1159   uint32_t * restrict dw = (uint32_t * restrict) dst;
1160
1161   dw[0] =
1162      __gen_uint(values->SourceElementOffset, 0, 11) |
1163      __gen_uint(values->EdgeFlagEnable, 15, 15) |
1164      __gen_uint(values->SourceElementFormat, 16, 24) |
1165      __gen_uint(values->Valid, 25, 25) |
1166      __gen_uint(values->VertexBufferIndex, 26, 31);
1167
1168   dw[1] =
1169      __gen_uint(values->Component3Control, 16, 18) |
1170      __gen_uint(values->Component2Control, 20, 22) |
1171      __gen_uint(values->Component1Control, 24, 26) |
1172      __gen_uint(values->Component0Control, 28, 30);
1173}
1174
1175#define GFX6_3DPRIMITIVE_length                6
1176#define GFX6_3DPRIMITIVE_length_bias           2
1177#define GFX6_3DPRIMITIVE_header                 \
1178   .DWordLength                         =      4,  \
1179   ._3DCommandSubOpcode                 =      0,  \
1180   ._3DCommandOpcode                    =      3,  \
1181   .CommandSubType                      =      3,  \
1182   .CommandType                         =      3
1183
1184struct GFX6_3DPRIMITIVE {
1185   uint32_t                             DWordLength;
1186   uint32_t                             InternalVertexCount;
1187   enum GFX6_3D_Prim_Topo_Type          PrimitiveTopologyType;
1188   uint32_t                             VertexAccessType;
1189#define SEQUENTIAL                               0
1190#define RANDOM                                   1
1191   uint32_t                             _3DCommandSubOpcode;
1192   uint32_t                             _3DCommandOpcode;
1193   uint32_t                             CommandSubType;
1194   uint32_t                             CommandType;
1195   uint32_t                             VertexCountPerInstance;
1196   uint32_t                             StartVertexLocation;
1197   uint32_t                             InstanceCount;
1198#define UNDEFINED                                0
1199#define noninstancedoperation                    1
1200   uint32_t                             StartInstanceLocation;
1201   int32_t                              BaseVertexLocation;
1202};
1203
1204static inline __attribute__((always_inline)) void
1205GFX6_3DPRIMITIVE_pack(__attribute__((unused)) __gen_user_data *data,
1206                      __attribute__((unused)) void * restrict dst,
1207                      __attribute__((unused)) const struct GFX6_3DPRIMITIVE * restrict values)
1208{
1209   uint32_t * restrict dw = (uint32_t * restrict) dst;
1210
1211   dw[0] =
1212      __gen_uint(values->DWordLength, 0, 7) |
1213      __gen_uint(values->InternalVertexCount, 9, 9) |
1214      __gen_uint(values->PrimitiveTopologyType, 10, 14) |
1215      __gen_uint(values->VertexAccessType, 15, 15) |
1216      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1217      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1218      __gen_uint(values->CommandSubType, 27, 28) |
1219      __gen_uint(values->CommandType, 29, 31);
1220
1221   dw[1] =
1222      __gen_uint(values->VertexCountPerInstance, 0, 31);
1223
1224   dw[2] =
1225      __gen_uint(values->StartVertexLocation, 0, 31);
1226
1227   dw[3] =
1228      __gen_uint(values->InstanceCount, 0, 31);
1229
1230   dw[4] =
1231      __gen_uint(values->StartInstanceLocation, 0, 31);
1232
1233   dw[5] =
1234      __gen_sint(values->BaseVertexLocation, 0, 31);
1235}
1236
1237#define GFX6_3DSTATE_AA_LINE_PARAMETERS_length      3
1238#define GFX6_3DSTATE_AA_LINE_PARAMETERS_length_bias      2
1239#define GFX6_3DSTATE_AA_LINE_PARAMETERS_header  \
1240   .DWordLength                         =      1,  \
1241   ._3DCommandSubOpcode                 =     10,  \
1242   ._3DCommandOpcode                    =      1,  \
1243   .CommandSubType                      =      3,  \
1244   .CommandType                         =      3
1245
1246struct GFX6_3DSTATE_AA_LINE_PARAMETERS {
1247   uint32_t                             DWordLength;
1248   uint32_t                             _3DCommandSubOpcode;
1249   uint32_t                             _3DCommandOpcode;
1250   uint32_t                             CommandSubType;
1251   uint32_t                             CommandType;
1252   float                                AACoverageSlope;
1253   float                                AACoverageBias;
1254   float                                AACoverageEndCapSlope;
1255   float                                AACoverageEndCapBias;
1256};
1257
1258static inline __attribute__((always_inline)) void
1259GFX6_3DSTATE_AA_LINE_PARAMETERS_pack(__attribute__((unused)) __gen_user_data *data,
1260                                     __attribute__((unused)) void * restrict dst,
1261                                     __attribute__((unused)) const struct GFX6_3DSTATE_AA_LINE_PARAMETERS * restrict values)
1262{
1263   uint32_t * restrict dw = (uint32_t * restrict) dst;
1264
1265   dw[0] =
1266      __gen_uint(values->DWordLength, 0, 7) |
1267      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1268      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1269      __gen_uint(values->CommandSubType, 27, 28) |
1270      __gen_uint(values->CommandType, 29, 31);
1271
1272   dw[1] =
1273      __gen_ufixed(values->AACoverageSlope, 0, 7, 8) |
1274      __gen_ufixed(values->AACoverageBias, 16, 23, 8);
1275
1276   dw[2] =
1277      __gen_ufixed(values->AACoverageEndCapSlope, 0, 7, 8) |
1278      __gen_ufixed(values->AACoverageEndCapBias, 16, 23, 8);
1279}
1280
1281#define GFX6_3DSTATE_BINDING_TABLE_POINTERS_length      4
1282#define GFX6_3DSTATE_BINDING_TABLE_POINTERS_length_bias      2
1283#define GFX6_3DSTATE_BINDING_TABLE_POINTERS_header\
1284   .DWordLength                         =      2,  \
1285   ._3DCommandSubOpcode                 =      1,  \
1286   ._3DCommandOpcode                    =      0,  \
1287   .CommandSubType                      =      3,  \
1288   .CommandType                         =      3
1289
1290struct GFX6_3DSTATE_BINDING_TABLE_POINTERS {
1291   uint32_t                             DWordLength;
1292   bool                                 VSBindingTableChange;
1293   bool                                 GSBindingTableChange;
1294   bool                                 PSBindingTableChange;
1295   uint32_t                             _3DCommandSubOpcode;
1296   uint32_t                             _3DCommandOpcode;
1297   uint32_t                             CommandSubType;
1298   uint32_t                             CommandType;
1299   uint64_t                             PointertoVSBindingTable;
1300   uint64_t                             PointertoGSBindingTable;
1301   uint64_t                             PointertoPSBindingTable;
1302};
1303
1304static inline __attribute__((always_inline)) void
1305GFX6_3DSTATE_BINDING_TABLE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
1306                                         __attribute__((unused)) void * restrict dst,
1307                                         __attribute__((unused)) const struct GFX6_3DSTATE_BINDING_TABLE_POINTERS * restrict values)
1308{
1309   uint32_t * restrict dw = (uint32_t * restrict) dst;
1310
1311   dw[0] =
1312      __gen_uint(values->DWordLength, 0, 7) |
1313      __gen_uint(values->VSBindingTableChange, 8, 8) |
1314      __gen_uint(values->GSBindingTableChange, 9, 9) |
1315      __gen_uint(values->PSBindingTableChange, 12, 12) |
1316      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1317      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1318      __gen_uint(values->CommandSubType, 27, 28) |
1319      __gen_uint(values->CommandType, 29, 31);
1320
1321   dw[1] =
1322      __gen_offset(values->PointertoVSBindingTable, 5, 31);
1323
1324   dw[2] =
1325      __gen_offset(values->PointertoGSBindingTable, 5, 31);
1326
1327   dw[3] =
1328      __gen_offset(values->PointertoPSBindingTable, 5, 31);
1329}
1330
1331#define GFX6_3DSTATE_CC_STATE_POINTERS_length      4
1332#define GFX6_3DSTATE_CC_STATE_POINTERS_length_bias      2
1333#define GFX6_3DSTATE_CC_STATE_POINTERS_header   \
1334   .DWordLength                         =      2,  \
1335   ._3DCommandSubOpcode                 =     14,  \
1336   ._3DCommandOpcode                    =      0,  \
1337   .CommandSubType                      =      3,  \
1338   .CommandType                         =      3
1339
1340struct GFX6_3DSTATE_CC_STATE_POINTERS {
1341   uint32_t                             DWordLength;
1342   uint32_t                             _3DCommandSubOpcode;
1343   uint32_t                             _3DCommandOpcode;
1344   uint32_t                             CommandSubType;
1345   uint32_t                             CommandType;
1346   bool                                 BLEND_STATEChange;
1347   uint64_t                             PointertoBLEND_STATE;
1348   bool                                 DEPTH_STENCIL_STATEChange;
1349   uint64_t                             PointertoDEPTH_STENCIL_STATE;
1350   bool                                 ColorCalcStatePointerValid;
1351   uint64_t                             ColorCalcStatePointer;
1352};
1353
1354static inline __attribute__((always_inline)) void
1355GFX6_3DSTATE_CC_STATE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
1356                                    __attribute__((unused)) void * restrict dst,
1357                                    __attribute__((unused)) const struct GFX6_3DSTATE_CC_STATE_POINTERS * restrict values)
1358{
1359   uint32_t * restrict dw = (uint32_t * restrict) dst;
1360
1361   dw[0] =
1362      __gen_uint(values->DWordLength, 0, 7) |
1363      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1364      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1365      __gen_uint(values->CommandSubType, 27, 28) |
1366      __gen_uint(values->CommandType, 29, 31);
1367
1368   dw[1] =
1369      __gen_uint(values->BLEND_STATEChange, 0, 0) |
1370      __gen_offset(values->PointertoBLEND_STATE, 6, 31);
1371
1372   dw[2] =
1373      __gen_uint(values->DEPTH_STENCIL_STATEChange, 0, 0) |
1374      __gen_offset(values->PointertoDEPTH_STENCIL_STATE, 6, 31);
1375
1376   dw[3] =
1377      __gen_uint(values->ColorCalcStatePointerValid, 0, 0) |
1378      __gen_offset(values->ColorCalcStatePointer, 6, 31);
1379}
1380
1381#define GFX6_3DSTATE_CHROMA_KEY_length         4
1382#define GFX6_3DSTATE_CHROMA_KEY_length_bias      2
1383#define GFX6_3DSTATE_CHROMA_KEY_header          \
1384   .DWordLength                         =      2,  \
1385   ._3DCommandSubOpcode                 =      4,  \
1386   ._3DCommandOpcode                    =      1,  \
1387   .CommandSubType                      =      3,  \
1388   .CommandType                         =      3
1389
1390struct GFX6_3DSTATE_CHROMA_KEY {
1391   uint32_t                             DWordLength;
1392   uint32_t                             _3DCommandSubOpcode;
1393   uint32_t                             _3DCommandOpcode;
1394   uint32_t                             CommandSubType;
1395   uint32_t                             CommandType;
1396   uint32_t                             ChromaKeyTableIndex;
1397   uint32_t                             ChromaKeyLowValue;
1398   uint32_t                             ChromaKeyHighValue;
1399};
1400
1401static inline __attribute__((always_inline)) void
1402GFX6_3DSTATE_CHROMA_KEY_pack(__attribute__((unused)) __gen_user_data *data,
1403                             __attribute__((unused)) void * restrict dst,
1404                             __attribute__((unused)) const struct GFX6_3DSTATE_CHROMA_KEY * restrict values)
1405{
1406   uint32_t * restrict dw = (uint32_t * restrict) dst;
1407
1408   dw[0] =
1409      __gen_uint(values->DWordLength, 0, 7) |
1410      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1411      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1412      __gen_uint(values->CommandSubType, 27, 28) |
1413      __gen_uint(values->CommandType, 29, 31);
1414
1415   dw[1] =
1416      __gen_uint(values->ChromaKeyTableIndex, 30, 31);
1417
1418   dw[2] =
1419      __gen_uint(values->ChromaKeyLowValue, 0, 31);
1420
1421   dw[3] =
1422      __gen_uint(values->ChromaKeyHighValue, 0, 31);
1423}
1424
1425#define GFX6_3DSTATE_CLEAR_PARAMS_length       2
1426#define GFX6_3DSTATE_CLEAR_PARAMS_length_bias      2
1427#define GFX6_3DSTATE_CLEAR_PARAMS_header        \
1428   .DWordLength                         =      0,  \
1429   ._3DCommandSubOpcode                 =     16,  \
1430   ._3DCommandOpcode                    =      1,  \
1431   .CommandSubType                      =      3,  \
1432   .CommandType                         =      3
1433
1434struct GFX6_3DSTATE_CLEAR_PARAMS {
1435   uint32_t                             DWordLength;
1436   bool                                 DepthClearValueValid;
1437   uint32_t                             _3DCommandSubOpcode;
1438   uint32_t                             _3DCommandOpcode;
1439   uint32_t                             CommandSubType;
1440   uint32_t                             CommandType;
1441   uint32_t                             DepthClearValue;
1442};
1443
1444static inline __attribute__((always_inline)) void
1445GFX6_3DSTATE_CLEAR_PARAMS_pack(__attribute__((unused)) __gen_user_data *data,
1446                               __attribute__((unused)) void * restrict dst,
1447                               __attribute__((unused)) const struct GFX6_3DSTATE_CLEAR_PARAMS * restrict values)
1448{
1449   uint32_t * restrict dw = (uint32_t * restrict) dst;
1450
1451   dw[0] =
1452      __gen_uint(values->DWordLength, 0, 7) |
1453      __gen_uint(values->DepthClearValueValid, 15, 15) |
1454      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1455      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1456      __gen_uint(values->CommandSubType, 27, 28) |
1457      __gen_uint(values->CommandType, 29, 31);
1458
1459   dw[1] =
1460      __gen_uint(values->DepthClearValue, 0, 31);
1461}
1462
1463#define GFX6_3DSTATE_CLIP_length               4
1464#define GFX6_3DSTATE_CLIP_length_bias          2
1465#define GFX6_3DSTATE_CLIP_header                \
1466   .DWordLength                         =      2,  \
1467   ._3DCommandSubOpcode                 =     18,  \
1468   ._3DCommandOpcode                    =      0,  \
1469   .CommandSubType                      =      3,  \
1470   .CommandType                         =      3
1471
1472struct GFX6_3DSTATE_CLIP {
1473   uint32_t                             DWordLength;
1474   uint32_t                             _3DCommandSubOpcode;
1475   uint32_t                             _3DCommandOpcode;
1476   uint32_t                             CommandSubType;
1477   uint32_t                             CommandType;
1478   uint32_t                             UserClipDistanceCullTestEnableBitmask;
1479   bool                                 StatisticsEnable;
1480   uint32_t                             TriangleFanProvokingVertexSelect;
1481#define Vertex0                                  0
1482#define Vertex1                                  1
1483#define Vertex2                                  2
1484   uint32_t                             LineStripListProvokingVertexSelect;
1485#define Vertex0                                  0
1486#define Vertex1                                  1
1487   uint32_t                             TriangleStripListProvokingVertexSelect;
1488#define Vertex0                                  0
1489#define Vertex1                                  1
1490#define Vertex2                                  2
1491   bool                                 NonPerspectiveBarycentricEnable;
1492   bool                                 PerspectiveDivideDisable;
1493   uint32_t                             ClipMode;
1494#define CLIPMODE_NORMAL                          0
1495#define CLIPMODE_REJECT_ALL                      3
1496#define CLIPMODE_ACCEPT_ALL                      4
1497   uint32_t                             UserClipDistanceClipTestEnableBitmask;
1498   bool                                 GuardbandClipTestEnable;
1499   bool                                 ViewportZClipTestEnable;
1500   bool                                 ViewportXYClipTestEnable;
1501   uint32_t                             APIMode;
1502#define APIMODE_OGL                              0
1503#define APIMODE_D3D                              1
1504   bool                                 ClipEnable;
1505   uint32_t                             MaximumVPIndex;
1506   bool                                 ForceZeroRTAIndexEnable;
1507   float                                MaximumPointWidth;
1508   float                                MinimumPointWidth;
1509};
1510
1511static inline __attribute__((always_inline)) void
1512GFX6_3DSTATE_CLIP_pack(__attribute__((unused)) __gen_user_data *data,
1513                       __attribute__((unused)) void * restrict dst,
1514                       __attribute__((unused)) const struct GFX6_3DSTATE_CLIP * restrict values)
1515{
1516   uint32_t * restrict dw = (uint32_t * restrict) dst;
1517
1518   dw[0] =
1519      __gen_uint(values->DWordLength, 0, 7) |
1520      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1521      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1522      __gen_uint(values->CommandSubType, 27, 28) |
1523      __gen_uint(values->CommandType, 29, 31);
1524
1525   dw[1] =
1526      __gen_uint(values->UserClipDistanceCullTestEnableBitmask, 0, 7) |
1527      __gen_uint(values->StatisticsEnable, 10, 10);
1528
1529   dw[2] =
1530      __gen_uint(values->TriangleFanProvokingVertexSelect, 0, 1) |
1531      __gen_uint(values->LineStripListProvokingVertexSelect, 2, 3) |
1532      __gen_uint(values->TriangleStripListProvokingVertexSelect, 4, 5) |
1533      __gen_uint(values->NonPerspectiveBarycentricEnable, 8, 8) |
1534      __gen_uint(values->PerspectiveDivideDisable, 9, 9) |
1535      __gen_uint(values->ClipMode, 13, 15) |
1536      __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 16, 23) |
1537      __gen_uint(values->GuardbandClipTestEnable, 26, 26) |
1538      __gen_uint(values->ViewportZClipTestEnable, 27, 27) |
1539      __gen_uint(values->ViewportXYClipTestEnable, 28, 28) |
1540      __gen_uint(values->APIMode, 30, 30) |
1541      __gen_uint(values->ClipEnable, 31, 31);
1542
1543   dw[3] =
1544      __gen_uint(values->MaximumVPIndex, 0, 3) |
1545      __gen_uint(values->ForceZeroRTAIndexEnable, 5, 5) |
1546      __gen_ufixed(values->MaximumPointWidth, 6, 16, 3) |
1547      __gen_ufixed(values->MinimumPointWidth, 17, 27, 3);
1548}
1549
1550#define GFX6_3DSTATE_CONSTANT_GS_length        5
1551#define GFX6_3DSTATE_CONSTANT_GS_length_bias      2
1552#define GFX6_3DSTATE_CONSTANT_GS_header         \
1553   .DWordLength                         =      3,  \
1554   ._3DCommandSubOpcode                 =     22,  \
1555   ._3DCommandOpcode                    =      0,  \
1556   .CommandSubType                      =      3,  \
1557   .CommandType                         =      3
1558
1559struct GFX6_3DSTATE_CONSTANT_GS {
1560   uint32_t                             DWordLength;
1561   uint32_t                             MOCS;
1562   bool                                 Buffer0Valid;
1563   bool                                 Buffer1Valid;
1564   bool                                 Buffer2Valid;
1565   bool                                 Buffer3Valid;
1566   uint32_t                             _3DCommandSubOpcode;
1567   uint32_t                             _3DCommandOpcode;
1568   uint32_t                             CommandSubType;
1569   uint32_t                             CommandType;
1570   struct GFX6_3DSTATE_CONSTANT_BODY    ConstantBody;
1571};
1572
1573static inline __attribute__((always_inline)) void
1574GFX6_3DSTATE_CONSTANT_GS_pack(__attribute__((unused)) __gen_user_data *data,
1575                              __attribute__((unused)) void * restrict dst,
1576                              __attribute__((unused)) const struct GFX6_3DSTATE_CONSTANT_GS * restrict values)
1577{
1578   uint32_t * restrict dw = (uint32_t * restrict) dst;
1579
1580   dw[0] =
1581      __gen_uint(values->DWordLength, 0, 7) |
1582      __gen_uint(values->MOCS, 8, 11) |
1583      __gen_uint(values->Buffer0Valid, 12, 12) |
1584      __gen_uint(values->Buffer1Valid, 13, 13) |
1585      __gen_uint(values->Buffer2Valid, 14, 14) |
1586      __gen_uint(values->Buffer3Valid, 15, 15) |
1587      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1588      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1589      __gen_uint(values->CommandSubType, 27, 28) |
1590      __gen_uint(values->CommandType, 29, 31);
1591
1592   GFX6_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
1593}
1594
1595#define GFX6_3DSTATE_CONSTANT_PS_length        5
1596#define GFX6_3DSTATE_CONSTANT_PS_length_bias      2
1597#define GFX6_3DSTATE_CONSTANT_PS_header         \
1598   .DWordLength                         =      3,  \
1599   ._3DCommandSubOpcode                 =     23,  \
1600   ._3DCommandOpcode                    =      0,  \
1601   .CommandSubType                      =      3,  \
1602   .CommandType                         =      3
1603
1604struct GFX6_3DSTATE_CONSTANT_PS {
1605   uint32_t                             DWordLength;
1606   uint32_t                             MOCS;
1607   bool                                 Buffer0Valid;
1608   bool                                 Buffer1Valid;
1609   bool                                 Buffer2Valid;
1610   bool                                 Buffer3Valid;
1611   uint32_t                             _3DCommandSubOpcode;
1612   uint32_t                             _3DCommandOpcode;
1613   uint32_t                             CommandSubType;
1614   uint32_t                             CommandType;
1615   struct GFX6_3DSTATE_CONSTANT_BODY    ConstantBody;
1616};
1617
1618static inline __attribute__((always_inline)) void
1619GFX6_3DSTATE_CONSTANT_PS_pack(__attribute__((unused)) __gen_user_data *data,
1620                              __attribute__((unused)) void * restrict dst,
1621                              __attribute__((unused)) const struct GFX6_3DSTATE_CONSTANT_PS * restrict values)
1622{
1623   uint32_t * restrict dw = (uint32_t * restrict) dst;
1624
1625   dw[0] =
1626      __gen_uint(values->DWordLength, 0, 7) |
1627      __gen_uint(values->MOCS, 8, 11) |
1628      __gen_uint(values->Buffer0Valid, 12, 12) |
1629      __gen_uint(values->Buffer1Valid, 13, 13) |
1630      __gen_uint(values->Buffer2Valid, 14, 14) |
1631      __gen_uint(values->Buffer3Valid, 15, 15) |
1632      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1633      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1634      __gen_uint(values->CommandSubType, 27, 28) |
1635      __gen_uint(values->CommandType, 29, 31);
1636
1637   GFX6_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
1638}
1639
1640#define GFX6_3DSTATE_CONSTANT_VS_length        5
1641#define GFX6_3DSTATE_CONSTANT_VS_length_bias      2
1642#define GFX6_3DSTATE_CONSTANT_VS_header         \
1643   .DWordLength                         =      3,  \
1644   ._3DCommandSubOpcode                 =     21,  \
1645   ._3DCommandOpcode                    =      0,  \
1646   .CommandSubType                      =      3,  \
1647   .CommandType                         =      3
1648
1649struct GFX6_3DSTATE_CONSTANT_VS {
1650   uint32_t                             DWordLength;
1651   uint32_t                             MOCS;
1652   bool                                 Buffer0Valid;
1653   bool                                 Buffer1Valid;
1654   bool                                 Buffer2Valid;
1655   bool                                 Buffer3Valid;
1656   uint32_t                             _3DCommandSubOpcode;
1657   uint32_t                             _3DCommandOpcode;
1658   uint32_t                             CommandSubType;
1659   uint32_t                             CommandType;
1660   struct GFX6_3DSTATE_CONSTANT_BODY    ConstantBody;
1661};
1662
1663static inline __attribute__((always_inline)) void
1664GFX6_3DSTATE_CONSTANT_VS_pack(__attribute__((unused)) __gen_user_data *data,
1665                              __attribute__((unused)) void * restrict dst,
1666                              __attribute__((unused)) const struct GFX6_3DSTATE_CONSTANT_VS * restrict values)
1667{
1668   uint32_t * restrict dw = (uint32_t * restrict) dst;
1669
1670   dw[0] =
1671      __gen_uint(values->DWordLength, 0, 7) |
1672      __gen_uint(values->MOCS, 8, 11) |
1673      __gen_uint(values->Buffer0Valid, 12, 12) |
1674      __gen_uint(values->Buffer1Valid, 13, 13) |
1675      __gen_uint(values->Buffer2Valid, 14, 14) |
1676      __gen_uint(values->Buffer3Valid, 15, 15) |
1677      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1678      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1679      __gen_uint(values->CommandSubType, 27, 28) |
1680      __gen_uint(values->CommandType, 29, 31);
1681
1682   GFX6_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
1683}
1684
1685#define GFX6_3DSTATE_DEPTH_BUFFER_length       7
1686#define GFX6_3DSTATE_DEPTH_BUFFER_length_bias      2
1687#define GFX6_3DSTATE_DEPTH_BUFFER_header        \
1688   .DWordLength                         =      5,  \
1689   ._3DCommandSubOpcode                 =      5,  \
1690   ._3DCommandOpcode                    =      1,  \
1691   .CommandSubType                      =      3,  \
1692   .CommandType                         =      3
1693
1694struct GFX6_3DSTATE_DEPTH_BUFFER {
1695   uint32_t                             DWordLength;
1696   uint32_t                             _3DCommandSubOpcode;
1697   uint32_t                             _3DCommandOpcode;
1698   uint32_t                             CommandSubType;
1699   uint32_t                             CommandType;
1700   uint32_t                             SurfacePitch;
1701   uint32_t                             SurfaceFormat;
1702#define D32_FLOAT_S8X24_UINT                     0
1703#define D32_FLOAT                                1
1704#define D24_UNORM_S8_UINT                        2
1705#define D24_UNORM_X8_UINT                        3
1706#define D16_UNORM                                5
1707   bool                                 SeparateStencilBufferEnable;
1708   bool                                 HierarchicalDepthBufferEnable;
1709   uint32_t                             SoftwareTiledRenderingMode;
1710#define NORMAL                                   0
1711#define STR1                                     1
1712#define STR2                                     3
1713   uint32_t                             TileWalk;
1714#define TILEWALK_YMAJOR                          1
1715   bool                                 TiledSurface;
1716   uint32_t                             SurfaceType;
1717#define SURFTYPE_1D                              0
1718#define SURFTYPE_2D                              1
1719#define SURFTYPE_3D                              2
1720#define SURFTYPE_CUBE                            3
1721#define SURFTYPE_NULL                            7
1722   __gen_address_type                   SurfaceBaseAddress;
1723   uint32_t                             MIPMapLayoutMode;
1724#define MIPLAYOUT_BELOW                          0
1725#define MIPLAYOUT_RIGHT                          1
1726   uint32_t                             LOD;
1727   uint32_t                             Width;
1728   uint32_t                             Height;
1729   uint32_t                             RenderTargetViewExtent;
1730   uint32_t                             MinimumArrayElement;
1731   uint32_t                             Depth;
1732   int32_t                              DepthCoordinateOffsetX;
1733   int32_t                              DepthCoordinateOffsetY;
1734   uint32_t                             MOCS;
1735};
1736
1737static inline __attribute__((always_inline)) void
1738GFX6_3DSTATE_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
1739                               __attribute__((unused)) void * restrict dst,
1740                               __attribute__((unused)) const struct GFX6_3DSTATE_DEPTH_BUFFER * restrict values)
1741{
1742   uint32_t * restrict dw = (uint32_t * restrict) dst;
1743
1744   dw[0] =
1745      __gen_uint(values->DWordLength, 0, 7) |
1746      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1747      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1748      __gen_uint(values->CommandSubType, 27, 28) |
1749      __gen_uint(values->CommandType, 29, 31);
1750
1751   dw[1] =
1752      __gen_uint(values->SurfacePitch, 0, 16) |
1753      __gen_uint(values->SurfaceFormat, 18, 20) |
1754      __gen_uint(values->SeparateStencilBufferEnable, 21, 21) |
1755      __gen_uint(values->HierarchicalDepthBufferEnable, 22, 22) |
1756      __gen_uint(values->SoftwareTiledRenderingMode, 23, 24) |
1757      __gen_uint(values->TileWalk, 26, 26) |
1758      __gen_uint(values->TiledSurface, 27, 27) |
1759      __gen_uint(values->SurfaceType, 29, 31);
1760
1761   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
1762
1763   dw[3] =
1764      __gen_uint(values->MIPMapLayoutMode, 1, 1) |
1765      __gen_uint(values->LOD, 2, 5) |
1766      __gen_uint(values->Width, 6, 18) |
1767      __gen_uint(values->Height, 19, 31);
1768
1769   dw[4] =
1770      __gen_uint(values->RenderTargetViewExtent, 1, 9) |
1771      __gen_uint(values->MinimumArrayElement, 10, 20) |
1772      __gen_uint(values->Depth, 21, 31);
1773
1774   dw[5] =
1775      __gen_sint(values->DepthCoordinateOffsetX, 0, 15) |
1776      __gen_sint(values->DepthCoordinateOffsetY, 16, 31);
1777
1778   dw[6] =
1779      __gen_uint(values->MOCS, 27, 31);
1780}
1781
1782#define GFX6_3DSTATE_DRAWING_RECTANGLE_length      4
1783#define GFX6_3DSTATE_DRAWING_RECTANGLE_length_bias      2
1784#define GFX6_3DSTATE_DRAWING_RECTANGLE_header   \
1785   .DWordLength                         =      2,  \
1786   ._3DCommandSubOpcode                 =      0,  \
1787   ._3DCommandOpcode                    =      1,  \
1788   .CommandSubType                      =      3,  \
1789   .CommandType                         =      3
1790
1791struct GFX6_3DSTATE_DRAWING_RECTANGLE {
1792   uint32_t                             DWordLength;
1793   uint32_t                             _3DCommandSubOpcode;
1794   uint32_t                             _3DCommandOpcode;
1795   uint32_t                             CommandSubType;
1796   uint32_t                             CommandType;
1797   uint32_t                             ClippedDrawingRectangleXMin;
1798   uint32_t                             ClippedDrawingRectangleYMin;
1799   uint32_t                             ClippedDrawingRectangleXMax;
1800   uint32_t                             ClippedDrawingRectangleYMax;
1801   int32_t                              DrawingRectangleOriginX;
1802   int32_t                              DrawingRectangleOriginY;
1803};
1804
1805static inline __attribute__((always_inline)) void
1806GFX6_3DSTATE_DRAWING_RECTANGLE_pack(__attribute__((unused)) __gen_user_data *data,
1807                                    __attribute__((unused)) void * restrict dst,
1808                                    __attribute__((unused)) const struct GFX6_3DSTATE_DRAWING_RECTANGLE * restrict values)
1809{
1810   uint32_t * restrict dw = (uint32_t * restrict) dst;
1811
1812   dw[0] =
1813      __gen_uint(values->DWordLength, 0, 7) |
1814      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1815      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1816      __gen_uint(values->CommandSubType, 27, 28) |
1817      __gen_uint(values->CommandType, 29, 31);
1818
1819   dw[1] =
1820      __gen_uint(values->ClippedDrawingRectangleXMin, 0, 15) |
1821      __gen_uint(values->ClippedDrawingRectangleYMin, 16, 31);
1822
1823   dw[2] =
1824      __gen_uint(values->ClippedDrawingRectangleXMax, 0, 15) |
1825      __gen_uint(values->ClippedDrawingRectangleYMax, 16, 31);
1826
1827   dw[3] =
1828      __gen_sint(values->DrawingRectangleOriginX, 0, 15) |
1829      __gen_sint(values->DrawingRectangleOriginY, 16, 31);
1830}
1831
1832#define GFX6_3DSTATE_GS_length                 7
1833#define GFX6_3DSTATE_GS_length_bias            2
1834#define GFX6_3DSTATE_GS_header                  \
1835   .DWordLength                         =      5,  \
1836   ._3DCommandSubOpcode                 =     17,  \
1837   ._3DCommandOpcode                    =      0,  \
1838   .CommandSubType                      =      3,  \
1839   .CommandType                         =      3
1840
1841struct GFX6_3DSTATE_GS {
1842   uint32_t                             DWordLength;
1843   uint32_t                             _3DCommandSubOpcode;
1844   uint32_t                             _3DCommandOpcode;
1845   uint32_t                             CommandSubType;
1846   uint32_t                             CommandType;
1847   uint64_t                             KernelStartPointer;
1848   bool                                 SoftwareExceptionEnable;
1849   bool                                 MaskStackExceptionEnable;
1850   bool                                 IllegalOpcodeExceptionEnable;
1851   uint32_t                             FloatingPointMode;
1852#define IEEE754                                  0
1853#define Alternate                                1
1854   uint32_t                             ThreadPriority;
1855#define NormalPriority                           0
1856#define HighPriority                             1
1857   uint32_t                             BindingTableEntryCount;
1858   uint32_t                             SamplerCount;
1859#define NoSamplers                               0
1860#define _14Samplers                              1
1861#define _58Samplers                              2
1862#define _912Samplers                             3
1863#define _1316Samplers                            4
1864   bool                                 VectorMaskEnable;
1865   bool                                 SingleProgramFlow;
1866   uint32_t                             PerThreadScratchSpace;
1867   __gen_address_type                   ScratchSpaceBasePointer;
1868   uint32_t                             DispatchGRFStartRegisterForURBData;
1869   uint32_t                             VertexURBEntryReadOffset;
1870   uint32_t                             VertexURBEntryReadLength;
1871   uint32_t                             RenderingEnabled;
1872   bool                                 SOStatisticsEnable;
1873   bool                                 StatisticsEnable;
1874   uint32_t                             MaximumNumberofThreads;
1875   bool                                 Enable;
1876   uint32_t                             SVBIPostIncrementValue;
1877   bool                                 SVBIPostIncrementEnable;
1878   bool                                 SVBIPayloadEnable;
1879   bool                                 DiscardAdjacency;
1880   uint32_t                             ReorderMode;
1881#define LEADING                                  0
1882#define TRAILING                                 1
1883};
1884
1885static inline __attribute__((always_inline)) void
1886GFX6_3DSTATE_GS_pack(__attribute__((unused)) __gen_user_data *data,
1887                     __attribute__((unused)) void * restrict dst,
1888                     __attribute__((unused)) const struct GFX6_3DSTATE_GS * restrict values)
1889{
1890   uint32_t * restrict dw = (uint32_t * restrict) dst;
1891
1892   dw[0] =
1893      __gen_uint(values->DWordLength, 0, 7) |
1894      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1895      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1896      __gen_uint(values->CommandSubType, 27, 28) |
1897      __gen_uint(values->CommandType, 29, 31);
1898
1899   dw[1] =
1900      __gen_offset(values->KernelStartPointer, 6, 31);
1901
1902   dw[2] =
1903      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
1904      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
1905      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
1906      __gen_uint(values->FloatingPointMode, 16, 16) |
1907      __gen_uint(values->ThreadPriority, 17, 17) |
1908      __gen_uint(values->BindingTableEntryCount, 18, 25) |
1909      __gen_uint(values->SamplerCount, 27, 29) |
1910      __gen_uint(values->VectorMaskEnable, 30, 30) |
1911      __gen_uint(values->SingleProgramFlow, 31, 31);
1912
1913   const uint32_t v3 =
1914      __gen_uint(values->PerThreadScratchSpace, 0, 3);
1915   dw[3] = __gen_address(data, &dw[3], values->ScratchSpaceBasePointer, v3, 10, 31);
1916
1917   dw[4] =
1918      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
1919      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
1920      __gen_uint(values->VertexURBEntryReadLength, 11, 16);
1921
1922   dw[5] =
1923      __gen_uint(values->RenderingEnabled, 8, 8) |
1924      __gen_uint(values->SOStatisticsEnable, 9, 9) |
1925      __gen_uint(values->StatisticsEnable, 10, 10) |
1926      __gen_uint(values->MaximumNumberofThreads, 25, 31);
1927
1928   dw[6] =
1929      __gen_uint(values->Enable, 15, 15) |
1930      __gen_uint(values->SVBIPostIncrementValue, 16, 25) |
1931      __gen_uint(values->SVBIPostIncrementEnable, 27, 27) |
1932      __gen_uint(values->SVBIPayloadEnable, 28, 28) |
1933      __gen_uint(values->DiscardAdjacency, 29, 29) |
1934      __gen_uint(values->ReorderMode, 30, 30);
1935}
1936
1937#define GFX6_3DSTATE_GS_SVB_INDEX_length       4
1938#define GFX6_3DSTATE_GS_SVB_INDEX_length_bias      2
1939#define GFX6_3DSTATE_GS_SVB_INDEX_header        \
1940   .DWordLength                         =      2,  \
1941   ._3DCommandSubOpcode                 =     11,  \
1942   ._3DCommandOpcode                    =      1,  \
1943   .CommandSubType                      =      3,  \
1944   .CommandType                         =      3
1945
1946struct GFX6_3DSTATE_GS_SVB_INDEX {
1947   uint32_t                             DWordLength;
1948   uint32_t                             _3DCommandSubOpcode;
1949   uint32_t                             _3DCommandOpcode;
1950   uint32_t                             CommandSubType;
1951   uint32_t                             CommandType;
1952   uint32_t                             LoadInternalVertexCount;
1953   uint32_t                             IndexNumber;
1954   uint32_t                             StreamedVertexBufferIndex;
1955   uint32_t                             MaximumIndex;
1956};
1957
1958static inline __attribute__((always_inline)) void
1959GFX6_3DSTATE_GS_SVB_INDEX_pack(__attribute__((unused)) __gen_user_data *data,
1960                               __attribute__((unused)) void * restrict dst,
1961                               __attribute__((unused)) const struct GFX6_3DSTATE_GS_SVB_INDEX * restrict values)
1962{
1963   uint32_t * restrict dw = (uint32_t * restrict) dst;
1964
1965   dw[0] =
1966      __gen_uint(values->DWordLength, 0, 7) |
1967      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1968      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1969      __gen_uint(values->CommandSubType, 27, 28) |
1970      __gen_uint(values->CommandType, 29, 31);
1971
1972   dw[1] =
1973      __gen_uint(values->LoadInternalVertexCount, 0, 0) |
1974      __gen_uint(values->IndexNumber, 29, 30);
1975
1976   dw[2] =
1977      __gen_uint(values->StreamedVertexBufferIndex, 0, 31);
1978
1979   dw[3] =
1980      __gen_uint(values->MaximumIndex, 0, 31);
1981}
1982
1983#define GFX6_3DSTATE_HIER_DEPTH_BUFFER_length      3
1984#define GFX6_3DSTATE_HIER_DEPTH_BUFFER_length_bias      2
1985#define GFX6_3DSTATE_HIER_DEPTH_BUFFER_header   \
1986   .DWordLength                         =      1,  \
1987   ._3DCommandSubOpcode                 =     15,  \
1988   ._3DCommandOpcode                    =      1,  \
1989   .CommandSubType                      =      3,  \
1990   .CommandType                         =      3
1991
1992struct GFX6_3DSTATE_HIER_DEPTH_BUFFER {
1993   uint32_t                             DWordLength;
1994   uint32_t                             _3DCommandSubOpcode;
1995   uint32_t                             _3DCommandOpcode;
1996   uint32_t                             CommandSubType;
1997   uint32_t                             CommandType;
1998   uint32_t                             SurfacePitch;
1999   uint32_t                             MOCS;
2000   __gen_address_type                   SurfaceBaseAddress;
2001};
2002
2003static inline __attribute__((always_inline)) void
2004GFX6_3DSTATE_HIER_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2005                                    __attribute__((unused)) void * restrict dst,
2006                                    __attribute__((unused)) const struct GFX6_3DSTATE_HIER_DEPTH_BUFFER * restrict values)
2007{
2008   uint32_t * restrict dw = (uint32_t * restrict) dst;
2009
2010   dw[0] =
2011      __gen_uint(values->DWordLength, 0, 7) |
2012      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2013      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2014      __gen_uint(values->CommandSubType, 27, 28) |
2015      __gen_uint(values->CommandType, 29, 31);
2016
2017   dw[1] =
2018      __gen_uint(values->SurfacePitch, 0, 16) |
2019      __gen_uint(values->MOCS, 25, 28);
2020
2021   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
2022}
2023
2024#define GFX6_3DSTATE_INDEX_BUFFER_length       3
2025#define GFX6_3DSTATE_INDEX_BUFFER_length_bias      2
2026#define GFX6_3DSTATE_INDEX_BUFFER_header        \
2027   .DWordLength                         =      1,  \
2028   ._3DCommandSubOpcode                 =     10,  \
2029   ._3DCommandOpcode                    =      0,  \
2030   .CommandSubType                      =      3,  \
2031   .CommandType                         =      3
2032
2033struct GFX6_3DSTATE_INDEX_BUFFER {
2034   uint32_t                             DWordLength;
2035   uint32_t                             IndexFormat;
2036#define INDEX_BYTE                               0
2037#define INDEX_WORD                               1
2038#define INDEX_DWORD                              2
2039   bool                                 CutIndexEnable;
2040   uint32_t                             MOCS;
2041   uint32_t                             _3DCommandSubOpcode;
2042   uint32_t                             _3DCommandOpcode;
2043   uint32_t                             CommandSubType;
2044   uint32_t                             CommandType;
2045   __gen_address_type                   BufferStartingAddress;
2046   __gen_address_type                   BufferEndingAddress;
2047};
2048
2049static inline __attribute__((always_inline)) void
2050GFX6_3DSTATE_INDEX_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2051                               __attribute__((unused)) void * restrict dst,
2052                               __attribute__((unused)) const struct GFX6_3DSTATE_INDEX_BUFFER * restrict values)
2053{
2054   uint32_t * restrict dw = (uint32_t * restrict) dst;
2055
2056   dw[0] =
2057      __gen_uint(values->DWordLength, 0, 7) |
2058      __gen_uint(values->IndexFormat, 8, 9) |
2059      __gen_uint(values->CutIndexEnable, 10, 10) |
2060      __gen_uint(values->MOCS, 12, 15) |
2061      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2062      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2063      __gen_uint(values->CommandSubType, 27, 28) |
2064      __gen_uint(values->CommandType, 29, 31);
2065
2066   dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, 0, 0, 31);
2067
2068   dw[2] = __gen_address(data, &dw[2], values->BufferEndingAddress, 0, 0, 31);
2069}
2070
2071#define GFX6_3DSTATE_LINE_STIPPLE_length       3
2072#define GFX6_3DSTATE_LINE_STIPPLE_length_bias      2
2073#define GFX6_3DSTATE_LINE_STIPPLE_header        \
2074   .DWordLength                         =      1,  \
2075   ._3DCommandSubOpcode                 =      8,  \
2076   ._3DCommandOpcode                    =      1,  \
2077   .CommandSubType                      =      3,  \
2078   .CommandType                         =      3
2079
2080struct GFX6_3DSTATE_LINE_STIPPLE {
2081   uint32_t                             DWordLength;
2082   uint32_t                             _3DCommandSubOpcode;
2083   uint32_t                             _3DCommandOpcode;
2084   uint32_t                             CommandSubType;
2085   uint32_t                             CommandType;
2086   uint32_t                             LineStipplePattern;
2087   uint32_t                             CurrentStippleIndex;
2088   uint32_t                             CurrentRepeatCounter;
2089   bool                                 ModifyEnableCurrentRepeatCounterCurrentStippleIndex;
2090   uint32_t                             LineStippleRepeatCount;
2091   float                                LineStippleInverseRepeatCount;
2092};
2093
2094static inline __attribute__((always_inline)) void
2095GFX6_3DSTATE_LINE_STIPPLE_pack(__attribute__((unused)) __gen_user_data *data,
2096                               __attribute__((unused)) void * restrict dst,
2097                               __attribute__((unused)) const struct GFX6_3DSTATE_LINE_STIPPLE * restrict values)
2098{
2099   uint32_t * restrict dw = (uint32_t * restrict) dst;
2100
2101   dw[0] =
2102      __gen_uint(values->DWordLength, 0, 7) |
2103      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2104      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2105      __gen_uint(values->CommandSubType, 27, 28) |
2106      __gen_uint(values->CommandType, 29, 31);
2107
2108   dw[1] =
2109      __gen_uint(values->LineStipplePattern, 0, 15) |
2110      __gen_uint(values->CurrentStippleIndex, 16, 19) |
2111      __gen_uint(values->CurrentRepeatCounter, 21, 29) |
2112      __gen_uint(values->ModifyEnableCurrentRepeatCounterCurrentStippleIndex, 31, 31);
2113
2114   dw[2] =
2115      __gen_uint(values->LineStippleRepeatCount, 0, 8) |
2116      __gen_ufixed(values->LineStippleInverseRepeatCount, 16, 31, 13);
2117}
2118
2119#define GFX6_3DSTATE_MONOFILTER_SIZE_length      2
2120#define GFX6_3DSTATE_MONOFILTER_SIZE_length_bias      2
2121#define GFX6_3DSTATE_MONOFILTER_SIZE_header     \
2122   .DWordLength                         =      0,  \
2123   ._3DCommandSubOpcode                 =     17,  \
2124   ._3DCommandOpcode                    =      1,  \
2125   .CommandSubType                      =      3,  \
2126   .CommandType                         =      3
2127
2128struct GFX6_3DSTATE_MONOFILTER_SIZE {
2129   uint32_t                             DWordLength;
2130   uint32_t                             _3DCommandSubOpcode;
2131   uint32_t                             _3DCommandOpcode;
2132   uint32_t                             CommandSubType;
2133   uint32_t                             CommandType;
2134   uint32_t                             MonochromeFilterHeight;
2135   uint32_t                             MonochromeFilterWidth;
2136};
2137
2138static inline __attribute__((always_inline)) void
2139GFX6_3DSTATE_MONOFILTER_SIZE_pack(__attribute__((unused)) __gen_user_data *data,
2140                                  __attribute__((unused)) void * restrict dst,
2141                                  __attribute__((unused)) const struct GFX6_3DSTATE_MONOFILTER_SIZE * restrict values)
2142{
2143   uint32_t * restrict dw = (uint32_t * restrict) dst;
2144
2145   dw[0] =
2146      __gen_uint(values->DWordLength, 0, 7) |
2147      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2148      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2149      __gen_uint(values->CommandSubType, 27, 28) |
2150      __gen_uint(values->CommandType, 29, 31);
2151
2152   dw[1] =
2153      __gen_uint(values->MonochromeFilterHeight, 0, 2) |
2154      __gen_uint(values->MonochromeFilterWidth, 3, 5);
2155}
2156
2157#define GFX6_3DSTATE_MULTISAMPLE_length        3
2158#define GFX6_3DSTATE_MULTISAMPLE_length_bias      2
2159#define GFX6_3DSTATE_MULTISAMPLE_header         \
2160   .DWordLength                         =      1,  \
2161   ._3DCommandSubOpcode                 =     13,  \
2162   ._3DCommandOpcode                    =      1,  \
2163   .CommandSubType                      =      3,  \
2164   .CommandType                         =      3
2165
2166struct GFX6_3DSTATE_MULTISAMPLE {
2167   uint32_t                             DWordLength;
2168   uint32_t                             _3DCommandSubOpcode;
2169   uint32_t                             _3DCommandOpcode;
2170   uint32_t                             CommandSubType;
2171   uint32_t                             CommandType;
2172   uint32_t                             NumberofMultisamples;
2173#define NUMSAMPLES_1                             0
2174#define NUMSAMPLES_4                             2
2175   uint32_t                             PixelLocation;
2176#define CENTER                                   0
2177#define UL_CORNER                                1
2178   float                                Sample0YOffset;
2179   float                                Sample0XOffset;
2180   float                                Sample1YOffset;
2181   float                                Sample1XOffset;
2182   float                                Sample2YOffset;
2183   float                                Sample2XOffset;
2184   float                                Sample3YOffset;
2185   float                                Sample3XOffset;
2186};
2187
2188static inline __attribute__((always_inline)) void
2189GFX6_3DSTATE_MULTISAMPLE_pack(__attribute__((unused)) __gen_user_data *data,
2190                              __attribute__((unused)) void * restrict dst,
2191                              __attribute__((unused)) const struct GFX6_3DSTATE_MULTISAMPLE * restrict values)
2192{
2193   uint32_t * restrict dw = (uint32_t * restrict) dst;
2194
2195   dw[0] =
2196      __gen_uint(values->DWordLength, 0, 7) |
2197      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2198      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2199      __gen_uint(values->CommandSubType, 27, 28) |
2200      __gen_uint(values->CommandType, 29, 31);
2201
2202   dw[1] =
2203      __gen_uint(values->NumberofMultisamples, 1, 3) |
2204      __gen_uint(values->PixelLocation, 4, 4);
2205
2206   dw[2] =
2207      __gen_ufixed(values->Sample0YOffset, 0, 3, 4) |
2208      __gen_ufixed(values->Sample0XOffset, 4, 7, 4) |
2209      __gen_ufixed(values->Sample1YOffset, 8, 11, 4) |
2210      __gen_ufixed(values->Sample1XOffset, 12, 15, 4) |
2211      __gen_ufixed(values->Sample2YOffset, 16, 19, 4) |
2212      __gen_ufixed(values->Sample2XOffset, 20, 23, 4) |
2213      __gen_ufixed(values->Sample3YOffset, 24, 27, 4) |
2214      __gen_ufixed(values->Sample3XOffset, 28, 31, 4);
2215}
2216
2217#define GFX6_3DSTATE_POLY_STIPPLE_OFFSET_length      2
2218#define GFX6_3DSTATE_POLY_STIPPLE_OFFSET_length_bias      2
2219#define GFX6_3DSTATE_POLY_STIPPLE_OFFSET_header \
2220   .DWordLength                         =      0,  \
2221   ._3DCommandSubOpcode                 =      6,  \
2222   ._3DCommandOpcode                    =      1,  \
2223   .CommandSubType                      =      3,  \
2224   .CommandType                         =      3
2225
2226struct GFX6_3DSTATE_POLY_STIPPLE_OFFSET {
2227   uint32_t                             DWordLength;
2228   uint32_t                             _3DCommandSubOpcode;
2229   uint32_t                             _3DCommandOpcode;
2230   uint32_t                             CommandSubType;
2231   uint32_t                             CommandType;
2232   uint32_t                             PolygonStippleYOffset;
2233   uint32_t                             PolygonStippleXOffset;
2234};
2235
2236static inline __attribute__((always_inline)) void
2237GFX6_3DSTATE_POLY_STIPPLE_OFFSET_pack(__attribute__((unused)) __gen_user_data *data,
2238                                      __attribute__((unused)) void * restrict dst,
2239                                      __attribute__((unused)) const struct GFX6_3DSTATE_POLY_STIPPLE_OFFSET * restrict values)
2240{
2241   uint32_t * restrict dw = (uint32_t * restrict) dst;
2242
2243   dw[0] =
2244      __gen_uint(values->DWordLength, 0, 7) |
2245      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2246      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2247      __gen_uint(values->CommandSubType, 27, 28) |
2248      __gen_uint(values->CommandType, 29, 31);
2249
2250   dw[1] =
2251      __gen_uint(values->PolygonStippleYOffset, 0, 4) |
2252      __gen_uint(values->PolygonStippleXOffset, 8, 12);
2253}
2254
2255#define GFX6_3DSTATE_POLY_STIPPLE_PATTERN_length     33
2256#define GFX6_3DSTATE_POLY_STIPPLE_PATTERN_length_bias      2
2257#define GFX6_3DSTATE_POLY_STIPPLE_PATTERN_header\
2258   .DWordLength                         =     31,  \
2259   ._3DCommandSubOpcode                 =      7,  \
2260   ._3DCommandOpcode                    =      1,  \
2261   .CommandSubType                      =      3,  \
2262   .CommandType                         =      3
2263
2264struct GFX6_3DSTATE_POLY_STIPPLE_PATTERN {
2265   uint32_t                             DWordLength;
2266   uint32_t                             _3DCommandSubOpcode;
2267   uint32_t                             _3DCommandOpcode;
2268   uint32_t                             CommandSubType;
2269   uint32_t                             CommandType;
2270   uint32_t                             PatternRow[32];
2271};
2272
2273static inline __attribute__((always_inline)) void
2274GFX6_3DSTATE_POLY_STIPPLE_PATTERN_pack(__attribute__((unused)) __gen_user_data *data,
2275                                       __attribute__((unused)) void * restrict dst,
2276                                       __attribute__((unused)) const struct GFX6_3DSTATE_POLY_STIPPLE_PATTERN * restrict values)
2277{
2278   uint32_t * restrict dw = (uint32_t * restrict) dst;
2279
2280   dw[0] =
2281      __gen_uint(values->DWordLength, 0, 7) |
2282      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2283      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2284      __gen_uint(values->CommandSubType, 27, 28) |
2285      __gen_uint(values->CommandType, 29, 31);
2286
2287   dw[1] =
2288      __gen_uint(values->PatternRow[0], 0, 31);
2289
2290   dw[2] =
2291      __gen_uint(values->PatternRow[1], 0, 31);
2292
2293   dw[3] =
2294      __gen_uint(values->PatternRow[2], 0, 31);
2295
2296   dw[4] =
2297      __gen_uint(values->PatternRow[3], 0, 31);
2298
2299   dw[5] =
2300      __gen_uint(values->PatternRow[4], 0, 31);
2301
2302   dw[6] =
2303      __gen_uint(values->PatternRow[5], 0, 31);
2304
2305   dw[7] =
2306      __gen_uint(values->PatternRow[6], 0, 31);
2307
2308   dw[8] =
2309      __gen_uint(values->PatternRow[7], 0, 31);
2310
2311   dw[9] =
2312      __gen_uint(values->PatternRow[8], 0, 31);
2313
2314   dw[10] =
2315      __gen_uint(values->PatternRow[9], 0, 31);
2316
2317   dw[11] =
2318      __gen_uint(values->PatternRow[10], 0, 31);
2319
2320   dw[12] =
2321      __gen_uint(values->PatternRow[11], 0, 31);
2322
2323   dw[13] =
2324      __gen_uint(values->PatternRow[12], 0, 31);
2325
2326   dw[14] =
2327      __gen_uint(values->PatternRow[13], 0, 31);
2328
2329   dw[15] =
2330      __gen_uint(values->PatternRow[14], 0, 31);
2331
2332   dw[16] =
2333      __gen_uint(values->PatternRow[15], 0, 31);
2334
2335   dw[17] =
2336      __gen_uint(values->PatternRow[16], 0, 31);
2337
2338   dw[18] =
2339      __gen_uint(values->PatternRow[17], 0, 31);
2340
2341   dw[19] =
2342      __gen_uint(values->PatternRow[18], 0, 31);
2343
2344   dw[20] =
2345      __gen_uint(values->PatternRow[19], 0, 31);
2346
2347   dw[21] =
2348      __gen_uint(values->PatternRow[20], 0, 31);
2349
2350   dw[22] =
2351      __gen_uint(values->PatternRow[21], 0, 31);
2352
2353   dw[23] =
2354      __gen_uint(values->PatternRow[22], 0, 31);
2355
2356   dw[24] =
2357      __gen_uint(values->PatternRow[23], 0, 31);
2358
2359   dw[25] =
2360      __gen_uint(values->PatternRow[24], 0, 31);
2361
2362   dw[26] =
2363      __gen_uint(values->PatternRow[25], 0, 31);
2364
2365   dw[27] =
2366      __gen_uint(values->PatternRow[26], 0, 31);
2367
2368   dw[28] =
2369      __gen_uint(values->PatternRow[27], 0, 31);
2370
2371   dw[29] =
2372      __gen_uint(values->PatternRow[28], 0, 31);
2373
2374   dw[30] =
2375      __gen_uint(values->PatternRow[29], 0, 31);
2376
2377   dw[31] =
2378      __gen_uint(values->PatternRow[30], 0, 31);
2379
2380   dw[32] =
2381      __gen_uint(values->PatternRow[31], 0, 31);
2382}
2383
2384#define GFX6_3DSTATE_SAMPLER_PALETTE_LOAD0_length_bias      2
2385#define GFX6_3DSTATE_SAMPLER_PALETTE_LOAD0_header\
2386   ._3DCommandSubOpcode                 =      2,  \
2387   ._3DCommandOpcode                    =      1,  \
2388   .CommandSubType                      =      3,  \
2389   .CommandType                         =      3
2390
2391struct GFX6_3DSTATE_SAMPLER_PALETTE_LOAD0 {
2392   uint32_t                             DWordLength;
2393   uint32_t                             _3DCommandSubOpcode;
2394   uint32_t                             _3DCommandOpcode;
2395   uint32_t                             CommandSubType;
2396   uint32_t                             CommandType;
2397   /* variable length fields follow */
2398};
2399
2400static inline __attribute__((always_inline)) void
2401GFX6_3DSTATE_SAMPLER_PALETTE_LOAD0_pack(__attribute__((unused)) __gen_user_data *data,
2402                                        __attribute__((unused)) void * restrict dst,
2403                                        __attribute__((unused)) const struct GFX6_3DSTATE_SAMPLER_PALETTE_LOAD0 * restrict values)
2404{
2405   uint32_t * restrict dw = (uint32_t * restrict) dst;
2406
2407   dw[0] =
2408      __gen_uint(values->DWordLength, 0, 7) |
2409      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2410      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2411      __gen_uint(values->CommandSubType, 27, 28) |
2412      __gen_uint(values->CommandType, 29, 31);
2413}
2414
2415#define GFX6_3DSTATE_SAMPLER_PALETTE_LOAD1_length_bias      2
2416#define GFX6_3DSTATE_SAMPLER_PALETTE_LOAD1_header\
2417   .DWordLength                         =      0,  \
2418   ._3DCommandSubOpcode                 =     12,  \
2419   ._3DCommandOpcode                    =      1,  \
2420   .CommandSubType                      =      3,  \
2421   .CommandType                         =      3
2422
2423struct GFX6_3DSTATE_SAMPLER_PALETTE_LOAD1 {
2424   uint32_t                             DWordLength;
2425   uint32_t                             _3DCommandSubOpcode;
2426   uint32_t                             _3DCommandOpcode;
2427   uint32_t                             CommandSubType;
2428   uint32_t                             CommandType;
2429   /* variable length fields follow */
2430};
2431
2432static inline __attribute__((always_inline)) void
2433GFX6_3DSTATE_SAMPLER_PALETTE_LOAD1_pack(__attribute__((unused)) __gen_user_data *data,
2434                                        __attribute__((unused)) void * restrict dst,
2435                                        __attribute__((unused)) const struct GFX6_3DSTATE_SAMPLER_PALETTE_LOAD1 * restrict values)
2436{
2437   uint32_t * restrict dw = (uint32_t * restrict) dst;
2438
2439   dw[0] =
2440      __gen_uint(values->DWordLength, 0, 7) |
2441      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2442      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2443      __gen_uint(values->CommandSubType, 27, 28) |
2444      __gen_uint(values->CommandType, 29, 31);
2445}
2446
2447#define GFX6_3DSTATE_SAMPLER_STATE_POINTERS_length      4
2448#define GFX6_3DSTATE_SAMPLER_STATE_POINTERS_length_bias      2
2449#define GFX6_3DSTATE_SAMPLER_STATE_POINTERS_header\
2450   .DWordLength                         =      2,  \
2451   ._3DCommandSubOpcode                 =      2,  \
2452   ._3DCommandOpcode                    =      0,  \
2453   .CommandSubType                      =      3,  \
2454   .CommandType                         =      3
2455
2456struct GFX6_3DSTATE_SAMPLER_STATE_POINTERS {
2457   uint32_t                             DWordLength;
2458   uint32_t                             VSSamplerStateChange;
2459   uint32_t                             GSSamplerStateChange;
2460   uint32_t                             PSSamplerStateChange;
2461   uint32_t                             _3DCommandSubOpcode;
2462   uint32_t                             _3DCommandOpcode;
2463   uint32_t                             CommandSubType;
2464   uint32_t                             CommandType;
2465   uint64_t                             PointertoVSSamplerState;
2466   uint64_t                             PointertoGSSamplerState;
2467   uint64_t                             PointertoPSSamplerState;
2468};
2469
2470static inline __attribute__((always_inline)) void
2471GFX6_3DSTATE_SAMPLER_STATE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
2472                                         __attribute__((unused)) void * restrict dst,
2473                                         __attribute__((unused)) const struct GFX6_3DSTATE_SAMPLER_STATE_POINTERS * restrict values)
2474{
2475   uint32_t * restrict dw = (uint32_t * restrict) dst;
2476
2477   dw[0] =
2478      __gen_uint(values->DWordLength, 0, 7) |
2479      __gen_uint(values->VSSamplerStateChange, 8, 8) |
2480      __gen_uint(values->GSSamplerStateChange, 9, 9) |
2481      __gen_uint(values->PSSamplerStateChange, 12, 12) |
2482      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2483      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2484      __gen_uint(values->CommandSubType, 27, 28) |
2485      __gen_uint(values->CommandType, 29, 31);
2486
2487   dw[1] =
2488      __gen_offset(values->PointertoVSSamplerState, 5, 31);
2489
2490   dw[2] =
2491      __gen_offset(values->PointertoGSSamplerState, 5, 31);
2492
2493   dw[3] =
2494      __gen_offset(values->PointertoPSSamplerState, 5, 31);
2495}
2496
2497#define GFX6_3DSTATE_SAMPLE_MASK_length        2
2498#define GFX6_3DSTATE_SAMPLE_MASK_length_bias      2
2499#define GFX6_3DSTATE_SAMPLE_MASK_header         \
2500   .DWordLength                         =      0,  \
2501   ._3DCommandSubOpcode                 =     24,  \
2502   ._3DCommandOpcode                    =      0,  \
2503   .CommandSubType                      =      3,  \
2504   .CommandType                         =      3
2505
2506struct GFX6_3DSTATE_SAMPLE_MASK {
2507   uint32_t                             DWordLength;
2508   uint32_t                             _3DCommandSubOpcode;
2509   uint32_t                             _3DCommandOpcode;
2510   uint32_t                             CommandSubType;
2511   uint32_t                             CommandType;
2512   uint32_t                             SampleMask;
2513};
2514
2515static inline __attribute__((always_inline)) void
2516GFX6_3DSTATE_SAMPLE_MASK_pack(__attribute__((unused)) __gen_user_data *data,
2517                              __attribute__((unused)) void * restrict dst,
2518                              __attribute__((unused)) const struct GFX6_3DSTATE_SAMPLE_MASK * restrict values)
2519{
2520   uint32_t * restrict dw = (uint32_t * restrict) dst;
2521
2522   dw[0] =
2523      __gen_uint(values->DWordLength, 0, 7) |
2524      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2525      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2526      __gen_uint(values->CommandSubType, 27, 28) |
2527      __gen_uint(values->CommandType, 29, 31);
2528
2529   dw[1] =
2530      __gen_uint(values->SampleMask, 0, 3);
2531}
2532
2533#define GFX6_3DSTATE_SCISSOR_STATE_POINTERS_length      2
2534#define GFX6_3DSTATE_SCISSOR_STATE_POINTERS_length_bias      2
2535#define GFX6_3DSTATE_SCISSOR_STATE_POINTERS_header\
2536   .DWordLength                         =      0,  \
2537   ._3DCommandSubOpcode                 =     15,  \
2538   ._3DCommandOpcode                    =      0,  \
2539   .CommandSubType                      =      3,  \
2540   .CommandType                         =      3
2541
2542struct GFX6_3DSTATE_SCISSOR_STATE_POINTERS {
2543   uint32_t                             DWordLength;
2544   uint32_t                             _3DCommandSubOpcode;
2545   uint32_t                             _3DCommandOpcode;
2546   uint32_t                             CommandSubType;
2547   uint32_t                             CommandType;
2548   uint64_t                             ScissorRectPointer;
2549};
2550
2551static inline __attribute__((always_inline)) void
2552GFX6_3DSTATE_SCISSOR_STATE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
2553                                         __attribute__((unused)) void * restrict dst,
2554                                         __attribute__((unused)) const struct GFX6_3DSTATE_SCISSOR_STATE_POINTERS * restrict values)
2555{
2556   uint32_t * restrict dw = (uint32_t * restrict) dst;
2557
2558   dw[0] =
2559      __gen_uint(values->DWordLength, 0, 7) |
2560      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2561      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2562      __gen_uint(values->CommandSubType, 27, 28) |
2563      __gen_uint(values->CommandType, 29, 31);
2564
2565   dw[1] =
2566      __gen_offset(values->ScissorRectPointer, 5, 31);
2567}
2568
2569#define GFX6_3DSTATE_SF_length                20
2570#define GFX6_3DSTATE_SF_length_bias            2
2571#define GFX6_3DSTATE_SF_header                  \
2572   .DWordLength                         =     18,  \
2573   ._3DCommandSubOpcode                 =     19,  \
2574   ._3DCommandOpcode                    =      0,  \
2575   .CommandSubType                      =      3,  \
2576   .CommandType                         =      3
2577
2578struct GFX6_3DSTATE_SF {
2579   uint32_t                             DWordLength;
2580   uint32_t                             _3DCommandSubOpcode;
2581   uint32_t                             _3DCommandOpcode;
2582   uint32_t                             CommandSubType;
2583   uint32_t                             CommandType;
2584   uint32_t                             VertexURBEntryReadOffset;
2585   uint32_t                             VertexURBEntryReadLength;
2586   uint32_t                             PointSpriteTextureCoordinateOrigin;
2587#define UPPERLEFT                                0
2588#define LOWERLEFT                                1
2589   bool                                 AttributeSwizzleEnable;
2590   uint32_t                             NumberofSFOutputAttributes;
2591   uint32_t                             FrontWinding;
2592#define FRONTWINDING_CW                          0
2593#define FRONTWINDING_CCW                         1
2594   bool                                 ViewportTransformEnable;
2595   uint32_t                             BackFaceFillMode;
2596#define FILL_MODE_SOLID                          0
2597#define FILL_MODE_WIREFRAME                      1
2598#define FILL_MODE_POINT                          2
2599   uint32_t                             FrontFaceFillMode;
2600#define FILL_MODE_SOLID                          0
2601#define FILL_MODE_WIREFRAME                      1
2602#define FILL_MODE_POINT                          2
2603   bool                                 GlobalDepthOffsetEnablePoint;
2604   bool                                 GlobalDepthOffsetEnableWireframe;
2605   bool                                 GlobalDepthOffsetEnableSolid;
2606   bool                                 StatisticsEnable;
2607   bool                                 LegacyGlobalDepthBiasEnable;
2608   uint32_t                             MultisampleRasterizationMode;
2609#define MSRASTMODE_OFF_PIXEL                     0
2610#define MSRASTMODE_OFF_PATTERN                   1
2611#define MSRASTMODE_ON_PIXEL                      2
2612#define MSRASTMODE_ON_PATTERN                    3
2613   bool                                 ScissorRectangleEnable;
2614   uint32_t                             LineEndCapAntialiasingRegionWidth;
2615#define _05pixels                                0
2616#define _10pixels                                1
2617#define _20pixels                                2
2618#define _40pixels                                3
2619   float                                LineWidth;
2620   uint32_t                             CullMode;
2621#define CULLMODE_BOTH                            0
2622#define CULLMODE_NONE                            1
2623#define CULLMODE_FRONT                           2
2624#define CULLMODE_BACK                            3
2625   bool                                 AntialiasingEnable;
2626   float                                PointWidth;
2627   uint32_t                             PointWidthSource;
2628#define Vertex                                   0
2629#define State                                    1
2630   uint32_t                             VertexSubPixelPrecisionSelect;
2631#define _8SubPixelPrecisionBits                  0
2632#define _4SubPixelPrecisionBits                  1
2633   uint32_t                             AALineDistanceMode;
2634#define AALINEDISTANCE_TRUE                      1
2635   uint32_t                             TriangleFanProvokingVertexSelect;
2636#define Vertex0                                  0
2637#define Vertex1                                  1
2638#define Vertex2                                  2
2639   uint32_t                             LineStripListProvokingVertexSelect;
2640#define Vertex0                                  0
2641#define Vertex1                                  1
2642   uint32_t                             TriangleStripListProvokingVertexSelect;
2643#define Vertex0                                  0
2644#define Vertex1                                  1
2645#define Vertex2                                  2
2646   bool                                 LastPixelEnable;
2647   float                                GlobalDepthOffsetConstant;
2648   float                                GlobalDepthOffsetScale;
2649   float                                GlobalDepthOffsetClamp;
2650   struct GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL Attribute[16];
2651   uint32_t                             PointSpriteTextureCoordinateEnable;
2652   uint32_t                             ConstantInterpolationEnable;
2653   uint32_t                             Attribute0WrapShortestEnables;
2654   uint32_t                             Attribute1WrapShortestEnables;
2655   uint32_t                             Attribute2WrapShortestEnables;
2656   uint32_t                             Attribute3WrapShortestEnables;
2657   uint32_t                             Attribute4WrapShortestEnables;
2658   uint32_t                             Attribute5WrapShortestEnables;
2659   uint32_t                             Attribute6WrapShortestEnables;
2660   uint32_t                             Attribute7WrapShortestEnables;
2661   uint32_t                             Attribute8WrapShortestEnables;
2662   uint32_t                             Attribute9WrapShortestEnables;
2663   uint32_t                             Attribute10WrapShortestEnables;
2664   uint32_t                             Attribute11WrapShortestEnables;
2665   uint32_t                             Attribute12WrapShortestEnables;
2666   uint32_t                             Attribute13WrapShortestEnables;
2667   uint32_t                             Attribute14WrapShortestEnables;
2668   uint32_t                             Attribute15WrapShortestEnables;
2669};
2670
2671static inline __attribute__((always_inline)) void
2672GFX6_3DSTATE_SF_pack(__attribute__((unused)) __gen_user_data *data,
2673                     __attribute__((unused)) void * restrict dst,
2674                     __attribute__((unused)) const struct GFX6_3DSTATE_SF * restrict values)
2675{
2676   uint32_t * restrict dw = (uint32_t * restrict) dst;
2677
2678   dw[0] =
2679      __gen_uint(values->DWordLength, 0, 7) |
2680      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2681      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2682      __gen_uint(values->CommandSubType, 27, 28) |
2683      __gen_uint(values->CommandType, 29, 31);
2684
2685   dw[1] =
2686      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
2687      __gen_uint(values->VertexURBEntryReadLength, 11, 15) |
2688      __gen_uint(values->PointSpriteTextureCoordinateOrigin, 20, 20) |
2689      __gen_uint(values->AttributeSwizzleEnable, 21, 21) |
2690      __gen_uint(values->NumberofSFOutputAttributes, 22, 27);
2691
2692   dw[2] =
2693      __gen_uint(values->FrontWinding, 0, 0) |
2694      __gen_uint(values->ViewportTransformEnable, 1, 1) |
2695      __gen_uint(values->BackFaceFillMode, 3, 4) |
2696      __gen_uint(values->FrontFaceFillMode, 5, 6) |
2697      __gen_uint(values->GlobalDepthOffsetEnablePoint, 7, 7) |
2698      __gen_uint(values->GlobalDepthOffsetEnableWireframe, 8, 8) |
2699      __gen_uint(values->GlobalDepthOffsetEnableSolid, 9, 9) |
2700      __gen_uint(values->StatisticsEnable, 10, 10) |
2701      __gen_uint(values->LegacyGlobalDepthBiasEnable, 11, 11);
2702
2703   dw[3] =
2704      __gen_uint(values->MultisampleRasterizationMode, 8, 9) |
2705      __gen_uint(values->ScissorRectangleEnable, 11, 11) |
2706      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 16, 17) |
2707      __gen_ufixed(values->LineWidth, 18, 27, 7) |
2708      __gen_uint(values->CullMode, 29, 30) |
2709      __gen_uint(values->AntialiasingEnable, 31, 31);
2710
2711   dw[4] =
2712      __gen_ufixed(values->PointWidth, 0, 10, 3) |
2713      __gen_uint(values->PointWidthSource, 11, 11) |
2714      __gen_uint(values->VertexSubPixelPrecisionSelect, 12, 12) |
2715      __gen_uint(values->AALineDistanceMode, 14, 14) |
2716      __gen_uint(values->TriangleFanProvokingVertexSelect, 25, 26) |
2717      __gen_uint(values->LineStripListProvokingVertexSelect, 27, 28) |
2718      __gen_uint(values->TriangleStripListProvokingVertexSelect, 29, 30) |
2719      __gen_uint(values->LastPixelEnable, 31, 31);
2720
2721   dw[5] =
2722      __gen_float(values->GlobalDepthOffsetConstant);
2723
2724   dw[6] =
2725      __gen_float(values->GlobalDepthOffsetScale);
2726
2727   dw[7] =
2728      __gen_float(values->GlobalDepthOffsetClamp);
2729
2730   uint32_t v8_0;
2731   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v8_0, &values->Attribute[0]);
2732
2733   uint32_t v8_1;
2734   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v8_1, &values->Attribute[1]);
2735
2736   dw[8] =
2737      __gen_uint(v8_0, 0, 15) |
2738      __gen_uint(v8_1, 16, 31);
2739
2740   uint32_t v9_0;
2741   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v9_0, &values->Attribute[2]);
2742
2743   uint32_t v9_1;
2744   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v9_1, &values->Attribute[3]);
2745
2746   dw[9] =
2747      __gen_uint(v9_0, 0, 15) |
2748      __gen_uint(v9_1, 16, 31);
2749
2750   uint32_t v10_0;
2751   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v10_0, &values->Attribute[4]);
2752
2753   uint32_t v10_1;
2754   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v10_1, &values->Attribute[5]);
2755
2756   dw[10] =
2757      __gen_uint(v10_0, 0, 15) |
2758      __gen_uint(v10_1, 16, 31);
2759
2760   uint32_t v11_0;
2761   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v11_0, &values->Attribute[6]);
2762
2763   uint32_t v11_1;
2764   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v11_1, &values->Attribute[7]);
2765
2766   dw[11] =
2767      __gen_uint(v11_0, 0, 15) |
2768      __gen_uint(v11_1, 16, 31);
2769
2770   uint32_t v12_0;
2771   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v12_0, &values->Attribute[8]);
2772
2773   uint32_t v12_1;
2774   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v12_1, &values->Attribute[9]);
2775
2776   dw[12] =
2777      __gen_uint(v12_0, 0, 15) |
2778      __gen_uint(v12_1, 16, 31);
2779
2780   uint32_t v13_0;
2781   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v13_0, &values->Attribute[10]);
2782
2783   uint32_t v13_1;
2784   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v13_1, &values->Attribute[11]);
2785
2786   dw[13] =
2787      __gen_uint(v13_0, 0, 15) |
2788      __gen_uint(v13_1, 16, 31);
2789
2790   uint32_t v14_0;
2791   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v14_0, &values->Attribute[12]);
2792
2793   uint32_t v14_1;
2794   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v14_1, &values->Attribute[13]);
2795
2796   dw[14] =
2797      __gen_uint(v14_0, 0, 15) |
2798      __gen_uint(v14_1, 16, 31);
2799
2800   uint32_t v15_0;
2801   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v15_0, &values->Attribute[14]);
2802
2803   uint32_t v15_1;
2804   GFX6_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v15_1, &values->Attribute[15]);
2805
2806   dw[15] =
2807      __gen_uint(v15_0, 0, 15) |
2808      __gen_uint(v15_1, 16, 31);
2809
2810   dw[16] =
2811      __gen_uint(values->PointSpriteTextureCoordinateEnable, 0, 31);
2812
2813   dw[17] =
2814      __gen_uint(values->ConstantInterpolationEnable, 0, 31);
2815
2816   dw[18] =
2817      __gen_uint(values->Attribute0WrapShortestEnables, 0, 3) |
2818      __gen_uint(values->Attribute1WrapShortestEnables, 4, 7) |
2819      __gen_uint(values->Attribute2WrapShortestEnables, 8, 11) |
2820      __gen_uint(values->Attribute3WrapShortestEnables, 12, 15) |
2821      __gen_uint(values->Attribute4WrapShortestEnables, 16, 19) |
2822      __gen_uint(values->Attribute5WrapShortestEnables, 20, 23) |
2823      __gen_uint(values->Attribute6WrapShortestEnables, 24, 27) |
2824      __gen_uint(values->Attribute7WrapShortestEnables, 28, 31);
2825
2826   dw[19] =
2827      __gen_uint(values->Attribute8WrapShortestEnables, 0, 3) |
2828      __gen_uint(values->Attribute9WrapShortestEnables, 4, 7) |
2829      __gen_uint(values->Attribute10WrapShortestEnables, 8, 11) |
2830      __gen_uint(values->Attribute11WrapShortestEnables, 12, 15) |
2831      __gen_uint(values->Attribute12WrapShortestEnables, 16, 19) |
2832      __gen_uint(values->Attribute13WrapShortestEnables, 20, 23) |
2833      __gen_uint(values->Attribute14WrapShortestEnables, 24, 27) |
2834      __gen_uint(values->Attribute15WrapShortestEnables, 28, 31);
2835}
2836
2837#define GFX6_3DSTATE_STENCIL_BUFFER_length      3
2838#define GFX6_3DSTATE_STENCIL_BUFFER_length_bias      2
2839#define GFX6_3DSTATE_STENCIL_BUFFER_header      \
2840   .DWordLength                         =      1,  \
2841   ._3DCommandSubOpcode                 =     14,  \
2842   ._3DCommandOpcode                    =      1,  \
2843   .CommandSubType                      =      3,  \
2844   .CommandType                         =      3
2845
2846struct GFX6_3DSTATE_STENCIL_BUFFER {
2847   uint32_t                             DWordLength;
2848   uint32_t                             _3DCommandSubOpcode;
2849   uint32_t                             _3DCommandOpcode;
2850   uint32_t                             CommandSubType;
2851   uint32_t                             CommandType;
2852   uint32_t                             SurfacePitch;
2853   uint32_t                             MOCS;
2854   __gen_address_type                   SurfaceBaseAddress;
2855};
2856
2857static inline __attribute__((always_inline)) void
2858GFX6_3DSTATE_STENCIL_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2859                                 __attribute__((unused)) void * restrict dst,
2860                                 __attribute__((unused)) const struct GFX6_3DSTATE_STENCIL_BUFFER * restrict values)
2861{
2862   uint32_t * restrict dw = (uint32_t * restrict) dst;
2863
2864   dw[0] =
2865      __gen_uint(values->DWordLength, 0, 7) |
2866      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2867      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2868      __gen_uint(values->CommandSubType, 27, 28) |
2869      __gen_uint(values->CommandType, 29, 31);
2870
2871   dw[1] =
2872      __gen_uint(values->SurfacePitch, 0, 16) |
2873      __gen_uint(values->MOCS, 25, 28);
2874
2875   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
2876}
2877
2878#define GFX6_3DSTATE_URB_length                3
2879#define GFX6_3DSTATE_URB_length_bias           2
2880#define GFX6_3DSTATE_URB_header                 \
2881   .DWordLength                         =      1,  \
2882   ._3DCommandSubOpcode                 =      5,  \
2883   ._3DCommandOpcode                    =      0,  \
2884   .CommandSubType                      =      3,  \
2885   .CommandType                         =      3
2886
2887struct GFX6_3DSTATE_URB {
2888   uint32_t                             DWordLength;
2889   uint32_t                             _3DCommandSubOpcode;
2890   uint32_t                             _3DCommandOpcode;
2891   uint32_t                             CommandSubType;
2892   uint32_t                             CommandType;
2893   uint32_t                             VSNumberofURBEntries;
2894   uint32_t                             VSURBEntryAllocationSize;
2895   uint32_t                             GSURBEntryAllocationSize;
2896   uint32_t                             GSNumberofURBEntries;
2897};
2898
2899static inline __attribute__((always_inline)) void
2900GFX6_3DSTATE_URB_pack(__attribute__((unused)) __gen_user_data *data,
2901                      __attribute__((unused)) void * restrict dst,
2902                      __attribute__((unused)) const struct GFX6_3DSTATE_URB * restrict values)
2903{
2904   uint32_t * restrict dw = (uint32_t * restrict) dst;
2905
2906   dw[0] =
2907      __gen_uint(values->DWordLength, 0, 7) |
2908      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2909      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2910      __gen_uint(values->CommandSubType, 27, 28) |
2911      __gen_uint(values->CommandType, 29, 31);
2912
2913   dw[1] =
2914      __gen_uint(values->VSNumberofURBEntries, 0, 15) |
2915      __gen_uint(values->VSURBEntryAllocationSize, 16, 23);
2916
2917   dw[2] =
2918      __gen_uint(values->GSURBEntryAllocationSize, 0, 2) |
2919      __gen_uint(values->GSNumberofURBEntries, 8, 17);
2920}
2921
2922#define GFX6_3DSTATE_VERTEX_BUFFERS_length_bias      2
2923#define GFX6_3DSTATE_VERTEX_BUFFERS_header      \
2924   .DWordLength                         =      3,  \
2925   ._3DCommandSubOpcode                 =      8,  \
2926   ._3DCommandOpcode                    =      0,  \
2927   .CommandSubType                      =      3,  \
2928   .CommandType                         =      3
2929
2930struct GFX6_3DSTATE_VERTEX_BUFFERS {
2931   uint32_t                             DWordLength;
2932   uint32_t                             _3DCommandSubOpcode;
2933   uint32_t                             _3DCommandOpcode;
2934   uint32_t                             CommandSubType;
2935   uint32_t                             CommandType;
2936   /* variable length fields follow */
2937};
2938
2939static inline __attribute__((always_inline)) void
2940GFX6_3DSTATE_VERTEX_BUFFERS_pack(__attribute__((unused)) __gen_user_data *data,
2941                                 __attribute__((unused)) void * restrict dst,
2942                                 __attribute__((unused)) const struct GFX6_3DSTATE_VERTEX_BUFFERS * restrict values)
2943{
2944   uint32_t * restrict dw = (uint32_t * restrict) dst;
2945
2946   dw[0] =
2947      __gen_uint(values->DWordLength, 0, 7) |
2948      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2949      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2950      __gen_uint(values->CommandSubType, 27, 28) |
2951      __gen_uint(values->CommandType, 29, 31);
2952}
2953
2954#define GFX6_3DSTATE_VERTEX_ELEMENTS_length_bias      2
2955#define GFX6_3DSTATE_VERTEX_ELEMENTS_header     \
2956   .DWordLength                         =      1,  \
2957   ._3DCommandSubOpcode                 =      9,  \
2958   ._3DCommandOpcode                    =      0,  \
2959   .CommandSubType                      =      3,  \
2960   .CommandType                         =      3
2961
2962struct GFX6_3DSTATE_VERTEX_ELEMENTS {
2963   uint32_t                             DWordLength;
2964   uint32_t                             _3DCommandSubOpcode;
2965   uint32_t                             _3DCommandOpcode;
2966   uint32_t                             CommandSubType;
2967   uint32_t                             CommandType;
2968   /* variable length fields follow */
2969};
2970
2971static inline __attribute__((always_inline)) void
2972GFX6_3DSTATE_VERTEX_ELEMENTS_pack(__attribute__((unused)) __gen_user_data *data,
2973                                  __attribute__((unused)) void * restrict dst,
2974                                  __attribute__((unused)) const struct GFX6_3DSTATE_VERTEX_ELEMENTS * restrict values)
2975{
2976   uint32_t * restrict dw = (uint32_t * restrict) dst;
2977
2978   dw[0] =
2979      __gen_uint(values->DWordLength, 0, 7) |
2980      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2981      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2982      __gen_uint(values->CommandSubType, 27, 28) |
2983      __gen_uint(values->CommandType, 29, 31);
2984}
2985
2986#define GFX6_3DSTATE_VF_STATISTICS_length      1
2987#define GFX6_3DSTATE_VF_STATISTICS_length_bias      1
2988#define GFX6_3DSTATE_VF_STATISTICS_header       \
2989   ._3DCommandSubOpcode                 =     11,  \
2990   ._3DCommandOpcode                    =      0,  \
2991   .CommandSubType                      =      1,  \
2992   .CommandType                         =      3
2993
2994struct GFX6_3DSTATE_VF_STATISTICS {
2995   bool                                 StatisticsEnable;
2996   uint32_t                             _3DCommandSubOpcode;
2997   uint32_t                             _3DCommandOpcode;
2998   uint32_t                             CommandSubType;
2999   uint32_t                             CommandType;
3000};
3001
3002static inline __attribute__((always_inline)) void
3003GFX6_3DSTATE_VF_STATISTICS_pack(__attribute__((unused)) __gen_user_data *data,
3004                                __attribute__((unused)) void * restrict dst,
3005                                __attribute__((unused)) const struct GFX6_3DSTATE_VF_STATISTICS * restrict values)
3006{
3007   uint32_t * restrict dw = (uint32_t * restrict) dst;
3008
3009   dw[0] =
3010      __gen_uint(values->StatisticsEnable, 0, 0) |
3011      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3012      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3013      __gen_uint(values->CommandSubType, 27, 28) |
3014      __gen_uint(values->CommandType, 29, 31);
3015}
3016
3017#define GFX6_3DSTATE_VIEWPORT_STATE_POINTERS_length      4
3018#define GFX6_3DSTATE_VIEWPORT_STATE_POINTERS_length_bias      2
3019#define GFX6_3DSTATE_VIEWPORT_STATE_POINTERS_header\
3020   .DWordLength                         =      2,  \
3021   ._3DCommandSubOpcode                 =     13,  \
3022   ._3DCommandOpcode                    =      0,  \
3023   .CommandSubType                      =      3,  \
3024   .CommandType                         =      3
3025
3026struct GFX6_3DSTATE_VIEWPORT_STATE_POINTERS {
3027   uint32_t                             DWordLength;
3028   uint32_t                             CLIPViewportStateChange;
3029   uint32_t                             SFViewportStateChange;
3030   uint32_t                             CCViewportStateChange;
3031   uint32_t                             _3DCommandSubOpcode;
3032   uint32_t                             _3DCommandOpcode;
3033   uint32_t                             CommandSubType;
3034   uint32_t                             CommandType;
3035   uint64_t                             PointertoCLIP_VIEWPORT;
3036   uint64_t                             PointertoSF_VIEWPORT;
3037   uint64_t                             PointertoCC_VIEWPORT;
3038};
3039
3040static inline __attribute__((always_inline)) void
3041GFX6_3DSTATE_VIEWPORT_STATE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
3042                                          __attribute__((unused)) void * restrict dst,
3043                                          __attribute__((unused)) const struct GFX6_3DSTATE_VIEWPORT_STATE_POINTERS * restrict values)
3044{
3045   uint32_t * restrict dw = (uint32_t * restrict) dst;
3046
3047   dw[0] =
3048      __gen_uint(values->DWordLength, 0, 7) |
3049      __gen_uint(values->CLIPViewportStateChange, 10, 10) |
3050      __gen_uint(values->SFViewportStateChange, 11, 11) |
3051      __gen_uint(values->CCViewportStateChange, 12, 12) |
3052      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3053      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3054      __gen_uint(values->CommandSubType, 27, 28) |
3055      __gen_uint(values->CommandType, 29, 31);
3056
3057   dw[1] =
3058      __gen_offset(values->PointertoCLIP_VIEWPORT, 5, 31);
3059
3060   dw[2] =
3061      __gen_offset(values->PointertoSF_VIEWPORT, 5, 31);
3062
3063   dw[3] =
3064      __gen_offset(values->PointertoCC_VIEWPORT, 5, 31);
3065}
3066
3067#define GFX6_3DSTATE_VS_length                 6
3068#define GFX6_3DSTATE_VS_length_bias            2
3069#define GFX6_3DSTATE_VS_header                  \
3070   .DWordLength                         =      4,  \
3071   ._3DCommandSubOpcode                 =     16,  \
3072   ._3DCommandOpcode                    =      0,  \
3073   .CommandSubType                      =      3,  \
3074   .CommandType                         =      3
3075
3076struct GFX6_3DSTATE_VS {
3077   uint32_t                             DWordLength;
3078   uint32_t                             _3DCommandSubOpcode;
3079   uint32_t                             _3DCommandOpcode;
3080   uint32_t                             CommandSubType;
3081   uint32_t                             CommandType;
3082   uint64_t                             KernelStartPointer;
3083   bool                                 SoftwareExceptionEnable;
3084   bool                                 IllegalOpcodeExceptionEnable;
3085   uint32_t                             FloatingPointMode;
3086#define IEEE754                                  0
3087#define Alternate                                1
3088   uint32_t                             BindingTableEntryCount;
3089   uint32_t                             SamplerCount;
3090#define NoSamplers                               0
3091#define _14Samplers                              1
3092#define _58Samplers                              2
3093#define _912Samplers                             3
3094#define _1316Samplers                            4
3095   bool                                 VectorMaskEnable;
3096   bool                                 SingleVertexDispatch;
3097   uint32_t                             PerThreadScratchSpace;
3098   __gen_address_type                   ScratchSpaceBasePointer;
3099   uint32_t                             VertexURBEntryReadOffset;
3100   uint32_t                             VertexURBEntryReadLength;
3101   uint32_t                             DispatchGRFStartRegisterForURBData;
3102   bool                                 Enable;
3103   bool                                 VertexCacheDisable;
3104   bool                                 StatisticsEnable;
3105   uint32_t                             MaximumNumberofThreads;
3106};
3107
3108static inline __attribute__((always_inline)) void
3109GFX6_3DSTATE_VS_pack(__attribute__((unused)) __gen_user_data *data,
3110                     __attribute__((unused)) void * restrict dst,
3111                     __attribute__((unused)) const struct GFX6_3DSTATE_VS * restrict values)
3112{
3113   uint32_t * restrict dw = (uint32_t * restrict) dst;
3114
3115   dw[0] =
3116      __gen_uint(values->DWordLength, 0, 7) |
3117      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3118      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3119      __gen_uint(values->CommandSubType, 27, 28) |
3120      __gen_uint(values->CommandType, 29, 31);
3121
3122   dw[1] =
3123      __gen_offset(values->KernelStartPointer, 6, 31);
3124
3125   dw[2] =
3126      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
3127      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
3128      __gen_uint(values->FloatingPointMode, 16, 16) |
3129      __gen_uint(values->BindingTableEntryCount, 18, 25) |
3130      __gen_uint(values->SamplerCount, 27, 29) |
3131      __gen_uint(values->VectorMaskEnable, 30, 30) |
3132      __gen_uint(values->SingleVertexDispatch, 31, 31);
3133
3134   const uint32_t v3 =
3135      __gen_uint(values->PerThreadScratchSpace, 0, 3);
3136   dw[3] = __gen_address(data, &dw[3], values->ScratchSpaceBasePointer, v3, 10, 31);
3137
3138   dw[4] =
3139      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
3140      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
3141      __gen_uint(values->DispatchGRFStartRegisterForURBData, 20, 24);
3142
3143   dw[5] =
3144      __gen_uint(values->Enable, 0, 0) |
3145      __gen_uint(values->VertexCacheDisable, 1, 1) |
3146      __gen_uint(values->StatisticsEnable, 10, 10) |
3147      __gen_uint(values->MaximumNumberofThreads, 25, 31);
3148}
3149
3150#define GFX6_3DSTATE_WM_length                 9
3151#define GFX6_3DSTATE_WM_length_bias            2
3152#define GFX6_3DSTATE_WM_header                  \
3153   .DWordLength                         =      7,  \
3154   ._3DCommandSubOpcode                 =     20,  \
3155   ._3DCommandOpcode                    =      0,  \
3156   .CommandSubType                      =      3,  \
3157   .CommandType                         =      3
3158
3159struct GFX6_3DSTATE_WM {
3160   uint32_t                             DWordLength;
3161   uint32_t                             _3DCommandSubOpcode;
3162   uint32_t                             _3DCommandOpcode;
3163   uint32_t                             CommandSubType;
3164   uint32_t                             CommandType;
3165   uint64_t                             KernelStartPointer0;
3166   bool                                 SoftwareExceptionEnable;
3167   bool                                 MaskStackExceptionEnable;
3168   bool                                 IllegalOpcodeExceptionEnable;
3169   uint32_t                             FloatingPointMode;
3170#define FLOATING_POINT_MODE_IEEE745              0
3171#define FLOATING_POINT_MODE_Alternate            1
3172   uint32_t                             ThreadPriority;
3173#define High                                     1
3174   uint32_t                             BindingTableEntryCount;
3175   uint32_t                             SamplerCount;
3176   bool                                 VectorMaskEnable;
3177   bool                                 SingleProgramFlow;
3178   uint32_t                             PerThreadScratchSpace;
3179   __gen_address_type                   ScratchSpaceBasePointer;
3180   uint32_t                             DispatchGRFStartRegisterForConstantSetupData2;
3181   uint32_t                             DispatchGRFStartRegisterForConstantSetupData1;
3182   uint32_t                             DispatchGRFStartRegisterForConstantSetupData0;
3183   bool                                 HierarchicalDepthBufferResolveEnable;
3184   bool                                 DepthBufferResolveEnable;
3185   bool                                 DepthBufferClear;
3186   bool                                 StatisticsEnable;
3187   bool                                 _8PixelDispatchEnable;
3188   bool                                 _16PixelDispatchEnable;
3189   bool                                 _32PixelDispatchEnable;
3190   bool                                 DualSourceBlendEnable;
3191   bool                                 PixelShaderUsesSourceW;
3192   bool                                 oMaskPresenttoRenderTarget;
3193   bool                                 LineStippleEnable;
3194   bool                                 PolygonStippleEnable;
3195   uint32_t                             LineAntialiasingRegionWidth;
3196#define _05pixels                                0
3197#define _10pixels                                1
3198#define _20pixels                                2
3199#define _40pixels                                3
3200   uint32_t                             LineEndCapAntialiasingRegionWidth;
3201#define _05pixels                                0
3202#define _10pixels                                1
3203#define _20pixels                                2
3204#define _40pixels                                3
3205   bool                                 ThreadDispatchEnable;
3206   bool                                 PixelShaderUsesSourceDepth;
3207   bool                                 PixelShaderComputedDepth;
3208   bool                                 PixelShaderKillsPixel;
3209   bool                                 LegacyDiamondLineRasterization;
3210   uint32_t                             MaximumNumberofThreads;
3211   uint32_t                             MultisampleDispatchMode;
3212#define MSDISPMODE_PERSAMPLE                     0
3213#define MSDISPMODE_PERPIXEL                      1
3214   uint32_t                             MultisampleRasterizationMode;
3215#define MSRASTMODE_OFF_PIXEL                     0
3216#define MSRASTMODE_OFF_PATTERN                   1
3217#define MSRASTMODE_ON_PIXEL                      2
3218#define MSRASTMODE_ON_PATTERN                    3
3219   uint32_t                             PointRasterizationRule;
3220#define RASTRULE_UPPER_LEFT                      0
3221#define RASTRULE_UPPER_RIGHT                     1
3222   uint32_t                             BarycentricInterpolationMode;
3223#define BIM_PERSPECTIVE_PIXEL                    1
3224#define BIM_PERSPECTIVE_CENTROID                 2
3225#define BIM_PERSPECTIVE_SAMPLE                   4
3226#define BIM_LINEAR_PIXEL                         8
3227#define BIM_LINEAR_CENTROID                      16
3228#define BIM_LINEAR_SAMPLE                        32
3229   uint32_t                             PositionZWInterpolationMode;
3230#define INTERP_PIXEL                             0
3231#define INTERP_CENTROID                          2
3232#define INTERP_SAMPLE                            3
3233   uint32_t                             PositionXYOffsetSelect;
3234#define POSOFFSET_NONE                           0
3235#define POSOFFSET_CENTROID                       2
3236#define POSOFFSET_SAMPLE                         3
3237   uint32_t                             NumberofSFOutputAttributes;
3238   uint64_t                             KernelStartPointer1;
3239   uint64_t                             KernelStartPointer2;
3240};
3241
3242static inline __attribute__((always_inline)) void
3243GFX6_3DSTATE_WM_pack(__attribute__((unused)) __gen_user_data *data,
3244                     __attribute__((unused)) void * restrict dst,
3245                     __attribute__((unused)) const struct GFX6_3DSTATE_WM * restrict values)
3246{
3247   uint32_t * restrict dw = (uint32_t * restrict) dst;
3248
3249   dw[0] =
3250      __gen_uint(values->DWordLength, 0, 7) |
3251      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3252      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3253      __gen_uint(values->CommandSubType, 27, 28) |
3254      __gen_uint(values->CommandType, 29, 31);
3255
3256   dw[1] =
3257      __gen_offset(values->KernelStartPointer0, 6, 31);
3258
3259   dw[2] =
3260      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
3261      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
3262      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
3263      __gen_uint(values->FloatingPointMode, 16, 16) |
3264      __gen_uint(values->ThreadPriority, 17, 17) |
3265      __gen_uint(values->BindingTableEntryCount, 18, 25) |
3266      __gen_uint(values->SamplerCount, 27, 29) |
3267      __gen_uint(values->VectorMaskEnable, 30, 30) |
3268      __gen_uint(values->SingleProgramFlow, 31, 31);
3269
3270   const uint32_t v3 =
3271      __gen_uint(values->PerThreadScratchSpace, 0, 3);
3272   dw[3] = __gen_address(data, &dw[3], values->ScratchSpaceBasePointer, v3, 10, 31);
3273
3274   dw[4] =
3275      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData2, 0, 6) |
3276      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData1, 8, 14) |
3277      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData0, 16, 22) |
3278      __gen_uint(values->HierarchicalDepthBufferResolveEnable, 27, 27) |
3279      __gen_uint(values->DepthBufferResolveEnable, 28, 28) |
3280      __gen_uint(values->DepthBufferClear, 30, 30) |
3281      __gen_uint(values->StatisticsEnable, 31, 31);
3282
3283   dw[5] =
3284      __gen_uint(values->_8PixelDispatchEnable, 0, 0) |
3285      __gen_uint(values->_16PixelDispatchEnable, 1, 1) |
3286      __gen_uint(values->_32PixelDispatchEnable, 2, 2) |
3287      __gen_uint(values->DualSourceBlendEnable, 7, 7) |
3288      __gen_uint(values->PixelShaderUsesSourceW, 8, 8) |
3289      __gen_uint(values->oMaskPresenttoRenderTarget, 9, 9) |
3290      __gen_uint(values->LineStippleEnable, 11, 11) |
3291      __gen_uint(values->PolygonStippleEnable, 13, 13) |
3292      __gen_uint(values->LineAntialiasingRegionWidth, 14, 15) |
3293      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 16, 17) |
3294      __gen_uint(values->ThreadDispatchEnable, 19, 19) |
3295      __gen_uint(values->PixelShaderUsesSourceDepth, 20, 20) |
3296      __gen_uint(values->PixelShaderComputedDepth, 21, 21) |
3297      __gen_uint(values->PixelShaderKillsPixel, 22, 22) |
3298      __gen_uint(values->LegacyDiamondLineRasterization, 23, 23) |
3299      __gen_uint(values->MaximumNumberofThreads, 25, 31);
3300
3301   dw[6] =
3302      __gen_uint(values->MultisampleDispatchMode, 0, 0) |
3303      __gen_uint(values->MultisampleRasterizationMode, 1, 2) |
3304      __gen_uint(values->PointRasterizationRule, 9, 9) |
3305      __gen_uint(values->BarycentricInterpolationMode, 10, 15) |
3306      __gen_uint(values->PositionZWInterpolationMode, 16, 17) |
3307      __gen_uint(values->PositionXYOffsetSelect, 18, 19) |
3308      __gen_uint(values->NumberofSFOutputAttributes, 20, 25);
3309
3310   dw[7] =
3311      __gen_offset(values->KernelStartPointer1, 6, 31);
3312
3313   dw[8] =
3314      __gen_offset(values->KernelStartPointer2, 6, 31);
3315}
3316
3317#define GFX6_MEDIA_CURBE_LOAD_length           4
3318#define GFX6_MEDIA_CURBE_LOAD_length_bias      2
3319#define GFX6_MEDIA_CURBE_LOAD_header            \
3320   .DWordLength                         =      2,  \
3321   .SubOpcode                           =      1,  \
3322   .MediaCommandOpcode                  =      0,  \
3323   .Pipeline                            =      2,  \
3324   .CommandType                         =      3
3325
3326struct GFX6_MEDIA_CURBE_LOAD {
3327   uint32_t                             DWordLength;
3328   uint32_t                             SubOpcode;
3329   uint32_t                             MediaCommandOpcode;
3330   uint32_t                             Pipeline;
3331   uint32_t                             CommandType;
3332   uint32_t                             CURBETotalDataLength;
3333   uint32_t                             CURBEDataStartAddress;
3334};
3335
3336static inline __attribute__((always_inline)) void
3337GFX6_MEDIA_CURBE_LOAD_pack(__attribute__((unused)) __gen_user_data *data,
3338                           __attribute__((unused)) void * restrict dst,
3339                           __attribute__((unused)) const struct GFX6_MEDIA_CURBE_LOAD * restrict values)
3340{
3341   uint32_t * restrict dw = (uint32_t * restrict) dst;
3342
3343   dw[0] =
3344      __gen_uint(values->DWordLength, 0, 15) |
3345      __gen_uint(values->SubOpcode, 16, 23) |
3346      __gen_uint(values->MediaCommandOpcode, 24, 26) |
3347      __gen_uint(values->Pipeline, 27, 28) |
3348      __gen_uint(values->CommandType, 29, 31);
3349
3350   dw[1] = 0;
3351
3352   dw[2] =
3353      __gen_uint(values->CURBETotalDataLength, 0, 16);
3354
3355   dw[3] =
3356      __gen_uint(values->CURBEDataStartAddress, 0, 31);
3357}
3358
3359#define GFX6_MEDIA_GATEWAY_STATE_length        2
3360#define GFX6_MEDIA_GATEWAY_STATE_length_bias      2
3361#define GFX6_MEDIA_GATEWAY_STATE_header         \
3362   .DWordLength                         =      0,  \
3363   .SubOpcode                           =      3,  \
3364   .MediaCommandOpcode                  =      0,  \
3365   .Pipeline                            =      2,  \
3366   .CommandType                         =      3
3367
3368struct GFX6_MEDIA_GATEWAY_STATE {
3369   uint32_t                             DWordLength;
3370   uint32_t                             SubOpcode;
3371   uint32_t                             MediaCommandOpcode;
3372   uint32_t                             Pipeline;
3373   uint32_t                             CommandType;
3374   uint32_t                             BarrierThreadCount;
3375   uint32_t                             BarrierByte;
3376   uint32_t                             BarrierID;
3377};
3378
3379static inline __attribute__((always_inline)) void
3380GFX6_MEDIA_GATEWAY_STATE_pack(__attribute__((unused)) __gen_user_data *data,
3381                              __attribute__((unused)) void * restrict dst,
3382                              __attribute__((unused)) const struct GFX6_MEDIA_GATEWAY_STATE * restrict values)
3383{
3384   uint32_t * restrict dw = (uint32_t * restrict) dst;
3385
3386   dw[0] =
3387      __gen_uint(values->DWordLength, 0, 15) |
3388      __gen_uint(values->SubOpcode, 16, 23) |
3389      __gen_uint(values->MediaCommandOpcode, 24, 26) |
3390      __gen_uint(values->Pipeline, 27, 28) |
3391      __gen_uint(values->CommandType, 29, 31);
3392
3393   dw[1] =
3394      __gen_uint(values->BarrierThreadCount, 0, 7) |
3395      __gen_uint(values->BarrierByte, 8, 15) |
3396      __gen_uint(values->BarrierID, 16, 23);
3397}
3398
3399#define GFX6_MEDIA_INTERFACE_DESCRIPTOR_LOAD_length      4
3400#define GFX6_MEDIA_INTERFACE_DESCRIPTOR_LOAD_length_bias      2
3401#define GFX6_MEDIA_INTERFACE_DESCRIPTOR_LOAD_header\
3402   .DWordLength                         =      2,  \
3403   .SubOpcode                           =      2,  \
3404   .MediaCommandOpcode                  =      0,  \
3405   .Pipeline                            =      2,  \
3406   .CommandType                         =      3
3407
3408struct GFX6_MEDIA_INTERFACE_DESCRIPTOR_LOAD {
3409   uint32_t                             DWordLength;
3410   uint32_t                             SubOpcode;
3411   uint32_t                             MediaCommandOpcode;
3412   uint32_t                             Pipeline;
3413   uint32_t                             CommandType;
3414   uint32_t                             InterfaceDescriptorTotalLength;
3415   uint64_t                             InterfaceDescriptorDataStartAddress;
3416};
3417
3418static inline __attribute__((always_inline)) void
3419GFX6_MEDIA_INTERFACE_DESCRIPTOR_LOAD_pack(__attribute__((unused)) __gen_user_data *data,
3420                                          __attribute__((unused)) void * restrict dst,
3421                                          __attribute__((unused)) const struct GFX6_MEDIA_INTERFACE_DESCRIPTOR_LOAD * restrict values)
3422{
3423   uint32_t * restrict dw = (uint32_t * restrict) dst;
3424
3425   dw[0] =
3426      __gen_uint(values->DWordLength, 0, 15) |
3427      __gen_uint(values->SubOpcode, 16, 23) |
3428      __gen_uint(values->MediaCommandOpcode, 24, 26) |
3429      __gen_uint(values->Pipeline, 27, 28) |
3430      __gen_uint(values->CommandType, 29, 31);
3431
3432   dw[1] = 0;
3433
3434   dw[2] =
3435      __gen_uint(values->InterfaceDescriptorTotalLength, 0, 16);
3436
3437   dw[3] =
3438      __gen_offset(values->InterfaceDescriptorDataStartAddress, 0, 31);
3439}
3440
3441#define GFX6_MEDIA_OBJECT_length_bias          2
3442#define GFX6_MEDIA_OBJECT_header                \
3443   .DWordLength                         =      4,  \
3444   .MediaCommandSubOpcode               =      0,  \
3445   .MediaCommandOpcode                  =      1,  \
3446   .MediaCommandPipeline                =      2,  \
3447   .CommandType                         =      3
3448
3449struct GFX6_MEDIA_OBJECT {
3450   uint32_t                             DWordLength;
3451   uint32_t                             MediaCommandSubOpcode;
3452   uint32_t                             MediaCommandOpcode;
3453   uint32_t                             MediaCommandPipeline;
3454   uint32_t                             CommandType;
3455   uint32_t                             InterfaceDescriptorOffset;
3456   uint32_t                             IndirectDataLength;
3457   uint32_t                             UseScoreboard;
3458#define Notusingscoreboard                       0
3459#define Usingscoreboard                          1
3460   uint32_t                             ThreadSynchronization;
3461#define Nothreadsynchronization                  0
3462#define Threaddispatchissynchronizedbythespawnrootthreadmessage 1
3463   bool                                 ChildrenPresent;
3464   __gen_address_type                   IndirectDataStartAddress;
3465   uint32_t                             ScoreboardX;
3466   uint32_t                             ScoredboardY;
3467   uint32_t                             ScoreboardMask;
3468   uint32_t                             ScoreboardColor;
3469   /* variable length fields follow */
3470};
3471
3472static inline __attribute__((always_inline)) void
3473GFX6_MEDIA_OBJECT_pack(__attribute__((unused)) __gen_user_data *data,
3474                       __attribute__((unused)) void * restrict dst,
3475                       __attribute__((unused)) const struct GFX6_MEDIA_OBJECT * restrict values)
3476{
3477   uint32_t * restrict dw = (uint32_t * restrict) dst;
3478
3479   dw[0] =
3480      __gen_uint(values->DWordLength, 0, 15) |
3481      __gen_uint(values->MediaCommandSubOpcode, 16, 23) |
3482      __gen_uint(values->MediaCommandOpcode, 24, 26) |
3483      __gen_uint(values->MediaCommandPipeline, 27, 28) |
3484      __gen_uint(values->CommandType, 29, 31);
3485
3486   dw[1] =
3487      __gen_uint(values->InterfaceDescriptorOffset, 0, 4);
3488
3489   dw[2] =
3490      __gen_uint(values->IndirectDataLength, 0, 16) |
3491      __gen_uint(values->UseScoreboard, 21, 21) |
3492      __gen_uint(values->ThreadSynchronization, 24, 24) |
3493      __gen_uint(values->ChildrenPresent, 31, 31);
3494
3495   dw[3] = __gen_address(data, &dw[3], values->IndirectDataStartAddress, 0, 0, 31);
3496
3497   dw[4] =
3498      __gen_uint(values->ScoreboardX, 0, 8) |
3499      __gen_uint(values->ScoredboardY, 16, 24);
3500
3501   dw[5] =
3502      __gen_uint(values->ScoreboardMask, 0, 7) |
3503      __gen_uint(values->ScoreboardColor, 16, 19);
3504}
3505
3506#define GFX6_MEDIA_OBJECT_PRT_length          16
3507#define GFX6_MEDIA_OBJECT_PRT_length_bias      2
3508#define GFX6_MEDIA_OBJECT_PRT_header            \
3509   .DWordLength                         =     14,  \
3510   .SubOpcode                           =      2,  \
3511   .MediaCommandOpcode                  =      1,  \
3512   .Pipeline                            =      2,  \
3513   .CommandType                         =      3
3514
3515struct GFX6_MEDIA_OBJECT_PRT {
3516   uint32_t                             DWordLength;
3517   uint32_t                             SubOpcode;
3518   uint32_t                             MediaCommandOpcode;
3519   uint32_t                             Pipeline;
3520   uint32_t                             CommandType;
3521   uint32_t                             InterfaceDescriptorOffset;
3522   uint32_t                             PRT_FenceType;
3523#define Rootthreadqueue                          0
3524#define VFEstateflush                            1
3525   bool                                 PRT_FenceNeeded;
3526   bool                                 ChildrenPresent;
3527   uint32_t                             InlineData[12];
3528};
3529
3530static inline __attribute__((always_inline)) void
3531GFX6_MEDIA_OBJECT_PRT_pack(__attribute__((unused)) __gen_user_data *data,
3532                           __attribute__((unused)) void * restrict dst,
3533                           __attribute__((unused)) const struct GFX6_MEDIA_OBJECT_PRT * restrict values)
3534{
3535   uint32_t * restrict dw = (uint32_t * restrict) dst;
3536
3537   dw[0] =
3538      __gen_uint(values->DWordLength, 0, 15) |
3539      __gen_uint(values->SubOpcode, 16, 23) |
3540      __gen_uint(values->MediaCommandOpcode, 24, 26) |
3541      __gen_uint(values->Pipeline, 27, 28) |
3542      __gen_uint(values->CommandType, 29, 31);
3543
3544   dw[1] =
3545      __gen_uint(values->InterfaceDescriptorOffset, 0, 4);
3546
3547   dw[2] =
3548      __gen_uint(values->PRT_FenceType, 22, 22) |
3549      __gen_uint(values->PRT_FenceNeeded, 23, 23) |
3550      __gen_uint(values->ChildrenPresent, 31, 31);
3551
3552   dw[3] = 0;
3553
3554   dw[4] =
3555      __gen_uint(values->InlineData[0], 0, 31);
3556
3557   dw[5] =
3558      __gen_uint(values->InlineData[1], 0, 31);
3559
3560   dw[6] =
3561      __gen_uint(values->InlineData[2], 0, 31);
3562
3563   dw[7] =
3564      __gen_uint(values->InlineData[3], 0, 31);
3565
3566   dw[8] =
3567      __gen_uint(values->InlineData[4], 0, 31);
3568
3569   dw[9] =
3570      __gen_uint(values->InlineData[5], 0, 31);
3571
3572   dw[10] =
3573      __gen_uint(values->InlineData[6], 0, 31);
3574
3575   dw[11] =
3576      __gen_uint(values->InlineData[7], 0, 31);
3577
3578   dw[12] =
3579      __gen_uint(values->InlineData[8], 0, 31);
3580
3581   dw[13] =
3582      __gen_uint(values->InlineData[9], 0, 31);
3583
3584   dw[14] =
3585      __gen_uint(values->InlineData[10], 0, 31);
3586
3587   dw[15] =
3588      __gen_uint(values->InlineData[11], 0, 31);
3589}
3590
3591#define GFX6_MEDIA_OBJECT_WALKER_length_bias      2
3592#define GFX6_MEDIA_OBJECT_WALKER_header         \
3593   .DWordLength                         =     15,  \
3594   .SubOpcode                           =      3,  \
3595   .MediaCommandOpcode                  =      1,  \
3596   .Pipeline                            =      2,  \
3597   .CommandType                         =      3
3598
3599struct GFX6_MEDIA_OBJECT_WALKER {
3600   uint32_t                             DWordLength;
3601   uint32_t                             SubOpcode;
3602   uint32_t                             MediaCommandOpcode;
3603   uint32_t                             Pipeline;
3604   uint32_t                             CommandType;
3605   uint32_t                             InterfaceDescriptorOffset;
3606   uint32_t                             IndirectDataLength;
3607   uint32_t                             UseScoreboard;
3608#define Notusingscoreboard                       0
3609#define Usingscoreboard                          1
3610   uint32_t                             ThreadSynchronization;
3611#define Nothreadsynchronization                  0
3612#define Threaddispatchissynchronizedbythespawnrootthreadmessage 1
3613   uint32_t                             ChildrenPresent;
3614   uint64_t                             IndirectDataStartAddress;
3615   uint32_t                             ScoreboardMask;
3616   int32_t                              MidLoopUnitX;
3617   int32_t                              LocalMidLoopUnitY;
3618   uint32_t                             MiddleLoopExtraSteps;
3619   uint32_t                             ColorCountMinusOne;
3620   uint32_t                             Repel;
3621   uint32_t                             DualMode;
3622   uint32_t                             LocalLoopExecCount;
3623   uint32_t                             GlobalLoopExecCount;
3624   uint32_t                             BlockResolutionX;
3625   uint32_t                             BlockResolutionY;
3626   uint32_t                             LocalStartX;
3627   uint32_t                             LocalStartY;
3628   uint32_t                             LocalEndX;
3629   uint32_t                             LocalEndY;
3630   int32_t                              LocalOuterLoopStrideX;
3631   int32_t                              LocalOuterLoopStrideY;
3632   int32_t                              LocalInnerLoopUnitX;
3633   int32_t                              LocalInnerLoopUnitY;
3634   uint32_t                             GlobalResolutionX;
3635   uint32_t                             GlobalResolutionY;
3636   int32_t                              GlobalStartX;
3637   int32_t                              GlobalStartY;
3638   int32_t                              GlobalOuterLoopStrideX;
3639   int32_t                              GlobalOuterLoopStrideY;
3640   int32_t                              GlobalInnerLoopUnitX;
3641   int32_t                              GlobalInnerLoopUnitY;
3642   /* variable length fields follow */
3643};
3644
3645static inline __attribute__((always_inline)) void
3646GFX6_MEDIA_OBJECT_WALKER_pack(__attribute__((unused)) __gen_user_data *data,
3647                              __attribute__((unused)) void * restrict dst,
3648                              __attribute__((unused)) const struct GFX6_MEDIA_OBJECT_WALKER * restrict values)
3649{
3650   uint32_t * restrict dw = (uint32_t * restrict) dst;
3651
3652   dw[0] =
3653      __gen_uint(values->DWordLength, 0, 15) |
3654      __gen_uint(values->SubOpcode, 16, 23) |
3655      __gen_uint(values->MediaCommandOpcode, 24, 26) |
3656      __gen_uint(values->Pipeline, 27, 28) |
3657      __gen_uint(values->CommandType, 29, 31);
3658
3659   dw[1] =
3660      __gen_uint(values->InterfaceDescriptorOffset, 0, 4);
3661
3662   dw[2] =
3663      __gen_uint(values->IndirectDataLength, 0, 16) |
3664      __gen_uint(values->UseScoreboard, 21, 21) |
3665      __gen_uint(values->ThreadSynchronization, 24, 24) |
3666      __gen_uint(values->ChildrenPresent, 31, 31);
3667
3668   dw[3] =
3669      __gen_offset(values->IndirectDataStartAddress, 0, 31);
3670
3671   dw[4] = 0;
3672
3673   dw[5] =
3674      __gen_uint(values->ScoreboardMask, 0, 7);
3675
3676   dw[6] =
3677      __gen_sint(values->MidLoopUnitX, 8, 9) |
3678      __gen_sint(values->LocalMidLoopUnitY, 12, 13) |
3679      __gen_uint(values->MiddleLoopExtraSteps, 16, 20) |
3680      __gen_uint(values->ColorCountMinusOne, 24, 27) |
3681      __gen_uint(values->Repel, 30, 30) |
3682      __gen_uint(values->DualMode, 31, 31);
3683
3684   dw[7] =
3685      __gen_uint(values->LocalLoopExecCount, 0, 9) |
3686      __gen_uint(values->GlobalLoopExecCount, 16, 25);
3687
3688   dw[8] =
3689      __gen_uint(values->BlockResolutionX, 0, 8) |
3690      __gen_uint(values->BlockResolutionY, 16, 24);
3691
3692   dw[9] =
3693      __gen_uint(values->LocalStartX, 0, 8) |
3694      __gen_uint(values->LocalStartY, 16, 24);
3695
3696   dw[10] =
3697      __gen_uint(values->LocalEndX, 0, 8) |
3698      __gen_uint(values->LocalEndY, 16, 24);
3699
3700   dw[11] =
3701      __gen_sint(values->LocalOuterLoopStrideX, 0, 9) |
3702      __gen_sint(values->LocalOuterLoopStrideY, 16, 25);
3703
3704   dw[12] =
3705      __gen_sint(values->LocalInnerLoopUnitX, 0, 9) |
3706      __gen_sint(values->LocalInnerLoopUnitY, 16, 25);
3707
3708   dw[13] =
3709      __gen_uint(values->GlobalResolutionX, 0, 8) |
3710      __gen_uint(values->GlobalResolutionY, 16, 24);
3711
3712   dw[14] =
3713      __gen_sint(values->GlobalStartX, 0, 9) |
3714      __gen_sint(values->GlobalStartY, 16, 25);
3715
3716   dw[15] =
3717      __gen_sint(values->GlobalOuterLoopStrideX, 0, 9) |
3718      __gen_sint(values->GlobalOuterLoopStrideY, 16, 25);
3719
3720   dw[16] =
3721      __gen_sint(values->GlobalInnerLoopUnitX, 0, 9) |
3722      __gen_sint(values->GlobalInnerLoopUnitY, 16, 25);
3723}
3724
3725#define GFX6_MEDIA_STATE_FLUSH_length          2
3726#define GFX6_MEDIA_STATE_FLUSH_length_bias      2
3727#define GFX6_MEDIA_STATE_FLUSH_header           \
3728   .DWordLength                         =      0,  \
3729   .SubOpcode                           =      4,  \
3730   .MediaCommandOpcode                  =      0,  \
3731   .Pipeline                            =      2,  \
3732   .CommandType                         =      3
3733
3734struct GFX6_MEDIA_STATE_FLUSH {
3735   uint32_t                             DWordLength;
3736   uint32_t                             SubOpcode;
3737   uint32_t                             MediaCommandOpcode;
3738   uint32_t                             Pipeline;
3739   uint32_t                             CommandType;
3740   uint32_t                             BarrierMask;
3741#define NotWaiting                               0
3742#define Waiting                                  1
3743   uint32_t                             ThreadCountWaterMark;
3744};
3745
3746static inline __attribute__((always_inline)) void
3747GFX6_MEDIA_STATE_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
3748                            __attribute__((unused)) void * restrict dst,
3749                            __attribute__((unused)) const struct GFX6_MEDIA_STATE_FLUSH * restrict values)
3750{
3751   uint32_t * restrict dw = (uint32_t * restrict) dst;
3752
3753   dw[0] =
3754      __gen_uint(values->DWordLength, 0, 15) |
3755      __gen_uint(values->SubOpcode, 16, 23) |
3756      __gen_uint(values->MediaCommandOpcode, 24, 26) |
3757      __gen_uint(values->Pipeline, 27, 28) |
3758      __gen_uint(values->CommandType, 29, 31);
3759
3760   dw[1] =
3761      __gen_uint(values->BarrierMask, 0, 15) |
3762      __gen_uint(values->ThreadCountWaterMark, 16, 23);
3763}
3764
3765#define GFX6_MEDIA_VFE_STATE_length            8
3766#define GFX6_MEDIA_VFE_STATE_length_bias       2
3767#define GFX6_MEDIA_VFE_STATE_header             \
3768   .DWordLength                         =      6,  \
3769   .SubOpcode                           =      0,  \
3770   .MediaCommandOpcode                  =      0,  \
3771   .Pipeline                            =      2,  \
3772   .CommandType                         =      3
3773
3774struct GFX6_MEDIA_VFE_STATE {
3775   uint32_t                             DWordLength;
3776   uint32_t                             SubOpcode;
3777   uint32_t                             MediaCommandOpcode;
3778   uint32_t                             Pipeline;
3779   uint32_t                             CommandType;
3780   uint32_t                             PerThreadScratchSpace;
3781   __gen_address_type                   ScratchSpaceBasePointer;
3782   uint32_t                             FastPreempt;
3783#define Preemptonly_PRT                          0
3784   uint32_t                             BypassGatewayControl;
3785#define MaintainingOpenGatewayForwardMsgCloseGatewayprotocollegacymode 0
3786#define BypassingOpenGatewayCloseGatewayprotocol 1
3787   uint32_t                             ResetGatewayTimer;
3788#define Maintainingtheexistingtimestampstate     0
3789#define Resettingrelativetimerandlatchingtheglobaltimestamp 1
3790   uint32_t                             NumberofURBEntries;
3791   uint32_t                             MaximumNumberofThreads;
3792   uint32_t                             CURBEAllocationSize;
3793   uint32_t                             URBEntryAllocationSize;
3794   uint32_t                             ScoreboardMask;
3795   uint32_t                             ScoreboardType;
3796#define StallingScoreboard                       0
3797   uint32_t                             ScoreboardEnable;
3798#define Scoreboarddisabled                       0
3799#define Scoreboardenabled                        1
3800   int32_t                              Scoreboard0DeltaX;
3801   int32_t                              Scoreboard0DeltaY;
3802   int32_t                              Scoreboard1DeltaX;
3803   int32_t                              Scoreboard1DeltaY;
3804   int32_t                              Scoreboard2DeltaX;
3805   int32_t                              Scoreboard2DeltaY;
3806   int32_t                              Scoreboard3DeltaX;
3807   int32_t                              Scoreboard3DeltaY;
3808   int32_t                              Scoreboard4DeltaX;
3809   int32_t                              Scoreboard4DeltaY;
3810   int32_t                              Scoreboard5DeltaX;
3811   int32_t                              Scoreboard5DeltaY;
3812   int32_t                              Scoreboard6DeltaX;
3813   int32_t                              Scoreboard6DeltaY;
3814   int32_t                              Scoreboard7DeltaX;
3815   int32_t                              Scoreboard7DeltaY;
3816};
3817
3818static inline __attribute__((always_inline)) void
3819GFX6_MEDIA_VFE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
3820                          __attribute__((unused)) void * restrict dst,
3821                          __attribute__((unused)) const struct GFX6_MEDIA_VFE_STATE * restrict values)
3822{
3823   uint32_t * restrict dw = (uint32_t * restrict) dst;
3824
3825   dw[0] =
3826      __gen_uint(values->DWordLength, 0, 15) |
3827      __gen_uint(values->SubOpcode, 16, 23) |
3828      __gen_uint(values->MediaCommandOpcode, 24, 26) |
3829      __gen_uint(values->Pipeline, 27, 28) |
3830      __gen_uint(values->CommandType, 29, 31);
3831
3832   const uint32_t v1 =
3833      __gen_uint(values->PerThreadScratchSpace, 0, 3);
3834   dw[1] = __gen_address(data, &dw[1], values->ScratchSpaceBasePointer, v1, 10, 31);
3835
3836   dw[2] =
3837      __gen_uint(values->FastPreempt, 5, 5) |
3838      __gen_uint(values->BypassGatewayControl, 6, 6) |
3839      __gen_uint(values->ResetGatewayTimer, 7, 7) |
3840      __gen_uint(values->NumberofURBEntries, 8, 15) |
3841      __gen_uint(values->MaximumNumberofThreads, 16, 31);
3842
3843   dw[3] = 0;
3844
3845   dw[4] =
3846      __gen_uint(values->CURBEAllocationSize, 0, 15) |
3847      __gen_uint(values->URBEntryAllocationSize, 16, 31);
3848
3849   dw[5] =
3850      __gen_uint(values->ScoreboardMask, 0, 7) |
3851      __gen_uint(values->ScoreboardType, 30, 30) |
3852      __gen_uint(values->ScoreboardEnable, 31, 31);
3853
3854   dw[6] =
3855      __gen_sint(values->Scoreboard0DeltaX, 0, 3) |
3856      __gen_sint(values->Scoreboard0DeltaY, 4, 7) |
3857      __gen_sint(values->Scoreboard1DeltaX, 8, 11) |
3858      __gen_sint(values->Scoreboard1DeltaY, 12, 15) |
3859      __gen_sint(values->Scoreboard2DeltaX, 16, 19) |
3860      __gen_sint(values->Scoreboard2DeltaY, 20, 23) |
3861      __gen_sint(values->Scoreboard3DeltaX, 24, 27) |
3862      __gen_sint(values->Scoreboard3DeltaY, 28, 31);
3863
3864   dw[7] =
3865      __gen_sint(values->Scoreboard4DeltaX, 0, 3) |
3866      __gen_sint(values->Scoreboard4DeltaY, 4, 7) |
3867      __gen_sint(values->Scoreboard5DeltaX, 8, 11) |
3868      __gen_sint(values->Scoreboard5DeltaY, 12, 15) |
3869      __gen_sint(values->Scoreboard6DeltaX, 16, 19) |
3870      __gen_sint(values->Scoreboard6DeltaY, 20, 23) |
3871      __gen_sint(values->Scoreboard7DeltaX, 24, 27) |
3872      __gen_sint(values->Scoreboard7DeltaY, 28, 31);
3873}
3874
3875#define GFX6_MI_ARB_CHECK_length               1
3876#define GFX6_MI_ARB_CHECK_length_bias          1
3877#define GFX6_MI_ARB_CHECK_header                \
3878   .MICommandOpcode                     =      5,  \
3879   .CommandType                         =      0
3880
3881struct GFX6_MI_ARB_CHECK {
3882   uint32_t                             MICommandOpcode;
3883   uint32_t                             CommandType;
3884};
3885
3886static inline __attribute__((always_inline)) void
3887GFX6_MI_ARB_CHECK_pack(__attribute__((unused)) __gen_user_data *data,
3888                       __attribute__((unused)) void * restrict dst,
3889                       __attribute__((unused)) const struct GFX6_MI_ARB_CHECK * restrict values)
3890{
3891   uint32_t * restrict dw = (uint32_t * restrict) dst;
3892
3893   dw[0] =
3894      __gen_uint(values->MICommandOpcode, 23, 28) |
3895      __gen_uint(values->CommandType, 29, 31);
3896}
3897
3898#define GFX6_MI_ARB_ON_OFF_length              1
3899#define GFX6_MI_ARB_ON_OFF_length_bias         1
3900#define GFX6_MI_ARB_ON_OFF_header               \
3901   .MICommandOpcode                     =      8,  \
3902   .CommandType                         =      0
3903
3904struct GFX6_MI_ARB_ON_OFF {
3905   bool                                 ArbitrationEnable;
3906   uint32_t                             MICommandOpcode;
3907   uint32_t                             CommandType;
3908};
3909
3910static inline __attribute__((always_inline)) void
3911GFX6_MI_ARB_ON_OFF_pack(__attribute__((unused)) __gen_user_data *data,
3912                        __attribute__((unused)) void * restrict dst,
3913                        __attribute__((unused)) const struct GFX6_MI_ARB_ON_OFF * restrict values)
3914{
3915   uint32_t * restrict dw = (uint32_t * restrict) dst;
3916
3917   dw[0] =
3918      __gen_uint(values->ArbitrationEnable, 0, 0) |
3919      __gen_uint(values->MICommandOpcode, 23, 28) |
3920      __gen_uint(values->CommandType, 29, 31);
3921}
3922
3923#define GFX6_MI_BATCH_BUFFER_END_length        1
3924#define GFX6_MI_BATCH_BUFFER_END_length_bias      1
3925#define GFX6_MI_BATCH_BUFFER_END_header         \
3926   .MICommandOpcode                     =     10,  \
3927   .CommandType                         =      0
3928
3929struct GFX6_MI_BATCH_BUFFER_END {
3930   uint32_t                             MICommandOpcode;
3931   uint32_t                             CommandType;
3932};
3933
3934static inline __attribute__((always_inline)) void
3935GFX6_MI_BATCH_BUFFER_END_pack(__attribute__((unused)) __gen_user_data *data,
3936                              __attribute__((unused)) void * restrict dst,
3937                              __attribute__((unused)) const struct GFX6_MI_BATCH_BUFFER_END * restrict values)
3938{
3939   uint32_t * restrict dw = (uint32_t * restrict) dst;
3940
3941   dw[0] =
3942      __gen_uint(values->MICommandOpcode, 23, 28) |
3943      __gen_uint(values->CommandType, 29, 31);
3944}
3945
3946#define GFX6_MI_BATCH_BUFFER_START_length      2
3947#define GFX6_MI_BATCH_BUFFER_START_length_bias      2
3948#define GFX6_MI_BATCH_BUFFER_START_header       \
3949   .DWordLength                         =      0,  \
3950   .MICommandOpcode                     =     49,  \
3951   .CommandType                         =      0
3952
3953struct GFX6_MI_BATCH_BUFFER_START {
3954   uint32_t                             DWordLength;
3955   uint32_t                             AddressSpaceIndicator;
3956#define ASI_GGTT                                 0
3957#define ASI_PPGTT                                1
3958   bool                                 ClearCommandBufferEnable;
3959   uint32_t                             MICommandOpcode;
3960   uint32_t                             CommandType;
3961   __gen_address_type                   BatchBufferStartAddress;
3962};
3963
3964static inline __attribute__((always_inline)) void
3965GFX6_MI_BATCH_BUFFER_START_pack(__attribute__((unused)) __gen_user_data *data,
3966                                __attribute__((unused)) void * restrict dst,
3967                                __attribute__((unused)) const struct GFX6_MI_BATCH_BUFFER_START * restrict values)
3968{
3969   uint32_t * restrict dw = (uint32_t * restrict) dst;
3970
3971   dw[0] =
3972      __gen_uint(values->DWordLength, 0, 7) |
3973      __gen_uint(values->AddressSpaceIndicator, 8, 8) |
3974      __gen_uint(values->ClearCommandBufferEnable, 11, 11) |
3975      __gen_uint(values->MICommandOpcode, 23, 28) |
3976      __gen_uint(values->CommandType, 29, 31);
3977
3978   dw[1] = __gen_address(data, &dw[1], values->BatchBufferStartAddress, 0, 2, 31);
3979}
3980
3981#define GFX6_MI_CLFLUSH_length_bias            2
3982#define GFX6_MI_CLFLUSH_header                  \
3983   .DWordLength                         =      0,  \
3984   .MICommandOpcode                     =     39,  \
3985   .CommandType                         =      0
3986
3987struct GFX6_MI_CLFLUSH {
3988   uint32_t                             DWordLength;
3989   bool                                 UseGlobalGTT;
3990   uint32_t                             MICommandOpcode;
3991   uint32_t                             CommandType;
3992   uint32_t                             StartingCachelineOffset;
3993   __gen_address_type                   PageBaseAddress;
3994   /* variable length fields follow */
3995};
3996
3997static inline __attribute__((always_inline)) void
3998GFX6_MI_CLFLUSH_pack(__attribute__((unused)) __gen_user_data *data,
3999                     __attribute__((unused)) void * restrict dst,
4000                     __attribute__((unused)) const struct GFX6_MI_CLFLUSH * restrict values)
4001{
4002   uint32_t * restrict dw = (uint32_t * restrict) dst;
4003
4004   dw[0] =
4005      __gen_uint(values->DWordLength, 0, 5) |
4006      __gen_uint(values->UseGlobalGTT, 22, 22) |
4007      __gen_uint(values->MICommandOpcode, 23, 28) |
4008      __gen_uint(values->CommandType, 29, 31);
4009
4010   const uint32_t v1 =
4011      __gen_uint(values->StartingCachelineOffset, 6, 11);
4012   dw[1] = __gen_address(data, &dw[1], values->PageBaseAddress, v1, 12, 31);
4013}
4014
4015#define GFX6_MI_CONDITIONAL_BATCH_BUFFER_END_length      2
4016#define GFX6_MI_CONDITIONAL_BATCH_BUFFER_END_length_bias      2
4017#define GFX6_MI_CONDITIONAL_BATCH_BUFFER_END_header\
4018   .DWordLength                         =      0,  \
4019   .CompareSemaphore                    =      0,  \
4020   .MICommandOpcode                     =     54,  \
4021   .CommandType                         =      0
4022
4023struct GFX6_MI_CONDITIONAL_BATCH_BUFFER_END {
4024   uint32_t                             DWordLength;
4025   uint32_t                             CompareSemaphore;
4026   bool                                 UseGlobalGTT;
4027   uint32_t                             MICommandOpcode;
4028   uint32_t                             CommandType;
4029   uint32_t                             CompareDataDword;
4030   __gen_address_type                   CompareAddress;
4031};
4032
4033static inline __attribute__((always_inline)) void
4034GFX6_MI_CONDITIONAL_BATCH_BUFFER_END_pack(__attribute__((unused)) __gen_user_data *data,
4035                                          __attribute__((unused)) void * restrict dst,
4036                                          __attribute__((unused)) const struct GFX6_MI_CONDITIONAL_BATCH_BUFFER_END * restrict values)
4037{
4038   uint32_t * restrict dw = (uint32_t * restrict) dst;
4039
4040   dw[0] =
4041      __gen_uint(values->DWordLength, 0, 7) |
4042      __gen_uint(values->CompareSemaphore, 21, 21) |
4043      __gen_uint(values->UseGlobalGTT, 22, 22) |
4044      __gen_uint(values->MICommandOpcode, 23, 28) |
4045      __gen_uint(values->CommandType, 29, 31);
4046
4047   dw[1] =
4048      __gen_uint(values->CompareDataDword, 0, 31);
4049}
4050
4051#define GFX6_MI_FLUSH_length                   1
4052#define GFX6_MI_FLUSH_length_bias              1
4053#define GFX6_MI_FLUSH_header                    \
4054   .MICommandOpcode                     =      4,  \
4055   .CommandType                         =      0
4056
4057struct GFX6_MI_FLUSH {
4058   uint32_t                             StateInstructionCacheInvalidate;
4059#define DontInvalidate                           0
4060#define Invalidate                               1
4061   uint32_t                             RenderCacheFlushInhibit;
4062#define Flush                                    0
4063#define DontFlush                                1
4064   uint32_t                             GlobalSnapshotCountReset;
4065#define DontReset                                0
4066#define Reset                                    1
4067   bool                                 GenericMediaStateClear;
4068   bool                                 IndirectStatePointersDisable;
4069   uint32_t                             MICommandOpcode;
4070   uint32_t                             CommandType;
4071};
4072
4073static inline __attribute__((always_inline)) void
4074GFX6_MI_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
4075                   __attribute__((unused)) void * restrict dst,
4076                   __attribute__((unused)) const struct GFX6_MI_FLUSH * restrict values)
4077{
4078   uint32_t * restrict dw = (uint32_t * restrict) dst;
4079
4080   dw[0] =
4081      __gen_uint(values->StateInstructionCacheInvalidate, 1, 1) |
4082      __gen_uint(values->RenderCacheFlushInhibit, 2, 2) |
4083      __gen_uint(values->GlobalSnapshotCountReset, 3, 3) |
4084      __gen_uint(values->GenericMediaStateClear, 4, 4) |
4085      __gen_uint(values->IndirectStatePointersDisable, 5, 5) |
4086      __gen_uint(values->MICommandOpcode, 23, 28) |
4087      __gen_uint(values->CommandType, 29, 31);
4088}
4089
4090#define GFX6_MI_LOAD_REGISTER_IMM_length       3
4091#define GFX6_MI_LOAD_REGISTER_IMM_length_bias      2
4092#define GFX6_MI_LOAD_REGISTER_IMM_header        \
4093   .DWordLength                         =      1,  \
4094   .MICommandOpcode                     =     34,  \
4095   .CommandType                         =      0
4096
4097struct GFX6_MI_LOAD_REGISTER_IMM {
4098   uint32_t                             DWordLength;
4099   uint32_t                             ByteWriteDisables;
4100   uint32_t                             MICommandOpcode;
4101   uint32_t                             CommandType;
4102   uint64_t                             RegisterOffset;
4103   uint32_t                             DataDWord;
4104   /* variable length fields follow */
4105};
4106
4107static inline __attribute__((always_inline)) void
4108GFX6_MI_LOAD_REGISTER_IMM_pack(__attribute__((unused)) __gen_user_data *data,
4109                               __attribute__((unused)) void * restrict dst,
4110                               __attribute__((unused)) const struct GFX6_MI_LOAD_REGISTER_IMM * restrict values)
4111{
4112   uint32_t * restrict dw = (uint32_t * restrict) dst;
4113
4114   dw[0] =
4115      __gen_uint(values->DWordLength, 0, 7) |
4116      __gen_uint(values->ByteWriteDisables, 8, 11) |
4117      __gen_uint(values->MICommandOpcode, 23, 28) |
4118      __gen_uint(values->CommandType, 29, 31);
4119
4120   dw[1] =
4121      __gen_offset(values->RegisterOffset, 2, 22);
4122
4123   dw[2] =
4124      __gen_uint(values->DataDWord, 0, 31);
4125}
4126
4127#define GFX6_MI_LOAD_SCAN_LINES_EXCL_length      2
4128#define GFX6_MI_LOAD_SCAN_LINES_EXCL_length_bias      2
4129#define GFX6_MI_LOAD_SCAN_LINES_EXCL_header     \
4130   .DWordLength                         =      0,  \
4131   .MICommandOpcode                     =     19,  \
4132   .CommandType                         =      0
4133
4134struct GFX6_MI_LOAD_SCAN_LINES_EXCL {
4135   uint32_t                             DWordLength;
4136   uint32_t                             DisplayPlaneSelect;
4137#define DisplayPlaneA                            0
4138#define DisplayPlaneB                            1
4139#define DisplayPlaneC                            4
4140   uint32_t                             MICommandOpcode;
4141   uint32_t                             CommandType;
4142   uint32_t                             EndScanLineNumber;
4143   uint32_t                             StartScanLineNumber;
4144};
4145
4146static inline __attribute__((always_inline)) void
4147GFX6_MI_LOAD_SCAN_LINES_EXCL_pack(__attribute__((unused)) __gen_user_data *data,
4148                                  __attribute__((unused)) void * restrict dst,
4149                                  __attribute__((unused)) const struct GFX6_MI_LOAD_SCAN_LINES_EXCL * restrict values)
4150{
4151   uint32_t * restrict dw = (uint32_t * restrict) dst;
4152
4153   dw[0] =
4154      __gen_uint(values->DWordLength, 0, 5) |
4155      __gen_uint(values->DisplayPlaneSelect, 19, 21) |
4156      __gen_uint(values->MICommandOpcode, 23, 28) |
4157      __gen_uint(values->CommandType, 29, 31);
4158
4159   dw[1] =
4160      __gen_uint(values->EndScanLineNumber, 0, 12) |
4161      __gen_uint(values->StartScanLineNumber, 16, 28);
4162}
4163
4164#define GFX6_MI_NOOP_length                    1
4165#define GFX6_MI_NOOP_length_bias               1
4166#define GFX6_MI_NOOP_header                     \
4167   .MICommandOpcode                     =      0,  \
4168   .CommandType                         =      0
4169
4170struct GFX6_MI_NOOP {
4171   uint32_t                             IdentificationNumber;
4172   bool                                 IdentificationNumberRegisterWriteEnable;
4173   uint32_t                             MICommandOpcode;
4174   uint32_t                             CommandType;
4175};
4176
4177static inline __attribute__((always_inline)) void
4178GFX6_MI_NOOP_pack(__attribute__((unused)) __gen_user_data *data,
4179                  __attribute__((unused)) void * restrict dst,
4180                  __attribute__((unused)) const struct GFX6_MI_NOOP * restrict values)
4181{
4182   uint32_t * restrict dw = (uint32_t * restrict) dst;
4183
4184   dw[0] =
4185      __gen_uint(values->IdentificationNumber, 0, 21) |
4186      __gen_uint(values->IdentificationNumberRegisterWriteEnable, 22, 22) |
4187      __gen_uint(values->MICommandOpcode, 23, 28) |
4188      __gen_uint(values->CommandType, 29, 31);
4189}
4190
4191#define GFX6_MI_REPORT_HEAD_length             1
4192#define GFX6_MI_REPORT_HEAD_length_bias        1
4193#define GFX6_MI_REPORT_HEAD_header              \
4194   .MICommandOpcode                     =      7,  \
4195   .CommandType                         =      0
4196
4197struct GFX6_MI_REPORT_HEAD {
4198   uint32_t                             MICommandOpcode;
4199   uint32_t                             CommandType;
4200};
4201
4202static inline __attribute__((always_inline)) void
4203GFX6_MI_REPORT_HEAD_pack(__attribute__((unused)) __gen_user_data *data,
4204                         __attribute__((unused)) void * restrict dst,
4205                         __attribute__((unused)) const struct GFX6_MI_REPORT_HEAD * restrict values)
4206{
4207   uint32_t * restrict dw = (uint32_t * restrict) dst;
4208
4209   dw[0] =
4210      __gen_uint(values->MICommandOpcode, 23, 28) |
4211      __gen_uint(values->CommandType, 29, 31);
4212}
4213
4214#define GFX6_MI_SEMAPHORE_MBOX_length          3
4215#define GFX6_MI_SEMAPHORE_MBOX_length_bias      2
4216#define GFX6_MI_SEMAPHORE_MBOX_header           \
4217   .DWordLength                         =      1,  \
4218   .MICommandOpcode                     =     22,  \
4219   .CommandType                         =      0
4220
4221struct GFX6_MI_SEMAPHORE_MBOX {
4222   uint32_t                             DWordLength;
4223   uint32_t                             RegisterSelect;
4224#define RVSYNC                                   0
4225#define RBSYNC                                   2
4226#define UseGeneralRegisterSelect                 3
4227   uint32_t                             MICommandOpcode;
4228   uint32_t                             CommandType;
4229   uint32_t                             SemaphoreDataDword;
4230};
4231
4232static inline __attribute__((always_inline)) void
4233GFX6_MI_SEMAPHORE_MBOX_pack(__attribute__((unused)) __gen_user_data *data,
4234                            __attribute__((unused)) void * restrict dst,
4235                            __attribute__((unused)) const struct GFX6_MI_SEMAPHORE_MBOX * restrict values)
4236{
4237   uint32_t * restrict dw = (uint32_t * restrict) dst;
4238
4239   dw[0] =
4240      __gen_uint(values->DWordLength, 0, 7) |
4241      __gen_uint(values->RegisterSelect, 16, 17) |
4242      __gen_uint(values->MICommandOpcode, 23, 28) |
4243      __gen_uint(values->CommandType, 29, 31);
4244
4245   dw[1] =
4246      __gen_uint(values->SemaphoreDataDword, 0, 31);
4247
4248   dw[2] = 0;
4249}
4250
4251#define GFX6_MI_SET_CONTEXT_length             2
4252#define GFX6_MI_SET_CONTEXT_length_bias        2
4253#define GFX6_MI_SET_CONTEXT_header              \
4254   .DWordLength                         =      0,  \
4255   .MICommandOpcode                     =     24,  \
4256   .CommandType                         =      0
4257
4258struct GFX6_MI_SET_CONTEXT {
4259   uint32_t                             DWordLength;
4260   uint32_t                             MICommandOpcode;
4261   uint32_t                             CommandType;
4262   uint32_t                             RestoreInhibit;
4263   uint32_t                             ForceRestore;
4264   bool                                 ExtendedStateRestoreEnable;
4265   bool                                 ExtendedStateSaveEnable;
4266   uint32_t                             ReservedMustbe1;
4267   bool                                 HDDVDContext;
4268   __gen_address_type                   LogicalContextAddress;
4269};
4270
4271static inline __attribute__((always_inline)) void
4272GFX6_MI_SET_CONTEXT_pack(__attribute__((unused)) __gen_user_data *data,
4273                         __attribute__((unused)) void * restrict dst,
4274                         __attribute__((unused)) const struct GFX6_MI_SET_CONTEXT * restrict values)
4275{
4276   uint32_t * restrict dw = (uint32_t * restrict) dst;
4277
4278   dw[0] =
4279      __gen_uint(values->DWordLength, 0, 7) |
4280      __gen_uint(values->MICommandOpcode, 23, 28) |
4281      __gen_uint(values->CommandType, 29, 31);
4282
4283   const uint32_t v1 =
4284      __gen_uint(values->RestoreInhibit, 0, 0) |
4285      __gen_uint(values->ForceRestore, 1, 1) |
4286      __gen_uint(values->ExtendedStateRestoreEnable, 2, 2) |
4287      __gen_uint(values->ExtendedStateSaveEnable, 3, 3) |
4288      __gen_uint(values->ReservedMustbe1, 8, 8) |
4289      __gen_uint(values->HDDVDContext, 9, 9);
4290   dw[1] = __gen_address(data, &dw[1], values->LogicalContextAddress, v1, 12, 31);
4291}
4292
4293#define GFX6_MI_STORE_DATA_IMM_length          4
4294#define GFX6_MI_STORE_DATA_IMM_length_bias      2
4295#define GFX6_MI_STORE_DATA_IMM_header           \
4296   .DWordLength                         =      2,  \
4297   .MICommandOpcode                     =     32,  \
4298   .CommandType                         =      0
4299
4300struct GFX6_MI_STORE_DATA_IMM {
4301   uint32_t                             DWordLength;
4302   bool                                 UseGlobalGTT;
4303   uint32_t                             MICommandOpcode;
4304   uint32_t                             CommandType;
4305   uint32_t                             CoreModeEnable;
4306   __gen_address_type                   Address;
4307   uint64_t                             ImmediateData;
4308};
4309
4310static inline __attribute__((always_inline)) void
4311GFX6_MI_STORE_DATA_IMM_pack(__attribute__((unused)) __gen_user_data *data,
4312                            __attribute__((unused)) void * restrict dst,
4313                            __attribute__((unused)) const struct GFX6_MI_STORE_DATA_IMM * restrict values)
4314{
4315   uint32_t * restrict dw = (uint32_t * restrict) dst;
4316
4317   dw[0] =
4318      __gen_uint(values->DWordLength, 0, 5) |
4319      __gen_uint(values->UseGlobalGTT, 22, 22) |
4320      __gen_uint(values->MICommandOpcode, 23, 28) |
4321      __gen_uint(values->CommandType, 29, 31);
4322
4323   dw[1] = 0;
4324
4325   const uint32_t v2 =
4326      __gen_uint(values->CoreModeEnable, 0, 0);
4327   dw[2] = __gen_address(data, &dw[2], values->Address, v2, 2, 31);
4328
4329   const uint64_t v3 =
4330      __gen_uint(values->ImmediateData, 0, 63);
4331   dw[3] = v3;
4332   dw[4] = v3 >> 32;
4333}
4334
4335#define GFX6_MI_STORE_DATA_INDEX_length        3
4336#define GFX6_MI_STORE_DATA_INDEX_length_bias      2
4337#define GFX6_MI_STORE_DATA_INDEX_header         \
4338   .DWordLength                         =      1,  \
4339   .MICommandOpcode                     =     33,  \
4340   .CommandType                         =      0
4341
4342struct GFX6_MI_STORE_DATA_INDEX {
4343   uint32_t                             DWordLength;
4344   uint32_t                             MICommandOpcode;
4345   uint32_t                             CommandType;
4346   uint32_t                             Offset;
4347   uint32_t                             DataDWord0;
4348   uint32_t                             DataDWord1;
4349};
4350
4351static inline __attribute__((always_inline)) void
4352GFX6_MI_STORE_DATA_INDEX_pack(__attribute__((unused)) __gen_user_data *data,
4353                              __attribute__((unused)) void * restrict dst,
4354                              __attribute__((unused)) const struct GFX6_MI_STORE_DATA_INDEX * restrict values)
4355{
4356   uint32_t * restrict dw = (uint32_t * restrict) dst;
4357
4358   dw[0] =
4359      __gen_uint(values->DWordLength, 0, 7) |
4360      __gen_uint(values->MICommandOpcode, 23, 28) |
4361      __gen_uint(values->CommandType, 29, 31);
4362
4363   dw[1] =
4364      __gen_uint(values->Offset, 2, 11);
4365
4366   dw[2] =
4367      __gen_uint(values->DataDWord0, 0, 31);
4368}
4369
4370#define GFX6_MI_STORE_REGISTER_MEM_length      3
4371#define GFX6_MI_STORE_REGISTER_MEM_length_bias      2
4372#define GFX6_MI_STORE_REGISTER_MEM_header       \
4373   .DWordLength                         =      1,  \
4374   .MICommandOpcode                     =     36,  \
4375   .CommandType                         =      0
4376
4377struct GFX6_MI_STORE_REGISTER_MEM {
4378   uint32_t                             DWordLength;
4379   bool                                 UseGlobalGTT;
4380   uint32_t                             MICommandOpcode;
4381   uint32_t                             CommandType;
4382   uint64_t                             RegisterAddress;
4383   __gen_address_type                   MemoryAddress;
4384};
4385
4386static inline __attribute__((always_inline)) void
4387GFX6_MI_STORE_REGISTER_MEM_pack(__attribute__((unused)) __gen_user_data *data,
4388                                __attribute__((unused)) void * restrict dst,
4389                                __attribute__((unused)) const struct GFX6_MI_STORE_REGISTER_MEM * restrict values)
4390{
4391   uint32_t * restrict dw = (uint32_t * restrict) dst;
4392
4393   dw[0] =
4394      __gen_uint(values->DWordLength, 0, 7) |
4395      __gen_uint(values->UseGlobalGTT, 22, 22) |
4396      __gen_uint(values->MICommandOpcode, 23, 28) |
4397      __gen_uint(values->CommandType, 29, 31);
4398
4399   dw[1] =
4400      __gen_offset(values->RegisterAddress, 2, 22);
4401
4402   dw[2] = __gen_address(data, &dw[2], values->MemoryAddress, 0, 2, 31);
4403}
4404
4405#define GFX6_MI_SUSPEND_FLUSH_length           1
4406#define GFX6_MI_SUSPEND_FLUSH_length_bias      1
4407#define GFX6_MI_SUSPEND_FLUSH_header            \
4408   .MICommandOpcode                     =     11,  \
4409   .CommandType                         =      0
4410
4411struct GFX6_MI_SUSPEND_FLUSH {
4412   bool                                 SuspendFlush;
4413   uint32_t                             MICommandOpcode;
4414   uint32_t                             CommandType;
4415};
4416
4417static inline __attribute__((always_inline)) void
4418GFX6_MI_SUSPEND_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
4419                           __attribute__((unused)) void * restrict dst,
4420                           __attribute__((unused)) const struct GFX6_MI_SUSPEND_FLUSH * restrict values)
4421{
4422   uint32_t * restrict dw = (uint32_t * restrict) dst;
4423
4424   dw[0] =
4425      __gen_uint(values->SuspendFlush, 0, 0) |
4426      __gen_uint(values->MICommandOpcode, 23, 28) |
4427      __gen_uint(values->CommandType, 29, 31);
4428}
4429
4430#define GFX6_MI_URB_CLEAR_length               2
4431#define GFX6_MI_URB_CLEAR_length_bias          2
4432#define GFX6_MI_URB_CLEAR_header                \
4433   .DWordLength                         =      0,  \
4434   .MICommandOpcode                     =     25,  \
4435   .CommandType                         =      0
4436
4437struct GFX6_MI_URB_CLEAR {
4438   uint32_t                             DWordLength;
4439   uint32_t                             MICommandOpcode;
4440   uint32_t                             CommandType;
4441   uint64_t                             URBAddress;
4442   uint32_t                             URBClearLength;
4443};
4444
4445static inline __attribute__((always_inline)) void
4446GFX6_MI_URB_CLEAR_pack(__attribute__((unused)) __gen_user_data *data,
4447                       __attribute__((unused)) void * restrict dst,
4448                       __attribute__((unused)) const struct GFX6_MI_URB_CLEAR * restrict values)
4449{
4450   uint32_t * restrict dw = (uint32_t * restrict) dst;
4451
4452   dw[0] =
4453      __gen_uint(values->DWordLength, 0, 7) |
4454      __gen_uint(values->MICommandOpcode, 23, 28) |
4455      __gen_uint(values->CommandType, 29, 31);
4456
4457   dw[1] =
4458      __gen_offset(values->URBAddress, 0, 13) |
4459      __gen_uint(values->URBClearLength, 16, 28);
4460}
4461
4462#define GFX6_MI_USER_INTERRUPT_length          1
4463#define GFX6_MI_USER_INTERRUPT_length_bias      1
4464#define GFX6_MI_USER_INTERRUPT_header           \
4465   .MICommandOpcode                     =      2,  \
4466   .CommandType                         =      0
4467
4468struct GFX6_MI_USER_INTERRUPT {
4469   uint32_t                             MICommandOpcode;
4470   uint32_t                             CommandType;
4471};
4472
4473static inline __attribute__((always_inline)) void
4474GFX6_MI_USER_INTERRUPT_pack(__attribute__((unused)) __gen_user_data *data,
4475                            __attribute__((unused)) void * restrict dst,
4476                            __attribute__((unused)) const struct GFX6_MI_USER_INTERRUPT * restrict values)
4477{
4478   uint32_t * restrict dw = (uint32_t * restrict) dst;
4479
4480   dw[0] =
4481      __gen_uint(values->MICommandOpcode, 23, 28) |
4482      __gen_uint(values->CommandType, 29, 31);
4483}
4484
4485#define GFX6_MI_WAIT_FOR_EVENT_length          1
4486#define GFX6_MI_WAIT_FOR_EVENT_length_bias      1
4487#define GFX6_MI_WAIT_FOR_EVENT_header           \
4488   .MICommandOpcode                     =      3,  \
4489   .CommandType                         =      0
4490
4491struct GFX6_MI_WAIT_FOR_EVENT {
4492   bool                                 DisplayPipeAScanLineWaitEnable;
4493   bool                                 DisplayPlaneAFlipPendingWaitEnable;
4494   bool                                 DisplaySpriteAFlipPendingWaitEnable;
4495   bool                                 DisplayPipeAVerticalBlankWaitEnable;
4496   bool                                 DisplayPipeAHorizontalBlankWaitEnable;
4497   bool                                 DisplayPipeBScanLineWaitEnable;
4498   bool                                 DisplayPlaneBFlipPendingWaitEnable;
4499   bool                                 DisplaySpriteBFlipPendingWaitEnable;
4500   bool                                 DisplayPipeBVerticalBlankWaitEnable;
4501   bool                                 DisplayPipeBHorizontalBlankWaitEnable;
4502   uint32_t                             ConditionCodeWaitSelect;
4503#define Notenabled                               0
4504   uint32_t                             MICommandOpcode;
4505   uint32_t                             CommandType;
4506};
4507
4508static inline __attribute__((always_inline)) void
4509GFX6_MI_WAIT_FOR_EVENT_pack(__attribute__((unused)) __gen_user_data *data,
4510                            __attribute__((unused)) void * restrict dst,
4511                            __attribute__((unused)) const struct GFX6_MI_WAIT_FOR_EVENT * restrict values)
4512{
4513   uint32_t * restrict dw = (uint32_t * restrict) dst;
4514
4515   dw[0] =
4516      __gen_uint(values->DisplayPipeAScanLineWaitEnable, 0, 0) |
4517      __gen_uint(values->DisplayPlaneAFlipPendingWaitEnable, 1, 1) |
4518      __gen_uint(values->DisplaySpriteAFlipPendingWaitEnable, 2, 2) |
4519      __gen_uint(values->DisplayPipeAVerticalBlankWaitEnable, 3, 3) |
4520      __gen_uint(values->DisplayPipeAHorizontalBlankWaitEnable, 5, 5) |
4521      __gen_uint(values->DisplayPipeBScanLineWaitEnable, 8, 8) |
4522      __gen_uint(values->DisplayPlaneBFlipPendingWaitEnable, 9, 9) |
4523      __gen_uint(values->DisplaySpriteBFlipPendingWaitEnable, 10, 10) |
4524      __gen_uint(values->DisplayPipeBVerticalBlankWaitEnable, 11, 11) |
4525      __gen_uint(values->DisplayPipeBHorizontalBlankWaitEnable, 13, 13) |
4526      __gen_uint(values->ConditionCodeWaitSelect, 16, 19) |
4527      __gen_uint(values->MICommandOpcode, 23, 28) |
4528      __gen_uint(values->CommandType, 29, 31);
4529}
4530
4531#define GFX6_PIPELINE_SELECT_length            1
4532#define GFX6_PIPELINE_SELECT_length_bias       1
4533#define GFX6_PIPELINE_SELECT_header             \
4534   ._3DCommandSubOpcode                 =      4,  \
4535   ._3DCommandOpcode                    =      1,  \
4536   .CommandSubType                      =      1,  \
4537   .CommandType                         =      3
4538
4539struct GFX6_PIPELINE_SELECT {
4540   uint32_t                             PipelineSelection;
4541#define _3D                                      0
4542#define Media                                    1
4543   uint32_t                             _3DCommandSubOpcode;
4544   uint32_t                             _3DCommandOpcode;
4545   uint32_t                             CommandSubType;
4546   uint32_t                             CommandType;
4547};
4548
4549static inline __attribute__((always_inline)) void
4550GFX6_PIPELINE_SELECT_pack(__attribute__((unused)) __gen_user_data *data,
4551                          __attribute__((unused)) void * restrict dst,
4552                          __attribute__((unused)) const struct GFX6_PIPELINE_SELECT * restrict values)
4553{
4554   uint32_t * restrict dw = (uint32_t * restrict) dst;
4555
4556   dw[0] =
4557      __gen_uint(values->PipelineSelection, 0, 1) |
4558      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4559      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4560      __gen_uint(values->CommandSubType, 27, 28) |
4561      __gen_uint(values->CommandType, 29, 31);
4562}
4563
4564#define GFX6_PIPE_CONTROL_length               5
4565#define GFX6_PIPE_CONTROL_length_bias          2
4566#define GFX6_PIPE_CONTROL_header                \
4567   .DWordLength                         =      3,  \
4568   ._3DCommandSubOpcode                 =      0,  \
4569   ._3DCommandOpcode                    =      2,  \
4570   .CommandSubType                      =      3,  \
4571   .CommandType                         =      3
4572
4573struct GFX6_PIPE_CONTROL {
4574   uint32_t                             DWordLength;
4575   uint32_t                             _3DCommandSubOpcode;
4576   uint32_t                             _3DCommandOpcode;
4577   uint32_t                             CommandSubType;
4578   uint32_t                             CommandType;
4579   bool                                 DepthCacheFlushEnable;
4580   bool                                 StallAtPixelScoreboard;
4581   bool                                 StateCacheInvalidationEnable;
4582   bool                                 ConstantCacheInvalidationEnable;
4583   bool                                 VFCacheInvalidationEnable;
4584   bool                                 NotifyEnable;
4585   bool                                 IndirectStatePointersDisable;
4586   bool                                 TextureCacheInvalidationEnable;
4587   bool                                 InstructionCacheInvalidateEnable;
4588   bool                                 RenderTargetCacheFlushEnable;
4589   bool                                 DepthStallEnable;
4590   uint32_t                             PostSyncOperation;
4591#define NoWrite                                  0
4592#define WriteImmediateData                       1
4593#define WritePSDepthCount                        2
4594#define WriteTimestamp                           3
4595   bool                                 GenericMediaStateClear;
4596   bool                                 SynchronizeGFDTSurface;
4597   bool                                 TLBInvalidate;
4598   bool                                 GlobalSnapshotCountReset;
4599   bool                                 CommandStreamerStallEnable;
4600   uint32_t                             StoreDataIndex;
4601   uint32_t                             DestinationAddressType;
4602#define DAT_GGTT                                 1
4603   __gen_address_type                   Address;
4604   uint64_t                             ImmediateData;
4605};
4606
4607static inline __attribute__((always_inline)) void
4608GFX6_PIPE_CONTROL_pack(__attribute__((unused)) __gen_user_data *data,
4609                       __attribute__((unused)) void * restrict dst,
4610                       __attribute__((unused)) const struct GFX6_PIPE_CONTROL * restrict values)
4611{
4612   uint32_t * restrict dw = (uint32_t * restrict) dst;
4613
4614   dw[0] =
4615      __gen_uint(values->DWordLength, 0, 7) |
4616      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4617      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4618      __gen_uint(values->CommandSubType, 27, 28) |
4619      __gen_uint(values->CommandType, 29, 31);
4620
4621   dw[1] =
4622      __gen_uint(values->DepthCacheFlushEnable, 0, 0) |
4623      __gen_uint(values->StallAtPixelScoreboard, 1, 1) |
4624      __gen_uint(values->StateCacheInvalidationEnable, 2, 2) |
4625      __gen_uint(values->ConstantCacheInvalidationEnable, 3, 3) |
4626      __gen_uint(values->VFCacheInvalidationEnable, 4, 4) |
4627      __gen_uint(values->NotifyEnable, 8, 8) |
4628      __gen_uint(values->IndirectStatePointersDisable, 9, 9) |
4629      __gen_uint(values->TextureCacheInvalidationEnable, 10, 10) |
4630      __gen_uint(values->InstructionCacheInvalidateEnable, 11, 11) |
4631      __gen_uint(values->RenderTargetCacheFlushEnable, 12, 12) |
4632      __gen_uint(values->DepthStallEnable, 13, 13) |
4633      __gen_uint(values->PostSyncOperation, 14, 15) |
4634      __gen_uint(values->GenericMediaStateClear, 16, 16) |
4635      __gen_uint(values->SynchronizeGFDTSurface, 17, 17) |
4636      __gen_uint(values->TLBInvalidate, 18, 18) |
4637      __gen_uint(values->GlobalSnapshotCountReset, 19, 19) |
4638      __gen_uint(values->CommandStreamerStallEnable, 20, 20) |
4639      __gen_uint(values->StoreDataIndex, 21, 21);
4640
4641   const uint32_t v2 =
4642      __gen_uint(values->DestinationAddressType, 2, 2);
4643   dw[2] = __gen_address(data, &dw[2], values->Address, v2, 3, 31);
4644
4645   const uint64_t v3 =
4646      __gen_uint(values->ImmediateData, 0, 63);
4647   dw[3] = v3;
4648   dw[4] = v3 >> 32;
4649}
4650
4651#define GFX6_STATE_BASE_ADDRESS_length        10
4652#define GFX6_STATE_BASE_ADDRESS_length_bias      2
4653#define GFX6_STATE_BASE_ADDRESS_header          \
4654   .DWordLength                         =      8,  \
4655   ._3DCommandSubOpcode                 =      1,  \
4656   ._3DCommandOpcode                    =      1,  \
4657   .CommandSubType                      =      0,  \
4658   .CommandType                         =      3
4659
4660struct GFX6_STATE_BASE_ADDRESS {
4661   uint32_t                             DWordLength;
4662   uint32_t                             _3DCommandSubOpcode;
4663   uint32_t                             _3DCommandOpcode;
4664   uint32_t                             CommandSubType;
4665   uint32_t                             CommandType;
4666   bool                                 GeneralStateBaseAddressModifyEnable;
4667   uint32_t                             StatelessDataPortAccessForceWriteThru;
4668   uint32_t                             StatelessDataPortAccessMOCS;
4669   uint32_t                             GeneralStateMOCS;
4670   __gen_address_type                   GeneralStateBaseAddress;
4671   bool                                 SurfaceStateBaseAddressModifyEnable;
4672   uint32_t                             SurfaceStateMOCS;
4673   __gen_address_type                   SurfaceStateBaseAddress;
4674   bool                                 DynamicStateBaseAddressModifyEnable;
4675   uint32_t                             DynamicStateMOCS;
4676   __gen_address_type                   DynamicStateBaseAddress;
4677   bool                                 IndirectObjectBaseAddressModifyEnable;
4678   uint32_t                             IndirectObjectMOCS;
4679   __gen_address_type                   IndirectObjectBaseAddress;
4680   bool                                 InstructionBaseAddressModifyEnable;
4681   uint32_t                             InstructionMOCS;
4682   __gen_address_type                   InstructionBaseAddress;
4683   bool                                 GeneralStateAccessUpperBoundModifyEnable;
4684   __gen_address_type                   GeneralStateAccessUpperBound;
4685   bool                                 DynamicStateAccessUpperBoundModifyEnable;
4686   __gen_address_type                   DynamicStateAccessUpperBound;
4687   bool                                 IndirectObjectAccessUpperBoundModifyEnable;
4688   __gen_address_type                   IndirectObjectAccessUpperBound;
4689   bool                                 InstructionAccessUpperBoundModifyEnable;
4690   __gen_address_type                   InstructionAccessUpperBound;
4691};
4692
4693static inline __attribute__((always_inline)) void
4694GFX6_STATE_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data,
4695                             __attribute__((unused)) void * restrict dst,
4696                             __attribute__((unused)) const struct GFX6_STATE_BASE_ADDRESS * restrict values)
4697{
4698   uint32_t * restrict dw = (uint32_t * restrict) dst;
4699
4700   dw[0] =
4701      __gen_uint(values->DWordLength, 0, 7) |
4702      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4703      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4704      __gen_uint(values->CommandSubType, 27, 28) |
4705      __gen_uint(values->CommandType, 29, 31);
4706
4707   const uint32_t v1 =
4708      __gen_uint(values->GeneralStateBaseAddressModifyEnable, 0, 0) |
4709      __gen_uint(values->StatelessDataPortAccessForceWriteThru, 3, 3) |
4710      __gen_uint(values->StatelessDataPortAccessMOCS, 4, 7) |
4711      __gen_uint(values->GeneralStateMOCS, 8, 11);
4712   dw[1] = __gen_address(data, &dw[1], values->GeneralStateBaseAddress, v1, 12, 31);
4713
4714   const uint32_t v2 =
4715      __gen_uint(values->SurfaceStateBaseAddressModifyEnable, 0, 0) |
4716      __gen_uint(values->SurfaceStateMOCS, 8, 11);
4717   dw[2] = __gen_address(data, &dw[2], values->SurfaceStateBaseAddress, v2, 12, 31);
4718
4719   const uint32_t v3 =
4720      __gen_uint(values->DynamicStateBaseAddressModifyEnable, 0, 0) |
4721      __gen_uint(values->DynamicStateMOCS, 8, 11);
4722   dw[3] = __gen_address(data, &dw[3], values->DynamicStateBaseAddress, v3, 12, 31);
4723
4724   const uint32_t v4 =
4725      __gen_uint(values->IndirectObjectBaseAddressModifyEnable, 0, 0) |
4726      __gen_uint(values->IndirectObjectMOCS, 8, 11);
4727   dw[4] = __gen_address(data, &dw[4], values->IndirectObjectBaseAddress, v4, 12, 31);
4728
4729   const uint32_t v5 =
4730      __gen_uint(values->InstructionBaseAddressModifyEnable, 0, 0) |
4731      __gen_uint(values->InstructionMOCS, 8, 11);
4732   dw[5] = __gen_address(data, &dw[5], values->InstructionBaseAddress, v5, 12, 31);
4733
4734   const uint32_t v6 =
4735      __gen_uint(values->GeneralStateAccessUpperBoundModifyEnable, 0, 0);
4736   dw[6] = __gen_address(data, &dw[6], values->GeneralStateAccessUpperBound, v6, 12, 31);
4737
4738   const uint32_t v7 =
4739      __gen_uint(values->DynamicStateAccessUpperBoundModifyEnable, 0, 0);
4740   dw[7] = __gen_address(data, &dw[7], values->DynamicStateAccessUpperBound, v7, 12, 31);
4741
4742   const uint32_t v8 =
4743      __gen_uint(values->IndirectObjectAccessUpperBoundModifyEnable, 0, 0);
4744   dw[8] = __gen_address(data, &dw[8], values->IndirectObjectAccessUpperBound, v8, 12, 31);
4745
4746   const uint32_t v9 =
4747      __gen_uint(values->InstructionAccessUpperBoundModifyEnable, 0, 0);
4748   dw[9] = __gen_address(data, &dw[9], values->InstructionAccessUpperBound, v9, 12, 31);
4749}
4750
4751#define GFX6_STATE_PREFETCH_length             2
4752#define GFX6_STATE_PREFETCH_length_bias        2
4753#define GFX6_STATE_PREFETCH_header              \
4754   .DWordLength                         =      0,  \
4755   ._3DCommandSubOpcode                 =      3,  \
4756   ._3DCommandOpcode                    =      0,  \
4757   .CommandSubType                      =      0,  \
4758   .CommandType                         =      3
4759
4760struct GFX6_STATE_PREFETCH {
4761   uint32_t                             DWordLength;
4762   uint32_t                             _3DCommandSubOpcode;
4763   uint32_t                             _3DCommandOpcode;
4764   uint32_t                             CommandSubType;
4765   uint32_t                             CommandType;
4766   uint32_t                             PrefetchCount;
4767   __gen_address_type                   PrefetchPointer;
4768};
4769
4770static inline __attribute__((always_inline)) void
4771GFX6_STATE_PREFETCH_pack(__attribute__((unused)) __gen_user_data *data,
4772                         __attribute__((unused)) void * restrict dst,
4773                         __attribute__((unused)) const struct GFX6_STATE_PREFETCH * restrict values)
4774{
4775   uint32_t * restrict dw = (uint32_t * restrict) dst;
4776
4777   dw[0] =
4778      __gen_uint(values->DWordLength, 0, 7) |
4779      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4780      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4781      __gen_uint(values->CommandSubType, 27, 28) |
4782      __gen_uint(values->CommandType, 29, 31);
4783
4784   const uint32_t v1 =
4785      __gen_uint(values->PrefetchCount, 0, 2);
4786   dw[1] = __gen_address(data, &dw[1], values->PrefetchPointer, v1, 6, 31);
4787}
4788
4789#define GFX6_STATE_SIP_length                  2
4790#define GFX6_STATE_SIP_length_bias             2
4791#define GFX6_STATE_SIP_header                   \
4792   .DWordLength                         =      0,  \
4793   ._3DCommandSubOpcode                 =      2,  \
4794   ._3DCommandOpcode                    =      1,  \
4795   .CommandSubType                      =      0,  \
4796   .CommandType                         =      3
4797
4798struct GFX6_STATE_SIP {
4799   uint32_t                             DWordLength;
4800   uint32_t                             _3DCommandSubOpcode;
4801   uint32_t                             _3DCommandOpcode;
4802   uint32_t                             CommandSubType;
4803   uint32_t                             CommandType;
4804   uint64_t                             SystemInstructionPointer;
4805};
4806
4807static inline __attribute__((always_inline)) void
4808GFX6_STATE_SIP_pack(__attribute__((unused)) __gen_user_data *data,
4809                    __attribute__((unused)) void * restrict dst,
4810                    __attribute__((unused)) const struct GFX6_STATE_SIP * restrict values)
4811{
4812   uint32_t * restrict dw = (uint32_t * restrict) dst;
4813
4814   dw[0] =
4815      __gen_uint(values->DWordLength, 0, 7) |
4816      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4817      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4818      __gen_uint(values->CommandSubType, 27, 28) |
4819      __gen_uint(values->CommandType, 29, 31);
4820
4821   dw[1] =
4822      __gen_offset(values->SystemInstructionPointer, 4, 31);
4823}
4824
4825#define GFX6_BCS_FAULT_REG_num            0x4294
4826#define GFX6_BCS_FAULT_REG_length              1
4827struct GFX6_BCS_FAULT_REG {
4828   bool                                 ValidBit;
4829   uint32_t                             FaultType;
4830#define PageFault                                0
4831#define InvalidPDFault                           1
4832#define UnloadedPDFault                          2
4833#define InvalidandUnloadedPDfault                3
4834   uint32_t                             SRCIDofFault;
4835   uint32_t                             GTTSEL;
4836#define PPGTT                                    0
4837#define GGTT                                     1
4838   __gen_address_type                   VirtualAddressofFault;
4839};
4840
4841static inline __attribute__((always_inline)) void
4842GFX6_BCS_FAULT_REG_pack(__attribute__((unused)) __gen_user_data *data,
4843                        __attribute__((unused)) void * restrict dst,
4844                        __attribute__((unused)) const struct GFX6_BCS_FAULT_REG * restrict values)
4845{
4846   uint32_t * restrict dw = (uint32_t * restrict) dst;
4847
4848   const uint32_t v0 =
4849      __gen_uint(values->ValidBit, 0, 0) |
4850      __gen_uint(values->FaultType, 1, 2) |
4851      __gen_uint(values->SRCIDofFault, 3, 10) |
4852      __gen_uint(values->GTTSEL, 11, 11);
4853   dw[0] = __gen_address(data, &dw[0], values->VirtualAddressofFault, v0, 12, 31);
4854}
4855
4856#define GFX6_BCS_INSTDONE_num             0x2206c
4857#define GFX6_BCS_INSTDONE_length               1
4858struct GFX6_BCS_INSTDONE {
4859   bool                                 RingEnable;
4860   bool                                 BlitterIDLE;
4861   bool                                 GABIDLE;
4862   bool                                 BCSDone;
4863};
4864
4865static inline __attribute__((always_inline)) void
4866GFX6_BCS_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
4867                       __attribute__((unused)) void * restrict dst,
4868                       __attribute__((unused)) const struct GFX6_BCS_INSTDONE * restrict values)
4869{
4870   uint32_t * restrict dw = (uint32_t * restrict) dst;
4871
4872   dw[0] =
4873      __gen_uint(values->RingEnable, 0, 0) |
4874      __gen_uint(values->BlitterIDLE, 1, 1) |
4875      __gen_uint(values->GABIDLE, 2, 2) |
4876      __gen_uint(values->BCSDone, 3, 3);
4877}
4878
4879#define GFX6_BCS_RING_BUFFER_CTL_num      0x2203c
4880#define GFX6_BCS_RING_BUFFER_CTL_length        1
4881struct GFX6_BCS_RING_BUFFER_CTL {
4882   bool                                 RingBufferEnable;
4883   uint32_t                             AutomaticReportHeadPointer;
4884#define MI_AUTOREPORT_OFF                        0
4885#define MI_AUTOREPORT_64KB                       1
4886#define MI_AUTOREPORT_4KB                        2
4887#define MI_AUTOREPORT_128KB                      3
4888   bool                                 DisableRegisterAccesses;
4889   bool                                 SemaphoreWait;
4890   bool                                 RBWait;
4891   uint32_t                             BufferLengthinpages1;
4892};
4893
4894static inline __attribute__((always_inline)) void
4895GFX6_BCS_RING_BUFFER_CTL_pack(__attribute__((unused)) __gen_user_data *data,
4896                              __attribute__((unused)) void * restrict dst,
4897                              __attribute__((unused)) const struct GFX6_BCS_RING_BUFFER_CTL * restrict values)
4898{
4899   uint32_t * restrict dw = (uint32_t * restrict) dst;
4900
4901   dw[0] =
4902      __gen_uint(values->RingBufferEnable, 0, 0) |
4903      __gen_uint(values->AutomaticReportHeadPointer, 1, 2) |
4904      __gen_uint(values->DisableRegisterAccesses, 8, 8) |
4905      __gen_uint(values->SemaphoreWait, 10, 10) |
4906      __gen_uint(values->RBWait, 11, 11) |
4907      __gen_uint(values->BufferLengthinpages1, 12, 20);
4908}
4909
4910#define GFX6_GFX_ARB_ERROR_RPT_num        0x40a0
4911#define GFX6_GFX_ARB_ERROR_RPT_length          1
4912struct GFX6_GFX_ARB_ERROR_RPT {
4913   bool                                 TLBPageFaultError;
4914   bool                                 ContextPageFaultError;
4915   bool                                 InvalidPageDirectoryentryerror;
4916   bool                                 HardwareStatusPageFaultError;
4917   bool                                 TLBPageVTDTranslationError;
4918   bool                                 ContextPageVTDTranslationError;
4919   bool                                 PageDirectoryEntryVTDTranslationError;
4920   bool                                 HardwareStatusPageVTDTranslationError;
4921   bool                                 UnloadedPDError;
4922};
4923
4924static inline __attribute__((always_inline)) void
4925GFX6_GFX_ARB_ERROR_RPT_pack(__attribute__((unused)) __gen_user_data *data,
4926                            __attribute__((unused)) void * restrict dst,
4927                            __attribute__((unused)) const struct GFX6_GFX_ARB_ERROR_RPT * restrict values)
4928{
4929   uint32_t * restrict dw = (uint32_t * restrict) dst;
4930
4931   dw[0] =
4932      __gen_uint(values->TLBPageFaultError, 0, 0) |
4933      __gen_uint(values->ContextPageFaultError, 1, 1) |
4934      __gen_uint(values->InvalidPageDirectoryentryerror, 2, 2) |
4935      __gen_uint(values->HardwareStatusPageFaultError, 3, 3) |
4936      __gen_uint(values->TLBPageVTDTranslationError, 4, 4) |
4937      __gen_uint(values->ContextPageVTDTranslationError, 5, 5) |
4938      __gen_uint(values->PageDirectoryEntryVTDTranslationError, 6, 6) |
4939      __gen_uint(values->HardwareStatusPageVTDTranslationError, 7, 7) |
4940      __gen_uint(values->UnloadedPDError, 8, 8);
4941}
4942
4943#define GFX6_INSTDONE_1_num               0x206c
4944#define GFX6_INSTDONE_1_length                 1
4945struct GFX6_INSTDONE_1 {
4946   bool                                 PRB0RingEnable;
4947   bool                                 AVSDone;
4948   bool                                 HIZDone;
4949   bool                                 GWDone;
4950   bool                                 TSDone;
4951   bool                                 TDDone;
4952   bool                                 VFEDone;
4953   bool                                 IEFDone;
4954   bool                                 VSCDone;
4955   bool                                 ISC23Done;
4956   bool                                 ISC10Done;
4957   bool                                 IC0Done;
4958   bool                                 IC1Done;
4959   bool                                 IC2Done;
4960   bool                                 IC3Done;
4961   bool                                 EU00Done;
4962   bool                                 EU01Done;
4963   bool                                 EU02Done;
4964   bool                                 MA0Done;
4965   bool                                 EU10Done;
4966   bool                                 EU11Done;
4967   bool                                 EU12Done;
4968   bool                                 MA1Done;
4969   bool                                 EU20Done;
4970   bool                                 EU21Done;
4971   bool                                 EU22Done;
4972   bool                                 MA2Done;
4973   bool                                 EU30Done;
4974   bool                                 EU31Done;
4975   bool                                 EU32Done;
4976   bool                                 MA3Done;
4977};
4978
4979static inline __attribute__((always_inline)) void
4980GFX6_INSTDONE_1_pack(__attribute__((unused)) __gen_user_data *data,
4981                     __attribute__((unused)) void * restrict dst,
4982                     __attribute__((unused)) const struct GFX6_INSTDONE_1 * restrict values)
4983{
4984   uint32_t * restrict dw = (uint32_t * restrict) dst;
4985
4986   dw[0] =
4987      __gen_uint(values->PRB0RingEnable, 0, 0) |
4988      __gen_uint(values->AVSDone, 1, 1) |
4989      __gen_uint(values->HIZDone, 2, 2) |
4990      __gen_uint(values->GWDone, 3, 3) |
4991      __gen_uint(values->TSDone, 4, 4) |
4992      __gen_uint(values->TDDone, 6, 6) |
4993      __gen_uint(values->VFEDone, 7, 7) |
4994      __gen_uint(values->IEFDone, 8, 8) |
4995      __gen_uint(values->VSCDone, 9, 9) |
4996      __gen_uint(values->ISC23Done, 10, 10) |
4997      __gen_uint(values->ISC10Done, 11, 11) |
4998      __gen_uint(values->IC0Done, 12, 12) |
4999      __gen_uint(values->IC1Done, 13, 13) |
5000      __gen_uint(values->IC2Done, 14, 14) |
5001      __gen_uint(values->IC3Done, 15, 15) |
5002      __gen_uint(values->EU00Done, 16, 16) |
5003      __gen_uint(values->EU01Done, 17, 17) |
5004      __gen_uint(values->EU02Done, 18, 18) |
5005      __gen_uint(values->MA0Done, 19, 19) |
5006      __gen_uint(values->EU10Done, 20, 20) |
5007      __gen_uint(values->EU11Done, 21, 21) |
5008      __gen_uint(values->EU12Done, 22, 22) |
5009      __gen_uint(values->MA1Done, 23, 23) |
5010      __gen_uint(values->EU20Done, 24, 24) |
5011      __gen_uint(values->EU21Done, 25, 25) |
5012      __gen_uint(values->EU22Done, 26, 26) |
5013      __gen_uint(values->MA2Done, 27, 27) |
5014      __gen_uint(values->EU30Done, 28, 28) |
5015      __gen_uint(values->EU31Done, 29, 29) |
5016      __gen_uint(values->EU32Done, 30, 30) |
5017      __gen_uint(values->MA3Done, 31, 31);
5018}
5019
5020#define GFX6_INSTDONE_2_num               0x207c
5021#define GFX6_INSTDONE_2_length                 1
5022struct GFX6_INSTDONE_2 {
5023   bool                                 VFDone;
5024   bool                                 VS0Done;
5025   bool                                 GSDone;
5026   bool                                 CLDone;
5027   bool                                 SFDone;
5028   bool                                 VMEDone;
5029   bool                                 PLDone;
5030   bool                                 SODone;
5031   bool                                 SIDone;
5032   bool                                 DGDone;
5033   bool                                 FTDone;
5034   bool                                 DMDone;
5035   bool                                 SCDone;
5036   bool                                 FLDone;
5037   bool                                 QCDone;
5038   bool                                 SVSMDone;
5039   bool                                 WMFEDone;
5040   bool                                 IZDone;
5041   bool                                 PSDDone;
5042   bool                                 DAPDone;
5043   bool                                 RCZDone;
5044   bool                                 VDIDone;
5045   bool                                 RCPBEDone;
5046   bool                                 RCPFEDone;
5047   bool                                 MTDone;
5048   bool                                 ISCDone;
5049   bool                                 SVGDone;
5050   bool                                 RCCDone;
5051   bool                                 SVRWDone;
5052   bool                                 WMBEDone;
5053   bool                                 CSDone;
5054   bool                                 GAMDone;
5055};
5056
5057static inline __attribute__((always_inline)) void
5058GFX6_INSTDONE_2_pack(__attribute__((unused)) __gen_user_data *data,
5059                     __attribute__((unused)) void * restrict dst,
5060                     __attribute__((unused)) const struct GFX6_INSTDONE_2 * restrict values)
5061{
5062   uint32_t * restrict dw = (uint32_t * restrict) dst;
5063
5064   dw[0] =
5065      __gen_uint(values->VFDone, 0, 0) |
5066      __gen_uint(values->VS0Done, 1, 1) |
5067      __gen_uint(values->GSDone, 2, 2) |
5068      __gen_uint(values->CLDone, 3, 3) |
5069      __gen_uint(values->SFDone, 4, 4) |
5070      __gen_uint(values->VMEDone, 5, 5) |
5071      __gen_uint(values->PLDone, 6, 6) |
5072      __gen_uint(values->SODone, 7, 7) |
5073      __gen_uint(values->SIDone, 8, 8) |
5074      __gen_uint(values->DGDone, 9, 9) |
5075      __gen_uint(values->FTDone, 10, 10) |
5076      __gen_uint(values->DMDone, 11, 11) |
5077      __gen_uint(values->SCDone, 12, 12) |
5078      __gen_uint(values->FLDone, 13, 13) |
5079      __gen_uint(values->QCDone, 14, 14) |
5080      __gen_uint(values->SVSMDone, 15, 15) |
5081      __gen_uint(values->WMFEDone, 16, 16) |
5082      __gen_uint(values->IZDone, 17, 17) |
5083      __gen_uint(values->PSDDone, 18, 18) |
5084      __gen_uint(values->DAPDone, 19, 19) |
5085      __gen_uint(values->RCZDone, 20, 20) |
5086      __gen_uint(values->VDIDone, 21, 21) |
5087      __gen_uint(values->RCPBEDone, 22, 22) |
5088      __gen_uint(values->RCPFEDone, 23, 23) |
5089      __gen_uint(values->MTDone, 24, 24) |
5090      __gen_uint(values->ISCDone, 25, 25) |
5091      __gen_uint(values->SVGDone, 26, 26) |
5092      __gen_uint(values->RCCDone, 27, 27) |
5093      __gen_uint(values->SVRWDone, 28, 28) |
5094      __gen_uint(values->WMBEDone, 29, 29) |
5095      __gen_uint(values->CSDone, 30, 30) |
5096      __gen_uint(values->GAMDone, 31, 31);
5097}
5098
5099#define GFX6_INSTPM_num                   0x20c0
5100#define GFX6_INSTPM_length                     1
5101struct GFX6_INSTPM {
5102   bool                                 _3DStateInstructionDisable;
5103   bool                                 _3DRenderingInstructionDisable;
5104   bool                                 MediaInstructionDisable;
5105   bool                                 CONSTANT_BUFFERAddressOffsetDisable;
5106   bool                                 _3DStateInstructionDisableMask;
5107   bool                                 _3DRenderingInstructionDisableMask;
5108   bool                                 MediaInstructionDisableMask;
5109   bool                                 CONSTANT_BUFFERAddressOffsetDisableMask;
5110};
5111
5112static inline __attribute__((always_inline)) void
5113GFX6_INSTPM_pack(__attribute__((unused)) __gen_user_data *data,
5114                 __attribute__((unused)) void * restrict dst,
5115                 __attribute__((unused)) const struct GFX6_INSTPM * restrict values)
5116{
5117   uint32_t * restrict dw = (uint32_t * restrict) dst;
5118
5119   dw[0] =
5120      __gen_uint(values->_3DStateInstructionDisable, 1, 1) |
5121      __gen_uint(values->_3DRenderingInstructionDisable, 2, 2) |
5122      __gen_uint(values->MediaInstructionDisable, 3, 3) |
5123      __gen_uint(values->CONSTANT_BUFFERAddressOffsetDisable, 6, 6) |
5124      __gen_uint(values->_3DStateInstructionDisableMask, 17, 17) |
5125      __gen_uint(values->_3DRenderingInstructionDisableMask, 18, 18) |
5126      __gen_uint(values->MediaInstructionDisableMask, 19, 19) |
5127      __gen_uint(values->CONSTANT_BUFFERAddressOffsetDisableMask, 22, 22);
5128}
5129
5130#define GFX6_RCS_FAULT_REG_num            0x4094
5131#define GFX6_RCS_FAULT_REG_length              1
5132struct GFX6_RCS_FAULT_REG {
5133   bool                                 ValidBit;
5134   uint32_t                             FaultType;
5135#define PageFault                                0
5136#define InvalidPDFault                           1
5137#define UnloadedPDFault                          2
5138#define InvalidandUnloadedPDfault                3
5139   uint32_t                             SRCIDofFault;
5140   uint32_t                             GTTSEL;
5141#define PPGTT                                    0
5142#define GGTT                                     1
5143   __gen_address_type                   VirtualAddressofFault;
5144};
5145
5146static inline __attribute__((always_inline)) void
5147GFX6_RCS_FAULT_REG_pack(__attribute__((unused)) __gen_user_data *data,
5148                        __attribute__((unused)) void * restrict dst,
5149                        __attribute__((unused)) const struct GFX6_RCS_FAULT_REG * restrict values)
5150{
5151   uint32_t * restrict dw = (uint32_t * restrict) dst;
5152
5153   const uint32_t v0 =
5154      __gen_uint(values->ValidBit, 0, 0) |
5155      __gen_uint(values->FaultType, 1, 2) |
5156      __gen_uint(values->SRCIDofFault, 3, 10) |
5157      __gen_uint(values->GTTSEL, 11, 11);
5158   dw[0] = __gen_address(data, &dw[0], values->VirtualAddressofFault, v0, 12, 31);
5159}
5160
5161#define GFX6_RCS_RING_BUFFER_CTL_num      0x203c
5162#define GFX6_RCS_RING_BUFFER_CTL_length        1
5163struct GFX6_RCS_RING_BUFFER_CTL {
5164   bool                                 RingBufferEnable;
5165   uint32_t                             AutomaticReportHeadPointer;
5166#define MI_AUTOREPORT_OFF                        0
5167#define MI_AUTOREPORT_64KBMI_AUTOREPORT_4KB      1
5168#define MI_AUTOREPORT_128KB                      3
5169   bool                                 SemaphoreWait;
5170   bool                                 RBWait;
5171   uint32_t                             BufferLengthinpages1;
5172};
5173
5174static inline __attribute__((always_inline)) void
5175GFX6_RCS_RING_BUFFER_CTL_pack(__attribute__((unused)) __gen_user_data *data,
5176                              __attribute__((unused)) void * restrict dst,
5177                              __attribute__((unused)) const struct GFX6_RCS_RING_BUFFER_CTL * restrict values)
5178{
5179   uint32_t * restrict dw = (uint32_t * restrict) dst;
5180
5181   dw[0] =
5182      __gen_uint(values->RingBufferEnable, 0, 0) |
5183      __gen_uint(values->AutomaticReportHeadPointer, 1, 2) |
5184      __gen_uint(values->SemaphoreWait, 10, 10) |
5185      __gen_uint(values->RBWait, 11, 11) |
5186      __gen_uint(values->BufferLengthinpages1, 12, 20);
5187}
5188
5189#define GFX6_RPSTAT1_num                  0xa01c
5190#define GFX6_RPSTAT1_length                    1
5191struct GFX6_RPSTAT1 {
5192   uint32_t                             PreviousGTFrequency;
5193   uint32_t                             CurrentGTFrequency;
5194};
5195
5196static inline __attribute__((always_inline)) void
5197GFX6_RPSTAT1_pack(__attribute__((unused)) __gen_user_data *data,
5198                  __attribute__((unused)) void * restrict dst,
5199                  __attribute__((unused)) const struct GFX6_RPSTAT1 * restrict values)
5200{
5201   uint32_t * restrict dw = (uint32_t * restrict) dst;
5202
5203   dw[0] =
5204      __gen_uint(values->PreviousGTFrequency, 0, 6) |
5205      __gen_uint(values->CurrentGTFrequency, 7, 14);
5206}
5207
5208#define GFX6_VCS_FAULT_REG_num            0x4194
5209#define GFX6_VCS_FAULT_REG_length              1
5210struct GFX6_VCS_FAULT_REG {
5211   bool                                 ValidBit;
5212   uint32_t                             FaultType;
5213#define PageFault                                0
5214#define InvalidPDFault                           1
5215#define UnloadedPDFault                          2
5216#define InvalidandUnloadedPDfault                3
5217   uint32_t                             SRCIDofFault;
5218   uint32_t                             GTTSEL;
5219#define PPGTT                                    0
5220#define GGTT                                     1
5221   __gen_address_type                   VirtualAddressofFault;
5222};
5223
5224static inline __attribute__((always_inline)) void
5225GFX6_VCS_FAULT_REG_pack(__attribute__((unused)) __gen_user_data *data,
5226                        __attribute__((unused)) void * restrict dst,
5227                        __attribute__((unused)) const struct GFX6_VCS_FAULT_REG * restrict values)
5228{
5229   uint32_t * restrict dw = (uint32_t * restrict) dst;
5230
5231   const uint32_t v0 =
5232      __gen_uint(values->ValidBit, 0, 0) |
5233      __gen_uint(values->FaultType, 1, 2) |
5234      __gen_uint(values->SRCIDofFault, 3, 10) |
5235      __gen_uint(values->GTTSEL, 11, 11);
5236   dw[0] = __gen_address(data, &dw[0], values->VirtualAddressofFault, v0, 12, 31);
5237}
5238
5239#define GFX6_VCS_INSTDONE_num             0x1206c
5240#define GFX6_VCS_INSTDONE_length               1
5241struct GFX6_VCS_INSTDONE {
5242   bool                                 RingEnable;
5243   bool                                 USBDone;
5244   bool                                 QRCDone;
5245   bool                                 SECDone;
5246   bool                                 MPCDone;
5247   bool                                 VFTDone;
5248   bool                                 BSPDone;
5249   bool                                 VLFDone;
5250   bool                                 VOPDone;
5251   bool                                 VMCDone;
5252   bool                                 VIPDone;
5253   bool                                 VITDone;
5254   bool                                 VDSDone;
5255   bool                                 VMXDone;
5256   bool                                 VCPDone;
5257   bool                                 VCDDone;
5258   bool                                 VADDone;
5259   bool                                 VMDDone;
5260   bool                                 VISDone;
5261   bool                                 VACDone;
5262   bool                                 VAMDone;
5263   bool                                 JPGDone;
5264   bool                                 VBPDone;
5265   bool                                 VHRDone;
5266   bool                                 VCIDone;
5267   bool                                 VCRDone;
5268   bool                                 VINDone;
5269   bool                                 VPRDone;
5270   bool                                 VTQDone;
5271   bool                                 VCSDone;
5272   bool                                 GACDone;
5273};
5274
5275static inline __attribute__((always_inline)) void
5276GFX6_VCS_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
5277                       __attribute__((unused)) void * restrict dst,
5278                       __attribute__((unused)) const struct GFX6_VCS_INSTDONE * restrict values)
5279{
5280   uint32_t * restrict dw = (uint32_t * restrict) dst;
5281
5282   dw[0] =
5283      __gen_uint(values->RingEnable, 0, 0) |
5284      __gen_uint(values->USBDone, 1, 1) |
5285      __gen_uint(values->QRCDone, 2, 2) |
5286      __gen_uint(values->SECDone, 3, 3) |
5287      __gen_uint(values->MPCDone, 4, 4) |
5288      __gen_uint(values->VFTDone, 5, 5) |
5289      __gen_uint(values->BSPDone, 6, 6) |
5290      __gen_uint(values->VLFDone, 7, 7) |
5291      __gen_uint(values->VOPDone, 8, 8) |
5292      __gen_uint(values->VMCDone, 9, 9) |
5293      __gen_uint(values->VIPDone, 10, 10) |
5294      __gen_uint(values->VITDone, 11, 11) |
5295      __gen_uint(values->VDSDone, 12, 12) |
5296      __gen_uint(values->VMXDone, 13, 13) |
5297      __gen_uint(values->VCPDone, 14, 14) |
5298      __gen_uint(values->VCDDone, 15, 15) |
5299      __gen_uint(values->VADDone, 16, 16) |
5300      __gen_uint(values->VMDDone, 17, 17) |
5301      __gen_uint(values->VISDone, 18, 18) |
5302      __gen_uint(values->VACDone, 19, 19) |
5303      __gen_uint(values->VAMDone, 20, 20) |
5304      __gen_uint(values->JPGDone, 21, 21) |
5305      __gen_uint(values->VBPDone, 22, 22) |
5306      __gen_uint(values->VHRDone, 23, 23) |
5307      __gen_uint(values->VCIDone, 24, 24) |
5308      __gen_uint(values->VCRDone, 25, 25) |
5309      __gen_uint(values->VINDone, 26, 26) |
5310      __gen_uint(values->VPRDone, 27, 27) |
5311      __gen_uint(values->VTQDone, 28, 28) |
5312      __gen_uint(values->VCSDone, 30, 30) |
5313      __gen_uint(values->GACDone, 31, 31);
5314}
5315
5316#define GFX6_VCS_RING_BUFFER_CTL_num      0x1203c
5317#define GFX6_VCS_RING_BUFFER_CTL_length        1
5318struct GFX6_VCS_RING_BUFFER_CTL {
5319   bool                                 RingBufferEnable;
5320   uint32_t                             AutomaticReportHeadPointer;
5321#define MI_AUTOREPORT_OFF                        0
5322#define MI_AUTOREPORT_64KB                       1
5323#define MI_AUTOREPORT_4KB                        2
5324#define MI_AUTOREPORT_128KB                      3
5325   bool                                 DisableRegisterAccesses;
5326   bool                                 SemaphoreWait;
5327   bool                                 RBWait;
5328   uint32_t                             BufferLengthinpages1;
5329};
5330
5331static inline __attribute__((always_inline)) void
5332GFX6_VCS_RING_BUFFER_CTL_pack(__attribute__((unused)) __gen_user_data *data,
5333                              __attribute__((unused)) void * restrict dst,
5334                              __attribute__((unused)) const struct GFX6_VCS_RING_BUFFER_CTL * restrict values)
5335{
5336   uint32_t * restrict dw = (uint32_t * restrict) dst;
5337
5338   dw[0] =
5339      __gen_uint(values->RingBufferEnable, 0, 0) |
5340      __gen_uint(values->AutomaticReportHeadPointer, 1, 2) |
5341      __gen_uint(values->DisableRegisterAccesses, 8, 8) |
5342      __gen_uint(values->SemaphoreWait, 10, 10) |
5343      __gen_uint(values->RBWait, 11, 11) |
5344      __gen_uint(values->BufferLengthinpages1, 12, 20);
5345}
5346
5347#endif /* GFX6_PACK_H */
5348