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 IVB.
26 *
27 * This file has been generated, do not hand edit.
28 */
29
30#ifndef GFX7_PACK_H
31#define GFX7_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 GFX7_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 GFX7_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 GFX7_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 GFX7_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 GFX7_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   _3DPRIM_PATCHLIST_1                  =     32,
268   _3DPRIM_PATCHLIST_2                  =     33,
269   _3DPRIM_PATCHLIST_3                  =     34,
270   _3DPRIM_PATCHLIST_4                  =     35,
271   _3DPRIM_PATCHLIST_5                  =     36,
272   _3DPRIM_PATCHLIST_6                  =     37,
273   _3DPRIM_PATCHLIST_7                  =     38,
274   _3DPRIM_PATCHLIST_8                  =     39,
275   _3DPRIM_PATCHLIST_9                  =     40,
276   _3DPRIM_PATCHLIST_10                 =     41,
277   _3DPRIM_PATCHLIST_11                 =     42,
278   _3DPRIM_PATCHLIST_12                 =     43,
279   _3DPRIM_PATCHLIST_13                 =     44,
280   _3DPRIM_PATCHLIST_14                 =     45,
281   _3DPRIM_PATCHLIST_15                 =     46,
282   _3DPRIM_PATCHLIST_16                 =     47,
283   _3DPRIM_PATCHLIST_17                 =     48,
284   _3DPRIM_PATCHLIST_18                 =     49,
285   _3DPRIM_PATCHLIST_19                 =     50,
286   _3DPRIM_PATCHLIST_20                 =     51,
287   _3DPRIM_PATCHLIST_21                 =     52,
288   _3DPRIM_PATCHLIST_22                 =     53,
289   _3DPRIM_PATCHLIST_23                 =     54,
290   _3DPRIM_PATCHLIST_24                 =     55,
291   _3DPRIM_PATCHLIST_25                 =     56,
292   _3DPRIM_PATCHLIST_26                 =     57,
293   _3DPRIM_PATCHLIST_27                 =     58,
294   _3DPRIM_PATCHLIST_28                 =     59,
295   _3DPRIM_PATCHLIST_29                 =     60,
296   _3DPRIM_PATCHLIST_30                 =     61,
297   _3DPRIM_PATCHLIST_31                 =     62,
298   _3DPRIM_PATCHLIST_32                 =     63,
299};
300
301enum GFX7_3D_Stencil_Operation {
302   STENCILOP_KEEP                       =      0,
303   STENCILOP_ZERO                       =      1,
304   STENCILOP_REPLACE                    =      2,
305   STENCILOP_INCRSAT                    =      3,
306   STENCILOP_DECRSAT                    =      4,
307   STENCILOP_INCR                       =      5,
308   STENCILOP_DECR                       =      6,
309   STENCILOP_INVERT                     =      7,
310};
311
312enum GFX7_3D_Vertex_Component_Control {
313   VFCOMP_NOSTORE                       =      0,
314   VFCOMP_STORE_SRC                     =      1,
315   VFCOMP_STORE_0                       =      2,
316   VFCOMP_STORE_1_FP                    =      3,
317   VFCOMP_STORE_1_INT                   =      4,
318   VFCOMP_STORE_VID                     =      5,
319   VFCOMP_STORE_IID                     =      6,
320   VFCOMP_STORE_PID                     =      7,
321};
322
323enum GFX7_TextureCoordinateMode {
324   TCM_WRAP                             =      0,
325   TCM_MIRROR                           =      1,
326   TCM_CLAMP                            =      2,
327   TCM_CUBE                             =      3,
328   TCM_CLAMP_BORDER                     =      4,
329   TCM_MIRROR_ONCE                      =      5,
330};
331
332#define GFX7_3DSTATE_CONSTANT_BODY_length      6
333struct GFX7_3DSTATE_CONSTANT_BODY {
334   uint32_t                             ReadLength[4];
335   uint32_t                             MOCS;
336   __gen_address_type                   Buffer[4];
337};
338
339static inline __attribute__((always_inline)) void
340GFX7_3DSTATE_CONSTANT_BODY_pack(__attribute__((unused)) __gen_user_data *data,
341                                __attribute__((unused)) void * restrict dst,
342                                __attribute__((unused)) const struct GFX7_3DSTATE_CONSTANT_BODY * restrict values)
343{
344   uint32_t * restrict dw = (uint32_t * restrict) dst;
345
346   dw[0] =
347      __gen_uint(values->ReadLength[0], 0, 15) |
348      __gen_uint(values->ReadLength[1], 16, 31);
349
350   dw[1] =
351      __gen_uint(values->ReadLength[2], 0, 15) |
352      __gen_uint(values->ReadLength[3], 16, 31);
353
354   const uint32_t v2 =
355      __gen_uint(values->MOCS, 0, 4);
356   dw[2] = __gen_address(data, &dw[2], values->Buffer[0], v2, 5, 31);
357
358   dw[3] = __gen_address(data, &dw[3], values->Buffer[1], 0, 5, 31);
359
360   dw[4] = __gen_address(data, &dw[4], values->Buffer[2], 0, 5, 31);
361
362   dw[5] = __gen_address(data, &dw[5], values->Buffer[3], 0, 5, 31);
363}
364
365#define GFX7_BINDING_TABLE_STATE_length        1
366struct GFX7_BINDING_TABLE_STATE {
367   uint64_t                             SurfaceStatePointer;
368};
369
370static inline __attribute__((always_inline)) void
371GFX7_BINDING_TABLE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
372                              __attribute__((unused)) void * restrict dst,
373                              __attribute__((unused)) const struct GFX7_BINDING_TABLE_STATE * restrict values)
374{
375   uint32_t * restrict dw = (uint32_t * restrict) dst;
376
377   dw[0] =
378      __gen_offset(values->SurfaceStatePointer, 5, 31);
379}
380
381#define GFX7_BLEND_STATE_ENTRY_length          2
382struct GFX7_BLEND_STATE_ENTRY {
383   enum GFX7_3D_Color_Buffer_Blend_Factor DestinationBlendFactor;
384   enum GFX7_3D_Color_Buffer_Blend_Factor SourceBlendFactor;
385   enum GFX7_3D_Color_Buffer_Blend_Function ColorBlendFunction;
386   enum GFX7_3D_Color_Buffer_Blend_Factor DestinationAlphaBlendFactor;
387   enum GFX7_3D_Color_Buffer_Blend_Factor SourceAlphaBlendFactor;
388   enum GFX7_3D_Color_Buffer_Blend_Function AlphaBlendFunction;
389   bool                                 IndependentAlphaBlendEnable;
390   bool                                 ColorBufferBlendEnable;
391   bool                                 PostBlendColorClampEnable;
392   bool                                 PreBlendColorClampEnable;
393   uint32_t                             ColorClampRange;
394#define COLORCLAMP_UNORM                         0
395#define COLORCLAMP_SNORM                         1
396#define COLORCLAMP_RTFORMAT                      2
397   uint32_t                             YDitherOffset;
398   uint32_t                             XDitherOffset;
399   bool                                 ColorDitherEnable;
400   enum GFX7_3D_Compare_Function        AlphaTestFunction;
401   bool                                 AlphaTestEnable;
402   enum GFX7_3D_Logic_Op_Function       LogicOpFunction;
403   bool                                 LogicOpEnable;
404   bool                                 WriteDisableBlue;
405   bool                                 WriteDisableGreen;
406   bool                                 WriteDisableRed;
407   bool                                 WriteDisableAlpha;
408   bool                                 AlphaToCoverageDitherEnable;
409   bool                                 AlphaToOneEnable;
410   bool                                 AlphaToCoverageEnable;
411};
412
413static inline __attribute__((always_inline)) void
414GFX7_BLEND_STATE_ENTRY_pack(__attribute__((unused)) __gen_user_data *data,
415                            __attribute__((unused)) void * restrict dst,
416                            __attribute__((unused)) const struct GFX7_BLEND_STATE_ENTRY * restrict values)
417{
418   uint32_t * restrict dw = (uint32_t * restrict) dst;
419
420   dw[0] =
421      __gen_uint(values->DestinationBlendFactor, 0, 4) |
422      __gen_uint(values->SourceBlendFactor, 5, 9) |
423      __gen_uint(values->ColorBlendFunction, 11, 13) |
424      __gen_uint(values->DestinationAlphaBlendFactor, 15, 19) |
425      __gen_uint(values->SourceAlphaBlendFactor, 20, 24) |
426      __gen_uint(values->AlphaBlendFunction, 26, 28) |
427      __gen_uint(values->IndependentAlphaBlendEnable, 30, 30) |
428      __gen_uint(values->ColorBufferBlendEnable, 31, 31);
429
430   dw[1] =
431      __gen_uint(values->PostBlendColorClampEnable, 0, 0) |
432      __gen_uint(values->PreBlendColorClampEnable, 1, 1) |
433      __gen_uint(values->ColorClampRange, 2, 3) |
434      __gen_uint(values->YDitherOffset, 8, 9) |
435      __gen_uint(values->XDitherOffset, 10, 11) |
436      __gen_uint(values->ColorDitherEnable, 12, 12) |
437      __gen_uint(values->AlphaTestFunction, 13, 15) |
438      __gen_uint(values->AlphaTestEnable, 16, 16) |
439      __gen_uint(values->LogicOpFunction, 18, 21) |
440      __gen_uint(values->LogicOpEnable, 22, 22) |
441      __gen_uint(values->WriteDisableBlue, 24, 24) |
442      __gen_uint(values->WriteDisableGreen, 25, 25) |
443      __gen_uint(values->WriteDisableRed, 26, 26) |
444      __gen_uint(values->WriteDisableAlpha, 27, 27) |
445      __gen_uint(values->AlphaToCoverageDitherEnable, 29, 29) |
446      __gen_uint(values->AlphaToOneEnable, 30, 30) |
447      __gen_uint(values->AlphaToCoverageEnable, 31, 31);
448}
449
450#define GFX7_BLEND_STATE_length                0
451struct GFX7_BLEND_STATE {
452   /* variable length fields follow */
453};
454
455static inline __attribute__((always_inline)) void
456GFX7_BLEND_STATE_pack(__attribute__((unused)) __gen_user_data *data,
457                      __attribute__((unused)) void * restrict dst,
458                      __attribute__((unused)) const struct GFX7_BLEND_STATE * restrict values)
459{
460}
461
462#define GFX7_CC_VIEWPORT_length                2
463struct GFX7_CC_VIEWPORT {
464   float                                MinimumDepth;
465   float                                MaximumDepth;
466};
467
468static inline __attribute__((always_inline)) void
469GFX7_CC_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
470                      __attribute__((unused)) void * restrict dst,
471                      __attribute__((unused)) const struct GFX7_CC_VIEWPORT * restrict values)
472{
473   uint32_t * restrict dw = (uint32_t * restrict) dst;
474
475   dw[0] =
476      __gen_float(values->MinimumDepth);
477
478   dw[1] =
479      __gen_float(values->MaximumDepth);
480}
481
482#define GFX7_COLOR_CALC_STATE_length           6
483struct GFX7_COLOR_CALC_STATE {
484   uint32_t                             AlphaTestFormat;
485#define ALPHATEST_UNORM8                         0
486#define ALPHATEST_FLOAT32                        1
487   bool                                 RoundDisableFunctionDisable;
488   uint32_t                             BackfaceStencilReferenceValue;
489   uint32_t                             StencilReferenceValue;
490   uint32_t                             AlphaReferenceValueAsUNORM8;
491   float                                AlphaReferenceValueAsFLOAT32;
492   float                                BlendConstantColorRed;
493   float                                BlendConstantColorGreen;
494   float                                BlendConstantColorBlue;
495   float                                BlendConstantColorAlpha;
496};
497
498static inline __attribute__((always_inline)) void
499GFX7_COLOR_CALC_STATE_pack(__attribute__((unused)) __gen_user_data *data,
500                           __attribute__((unused)) void * restrict dst,
501                           __attribute__((unused)) const struct GFX7_COLOR_CALC_STATE * restrict values)
502{
503   uint32_t * restrict dw = (uint32_t * restrict) dst;
504
505   dw[0] =
506      __gen_uint(values->AlphaTestFormat, 0, 0) |
507      __gen_uint(values->RoundDisableFunctionDisable, 15, 15) |
508      __gen_uint(values->BackfaceStencilReferenceValue, 16, 23) |
509      __gen_uint(values->StencilReferenceValue, 24, 31);
510
511   dw[1] =
512      __gen_uint(values->AlphaReferenceValueAsUNORM8, 0, 31) |
513      __gen_float(values->AlphaReferenceValueAsFLOAT32);
514
515   dw[2] =
516      __gen_float(values->BlendConstantColorRed);
517
518   dw[3] =
519      __gen_float(values->BlendConstantColorGreen);
520
521   dw[4] =
522      __gen_float(values->BlendConstantColorBlue);
523
524   dw[5] =
525      __gen_float(values->BlendConstantColorAlpha);
526}
527
528#define GFX7_DEPTH_STENCIL_STATE_length        3
529struct GFX7_DEPTH_STENCIL_STATE {
530   enum GFX7_3D_Stencil_Operation       BackfaceStencilPassDepthPassOp;
531   enum GFX7_3D_Stencil_Operation       BackfaceStencilPassDepthFailOp;
532   enum GFX7_3D_Stencil_Operation       BackfaceStencilFailOp;
533   enum GFX7_3D_Compare_Function        BackfaceStencilTestFunction;
534   bool                                 DoubleSidedStencilEnable;
535   bool                                 StencilBufferWriteEnable;
536   enum GFX7_3D_Stencil_Operation       StencilPassDepthPassOp;
537   enum GFX7_3D_Stencil_Operation       StencilPassDepthFailOp;
538   enum GFX7_3D_Stencil_Operation       StencilFailOp;
539   enum GFX7_3D_Compare_Function        StencilTestFunction;
540   bool                                 StencilTestEnable;
541   uint32_t                             BackfaceStencilWriteMask;
542   uint32_t                             BackfaceStencilTestMask;
543   uint32_t                             StencilWriteMask;
544   uint32_t                             StencilTestMask;
545   bool                                 DepthBufferWriteEnable;
546   enum GFX7_3D_Compare_Function        DepthTestFunction;
547   bool                                 DepthTestEnable;
548};
549
550static inline __attribute__((always_inline)) void
551GFX7_DEPTH_STENCIL_STATE_pack(__attribute__((unused)) __gen_user_data *data,
552                              __attribute__((unused)) void * restrict dst,
553                              __attribute__((unused)) const struct GFX7_DEPTH_STENCIL_STATE * restrict values)
554{
555   uint32_t * restrict dw = (uint32_t * restrict) dst;
556
557   dw[0] =
558      __gen_uint(values->BackfaceStencilPassDepthPassOp, 3, 5) |
559      __gen_uint(values->BackfaceStencilPassDepthFailOp, 6, 8) |
560      __gen_uint(values->BackfaceStencilFailOp, 9, 11) |
561      __gen_uint(values->BackfaceStencilTestFunction, 12, 14) |
562      __gen_uint(values->DoubleSidedStencilEnable, 15, 15) |
563      __gen_uint(values->StencilBufferWriteEnable, 18, 18) |
564      __gen_uint(values->StencilPassDepthPassOp, 19, 21) |
565      __gen_uint(values->StencilPassDepthFailOp, 22, 24) |
566      __gen_uint(values->StencilFailOp, 25, 27) |
567      __gen_uint(values->StencilTestFunction, 28, 30) |
568      __gen_uint(values->StencilTestEnable, 31, 31);
569
570   dw[1] =
571      __gen_uint(values->BackfaceStencilWriteMask, 0, 7) |
572      __gen_uint(values->BackfaceStencilTestMask, 8, 15) |
573      __gen_uint(values->StencilWriteMask, 16, 23) |
574      __gen_uint(values->StencilTestMask, 24, 31);
575
576   dw[2] =
577      __gen_uint(values->DepthBufferWriteEnable, 26, 26) |
578      __gen_uint(values->DepthTestFunction, 27, 29) |
579      __gen_uint(values->DepthTestEnable, 31, 31);
580}
581
582#define GFX7_INLINE_DATA_DESCRIPTION_FOR_MFD_AVC_BSD_OBJECT_length      2
583struct GFX7_INLINE_DATA_DESCRIPTION_FOR_MFD_AVC_BSD_OBJECT {
584   bool                                 MBErrorConcealmentPSliceWeightPredictionDisable;
585   bool                                 MBErrorConcealmentPSliceMotionVectorsOverrideDisable;
586   bool                                 MBErrorConcealmentPSliceReferenceIndexOverrideDisable;
587   bool                                 MBErrorConcealmentBSpatialWeightPredictionDisable;
588   bool                                 MBErrorConcealmentBSpatialMotionVectorsOverrideDisable;
589   bool                                 MBErrorConcealmentBSpatialReferenceIndexOverrideDisable;
590   uint32_t                             MBErrorConcealmentBSpatialPredictionMode;
591   bool                                 MBHeaderErrorHandling;
592   bool                                 EntropyErrorHandling;
593   bool                                 MPRErrorHandling;
594   bool                                 BSDPrematureCompleteErrorHandling;
595   uint32_t                             ConcealmentPictureID;
596   bool                                 MBErrorConcealmentBTemporalWeightPredictionDisable;
597   bool                                 MBErrorConcealmentBTemporalMotionVectorsOverrideEnable;
598   bool                                 MBErrorConcealmentBTemporalReferenceIndexOverrideEnable;
599   uint32_t                             MBErrorConcealmentBTemporalPredictionMode;
600   bool                                 InitCurrentMBNumber;
601   uint32_t                             ConcealmentMethod;
602   uint32_t                             FirstMBBitOffset;
603   bool                                 LastSlice;
604   bool                                 EmulationPreventionBytePresent;
605   bool                                 FixPrevMBSkipped;
606   uint32_t                             FirstMBByteOffsetofSliceDataorSliceHeader;
607};
608
609static inline __attribute__((always_inline)) void
610GFX7_INLINE_DATA_DESCRIPTION_FOR_MFD_AVC_BSD_OBJECT_pack(__attribute__((unused)) __gen_user_data *data,
611                                                         __attribute__((unused)) void * restrict dst,
612                                                         __attribute__((unused)) const struct GFX7_INLINE_DATA_DESCRIPTION_FOR_MFD_AVC_BSD_OBJECT * restrict values)
613{
614   uint32_t * restrict dw = (uint32_t * restrict) dst;
615
616   dw[0] =
617      __gen_uint(values->MBErrorConcealmentPSliceWeightPredictionDisable, 0, 0) |
618      __gen_uint(values->MBErrorConcealmentPSliceMotionVectorsOverrideDisable, 1, 1) |
619      __gen_uint(values->MBErrorConcealmentPSliceReferenceIndexOverrideDisable, 2, 2) |
620      __gen_uint(values->MBErrorConcealmentBSpatialWeightPredictionDisable, 3, 3) |
621      __gen_uint(values->MBErrorConcealmentBSpatialMotionVectorsOverrideDisable, 4, 4) |
622      __gen_uint(values->MBErrorConcealmentBSpatialReferenceIndexOverrideDisable, 5, 5) |
623      __gen_uint(values->MBErrorConcealmentBSpatialPredictionMode, 6, 7) |
624      __gen_uint(values->MBHeaderErrorHandling, 8, 8) |
625      __gen_uint(values->EntropyErrorHandling, 10, 10) |
626      __gen_uint(values->MPRErrorHandling, 12, 12) |
627      __gen_uint(values->BSDPrematureCompleteErrorHandling, 14, 14) |
628      __gen_uint(values->ConcealmentPictureID, 16, 21) |
629      __gen_uint(values->MBErrorConcealmentBTemporalWeightPredictionDisable, 24, 24) |
630      __gen_uint(values->MBErrorConcealmentBTemporalMotionVectorsOverrideEnable, 25, 25) |
631      __gen_uint(values->MBErrorConcealmentBTemporalReferenceIndexOverrideEnable, 26, 26) |
632      __gen_uint(values->MBErrorConcealmentBTemporalPredictionMode, 27, 28) |
633      __gen_uint(values->InitCurrentMBNumber, 30, 30) |
634      __gen_uint(values->ConcealmentMethod, 31, 31);
635
636   dw[1] =
637      __gen_uint(values->FirstMBBitOffset, 0, 2) |
638      __gen_uint(values->LastSlice, 3, 3) |
639      __gen_uint(values->EmulationPreventionBytePresent, 4, 4) |
640      __gen_uint(values->FixPrevMBSkipped, 7, 7) |
641      __gen_uint(values->FirstMBByteOffsetofSliceDataorSliceHeader, 16, 31);
642}
643
644#define GFX7_INTERFACE_DESCRIPTOR_DATA_length      8
645struct GFX7_INTERFACE_DESCRIPTOR_DATA {
646   uint64_t                             KernelStartPointer;
647   bool                                 SoftwareExceptionEnable;
648   bool                                 MaskStackExceptionEnable;
649   bool                                 IllegalOpcodeExceptionEnable;
650   uint32_t                             FloatingPointMode;
651#define IEEE754                                  0
652#define Alternate                                1
653   uint32_t                             ThreadPriority;
654#define NormalPriority                           0
655#define HighPriority                             1
656   bool                                 SingleProgramFlow;
657   uint32_t                             SamplerCount;
658#define Nosamplersused                           0
659#define Between1and4samplersused                 1
660#define Between5and8samplersused                 2
661#define Between9and12samplersused                3
662#define Between13and16samplersused               4
663   uint64_t                             SamplerStatePointer;
664   uint32_t                             BindingTableEntryCount;
665   uint64_t                             BindingTablePointer;
666   uint32_t                             ConstantURBEntryReadOffset;
667   uint32_t                             ConstantURBEntryReadLength;
668   uint32_t                             NumberofThreadsinGPGPUThreadGroup;
669   uint32_t                             SharedLocalMemorySize;
670   bool                                 BarrierEnable;
671   uint32_t                             RoundingMode;
672#define RTNE                                     0
673#define RU                                       1
674#define RD                                       2
675#define RTZ                                      3
676};
677
678static inline __attribute__((always_inline)) void
679GFX7_INTERFACE_DESCRIPTOR_DATA_pack(__attribute__((unused)) __gen_user_data *data,
680                                    __attribute__((unused)) void * restrict dst,
681                                    __attribute__((unused)) const struct GFX7_INTERFACE_DESCRIPTOR_DATA * restrict values)
682{
683   uint32_t * restrict dw = (uint32_t * restrict) dst;
684
685   dw[0] =
686      __gen_offset(values->KernelStartPointer, 6, 31);
687
688   dw[1] =
689      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
690      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
691      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
692      __gen_uint(values->FloatingPointMode, 16, 16) |
693      __gen_uint(values->ThreadPriority, 17, 17) |
694      __gen_uint(values->SingleProgramFlow, 18, 18);
695
696   dw[2] =
697      __gen_uint(values->SamplerCount, 2, 4) |
698      __gen_offset(values->SamplerStatePointer, 5, 31);
699
700   dw[3] =
701      __gen_uint(values->BindingTableEntryCount, 0, 4) |
702      __gen_offset(values->BindingTablePointer, 5, 15);
703
704   dw[4] =
705      __gen_uint(values->ConstantURBEntryReadOffset, 0, 15) |
706      __gen_uint(values->ConstantURBEntryReadLength, 16, 31);
707
708   dw[5] =
709      __gen_uint(values->NumberofThreadsinGPGPUThreadGroup, 0, 7) |
710      __gen_uint(values->SharedLocalMemorySize, 16, 20) |
711      __gen_uint(values->BarrierEnable, 21, 21) |
712      __gen_uint(values->RoundingMode, 22, 23);
713
714   dw[6] = 0;
715
716   dw[7] = 0;
717}
718
719#define GFX7_MEMORY_OBJECT_CONTROL_STATE_length      1
720struct GFX7_MEMORY_OBJECT_CONTROL_STATE {
721   uint32_t                             L3CacheabilityControlL3CC;
722   uint32_t                             LLCCacheabilityControlLLCCC;
723   uint32_t                             GraphicsDataTypeGFDT;
724};
725
726static inline __attribute__((always_inline)) void
727GFX7_MEMORY_OBJECT_CONTROL_STATE_pack(__attribute__((unused)) __gen_user_data *data,
728                                      __attribute__((unused)) void * restrict dst,
729                                      __attribute__((unused)) const struct GFX7_MEMORY_OBJECT_CONTROL_STATE * restrict values)
730{
731   uint32_t * restrict dw = (uint32_t * restrict) dst;
732
733   dw[0] =
734      __gen_uint(values->L3CacheabilityControlL3CC, 0, 0) |
735      __gen_uint(values->LLCCacheabilityControlLLCCC, 1, 1) |
736      __gen_uint(values->GraphicsDataTypeGFDT, 2, 2);
737}
738
739#define GFX7_MFD_MPEG2_BSD_OBJECT_INLINE_DATA_DESCRIPTION_length      2
740struct GFX7_MFD_MPEG2_BSD_OBJECT_INLINE_DATA_DESCRIPTION {
741   uint32_t                             FirstMBBitOffset;
742   bool                                 LastMB;
743   bool                                 LastPicSlice;
744   uint32_t                             MBCount;
745   uint32_t                             SliceVerticalPosition;
746   uint32_t                             SliceHorizontalPosition;
747   uint32_t                             QuantizerScaleCode;
748};
749
750static inline __attribute__((always_inline)) void
751GFX7_MFD_MPEG2_BSD_OBJECT_INLINE_DATA_DESCRIPTION_pack(__attribute__((unused)) __gen_user_data *data,
752                                                       __attribute__((unused)) void * restrict dst,
753                                                       __attribute__((unused)) const struct GFX7_MFD_MPEG2_BSD_OBJECT_INLINE_DATA_DESCRIPTION * restrict values)
754{
755   uint32_t * restrict dw = (uint32_t * restrict) dst;
756
757   dw[0] =
758      __gen_uint(values->FirstMBBitOffset, 0, 2) |
759      __gen_uint(values->LastMB, 3, 3) |
760      __gen_uint(values->LastPicSlice, 5, 5) |
761      __gen_uint(values->MBCount, 8, 14) |
762      __gen_uint(values->SliceVerticalPosition, 16, 22) |
763      __gen_uint(values->SliceHorizontalPosition, 24, 30);
764
765   dw[1] =
766      __gen_uint(values->QuantizerScaleCode, 24, 28);
767}
768
769#define GFX7_PALETTE_ENTRY_length              1
770struct GFX7_PALETTE_ENTRY {
771   uint32_t                             Blue;
772   uint32_t                             Green;
773   uint32_t                             Red;
774   uint32_t                             Alpha;
775};
776
777static inline __attribute__((always_inline)) void
778GFX7_PALETTE_ENTRY_pack(__attribute__((unused)) __gen_user_data *data,
779                        __attribute__((unused)) void * restrict dst,
780                        __attribute__((unused)) const struct GFX7_PALETTE_ENTRY * restrict values)
781{
782   uint32_t * restrict dw = (uint32_t * restrict) dst;
783
784   dw[0] =
785      __gen_uint(values->Blue, 0, 7) |
786      __gen_uint(values->Green, 8, 15) |
787      __gen_uint(values->Red, 16, 23) |
788      __gen_uint(values->Alpha, 24, 31);
789}
790
791#define GFX7_RENDER_SURFACE_STATE_length       8
792struct GFX7_RENDER_SURFACE_STATE {
793   bool                                 CubeFaceEnablePositiveZ;
794   bool                                 CubeFaceEnableNegativeZ;
795   bool                                 CubeFaceEnablePositiveY;
796   bool                                 CubeFaceEnableNegativeY;
797   bool                                 CubeFaceEnablePositiveX;
798   bool                                 CubeFaceEnableNegativeX;
799   uint32_t                             MediaBoundaryPixelMode;
800#define NORMAL_MODE                              0
801#define PROGRESSIVE_FRAME                        2
802#define INTERLACED_FRAME                         3
803   uint32_t                             RenderCacheReadWriteMode;
804   uint32_t                             SurfaceArraySpacing;
805#define ARYSPC_FULL                              0
806#define ARYSPC_LOD0                              1
807   uint32_t                             VerticalLineStrideOffset;
808   uint32_t                             VerticalLineStride;
809   uint32_t                             TileWalk;
810#define TILEWALK_XMAJOR                          0
811#define TILEWALK_YMAJOR                          1
812   bool                                 TiledSurface;
813   uint32_t                             SurfaceHorizontalAlignment;
814#define HALIGN_4                                 0
815#define HALIGN_8                                 1
816   uint32_t                             SurfaceVerticalAlignment;
817#define VALIGN_2                                 0
818#define VALIGN_4                                 1
819   uint32_t                             SurfaceFormat;
820   bool                                 SurfaceArray;
821   uint32_t                             SurfaceType;
822#define SURFTYPE_1D                              0
823#define SURFTYPE_2D                              1
824#define SURFTYPE_3D                              2
825#define SURFTYPE_CUBE                            3
826#define SURFTYPE_BUFFER                          4
827#define SURFTYPE_STRBUF                          5
828#define SURFTYPE_NULL                            7
829   __gen_address_type                   SurfaceBaseAddress;
830   uint32_t                             Width;
831   uint32_t                             Height;
832   uint32_t                             SurfacePitch;
833   uint32_t                             Depth;
834   uint32_t                             MultisamplePositionPaletteIndex;
835   uint32_t                             StrbufMinimumArrayElement;
836   uint32_t                             NumberofMultisamples;
837#define MULTISAMPLECOUNT_1                       0
838#define MULTISAMPLECOUNT_4                       2
839#define MULTISAMPLECOUNT_8                       3
840   uint32_t                             MultisampledSurfaceStorageFormat;
841#define MSFMT_MSS                                0
842#define MSFMT_DEPTH_STENCIL                      1
843   uint32_t                             RenderTargetViewExtent;
844   uint32_t                             MinimumArrayElement;
845   uint32_t                             RenderTargetRotation;
846#define RTROTATE_0DEG                            0
847#define RTROTATE_90DEG                           1
848#define RTROTATE_270DEG                          3
849   uint32_t                             MIPCountLOD;
850   uint32_t                             SurfaceMinLOD;
851   uint32_t                             MOCS;
852   uint32_t                             YOffset;
853   uint32_t                             XOffset;
854   bool                                 MCSEnable;
855   uint32_t                             YOffsetforUVPlane;
856   bool                                 AppendCounterEnable;
857   uint32_t                             AuxiliarySurfacePitch;
858   __gen_address_type                   AppendCounterAddress;
859   __gen_address_type                   AuxiliarySurfaceBaseAddress;
860   uint32_t                             XOffsetforUVPlane;
861   uint32_t                             ReservedMBZ;
862   float                                ResourceMinLOD;
863   uint32_t                             AlphaClearColor;
864#define CC_ZERO                                  0
865#define CC_ONE                                   1
866   uint32_t                             BlueClearColor;
867#define CC_ZERO                                  0
868#define CC_ONE                                   1
869   uint32_t                             GreenClearColor;
870#define CC_ZERO                                  0
871#define CC_ONE                                   1
872   uint32_t                             RedClearColor;
873#define CC_ZERO                                  0
874#define CC_ONE                                   1
875};
876
877static inline __attribute__((always_inline)) void
878GFX7_RENDER_SURFACE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
879                               __attribute__((unused)) void * restrict dst,
880                               __attribute__((unused)) const struct GFX7_RENDER_SURFACE_STATE * restrict values)
881{
882   uint32_t * restrict dw = (uint32_t * restrict) dst;
883
884   dw[0] =
885      __gen_uint(values->CubeFaceEnablePositiveZ, 0, 0) |
886      __gen_uint(values->CubeFaceEnableNegativeZ, 1, 1) |
887      __gen_uint(values->CubeFaceEnablePositiveY, 2, 2) |
888      __gen_uint(values->CubeFaceEnableNegativeY, 3, 3) |
889      __gen_uint(values->CubeFaceEnablePositiveX, 4, 4) |
890      __gen_uint(values->CubeFaceEnableNegativeX, 5, 5) |
891      __gen_uint(values->MediaBoundaryPixelMode, 6, 7) |
892      __gen_uint(values->RenderCacheReadWriteMode, 8, 8) |
893      __gen_uint(values->SurfaceArraySpacing, 10, 10) |
894      __gen_uint(values->VerticalLineStrideOffset, 11, 11) |
895      __gen_uint(values->VerticalLineStride, 12, 12) |
896      __gen_uint(values->TileWalk, 13, 13) |
897      __gen_uint(values->TiledSurface, 14, 14) |
898      __gen_uint(values->SurfaceHorizontalAlignment, 15, 15) |
899      __gen_uint(values->SurfaceVerticalAlignment, 16, 17) |
900      __gen_uint(values->SurfaceFormat, 18, 26) |
901      __gen_uint(values->SurfaceArray, 28, 28) |
902      __gen_uint(values->SurfaceType, 29, 31);
903
904   dw[1] = __gen_address(data, &dw[1], values->SurfaceBaseAddress, 0, 0, 31);
905
906   dw[2] =
907      __gen_uint(values->Width, 0, 13) |
908      __gen_uint(values->Height, 16, 29);
909
910   dw[3] =
911      __gen_uint(values->SurfacePitch, 0, 17) |
912      __gen_uint(values->Depth, 21, 31);
913
914   dw[4] =
915      __gen_uint(values->MultisamplePositionPaletteIndex, 0, 2) |
916      __gen_uint(values->StrbufMinimumArrayElement, 0, 26) |
917      __gen_uint(values->NumberofMultisamples, 3, 5) |
918      __gen_uint(values->MultisampledSurfaceStorageFormat, 6, 6) |
919      __gen_uint(values->RenderTargetViewExtent, 7, 17) |
920      __gen_uint(values->MinimumArrayElement, 18, 28) |
921      __gen_uint(values->RenderTargetRotation, 29, 30);
922
923   dw[5] =
924      __gen_uint(values->MIPCountLOD, 0, 3) |
925      __gen_uint(values->SurfaceMinLOD, 4, 7) |
926      __gen_uint(values->MOCS, 16, 19) |
927      __gen_uint(values->YOffset, 20, 23) |
928      __gen_uint(values->XOffset, 25, 31);
929
930   const uint32_t v6 =
931      __gen_uint(values->MCSEnable, 0, 0) |
932      __gen_uint(values->YOffsetforUVPlane, 0, 13) |
933      __gen_uint(values->AppendCounterEnable, 1, 1) |
934      __gen_uint(values->AuxiliarySurfacePitch, 3, 11) |
935      __gen_uint(values->XOffsetforUVPlane, 16, 29) |
936      __gen_uint(values->ReservedMBZ, 30, 31);
937   dw[6] = __gen_address(data, &dw[6], values->AuxiliarySurfaceBaseAddress, v6, 12, 31);
938
939   dw[7] =
940      __gen_ufixed(values->ResourceMinLOD, 0, 11, 8) |
941      __gen_uint(values->AlphaClearColor, 28, 28) |
942      __gen_uint(values->BlueClearColor, 29, 29) |
943      __gen_uint(values->GreenClearColor, 30, 30) |
944      __gen_uint(values->RedClearColor, 31, 31);
945}
946
947#define GFX7_SAMPLER_BORDER_COLOR_STATE_length      4
948struct GFX7_SAMPLER_BORDER_COLOR_STATE {
949   uint32_t                             BorderColorUnormRed;
950   float                                BorderColorFloatRed;
951   uint32_t                             BorderColorUnormGreen;
952   uint32_t                             BorderColorUnormBlue;
953   uint32_t                             BorderColorUnormAlpha;
954   float                                BorderColorFloatGreen;
955   float                                BorderColorFloatBlue;
956   float                                BorderColorFloatAlpha;
957};
958
959static inline __attribute__((always_inline)) void
960GFX7_SAMPLER_BORDER_COLOR_STATE_pack(__attribute__((unused)) __gen_user_data *data,
961                                     __attribute__((unused)) void * restrict dst,
962                                     __attribute__((unused)) const struct GFX7_SAMPLER_BORDER_COLOR_STATE * restrict values)
963{
964   uint32_t * restrict dw = (uint32_t * restrict) dst;
965
966   dw[0] =
967      __gen_uint(values->BorderColorUnormRed, 0, 7) |
968      __gen_float(values->BorderColorFloatRed) |
969      __gen_uint(values->BorderColorUnormGreen, 8, 15) |
970      __gen_uint(values->BorderColorUnormBlue, 16, 23) |
971      __gen_uint(values->BorderColorUnormAlpha, 24, 31);
972
973   dw[1] =
974      __gen_float(values->BorderColorFloatGreen);
975
976   dw[2] =
977      __gen_float(values->BorderColorFloatBlue);
978
979   dw[3] =
980      __gen_float(values->BorderColorFloatAlpha);
981}
982
983#define GFX7_SAMPLER_STATE_length              4
984struct GFX7_SAMPLER_STATE {
985   uint32_t                             AnisotropicAlgorithm;
986#define LEGACY                                   0
987#define EWAApproximation                         1
988   float                                TextureLODBias;
989   uint32_t                             MinModeFilter;
990#define MAPFILTER_NEAREST                        0
991#define MAPFILTER_LINEAR                         1
992#define MAPFILTER_ANISOTROPIC                    2
993#define MAPFILTER_MONO                           6
994   uint32_t                             MagModeFilter;
995#define MAPFILTER_NEAREST                        0
996#define MAPFILTER_LINEAR                         1
997#define MAPFILTER_ANISOTROPIC                    2
998#define MAPFILTER_MONO                           6
999   uint32_t                             MipModeFilter;
1000#define MIPFILTER_NONE                           0
1001#define MIPFILTER_NEAREST                        1
1002#define MIPFILTER_LINEAR                         3
1003   float                                BaseMipLevel;
1004   uint32_t                             LODPreClampEnable;
1005#define CLAMP_ENABLE_OGL                         1
1006   uint32_t                             TextureBorderColorMode;
1007#define DX10OGL                                  0
1008#define DX9                                      1
1009   bool                                 SamplerDisable;
1010   uint32_t                             CubeSurfaceControlMode;
1011#define PROGRAMMED                               0
1012#define OVERRIDE                                 1
1013   uint32_t                             ShadowFunction;
1014#define PREFILTEROP_ALWAYS                       0
1015#define PREFILTEROP_NEVER                        1
1016#define PREFILTEROP_LESS                         2
1017#define PREFILTEROP_EQUAL                        3
1018#define PREFILTEROP_LEQUAL                       4
1019#define PREFILTEROP_GREATER                      5
1020#define PREFILTEROP_NOTEQUAL                     6
1021#define PREFILTEROP_GEQUAL                       7
1022   float                                MaxLOD;
1023   float                                MinLOD;
1024   uint64_t                             BorderColorPointer;
1025   enum GFX7_TextureCoordinateMode      TCZAddressControlMode;
1026   enum GFX7_TextureCoordinateMode      TCYAddressControlMode;
1027   enum GFX7_TextureCoordinateMode      TCXAddressControlMode;
1028   bool                                 NonnormalizedCoordinateEnable;
1029   uint32_t                             TrilinearFilterQuality;
1030#define FULL                                     0
1031#define MED                                      2
1032#define LOW                                      3
1033   bool                                 RAddressMinFilterRoundingEnable;
1034   bool                                 RAddressMagFilterRoundingEnable;
1035   bool                                 VAddressMinFilterRoundingEnable;
1036   bool                                 VAddressMagFilterRoundingEnable;
1037   bool                                 UAddressMinFilterRoundingEnable;
1038   bool                                 UAddressMagFilterRoundingEnable;
1039   uint32_t                             MaximumAnisotropy;
1040#define RATIO21                                  0
1041#define RATIO41                                  1
1042#define RATIO61                                  2
1043#define RATIO81                                  3
1044#define RATIO101                                 4
1045#define RATIO121                                 5
1046#define RATIO141                                 6
1047#define RATIO161                                 7
1048   uint32_t                             ChromaKeyMode;
1049#define KEYFILTER_KILL_ON_ANY_MATCH              0
1050#define KEYFILTER_REPLACE_BLACK                  1
1051   uint32_t                             ChromaKeyIndex;
1052   bool                                 ChromaKeyEnable;
1053};
1054
1055static inline __attribute__((always_inline)) void
1056GFX7_SAMPLER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1057                        __attribute__((unused)) void * restrict dst,
1058                        __attribute__((unused)) const struct GFX7_SAMPLER_STATE * restrict values)
1059{
1060   uint32_t * restrict dw = (uint32_t * restrict) dst;
1061
1062   dw[0] =
1063      __gen_uint(values->AnisotropicAlgorithm, 0, 0) |
1064      __gen_sfixed(values->TextureLODBias, 1, 13, 8) |
1065      __gen_uint(values->MinModeFilter, 14, 16) |
1066      __gen_uint(values->MagModeFilter, 17, 19) |
1067      __gen_uint(values->MipModeFilter, 20, 21) |
1068      __gen_ufixed(values->BaseMipLevel, 22, 26, 1) |
1069      __gen_uint(values->LODPreClampEnable, 28, 28) |
1070      __gen_uint(values->TextureBorderColorMode, 29, 29) |
1071      __gen_uint(values->SamplerDisable, 31, 31);
1072
1073   dw[1] =
1074      __gen_uint(values->CubeSurfaceControlMode, 0, 0) |
1075      __gen_uint(values->ShadowFunction, 1, 3) |
1076      __gen_ufixed(values->MaxLOD, 8, 19, 8) |
1077      __gen_ufixed(values->MinLOD, 20, 31, 8);
1078
1079   dw[2] =
1080      __gen_offset(values->BorderColorPointer, 5, 31);
1081
1082   dw[3] =
1083      __gen_uint(values->TCZAddressControlMode, 0, 2) |
1084      __gen_uint(values->TCYAddressControlMode, 3, 5) |
1085      __gen_uint(values->TCXAddressControlMode, 6, 8) |
1086      __gen_uint(values->NonnormalizedCoordinateEnable, 10, 10) |
1087      __gen_uint(values->TrilinearFilterQuality, 11, 12) |
1088      __gen_uint(values->RAddressMinFilterRoundingEnable, 13, 13) |
1089      __gen_uint(values->RAddressMagFilterRoundingEnable, 14, 14) |
1090      __gen_uint(values->VAddressMinFilterRoundingEnable, 15, 15) |
1091      __gen_uint(values->VAddressMagFilterRoundingEnable, 16, 16) |
1092      __gen_uint(values->UAddressMinFilterRoundingEnable, 17, 17) |
1093      __gen_uint(values->UAddressMagFilterRoundingEnable, 18, 18) |
1094      __gen_uint(values->MaximumAnisotropy, 19, 21) |
1095      __gen_uint(values->ChromaKeyMode, 22, 22) |
1096      __gen_uint(values->ChromaKeyIndex, 23, 24) |
1097      __gen_uint(values->ChromaKeyEnable, 25, 25);
1098}
1099
1100#define GFX7_SCISSOR_RECT_length               2
1101struct GFX7_SCISSOR_RECT {
1102   uint32_t                             ScissorRectangleXMin;
1103   uint32_t                             ScissorRectangleYMin;
1104   uint32_t                             ScissorRectangleXMax;
1105   uint32_t                             ScissorRectangleYMax;
1106};
1107
1108static inline __attribute__((always_inline)) void
1109GFX7_SCISSOR_RECT_pack(__attribute__((unused)) __gen_user_data *data,
1110                       __attribute__((unused)) void * restrict dst,
1111                       __attribute__((unused)) const struct GFX7_SCISSOR_RECT * restrict values)
1112{
1113   uint32_t * restrict dw = (uint32_t * restrict) dst;
1114
1115   dw[0] =
1116      __gen_uint(values->ScissorRectangleXMin, 0, 15) |
1117      __gen_uint(values->ScissorRectangleYMin, 16, 31);
1118
1119   dw[1] =
1120      __gen_uint(values->ScissorRectangleXMax, 0, 15) |
1121      __gen_uint(values->ScissorRectangleYMax, 16, 31);
1122}
1123
1124#define GFX7_SF_CLIP_VIEWPORT_length          16
1125struct GFX7_SF_CLIP_VIEWPORT {
1126   float                                ViewportMatrixElementm00;
1127   float                                ViewportMatrixElementm11;
1128   float                                ViewportMatrixElementm22;
1129   float                                ViewportMatrixElementm30;
1130   float                                ViewportMatrixElementm31;
1131   float                                ViewportMatrixElementm32;
1132   float                                XMinClipGuardband;
1133   float                                XMaxClipGuardband;
1134   float                                YMinClipGuardband;
1135   float                                YMaxClipGuardband;
1136};
1137
1138static inline __attribute__((always_inline)) void
1139GFX7_SF_CLIP_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
1140                           __attribute__((unused)) void * restrict dst,
1141                           __attribute__((unused)) const struct GFX7_SF_CLIP_VIEWPORT * restrict values)
1142{
1143   uint32_t * restrict dw = (uint32_t * restrict) dst;
1144
1145   dw[0] =
1146      __gen_float(values->ViewportMatrixElementm00);
1147
1148   dw[1] =
1149      __gen_float(values->ViewportMatrixElementm11);
1150
1151   dw[2] =
1152      __gen_float(values->ViewportMatrixElementm22);
1153
1154   dw[3] =
1155      __gen_float(values->ViewportMatrixElementm30);
1156
1157   dw[4] =
1158      __gen_float(values->ViewportMatrixElementm31);
1159
1160   dw[5] =
1161      __gen_float(values->ViewportMatrixElementm32);
1162
1163   dw[6] = 0;
1164
1165   dw[7] = 0;
1166
1167   dw[8] =
1168      __gen_float(values->XMinClipGuardband);
1169
1170   dw[9] =
1171      __gen_float(values->XMaxClipGuardband);
1172
1173   dw[10] =
1174      __gen_float(values->YMinClipGuardband);
1175
1176   dw[11] =
1177      __gen_float(values->YMaxClipGuardband);
1178
1179   dw[12] = 0;
1180
1181   dw[13] = 0;
1182
1183   dw[14] = 0;
1184
1185   dw[15] = 0;
1186}
1187
1188#define GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_length      1
1189struct GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL {
1190   uint32_t                             SourceAttribute;
1191   uint32_t                             SwizzleSelect;
1192#define INPUTATTR                                0
1193#define INPUTATTR_FACING                         1
1194#define INPUTATTR_W                              2
1195#define INPUTATTR_FACING_W                       3
1196   uint32_t                             ConstantSource;
1197#define CONST_0000                               0
1198#define CONST_0001_FLOAT                         1
1199#define CONST_1111_FLOAT                         2
1200#define PRIM_ID                                  3
1201   uint32_t                             SwizzleControlMode;
1202   bool                                 ComponentOverrideX;
1203   bool                                 ComponentOverrideY;
1204   bool                                 ComponentOverrideZ;
1205   bool                                 ComponentOverrideW;
1206};
1207
1208static inline __attribute__((always_inline)) void
1209GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(__attribute__((unused)) __gen_user_data *data,
1210                                     __attribute__((unused)) void * restrict dst,
1211                                     __attribute__((unused)) const struct GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL * restrict values)
1212{
1213   uint32_t * restrict dw = (uint32_t * restrict) dst;
1214
1215   dw[0] =
1216      __gen_uint(values->SourceAttribute, 0, 4) |
1217      __gen_uint(values->SwizzleSelect, 6, 7) |
1218      __gen_uint(values->ConstantSource, 9, 10) |
1219      __gen_uint(values->SwizzleControlMode, 11, 11) |
1220      __gen_uint(values->ComponentOverrideX, 12, 12) |
1221      __gen_uint(values->ComponentOverrideY, 13, 13) |
1222      __gen_uint(values->ComponentOverrideZ, 14, 14) |
1223      __gen_uint(values->ComponentOverrideW, 15, 15);
1224}
1225
1226#define GFX7_SO_DECL_length                    1
1227struct GFX7_SO_DECL {
1228   uint32_t                             ComponentMask;
1229   uint32_t                             RegisterIndex;
1230   bool                                 HoleFlag;
1231   uint32_t                             OutputBufferSlot;
1232};
1233
1234static inline __attribute__((always_inline)) void
1235GFX7_SO_DECL_pack(__attribute__((unused)) __gen_user_data *data,
1236                  __attribute__((unused)) void * restrict dst,
1237                  __attribute__((unused)) const struct GFX7_SO_DECL * restrict values)
1238{
1239   uint32_t * restrict dw = (uint32_t * restrict) dst;
1240
1241   dw[0] =
1242      __gen_uint(values->ComponentMask, 0, 3) |
1243      __gen_uint(values->RegisterIndex, 4, 9) |
1244      __gen_uint(values->HoleFlag, 11, 11) |
1245      __gen_uint(values->OutputBufferSlot, 12, 13);
1246}
1247
1248#define GFX7_SO_DECL_ENTRY_length              2
1249struct GFX7_SO_DECL_ENTRY {
1250   struct GFX7_SO_DECL                  Stream0Decl;
1251   struct GFX7_SO_DECL                  Stream1Decl;
1252   struct GFX7_SO_DECL                  Stream2Decl;
1253   struct GFX7_SO_DECL                  Stream3Decl;
1254};
1255
1256static inline __attribute__((always_inline)) void
1257GFX7_SO_DECL_ENTRY_pack(__attribute__((unused)) __gen_user_data *data,
1258                        __attribute__((unused)) void * restrict dst,
1259                        __attribute__((unused)) const struct GFX7_SO_DECL_ENTRY * restrict values)
1260{
1261   uint32_t * restrict dw = (uint32_t * restrict) dst;
1262
1263   uint32_t v0_0;
1264   GFX7_SO_DECL_pack(data, &v0_0, &values->Stream0Decl);
1265
1266   uint32_t v0_1;
1267   GFX7_SO_DECL_pack(data, &v0_1, &values->Stream1Decl);
1268
1269   dw[0] =
1270      __gen_uint(v0_0, 0, 15) |
1271      __gen_uint(v0_1, 16, 31);
1272
1273   uint32_t v1_0;
1274   GFX7_SO_DECL_pack(data, &v1_0, &values->Stream2Decl);
1275
1276   uint32_t v1_1;
1277   GFX7_SO_DECL_pack(data, &v1_1, &values->Stream3Decl);
1278
1279   dw[1] =
1280      __gen_uint(v1_0, 0, 15) |
1281      __gen_uint(v1_1, 16, 31);
1282}
1283
1284#define GFX7_VERTEX_BUFFER_STATE_length        4
1285struct GFX7_VERTEX_BUFFER_STATE {
1286   uint32_t                             BufferPitch;
1287   bool                                 VertexFetchInvalidate;
1288   bool                                 NullVertexBuffer;
1289   bool                                 AddressModifyEnable;
1290   uint32_t                             MOCS;
1291   uint32_t                             BufferAccessType;
1292#define VERTEXDATA                               0
1293#define INSTANCEDATA                             1
1294   uint32_t                             VertexBufferIndex;
1295   __gen_address_type                   BufferStartingAddress;
1296   __gen_address_type                   EndAddress;
1297   uint32_t                             InstanceDataStepRate;
1298};
1299
1300static inline __attribute__((always_inline)) void
1301GFX7_VERTEX_BUFFER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1302                              __attribute__((unused)) void * restrict dst,
1303                              __attribute__((unused)) const struct GFX7_VERTEX_BUFFER_STATE * restrict values)
1304{
1305   uint32_t * restrict dw = (uint32_t * restrict) dst;
1306
1307   dw[0] =
1308      __gen_uint(values->BufferPitch, 0, 11) |
1309      __gen_uint(values->VertexFetchInvalidate, 12, 12) |
1310      __gen_uint(values->NullVertexBuffer, 13, 13) |
1311      __gen_uint(values->AddressModifyEnable, 14, 14) |
1312      __gen_uint(values->MOCS, 16, 19) |
1313      __gen_uint(values->BufferAccessType, 20, 20) |
1314      __gen_uint(values->VertexBufferIndex, 26, 31);
1315
1316   dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, 0, 0, 31);
1317
1318   dw[2] = __gen_address(data, &dw[2], values->EndAddress, 0, 0, 31);
1319
1320   dw[3] =
1321      __gen_uint(values->InstanceDataStepRate, 0, 31);
1322}
1323
1324#define GFX7_VERTEX_ELEMENT_STATE_length       2
1325struct GFX7_VERTEX_ELEMENT_STATE {
1326   uint32_t                             SourceElementOffset;
1327   bool                                 EdgeFlagEnable;
1328   uint32_t                             SourceElementFormat;
1329   bool                                 Valid;
1330   uint32_t                             VertexBufferIndex;
1331   enum GFX7_3D_Vertex_Component_Control Component3Control;
1332   enum GFX7_3D_Vertex_Component_Control Component2Control;
1333   enum GFX7_3D_Vertex_Component_Control Component1Control;
1334   enum GFX7_3D_Vertex_Component_Control Component0Control;
1335};
1336
1337static inline __attribute__((always_inline)) void
1338GFX7_VERTEX_ELEMENT_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1339                               __attribute__((unused)) void * restrict dst,
1340                               __attribute__((unused)) const struct GFX7_VERTEX_ELEMENT_STATE * restrict values)
1341{
1342   uint32_t * restrict dw = (uint32_t * restrict) dst;
1343
1344   dw[0] =
1345      __gen_uint(values->SourceElementOffset, 0, 11) |
1346      __gen_uint(values->EdgeFlagEnable, 15, 15) |
1347      __gen_uint(values->SourceElementFormat, 16, 24) |
1348      __gen_uint(values->Valid, 25, 25) |
1349      __gen_uint(values->VertexBufferIndex, 26, 31);
1350
1351   dw[1] =
1352      __gen_uint(values->Component3Control, 16, 18) |
1353      __gen_uint(values->Component2Control, 20, 22) |
1354      __gen_uint(values->Component1Control, 24, 26) |
1355      __gen_uint(values->Component0Control, 28, 30);
1356}
1357
1358#define GFX7_3DPRIMITIVE_length                7
1359#define GFX7_3DPRIMITIVE_length_bias           2
1360#define GFX7_3DPRIMITIVE_header                 \
1361   .DWordLength                         =      5,  \
1362   ._3DCommandSubOpcode                 =      0,  \
1363   ._3DCommandOpcode                    =      3,  \
1364   .CommandSubType                      =      3,  \
1365   .CommandType                         =      3
1366
1367struct GFX7_3DPRIMITIVE {
1368   uint32_t                             DWordLength;
1369   bool                                 PredicateEnable;
1370   bool                                 IndirectParameterEnable;
1371   uint32_t                             _3DCommandSubOpcode;
1372   uint32_t                             _3DCommandOpcode;
1373   uint32_t                             CommandSubType;
1374   uint32_t                             CommandType;
1375   enum GFX7_3D_Prim_Topo_Type          PrimitiveTopologyType;
1376   uint32_t                             VertexAccessType;
1377#define SEQUENTIAL                               0
1378#define RANDOM                                   1
1379   bool                                 EndOffsetEnable;
1380   uint32_t                             VertexCountPerInstance;
1381   uint32_t                             StartVertexLocation;
1382   uint32_t                             InstanceCount;
1383   uint32_t                             StartInstanceLocation;
1384   int32_t                              BaseVertexLocation;
1385};
1386
1387static inline __attribute__((always_inline)) void
1388GFX7_3DPRIMITIVE_pack(__attribute__((unused)) __gen_user_data *data,
1389                      __attribute__((unused)) void * restrict dst,
1390                      __attribute__((unused)) const struct GFX7_3DPRIMITIVE * restrict values)
1391{
1392   uint32_t * restrict dw = (uint32_t * restrict) dst;
1393
1394   dw[0] =
1395      __gen_uint(values->DWordLength, 0, 7) |
1396      __gen_uint(values->PredicateEnable, 8, 8) |
1397      __gen_uint(values->IndirectParameterEnable, 10, 10) |
1398      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1399      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1400      __gen_uint(values->CommandSubType, 27, 28) |
1401      __gen_uint(values->CommandType, 29, 31);
1402
1403   dw[1] =
1404      __gen_uint(values->PrimitiveTopologyType, 0, 5) |
1405      __gen_uint(values->VertexAccessType, 8, 8) |
1406      __gen_uint(values->EndOffsetEnable, 9, 9);
1407
1408   dw[2] =
1409      __gen_uint(values->VertexCountPerInstance, 0, 31);
1410
1411   dw[3] =
1412      __gen_uint(values->StartVertexLocation, 0, 31);
1413
1414   dw[4] =
1415      __gen_uint(values->InstanceCount, 0, 31);
1416
1417   dw[5] =
1418      __gen_uint(values->StartInstanceLocation, 0, 31);
1419
1420   dw[6] =
1421      __gen_sint(values->BaseVertexLocation, 0, 31);
1422}
1423
1424#define GFX7_3DSTATE_AA_LINE_PARAMETERS_length      3
1425#define GFX7_3DSTATE_AA_LINE_PARAMETERS_length_bias      2
1426#define GFX7_3DSTATE_AA_LINE_PARAMETERS_header  \
1427   .DWordLength                         =      1,  \
1428   ._3DCommandSubOpcode                 =     10,  \
1429   ._3DCommandOpcode                    =      1,  \
1430   .CommandSubType                      =      3,  \
1431   .CommandType                         =      3
1432
1433struct GFX7_3DSTATE_AA_LINE_PARAMETERS {
1434   uint32_t                             DWordLength;
1435   uint32_t                             _3DCommandSubOpcode;
1436   uint32_t                             _3DCommandOpcode;
1437   uint32_t                             CommandSubType;
1438   uint32_t                             CommandType;
1439   float                                AACoverageSlope;
1440   float                                AACoverageBias;
1441   float                                AACoverageEndCapSlope;
1442   float                                AACoverageEndCapBias;
1443};
1444
1445static inline __attribute__((always_inline)) void
1446GFX7_3DSTATE_AA_LINE_PARAMETERS_pack(__attribute__((unused)) __gen_user_data *data,
1447                                     __attribute__((unused)) void * restrict dst,
1448                                     __attribute__((unused)) const struct GFX7_3DSTATE_AA_LINE_PARAMETERS * restrict values)
1449{
1450   uint32_t * restrict dw = (uint32_t * restrict) dst;
1451
1452   dw[0] =
1453      __gen_uint(values->DWordLength, 0, 7) |
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_ufixed(values->AACoverageSlope, 0, 7, 8) |
1461      __gen_ufixed(values->AACoverageBias, 16, 23, 8);
1462
1463   dw[2] =
1464      __gen_ufixed(values->AACoverageEndCapSlope, 0, 7, 8) |
1465      __gen_ufixed(values->AACoverageEndCapBias, 16, 23, 8);
1466}
1467
1468#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_DS_length      2
1469#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_DS_length_bias      2
1470#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_DS_header\
1471   .DWordLength                         =      0,  \
1472   ._3DCommandSubOpcode                 =     40,  \
1473   ._3DCommandOpcode                    =      0,  \
1474   .CommandSubType                      =      3,  \
1475   .CommandType                         =      3
1476
1477struct GFX7_3DSTATE_BINDING_TABLE_POINTERS_DS {
1478   uint32_t                             DWordLength;
1479   uint32_t                             _3DCommandSubOpcode;
1480   uint32_t                             _3DCommandOpcode;
1481   uint32_t                             CommandSubType;
1482   uint32_t                             CommandType;
1483   uint64_t                             PointertoDSBindingTable;
1484};
1485
1486static inline __attribute__((always_inline)) void
1487GFX7_3DSTATE_BINDING_TABLE_POINTERS_DS_pack(__attribute__((unused)) __gen_user_data *data,
1488                                            __attribute__((unused)) void * restrict dst,
1489                                            __attribute__((unused)) const struct GFX7_3DSTATE_BINDING_TABLE_POINTERS_DS * restrict values)
1490{
1491   uint32_t * restrict dw = (uint32_t * restrict) dst;
1492
1493   dw[0] =
1494      __gen_uint(values->DWordLength, 0, 7) |
1495      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1496      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1497      __gen_uint(values->CommandSubType, 27, 28) |
1498      __gen_uint(values->CommandType, 29, 31);
1499
1500   dw[1] =
1501      __gen_offset(values->PointertoDSBindingTable, 5, 15);
1502}
1503
1504#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_GS_length      2
1505#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_GS_length_bias      2
1506#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_GS_header\
1507   .DWordLength                         =      0,  \
1508   ._3DCommandSubOpcode                 =     41,  \
1509   ._3DCommandOpcode                    =      0,  \
1510   .CommandSubType                      =      3,  \
1511   .CommandType                         =      3
1512
1513struct GFX7_3DSTATE_BINDING_TABLE_POINTERS_GS {
1514   uint32_t                             DWordLength;
1515   uint32_t                             _3DCommandSubOpcode;
1516   uint32_t                             _3DCommandOpcode;
1517   uint32_t                             CommandSubType;
1518   uint32_t                             CommandType;
1519   uint64_t                             PointertoGSBindingTable;
1520};
1521
1522static inline __attribute__((always_inline)) void
1523GFX7_3DSTATE_BINDING_TABLE_POINTERS_GS_pack(__attribute__((unused)) __gen_user_data *data,
1524                                            __attribute__((unused)) void * restrict dst,
1525                                            __attribute__((unused)) const struct GFX7_3DSTATE_BINDING_TABLE_POINTERS_GS * restrict values)
1526{
1527   uint32_t * restrict dw = (uint32_t * restrict) dst;
1528
1529   dw[0] =
1530      __gen_uint(values->DWordLength, 0, 7) |
1531      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1532      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1533      __gen_uint(values->CommandSubType, 27, 28) |
1534      __gen_uint(values->CommandType, 29, 31);
1535
1536   dw[1] =
1537      __gen_offset(values->PointertoGSBindingTable, 5, 15);
1538}
1539
1540#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_HS_length      2
1541#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_HS_length_bias      2
1542#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_HS_header\
1543   .DWordLength                         =      0,  \
1544   ._3DCommandSubOpcode                 =     39,  \
1545   ._3DCommandOpcode                    =      0,  \
1546   .CommandSubType                      =      3,  \
1547   .CommandType                         =      3
1548
1549struct GFX7_3DSTATE_BINDING_TABLE_POINTERS_HS {
1550   uint32_t                             DWordLength;
1551   uint32_t                             _3DCommandSubOpcode;
1552   uint32_t                             _3DCommandOpcode;
1553   uint32_t                             CommandSubType;
1554   uint32_t                             CommandType;
1555   uint64_t                             PointertoHSBindingTable;
1556};
1557
1558static inline __attribute__((always_inline)) void
1559GFX7_3DSTATE_BINDING_TABLE_POINTERS_HS_pack(__attribute__((unused)) __gen_user_data *data,
1560                                            __attribute__((unused)) void * restrict dst,
1561                                            __attribute__((unused)) const struct GFX7_3DSTATE_BINDING_TABLE_POINTERS_HS * restrict values)
1562{
1563   uint32_t * restrict dw = (uint32_t * restrict) dst;
1564
1565   dw[0] =
1566      __gen_uint(values->DWordLength, 0, 7) |
1567      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1568      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1569      __gen_uint(values->CommandSubType, 27, 28) |
1570      __gen_uint(values->CommandType, 29, 31);
1571
1572   dw[1] =
1573      __gen_offset(values->PointertoHSBindingTable, 5, 15);
1574}
1575
1576#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_PS_length      2
1577#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_PS_length_bias      2
1578#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_PS_header\
1579   .DWordLength                         =      0,  \
1580   ._3DCommandSubOpcode                 =     42,  \
1581   ._3DCommandOpcode                    =      0,  \
1582   .CommandSubType                      =      3,  \
1583   .CommandType                         =      3
1584
1585struct GFX7_3DSTATE_BINDING_TABLE_POINTERS_PS {
1586   uint32_t                             DWordLength;
1587   uint32_t                             _3DCommandSubOpcode;
1588   uint32_t                             _3DCommandOpcode;
1589   uint32_t                             CommandSubType;
1590   uint32_t                             CommandType;
1591   uint64_t                             PointertoPSBindingTable;
1592};
1593
1594static inline __attribute__((always_inline)) void
1595GFX7_3DSTATE_BINDING_TABLE_POINTERS_PS_pack(__attribute__((unused)) __gen_user_data *data,
1596                                            __attribute__((unused)) void * restrict dst,
1597                                            __attribute__((unused)) const struct GFX7_3DSTATE_BINDING_TABLE_POINTERS_PS * restrict values)
1598{
1599   uint32_t * restrict dw = (uint32_t * restrict) dst;
1600
1601   dw[0] =
1602      __gen_uint(values->DWordLength, 0, 7) |
1603      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1604      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1605      __gen_uint(values->CommandSubType, 27, 28) |
1606      __gen_uint(values->CommandType, 29, 31);
1607
1608   dw[1] =
1609      __gen_offset(values->PointertoPSBindingTable, 5, 15);
1610}
1611
1612#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_VS_length      2
1613#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_VS_length_bias      2
1614#define GFX7_3DSTATE_BINDING_TABLE_POINTERS_VS_header\
1615   .DWordLength                         =      0,  \
1616   ._3DCommandSubOpcode                 =     38,  \
1617   ._3DCommandOpcode                    =      0,  \
1618   .CommandSubType                      =      3,  \
1619   .CommandType                         =      3
1620
1621struct GFX7_3DSTATE_BINDING_TABLE_POINTERS_VS {
1622   uint32_t                             DWordLength;
1623   uint32_t                             _3DCommandSubOpcode;
1624   uint32_t                             _3DCommandOpcode;
1625   uint32_t                             CommandSubType;
1626   uint32_t                             CommandType;
1627   uint64_t                             PointertoVSBindingTable;
1628};
1629
1630static inline __attribute__((always_inline)) void
1631GFX7_3DSTATE_BINDING_TABLE_POINTERS_VS_pack(__attribute__((unused)) __gen_user_data *data,
1632                                            __attribute__((unused)) void * restrict dst,
1633                                            __attribute__((unused)) const struct GFX7_3DSTATE_BINDING_TABLE_POINTERS_VS * restrict values)
1634{
1635   uint32_t * restrict dw = (uint32_t * restrict) dst;
1636
1637   dw[0] =
1638      __gen_uint(values->DWordLength, 0, 7) |
1639      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1640      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1641      __gen_uint(values->CommandSubType, 27, 28) |
1642      __gen_uint(values->CommandType, 29, 31);
1643
1644   dw[1] =
1645      __gen_offset(values->PointertoVSBindingTable, 5, 15);
1646}
1647
1648#define GFX7_3DSTATE_BLEND_STATE_POINTERS_length      2
1649#define GFX7_3DSTATE_BLEND_STATE_POINTERS_length_bias      2
1650#define GFX7_3DSTATE_BLEND_STATE_POINTERS_header\
1651   .DWordLength                         =      0,  \
1652   ._3DCommandSubOpcode                 =     36,  \
1653   ._3DCommandOpcode                    =      0,  \
1654   .CommandSubType                      =      3,  \
1655   .CommandType                         =      3
1656
1657struct GFX7_3DSTATE_BLEND_STATE_POINTERS {
1658   uint32_t                             DWordLength;
1659   uint32_t                             _3DCommandSubOpcode;
1660   uint32_t                             _3DCommandOpcode;
1661   uint32_t                             CommandSubType;
1662   uint32_t                             CommandType;
1663   uint64_t                             BlendStatePointer;
1664};
1665
1666static inline __attribute__((always_inline)) void
1667GFX7_3DSTATE_BLEND_STATE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
1668                                       __attribute__((unused)) void * restrict dst,
1669                                       __attribute__((unused)) const struct GFX7_3DSTATE_BLEND_STATE_POINTERS * restrict values)
1670{
1671   uint32_t * restrict dw = (uint32_t * restrict) dst;
1672
1673   dw[0] =
1674      __gen_uint(values->DWordLength, 0, 7) |
1675      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1676      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1677      __gen_uint(values->CommandSubType, 27, 28) |
1678      __gen_uint(values->CommandType, 29, 31);
1679
1680   dw[1] =
1681      __gen_mbo(0, 0) |
1682      __gen_offset(values->BlendStatePointer, 6, 31);
1683}
1684
1685#define GFX7_3DSTATE_CC_STATE_POINTERS_length      2
1686#define GFX7_3DSTATE_CC_STATE_POINTERS_length_bias      2
1687#define GFX7_3DSTATE_CC_STATE_POINTERS_header   \
1688   .DWordLength                         =      0,  \
1689   ._3DCommandSubOpcode                 =     14,  \
1690   ._3DCommandOpcode                    =      0,  \
1691   .CommandSubType                      =      3,  \
1692   .CommandType                         =      3
1693
1694struct GFX7_3DSTATE_CC_STATE_POINTERS {
1695   uint32_t                             DWordLength;
1696   uint32_t                             _3DCommandSubOpcode;
1697   uint32_t                             _3DCommandOpcode;
1698   uint32_t                             CommandSubType;
1699   uint32_t                             CommandType;
1700   uint64_t                             ColorCalcStatePointer;
1701};
1702
1703static inline __attribute__((always_inline)) void
1704GFX7_3DSTATE_CC_STATE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
1705                                    __attribute__((unused)) void * restrict dst,
1706                                    __attribute__((unused)) const struct GFX7_3DSTATE_CC_STATE_POINTERS * restrict values)
1707{
1708   uint32_t * restrict dw = (uint32_t * restrict) dst;
1709
1710   dw[0] =
1711      __gen_uint(values->DWordLength, 0, 7) |
1712      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1713      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1714      __gen_uint(values->CommandSubType, 27, 28) |
1715      __gen_uint(values->CommandType, 29, 31);
1716
1717   dw[1] =
1718      __gen_mbo(0, 0) |
1719      __gen_offset(values->ColorCalcStatePointer, 6, 31);
1720}
1721
1722#define GFX7_3DSTATE_CHROMA_KEY_length         4
1723#define GFX7_3DSTATE_CHROMA_KEY_length_bias      2
1724#define GFX7_3DSTATE_CHROMA_KEY_header          \
1725   .DWordLength                         =      2,  \
1726   ._3DCommandSubOpcode                 =      4,  \
1727   ._3DCommandOpcode                    =      1,  \
1728   .CommandSubType                      =      3,  \
1729   .CommandType                         =      3
1730
1731struct GFX7_3DSTATE_CHROMA_KEY {
1732   uint32_t                             DWordLength;
1733   uint32_t                             _3DCommandSubOpcode;
1734   uint32_t                             _3DCommandOpcode;
1735   uint32_t                             CommandSubType;
1736   uint32_t                             CommandType;
1737   uint32_t                             ChromaKeyTableIndex;
1738   uint32_t                             ChromaKeyLowValue;
1739   uint32_t                             ChromaKeyHighValue;
1740};
1741
1742static inline __attribute__((always_inline)) void
1743GFX7_3DSTATE_CHROMA_KEY_pack(__attribute__((unused)) __gen_user_data *data,
1744                             __attribute__((unused)) void * restrict dst,
1745                             __attribute__((unused)) const struct GFX7_3DSTATE_CHROMA_KEY * restrict values)
1746{
1747   uint32_t * restrict dw = (uint32_t * restrict) dst;
1748
1749   dw[0] =
1750      __gen_uint(values->DWordLength, 0, 7) |
1751      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1752      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1753      __gen_uint(values->CommandSubType, 27, 28) |
1754      __gen_uint(values->CommandType, 29, 31);
1755
1756   dw[1] =
1757      __gen_uint(values->ChromaKeyTableIndex, 30, 31);
1758
1759   dw[2] =
1760      __gen_uint(values->ChromaKeyLowValue, 0, 31);
1761
1762   dw[3] =
1763      __gen_uint(values->ChromaKeyHighValue, 0, 31);
1764}
1765
1766#define GFX7_3DSTATE_CLEAR_PARAMS_length       3
1767#define GFX7_3DSTATE_CLEAR_PARAMS_length_bias      2
1768#define GFX7_3DSTATE_CLEAR_PARAMS_header        \
1769   .DWordLength                         =      1,  \
1770   ._3DCommandSubOpcode                 =      4,  \
1771   ._3DCommandOpcode                    =      0,  \
1772   .CommandSubType                      =      3,  \
1773   .CommandType                         =      3
1774
1775struct GFX7_3DSTATE_CLEAR_PARAMS {
1776   uint32_t                             DWordLength;
1777   uint32_t                             _3DCommandSubOpcode;
1778   uint32_t                             _3DCommandOpcode;
1779   uint32_t                             CommandSubType;
1780   uint32_t                             CommandType;
1781   uint32_t                             DepthClearValue;
1782   bool                                 DepthClearValueValid;
1783};
1784
1785static inline __attribute__((always_inline)) void
1786GFX7_3DSTATE_CLEAR_PARAMS_pack(__attribute__((unused)) __gen_user_data *data,
1787                               __attribute__((unused)) void * restrict dst,
1788                               __attribute__((unused)) const struct GFX7_3DSTATE_CLEAR_PARAMS * restrict values)
1789{
1790   uint32_t * restrict dw = (uint32_t * restrict) dst;
1791
1792   dw[0] =
1793      __gen_uint(values->DWordLength, 0, 7) |
1794      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1795      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1796      __gen_uint(values->CommandSubType, 27, 28) |
1797      __gen_uint(values->CommandType, 29, 31);
1798
1799   dw[1] =
1800      __gen_uint(values->DepthClearValue, 0, 31);
1801
1802   dw[2] =
1803      __gen_uint(values->DepthClearValueValid, 0, 0);
1804}
1805
1806#define GFX7_3DSTATE_CLIP_length               4
1807#define GFX7_3DSTATE_CLIP_length_bias          2
1808#define GFX7_3DSTATE_CLIP_header                \
1809   .DWordLength                         =      2,  \
1810   ._3DCommandSubOpcode                 =     18,  \
1811   ._3DCommandOpcode                    =      0,  \
1812   .CommandSubType                      =      3,  \
1813   .CommandType                         =      3
1814
1815struct GFX7_3DSTATE_CLIP {
1816   uint32_t                             DWordLength;
1817   uint32_t                             _3DCommandSubOpcode;
1818   uint32_t                             _3DCommandOpcode;
1819   uint32_t                             CommandSubType;
1820   uint32_t                             CommandType;
1821   uint32_t                             UserClipDistanceCullTestEnableBitmask;
1822   bool                                 StatisticsEnable;
1823   uint32_t                             CullMode;
1824#define CULLMODE_BOTH                            0
1825#define CULLMODE_NONE                            1
1826#define CULLMODE_FRONT                           2
1827#define CULLMODE_BACK                            3
1828   bool                                 EarlyCullEnable;
1829   uint32_t                             VertexSubPixelPrecisionSelect;
1830   uint32_t                             FrontWinding;
1831   uint32_t                             TriangleFanProvokingVertexSelect;
1832#define Vertex0                                  0
1833#define Vertex1                                  1
1834#define Vertex2                                  2
1835   uint32_t                             LineStripListProvokingVertexSelect;
1836#define Vertex0                                  0
1837#define Vertex1                                  1
1838   uint32_t                             TriangleStripListProvokingVertexSelect;
1839#define Vertex0                                  0
1840#define Vertex1                                  1
1841#define Vertex2                                  2
1842   bool                                 NonPerspectiveBarycentricEnable;
1843   bool                                 PerspectiveDivideDisable;
1844   uint32_t                             ClipMode;
1845#define CLIPMODE_NORMAL                          0
1846#define CLIPMODE_REJECT_ALL                      3
1847#define CLIPMODE_ACCEPT_ALL                      4
1848   uint32_t                             UserClipDistanceClipTestEnableBitmask;
1849   bool                                 GuardbandClipTestEnable;
1850   bool                                 ViewportZClipTestEnable;
1851   bool                                 ViewportXYClipTestEnable;
1852   uint32_t                             APIMode;
1853#define APIMODE_OGL                              0
1854#define APIMODE_D3D                              1
1855   bool                                 ClipEnable;
1856   uint32_t                             MaximumVPIndex;
1857   bool                                 ForceZeroRTAIndexEnable;
1858   float                                MaximumPointWidth;
1859   float                                MinimumPointWidth;
1860};
1861
1862static inline __attribute__((always_inline)) void
1863GFX7_3DSTATE_CLIP_pack(__attribute__((unused)) __gen_user_data *data,
1864                       __attribute__((unused)) void * restrict dst,
1865                       __attribute__((unused)) const struct GFX7_3DSTATE_CLIP * restrict values)
1866{
1867   uint32_t * restrict dw = (uint32_t * restrict) dst;
1868
1869   dw[0] =
1870      __gen_uint(values->DWordLength, 0, 7) |
1871      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1872      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1873      __gen_uint(values->CommandSubType, 27, 28) |
1874      __gen_uint(values->CommandType, 29, 31);
1875
1876   dw[1] =
1877      __gen_uint(values->UserClipDistanceCullTestEnableBitmask, 0, 7) |
1878      __gen_uint(values->StatisticsEnable, 10, 10) |
1879      __gen_uint(values->CullMode, 16, 17) |
1880      __gen_uint(values->EarlyCullEnable, 18, 18) |
1881      __gen_uint(values->VertexSubPixelPrecisionSelect, 19, 19) |
1882      __gen_uint(values->FrontWinding, 20, 20);
1883
1884   dw[2] =
1885      __gen_uint(values->TriangleFanProvokingVertexSelect, 0, 1) |
1886      __gen_uint(values->LineStripListProvokingVertexSelect, 2, 3) |
1887      __gen_uint(values->TriangleStripListProvokingVertexSelect, 4, 5) |
1888      __gen_uint(values->NonPerspectiveBarycentricEnable, 8, 8) |
1889      __gen_uint(values->PerspectiveDivideDisable, 9, 9) |
1890      __gen_uint(values->ClipMode, 13, 15) |
1891      __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 16, 23) |
1892      __gen_uint(values->GuardbandClipTestEnable, 26, 26) |
1893      __gen_uint(values->ViewportZClipTestEnable, 27, 27) |
1894      __gen_uint(values->ViewportXYClipTestEnable, 28, 28) |
1895      __gen_uint(values->APIMode, 30, 30) |
1896      __gen_uint(values->ClipEnable, 31, 31);
1897
1898   dw[3] =
1899      __gen_uint(values->MaximumVPIndex, 0, 3) |
1900      __gen_uint(values->ForceZeroRTAIndexEnable, 5, 5) |
1901      __gen_ufixed(values->MaximumPointWidth, 6, 16, 3) |
1902      __gen_ufixed(values->MinimumPointWidth, 17, 27, 3);
1903}
1904
1905#define GFX7_3DSTATE_CONSTANT_DS_length        7
1906#define GFX7_3DSTATE_CONSTANT_DS_length_bias      2
1907#define GFX7_3DSTATE_CONSTANT_DS_header         \
1908   .DWordLength                         =      5,  \
1909   ._3DCommandSubOpcode                 =     26,  \
1910   ._3DCommandOpcode                    =      0,  \
1911   .CommandSubType                      =      3,  \
1912   .CommandType                         =      3
1913
1914struct GFX7_3DSTATE_CONSTANT_DS {
1915   uint32_t                             DWordLength;
1916   uint32_t                             _3DCommandSubOpcode;
1917   uint32_t                             _3DCommandOpcode;
1918   uint32_t                             CommandSubType;
1919   uint32_t                             CommandType;
1920   struct GFX7_3DSTATE_CONSTANT_BODY    ConstantBody;
1921};
1922
1923static inline __attribute__((always_inline)) void
1924GFX7_3DSTATE_CONSTANT_DS_pack(__attribute__((unused)) __gen_user_data *data,
1925                              __attribute__((unused)) void * restrict dst,
1926                              __attribute__((unused)) const struct GFX7_3DSTATE_CONSTANT_DS * restrict values)
1927{
1928   uint32_t * restrict dw = (uint32_t * restrict) dst;
1929
1930   dw[0] =
1931      __gen_uint(values->DWordLength, 0, 7) |
1932      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1933      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1934      __gen_uint(values->CommandSubType, 27, 28) |
1935      __gen_uint(values->CommandType, 29, 31);
1936
1937   GFX7_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
1938}
1939
1940#define GFX7_3DSTATE_CONSTANT_GS_length        7
1941#define GFX7_3DSTATE_CONSTANT_GS_length_bias      2
1942#define GFX7_3DSTATE_CONSTANT_GS_header         \
1943   .DWordLength                         =      5,  \
1944   ._3DCommandSubOpcode                 =     22,  \
1945   ._3DCommandOpcode                    =      0,  \
1946   .CommandSubType                      =      3,  \
1947   .CommandType                         =      3
1948
1949struct GFX7_3DSTATE_CONSTANT_GS {
1950   uint32_t                             DWordLength;
1951   uint32_t                             _3DCommandSubOpcode;
1952   uint32_t                             _3DCommandOpcode;
1953   uint32_t                             CommandSubType;
1954   uint32_t                             CommandType;
1955   struct GFX7_3DSTATE_CONSTANT_BODY    ConstantBody;
1956};
1957
1958static inline __attribute__((always_inline)) void
1959GFX7_3DSTATE_CONSTANT_GS_pack(__attribute__((unused)) __gen_user_data *data,
1960                              __attribute__((unused)) void * restrict dst,
1961                              __attribute__((unused)) const struct GFX7_3DSTATE_CONSTANT_GS * 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   GFX7_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
1973}
1974
1975#define GFX7_3DSTATE_CONSTANT_HS_length        7
1976#define GFX7_3DSTATE_CONSTANT_HS_length_bias      2
1977#define GFX7_3DSTATE_CONSTANT_HS_header         \
1978   .DWordLength                         =      5,  \
1979   ._3DCommandSubOpcode                 =     25,  \
1980   ._3DCommandOpcode                    =      0,  \
1981   .CommandSubType                      =      3,  \
1982   .CommandType                         =      3
1983
1984struct GFX7_3DSTATE_CONSTANT_HS {
1985   uint32_t                             DWordLength;
1986   uint32_t                             _3DCommandSubOpcode;
1987   uint32_t                             _3DCommandOpcode;
1988   uint32_t                             CommandSubType;
1989   uint32_t                             CommandType;
1990   struct GFX7_3DSTATE_CONSTANT_BODY    ConstantBody;
1991};
1992
1993static inline __attribute__((always_inline)) void
1994GFX7_3DSTATE_CONSTANT_HS_pack(__attribute__((unused)) __gen_user_data *data,
1995                              __attribute__((unused)) void * restrict dst,
1996                              __attribute__((unused)) const struct GFX7_3DSTATE_CONSTANT_HS * restrict values)
1997{
1998   uint32_t * restrict dw = (uint32_t * restrict) dst;
1999
2000   dw[0] =
2001      __gen_uint(values->DWordLength, 0, 7) |
2002      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2003      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2004      __gen_uint(values->CommandSubType, 27, 28) |
2005      __gen_uint(values->CommandType, 29, 31);
2006
2007   GFX7_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
2008}
2009
2010#define GFX7_3DSTATE_CONSTANT_PS_length        7
2011#define GFX7_3DSTATE_CONSTANT_PS_length_bias      2
2012#define GFX7_3DSTATE_CONSTANT_PS_header         \
2013   .DWordLength                         =      5,  \
2014   ._3DCommandSubOpcode                 =     23,  \
2015   ._3DCommandOpcode                    =      0,  \
2016   .CommandSubType                      =      3,  \
2017   .CommandType                         =      3
2018
2019struct GFX7_3DSTATE_CONSTANT_PS {
2020   uint32_t                             DWordLength;
2021   uint32_t                             _3DCommandSubOpcode;
2022   uint32_t                             _3DCommandOpcode;
2023   uint32_t                             CommandSubType;
2024   uint32_t                             CommandType;
2025   struct GFX7_3DSTATE_CONSTANT_BODY    ConstantBody;
2026};
2027
2028static inline __attribute__((always_inline)) void
2029GFX7_3DSTATE_CONSTANT_PS_pack(__attribute__((unused)) __gen_user_data *data,
2030                              __attribute__((unused)) void * restrict dst,
2031                              __attribute__((unused)) const struct GFX7_3DSTATE_CONSTANT_PS * restrict values)
2032{
2033   uint32_t * restrict dw = (uint32_t * restrict) dst;
2034
2035   dw[0] =
2036      __gen_uint(values->DWordLength, 0, 7) |
2037      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2038      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2039      __gen_uint(values->CommandSubType, 27, 28) |
2040      __gen_uint(values->CommandType, 29, 31);
2041
2042   GFX7_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
2043}
2044
2045#define GFX7_3DSTATE_CONSTANT_VS_length        7
2046#define GFX7_3DSTATE_CONSTANT_VS_length_bias      2
2047#define GFX7_3DSTATE_CONSTANT_VS_header         \
2048   .DWordLength                         =      5,  \
2049   ._3DCommandSubOpcode                 =     21,  \
2050   ._3DCommandOpcode                    =      0,  \
2051   .CommandSubType                      =      3,  \
2052   .CommandType                         =      3
2053
2054struct GFX7_3DSTATE_CONSTANT_VS {
2055   uint32_t                             DWordLength;
2056   uint32_t                             _3DCommandSubOpcode;
2057   uint32_t                             _3DCommandOpcode;
2058   uint32_t                             CommandSubType;
2059   uint32_t                             CommandType;
2060   struct GFX7_3DSTATE_CONSTANT_BODY    ConstantBody;
2061};
2062
2063static inline __attribute__((always_inline)) void
2064GFX7_3DSTATE_CONSTANT_VS_pack(__attribute__((unused)) __gen_user_data *data,
2065                              __attribute__((unused)) void * restrict dst,
2066                              __attribute__((unused)) const struct GFX7_3DSTATE_CONSTANT_VS * restrict values)
2067{
2068   uint32_t * restrict dw = (uint32_t * restrict) dst;
2069
2070   dw[0] =
2071      __gen_uint(values->DWordLength, 0, 7) |
2072      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2073      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2074      __gen_uint(values->CommandSubType, 27, 28) |
2075      __gen_uint(values->CommandType, 29, 31);
2076
2077   GFX7_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
2078}
2079
2080#define GFX7_3DSTATE_DEPTH_BUFFER_length       7
2081#define GFX7_3DSTATE_DEPTH_BUFFER_length_bias      2
2082#define GFX7_3DSTATE_DEPTH_BUFFER_header        \
2083   .DWordLength                         =      5,  \
2084   ._3DCommandSubOpcode                 =      5,  \
2085   ._3DCommandOpcode                    =      0,  \
2086   .CommandSubType                      =      3,  \
2087   .CommandType                         =      3
2088
2089struct GFX7_3DSTATE_DEPTH_BUFFER {
2090   uint32_t                             DWordLength;
2091   uint32_t                             _3DCommandSubOpcode;
2092   uint32_t                             _3DCommandOpcode;
2093   uint32_t                             CommandSubType;
2094   uint32_t                             CommandType;
2095   uint32_t                             SurfacePitch;
2096   uint32_t                             SurfaceFormat;
2097#define D32_FLOAT                                1
2098#define D24_UNORM_X8_UINT                        3
2099#define D16_UNORM                                5
2100   bool                                 HierarchicalDepthBufferEnable;
2101   bool                                 StencilWriteEnable;
2102   bool                                 DepthWriteEnable;
2103   uint32_t                             SurfaceType;
2104#define SURFTYPE_1D                              0
2105#define SURFTYPE_2D                              1
2106#define SURFTYPE_3D                              2
2107#define SURFTYPE_CUBE                            3
2108#define SURFTYPE_NULL                            7
2109   __gen_address_type                   SurfaceBaseAddress;
2110   uint32_t                             LOD;
2111   uint32_t                             Width;
2112   uint32_t                             Height;
2113   uint32_t                             MOCS;
2114   uint32_t                             MinimumArrayElement;
2115   uint32_t                             Depth;
2116#define SURFTYPE_CUBEmustbezero                  0
2117   int32_t                              DepthCoordinateOffsetX;
2118   int32_t                              DepthCoordinateOffsetY;
2119   uint32_t                             RenderTargetViewExtent;
2120};
2121
2122static inline __attribute__((always_inline)) void
2123GFX7_3DSTATE_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2124                               __attribute__((unused)) void * restrict dst,
2125                               __attribute__((unused)) const struct GFX7_3DSTATE_DEPTH_BUFFER * restrict values)
2126{
2127   uint32_t * restrict dw = (uint32_t * restrict) dst;
2128
2129   dw[0] =
2130      __gen_uint(values->DWordLength, 0, 7) |
2131      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2132      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2133      __gen_uint(values->CommandSubType, 27, 28) |
2134      __gen_uint(values->CommandType, 29, 31);
2135
2136   dw[1] =
2137      __gen_uint(values->SurfacePitch, 0, 17) |
2138      __gen_uint(values->SurfaceFormat, 18, 20) |
2139      __gen_uint(values->HierarchicalDepthBufferEnable, 22, 22) |
2140      __gen_uint(values->StencilWriteEnable, 27, 27) |
2141      __gen_uint(values->DepthWriteEnable, 28, 28) |
2142      __gen_uint(values->SurfaceType, 29, 31);
2143
2144   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
2145
2146   dw[3] =
2147      __gen_uint(values->LOD, 0, 3) |
2148      __gen_uint(values->Width, 4, 17) |
2149      __gen_uint(values->Height, 18, 31);
2150
2151   dw[4] =
2152      __gen_uint(values->MOCS, 0, 3) |
2153      __gen_uint(values->MinimumArrayElement, 10, 20) |
2154      __gen_uint(values->Depth, 21, 31);
2155
2156   dw[5] =
2157      __gen_sint(values->DepthCoordinateOffsetX, 0, 15) |
2158      __gen_sint(values->DepthCoordinateOffsetY, 16, 31);
2159
2160   dw[6] =
2161      __gen_uint(values->RenderTargetViewExtent, 21, 31);
2162}
2163
2164#define GFX7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS_length      2
2165#define GFX7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS_length_bias      2
2166#define GFX7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS_header\
2167   .DWordLength                         =      0,  \
2168   ._3DCommandSubOpcode                 =     37,  \
2169   ._3DCommandOpcode                    =      0,  \
2170   .CommandSubType                      =      3,  \
2171   .CommandType                         =      3
2172
2173struct GFX7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS {
2174   uint32_t                             DWordLength;
2175   uint32_t                             _3DCommandSubOpcode;
2176   uint32_t                             _3DCommandOpcode;
2177   uint32_t                             CommandSubType;
2178   uint32_t                             CommandType;
2179   uint64_t                             PointertoDEPTH_STENCIL_STATE;
2180};
2181
2182static inline __attribute__((always_inline)) void
2183GFX7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
2184                                               __attribute__((unused)) void * restrict dst,
2185                                               __attribute__((unused)) const struct GFX7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS * restrict values)
2186{
2187   uint32_t * restrict dw = (uint32_t * restrict) dst;
2188
2189   dw[0] =
2190      __gen_uint(values->DWordLength, 0, 7) |
2191      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2192      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2193      __gen_uint(values->CommandSubType, 27, 28) |
2194      __gen_uint(values->CommandType, 29, 31);
2195
2196   dw[1] =
2197      __gen_mbo(0, 0) |
2198      __gen_offset(values->PointertoDEPTH_STENCIL_STATE, 6, 31);
2199}
2200
2201#define GFX7_3DSTATE_DRAWING_RECTANGLE_length      4
2202#define GFX7_3DSTATE_DRAWING_RECTANGLE_length_bias      2
2203#define GFX7_3DSTATE_DRAWING_RECTANGLE_header   \
2204   .DWordLength                         =      2,  \
2205   ._3DCommandSubOpcode                 =      0,  \
2206   ._3DCommandOpcode                    =      1,  \
2207   .CommandSubType                      =      3,  \
2208   .CommandType                         =      3
2209
2210struct GFX7_3DSTATE_DRAWING_RECTANGLE {
2211   uint32_t                             DWordLength;
2212   uint32_t                             _3DCommandSubOpcode;
2213   uint32_t                             _3DCommandOpcode;
2214   uint32_t                             CommandSubType;
2215   uint32_t                             CommandType;
2216   uint32_t                             ClippedDrawingRectangleXMin;
2217   uint32_t                             ClippedDrawingRectangleYMin;
2218   uint32_t                             ClippedDrawingRectangleXMax;
2219   uint32_t                             ClippedDrawingRectangleYMax;
2220   int32_t                              DrawingRectangleOriginX;
2221   int32_t                              DrawingRectangleOriginY;
2222};
2223
2224static inline __attribute__((always_inline)) void
2225GFX7_3DSTATE_DRAWING_RECTANGLE_pack(__attribute__((unused)) __gen_user_data *data,
2226                                    __attribute__((unused)) void * restrict dst,
2227                                    __attribute__((unused)) const struct GFX7_3DSTATE_DRAWING_RECTANGLE * restrict values)
2228{
2229   uint32_t * restrict dw = (uint32_t * restrict) dst;
2230
2231   dw[0] =
2232      __gen_uint(values->DWordLength, 0, 7) |
2233      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2234      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2235      __gen_uint(values->CommandSubType, 27, 28) |
2236      __gen_uint(values->CommandType, 29, 31);
2237
2238   dw[1] =
2239      __gen_uint(values->ClippedDrawingRectangleXMin, 0, 15) |
2240      __gen_uint(values->ClippedDrawingRectangleYMin, 16, 31);
2241
2242   dw[2] =
2243      __gen_uint(values->ClippedDrawingRectangleXMax, 0, 15) |
2244      __gen_uint(values->ClippedDrawingRectangleYMax, 16, 31);
2245
2246   dw[3] =
2247      __gen_sint(values->DrawingRectangleOriginX, 0, 15) |
2248      __gen_sint(values->DrawingRectangleOriginY, 16, 31);
2249}
2250
2251#define GFX7_3DSTATE_DS_length                 6
2252#define GFX7_3DSTATE_DS_length_bias            2
2253#define GFX7_3DSTATE_DS_header                  \
2254   .DWordLength                         =      4,  \
2255   ._3DCommandSubOpcode                 =     29,  \
2256   ._3DCommandOpcode                    =      0,  \
2257   .CommandSubType                      =      3,  \
2258   .CommandType                         =      3
2259
2260struct GFX7_3DSTATE_DS {
2261   uint32_t                             DWordLength;
2262   uint32_t                             _3DCommandSubOpcode;
2263   uint32_t                             _3DCommandOpcode;
2264   uint32_t                             CommandSubType;
2265   uint32_t                             CommandType;
2266   uint64_t                             KernelStartPointer;
2267   bool                                 SoftwareExceptionEnable;
2268   bool                                 IllegalOpcodeExceptionEnable;
2269   uint32_t                             FloatingPointMode;
2270#define IEEE754                                  0
2271#define Alternate                                1
2272   uint32_t                             BindingTableEntryCount;
2273   uint32_t                             SamplerCount;
2274#define NoSamplers                               0
2275#define _14Samplers                              1
2276#define _58Samplers                              2
2277#define _912Samplers                             3
2278#define _1316Samplers                            4
2279   bool                                 VectorMaskEnable;
2280   uint32_t                             SingleDomainPointDispatch;
2281   uint32_t                             PerThreadScratchSpace;
2282   __gen_address_type                   ScratchSpaceBasePointer;
2283   uint32_t                             PatchURBEntryReadOffset;
2284   uint32_t                             PatchURBEntryReadLength;
2285   uint32_t                             DispatchGRFStartRegisterForURBData;
2286   bool                                 Enable;
2287   bool                                 DSCacheDisable;
2288   bool                                 ComputeWCoordinateEnable;
2289   bool                                 StatisticsEnable;
2290   uint32_t                             MaximumNumberofThreads;
2291};
2292
2293static inline __attribute__((always_inline)) void
2294GFX7_3DSTATE_DS_pack(__attribute__((unused)) __gen_user_data *data,
2295                     __attribute__((unused)) void * restrict dst,
2296                     __attribute__((unused)) const struct GFX7_3DSTATE_DS * restrict values)
2297{
2298   uint32_t * restrict dw = (uint32_t * restrict) dst;
2299
2300   dw[0] =
2301      __gen_uint(values->DWordLength, 0, 7) |
2302      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2303      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2304      __gen_uint(values->CommandSubType, 27, 28) |
2305      __gen_uint(values->CommandType, 29, 31);
2306
2307   dw[1] =
2308      __gen_offset(values->KernelStartPointer, 6, 31);
2309
2310   dw[2] =
2311      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
2312      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
2313      __gen_uint(values->FloatingPointMode, 16, 16) |
2314      __gen_uint(values->BindingTableEntryCount, 18, 25) |
2315      __gen_uint(values->SamplerCount, 27, 29) |
2316      __gen_uint(values->VectorMaskEnable, 30, 30) |
2317      __gen_uint(values->SingleDomainPointDispatch, 31, 31);
2318
2319   const uint32_t v3 =
2320      __gen_uint(values->PerThreadScratchSpace, 0, 3);
2321   dw[3] = __gen_address(data, &dw[3], values->ScratchSpaceBasePointer, v3, 10, 31);
2322
2323   dw[4] =
2324      __gen_uint(values->PatchURBEntryReadOffset, 4, 9) |
2325      __gen_uint(values->PatchURBEntryReadLength, 11, 17) |
2326      __gen_uint(values->DispatchGRFStartRegisterForURBData, 20, 24);
2327
2328   dw[5] =
2329      __gen_uint(values->Enable, 0, 0) |
2330      __gen_uint(values->DSCacheDisable, 1, 1) |
2331      __gen_uint(values->ComputeWCoordinateEnable, 2, 2) |
2332      __gen_uint(values->StatisticsEnable, 10, 10) |
2333      __gen_uint(values->MaximumNumberofThreads, 25, 31);
2334}
2335
2336#define GFX7_3DSTATE_GS_length                 7
2337#define GFX7_3DSTATE_GS_length_bias            2
2338#define GFX7_3DSTATE_GS_header                  \
2339   .DWordLength                         =      5,  \
2340   ._3DCommandSubOpcode                 =     17,  \
2341   ._3DCommandOpcode                    =      0,  \
2342   .CommandSubType                      =      3,  \
2343   .CommandType                         =      3
2344
2345struct GFX7_3DSTATE_GS {
2346   uint32_t                             DWordLength;
2347   uint32_t                             _3DCommandSubOpcode;
2348   uint32_t                             _3DCommandOpcode;
2349   uint32_t                             CommandSubType;
2350   uint32_t                             CommandType;
2351   uint64_t                             KernelStartPointer;
2352   bool                                 SoftwareExceptionEnable;
2353   bool                                 MaskStackExceptionEnable;
2354   bool                                 IllegalOpcodeExceptionEnable;
2355   uint32_t                             FloatingPointMode;
2356#define IEEE754                                  0
2357#define alternate                                1
2358   uint32_t                             ThreadPriority;
2359#define NormalPriority                           0
2360#define HighPriority                             1
2361   uint32_t                             BindingTableEntryCount;
2362   uint32_t                             SamplerCount;
2363#define NoSamplers                               0
2364#define _14Samplers                              1
2365#define _58Samplers                              2
2366#define _912Samplers                             3
2367#define _1316Samplers                            4
2368   bool                                 VectorMaskEnable;
2369   bool                                 SingleProgramFlow;
2370   uint32_t                             PerThreadScratchSpace;
2371   __gen_address_type                   ScratchSpaceBasePointer;
2372   uint32_t                             DispatchGRFStartRegisterForURBData;
2373   uint32_t                             VertexURBEntryReadOffset;
2374   bool                                 IncludeVertexHandles;
2375   uint32_t                             VertexURBEntryReadLength;
2376   enum GFX7_3D_Prim_Topo_Type          OutputTopology;
2377   uint32_t                             OutputVertexSize;
2378   bool                                 Enable;
2379   bool                                 DiscardAdjacency;
2380   uint32_t                             ReorderMode;
2381#define LEADING                                  0
2382#define TRAILING                                 1
2383   uint32_t                             Hint;
2384   bool                                 IncludePrimitiveID;
2385   uint32_t                             GSInvocationsIncrementValue;
2386   uint32_t                             StatisticsEnable;
2387   uint32_t                             DispatchMode;
2388#define DISPATCH_MODE_SINGLE                     0
2389#define DISPATCH_MODE_DUAL_INSTANCE              1
2390#define DISPATCH_MODE_DUAL_OBJECT                2
2391   uint32_t                             DefaultStreamID;
2392   uint32_t                             InstanceControl;
2393   uint32_t                             ControlDataHeaderSize;
2394   uint32_t                             ControlDataFormat;
2395#define GSCTL_CUT                                0
2396#define GSCTL_SID                                1
2397   uint32_t                             MaximumNumberofThreads;
2398   uint64_t                             SemaphoreHandle;
2399};
2400
2401static inline __attribute__((always_inline)) void
2402GFX7_3DSTATE_GS_pack(__attribute__((unused)) __gen_user_data *data,
2403                     __attribute__((unused)) void * restrict dst,
2404                     __attribute__((unused)) const struct GFX7_3DSTATE_GS * restrict values)
2405{
2406   uint32_t * restrict dw = (uint32_t * restrict) dst;
2407
2408   dw[0] =
2409      __gen_uint(values->DWordLength, 0, 7) |
2410      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2411      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2412      __gen_uint(values->CommandSubType, 27, 28) |
2413      __gen_uint(values->CommandType, 29, 31);
2414
2415   dw[1] =
2416      __gen_offset(values->KernelStartPointer, 6, 31);
2417
2418   dw[2] =
2419      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
2420      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
2421      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
2422      __gen_uint(values->FloatingPointMode, 16, 16) |
2423      __gen_uint(values->ThreadPriority, 17, 17) |
2424      __gen_uint(values->BindingTableEntryCount, 18, 25) |
2425      __gen_uint(values->SamplerCount, 27, 29) |
2426      __gen_uint(values->VectorMaskEnable, 30, 30) |
2427      __gen_uint(values->SingleProgramFlow, 31, 31);
2428
2429   const uint32_t v3 =
2430      __gen_uint(values->PerThreadScratchSpace, 0, 3);
2431   dw[3] = __gen_address(data, &dw[3], values->ScratchSpaceBasePointer, v3, 10, 31);
2432
2433   dw[4] =
2434      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
2435      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
2436      __gen_uint(values->IncludeVertexHandles, 10, 10) |
2437      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
2438      __gen_uint(values->OutputTopology, 17, 22) |
2439      __gen_uint(values->OutputVertexSize, 23, 28);
2440
2441   dw[5] =
2442      __gen_uint(values->Enable, 0, 0) |
2443      __gen_uint(values->DiscardAdjacency, 1, 1) |
2444      __gen_uint(values->ReorderMode, 2, 2) |
2445      __gen_uint(values->Hint, 3, 3) |
2446      __gen_uint(values->IncludePrimitiveID, 4, 4) |
2447      __gen_uint(values->GSInvocationsIncrementValue, 5, 9) |
2448      __gen_uint(values->StatisticsEnable, 10, 10) |
2449      __gen_uint(values->DispatchMode, 11, 12) |
2450      __gen_uint(values->DefaultStreamID, 13, 14) |
2451      __gen_uint(values->InstanceControl, 15, 19) |
2452      __gen_uint(values->ControlDataHeaderSize, 20, 23) |
2453      __gen_uint(values->ControlDataFormat, 24, 24) |
2454      __gen_uint(values->MaximumNumberofThreads, 25, 31);
2455
2456   dw[6] =
2457      __gen_offset(values->SemaphoreHandle, 0, 11);
2458}
2459
2460#define GFX7_3DSTATE_HIER_DEPTH_BUFFER_length      3
2461#define GFX7_3DSTATE_HIER_DEPTH_BUFFER_length_bias      2
2462#define GFX7_3DSTATE_HIER_DEPTH_BUFFER_header   \
2463   .DWordLength                         =      1,  \
2464   ._3DCommandSubOpcode                 =      7,  \
2465   ._3DCommandOpcode                    =      0,  \
2466   .CommandSubType                      =      3,  \
2467   .CommandType                         =      3
2468
2469struct GFX7_3DSTATE_HIER_DEPTH_BUFFER {
2470   uint32_t                             DWordLength;
2471   uint32_t                             _3DCommandSubOpcode;
2472   uint32_t                             _3DCommandOpcode;
2473   uint32_t                             CommandSubType;
2474   uint32_t                             CommandType;
2475   uint32_t                             SurfacePitch;
2476   uint32_t                             MOCS;
2477   __gen_address_type                   SurfaceBaseAddress;
2478};
2479
2480static inline __attribute__((always_inline)) void
2481GFX7_3DSTATE_HIER_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2482                                    __attribute__((unused)) void * restrict dst,
2483                                    __attribute__((unused)) const struct GFX7_3DSTATE_HIER_DEPTH_BUFFER * restrict values)
2484{
2485   uint32_t * restrict dw = (uint32_t * restrict) dst;
2486
2487   dw[0] =
2488      __gen_uint(values->DWordLength, 0, 7) |
2489      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2490      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2491      __gen_uint(values->CommandSubType, 27, 28) |
2492      __gen_uint(values->CommandType, 29, 31);
2493
2494   dw[1] =
2495      __gen_uint(values->SurfacePitch, 0, 16) |
2496      __gen_uint(values->MOCS, 25, 28);
2497
2498   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
2499}
2500
2501#define GFX7_3DSTATE_HS_length                 7
2502#define GFX7_3DSTATE_HS_length_bias            2
2503#define GFX7_3DSTATE_HS_header                  \
2504   .DWordLength                         =      5,  \
2505   ._3DCommandSubOpcode                 =     27,  \
2506   ._3DCommandOpcode                    =      0,  \
2507   .CommandSubType                      =      3,  \
2508   .CommandType                         =      3
2509
2510struct GFX7_3DSTATE_HS {
2511   uint32_t                             DWordLength;
2512   uint32_t                             _3DCommandSubOpcode;
2513   uint32_t                             _3DCommandOpcode;
2514   uint32_t                             CommandSubType;
2515   uint32_t                             CommandType;
2516   uint32_t                             MaximumNumberofThreads;
2517   bool                                 SoftwareExceptionEnable;
2518   bool                                 IllegalOpcodeExceptionEnable;
2519   uint32_t                             FloatingPointMode;
2520#define IEEE754                                  0
2521#define alternate                                1
2522   uint32_t                             BindingTableEntryCount;
2523   uint32_t                             SamplerCount;
2524#define NoSamplers                               0
2525#define _14Samplers                              1
2526#define _58Samplers                              2
2527#define _912Samplers                             3
2528#define _1316Samplers                            4
2529   uint32_t                             InstanceCount;
2530   bool                                 StatisticsEnable;
2531   bool                                 Enable;
2532   uint64_t                             KernelStartPointer;
2533   uint32_t                             PerThreadScratchSpace;
2534   __gen_address_type                   ScratchSpaceBasePointer;
2535   uint32_t                             VertexURBEntryReadOffset;
2536   uint32_t                             VertexURBEntryReadLength;
2537   uint32_t                             DispatchGRFStartRegisterForURBData;
2538   bool                                 IncludeVertexHandles;
2539   bool                                 VectorMaskEnable;
2540   bool                                 SingleProgramFlow;
2541   uint64_t                             SemaphoreHandle;
2542};
2543
2544static inline __attribute__((always_inline)) void
2545GFX7_3DSTATE_HS_pack(__attribute__((unused)) __gen_user_data *data,
2546                     __attribute__((unused)) void * restrict dst,
2547                     __attribute__((unused)) const struct GFX7_3DSTATE_HS * restrict values)
2548{
2549   uint32_t * restrict dw = (uint32_t * restrict) dst;
2550
2551   dw[0] =
2552      __gen_uint(values->DWordLength, 0, 7) |
2553      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2554      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2555      __gen_uint(values->CommandSubType, 27, 28) |
2556      __gen_uint(values->CommandType, 29, 31);
2557
2558   dw[1] =
2559      __gen_uint(values->MaximumNumberofThreads, 0, 6) |
2560      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
2561      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
2562      __gen_uint(values->FloatingPointMode, 16, 16) |
2563      __gen_uint(values->BindingTableEntryCount, 18, 25) |
2564      __gen_uint(values->SamplerCount, 27, 29);
2565
2566   dw[2] =
2567      __gen_uint(values->InstanceCount, 0, 3) |
2568      __gen_uint(values->StatisticsEnable, 29, 29) |
2569      __gen_uint(values->Enable, 31, 31);
2570
2571   dw[3] =
2572      __gen_offset(values->KernelStartPointer, 6, 31);
2573
2574   const uint32_t v4 =
2575      __gen_uint(values->PerThreadScratchSpace, 0, 3);
2576   dw[4] = __gen_address(data, &dw[4], values->ScratchSpaceBasePointer, v4, 10, 31);
2577
2578   dw[5] =
2579      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
2580      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
2581      __gen_uint(values->DispatchGRFStartRegisterForURBData, 19, 23) |
2582      __gen_uint(values->IncludeVertexHandles, 24, 24) |
2583      __gen_uint(values->VectorMaskEnable, 26, 26) |
2584      __gen_uint(values->SingleProgramFlow, 27, 27);
2585
2586   dw[6] =
2587      __gen_offset(values->SemaphoreHandle, 0, 11);
2588}
2589
2590#define GFX7_3DSTATE_INDEX_BUFFER_length       3
2591#define GFX7_3DSTATE_INDEX_BUFFER_length_bias      2
2592#define GFX7_3DSTATE_INDEX_BUFFER_header        \
2593   .DWordLength                         =      1,  \
2594   ._3DCommandSubOpcode                 =     10,  \
2595   ._3DCommandOpcode                    =      0,  \
2596   .CommandSubType                      =      3,  \
2597   .CommandType                         =      3
2598
2599struct GFX7_3DSTATE_INDEX_BUFFER {
2600   uint32_t                             DWordLength;
2601   uint32_t                             IndexFormat;
2602#define INDEX_BYTE                               0
2603#define INDEX_WORD                               1
2604#define INDEX_DWORD                              2
2605   bool                                 CutIndexEnable;
2606   uint32_t                             MOCS;
2607   uint32_t                             _3DCommandSubOpcode;
2608   uint32_t                             _3DCommandOpcode;
2609   uint32_t                             CommandSubType;
2610   uint32_t                             CommandType;
2611   __gen_address_type                   BufferStartingAddress;
2612   __gen_address_type                   BufferEndingAddress;
2613};
2614
2615static inline __attribute__((always_inline)) void
2616GFX7_3DSTATE_INDEX_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2617                               __attribute__((unused)) void * restrict dst,
2618                               __attribute__((unused)) const struct GFX7_3DSTATE_INDEX_BUFFER * restrict values)
2619{
2620   uint32_t * restrict dw = (uint32_t * restrict) dst;
2621
2622   dw[0] =
2623      __gen_uint(values->DWordLength, 0, 7) |
2624      __gen_uint(values->IndexFormat, 8, 9) |
2625      __gen_uint(values->CutIndexEnable, 10, 10) |
2626      __gen_uint(values->MOCS, 12, 15) |
2627      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2628      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2629      __gen_uint(values->CommandSubType, 27, 28) |
2630      __gen_uint(values->CommandType, 29, 31);
2631
2632   dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, 0, 0, 31);
2633
2634   dw[2] = __gen_address(data, &dw[2], values->BufferEndingAddress, 0, 0, 31);
2635}
2636
2637#define GFX7_3DSTATE_LINE_STIPPLE_length       3
2638#define GFX7_3DSTATE_LINE_STIPPLE_length_bias      2
2639#define GFX7_3DSTATE_LINE_STIPPLE_header        \
2640   .DWordLength                         =      1,  \
2641   ._3DCommandSubOpcode                 =      8,  \
2642   ._3DCommandOpcode                    =      1,  \
2643   .CommandSubType                      =      3,  \
2644   .CommandType                         =      3
2645
2646struct GFX7_3DSTATE_LINE_STIPPLE {
2647   uint32_t                             DWordLength;
2648   uint32_t                             _3DCommandSubOpcode;
2649   uint32_t                             _3DCommandOpcode;
2650   uint32_t                             CommandSubType;
2651   uint32_t                             CommandType;
2652   uint32_t                             LineStipplePattern;
2653   uint32_t                             CurrentStippleIndex;
2654   uint32_t                             CurrentRepeatCounter;
2655   bool                                 ModifyEnableCurrentRepeatCounterCurrentStippleIndex;
2656   uint32_t                             LineStippleRepeatCount;
2657   float                                LineStippleInverseRepeatCount;
2658};
2659
2660static inline __attribute__((always_inline)) void
2661GFX7_3DSTATE_LINE_STIPPLE_pack(__attribute__((unused)) __gen_user_data *data,
2662                               __attribute__((unused)) void * restrict dst,
2663                               __attribute__((unused)) const struct GFX7_3DSTATE_LINE_STIPPLE * restrict values)
2664{
2665   uint32_t * restrict dw = (uint32_t * restrict) dst;
2666
2667   dw[0] =
2668      __gen_uint(values->DWordLength, 0, 7) |
2669      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2670      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2671      __gen_uint(values->CommandSubType, 27, 28) |
2672      __gen_uint(values->CommandType, 29, 31);
2673
2674   dw[1] =
2675      __gen_uint(values->LineStipplePattern, 0, 15) |
2676      __gen_uint(values->CurrentStippleIndex, 16, 19) |
2677      __gen_uint(values->CurrentRepeatCounter, 21, 29) |
2678      __gen_uint(values->ModifyEnableCurrentRepeatCounterCurrentStippleIndex, 31, 31);
2679
2680   dw[2] =
2681      __gen_uint(values->LineStippleRepeatCount, 0, 8) |
2682      __gen_ufixed(values->LineStippleInverseRepeatCount, 15, 31, 16);
2683}
2684
2685#define GFX7_3DSTATE_MONOFILTER_SIZE_length      2
2686#define GFX7_3DSTATE_MONOFILTER_SIZE_length_bias      2
2687#define GFX7_3DSTATE_MONOFILTER_SIZE_header     \
2688   .DWordLength                         =      0,  \
2689   ._3DCommandSubOpcode                 =     17,  \
2690   ._3DCommandOpcode                    =      1,  \
2691   .CommandSubType                      =      3,  \
2692   .CommandType                         =      3
2693
2694struct GFX7_3DSTATE_MONOFILTER_SIZE {
2695   uint32_t                             DWordLength;
2696   uint32_t                             _3DCommandSubOpcode;
2697   uint32_t                             _3DCommandOpcode;
2698   uint32_t                             CommandSubType;
2699   uint32_t                             CommandType;
2700   uint32_t                             MonochromeFilterHeight;
2701   uint32_t                             MonochromeFilterWidth;
2702};
2703
2704static inline __attribute__((always_inline)) void
2705GFX7_3DSTATE_MONOFILTER_SIZE_pack(__attribute__((unused)) __gen_user_data *data,
2706                                  __attribute__((unused)) void * restrict dst,
2707                                  __attribute__((unused)) const struct GFX7_3DSTATE_MONOFILTER_SIZE * restrict values)
2708{
2709   uint32_t * restrict dw = (uint32_t * restrict) dst;
2710
2711   dw[0] =
2712      __gen_uint(values->DWordLength, 0, 7) |
2713      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2714      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2715      __gen_uint(values->CommandSubType, 27, 28) |
2716      __gen_uint(values->CommandType, 29, 31);
2717
2718   dw[1] =
2719      __gen_uint(values->MonochromeFilterHeight, 0, 2) |
2720      __gen_uint(values->MonochromeFilterWidth, 3, 5);
2721}
2722
2723#define GFX7_3DSTATE_MULTISAMPLE_length        4
2724#define GFX7_3DSTATE_MULTISAMPLE_length_bias      2
2725#define GFX7_3DSTATE_MULTISAMPLE_header         \
2726   .DWordLength                         =      2,  \
2727   ._3DCommandSubOpcode                 =     13,  \
2728   ._3DCommandOpcode                    =      1,  \
2729   .CommandSubType                      =      3,  \
2730   .CommandType                         =      3
2731
2732struct GFX7_3DSTATE_MULTISAMPLE {
2733   uint32_t                             DWordLength;
2734   uint32_t                             _3DCommandSubOpcode;
2735   uint32_t                             _3DCommandOpcode;
2736   uint32_t                             CommandSubType;
2737   uint32_t                             CommandType;
2738   uint32_t                             NumberofMultisamples;
2739#define NUMSAMPLES_1                             0
2740#define NUMSAMPLES_4                             2
2741#define NUMSAMPLES_8                             3
2742   uint32_t                             PixelLocation;
2743#define CENTER                                   0
2744#define UL_CORNER                                1
2745   float                                Sample0YOffset;
2746   float                                Sample0XOffset;
2747   float                                Sample1YOffset;
2748   float                                Sample1XOffset;
2749   float                                Sample2YOffset;
2750   float                                Sample2XOffset;
2751   float                                Sample3YOffset;
2752   float                                Sample3XOffset;
2753   float                                Sample4YOffset;
2754   float                                Sample4XOffset;
2755   float                                Sample5YOffset;
2756   float                                Sample5XOffset;
2757   float                                Sample6YOffset;
2758   float                                Sample6XOffset;
2759   float                                Sample7YOffset;
2760   float                                Sample7XOffset;
2761};
2762
2763static inline __attribute__((always_inline)) void
2764GFX7_3DSTATE_MULTISAMPLE_pack(__attribute__((unused)) __gen_user_data *data,
2765                              __attribute__((unused)) void * restrict dst,
2766                              __attribute__((unused)) const struct GFX7_3DSTATE_MULTISAMPLE * restrict values)
2767{
2768   uint32_t * restrict dw = (uint32_t * restrict) dst;
2769
2770   dw[0] =
2771      __gen_uint(values->DWordLength, 0, 7) |
2772      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2773      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2774      __gen_uint(values->CommandSubType, 27, 28) |
2775      __gen_uint(values->CommandType, 29, 31);
2776
2777   dw[1] =
2778      __gen_uint(values->NumberofMultisamples, 1, 3) |
2779      __gen_uint(values->PixelLocation, 4, 4);
2780
2781   dw[2] =
2782      __gen_ufixed(values->Sample0YOffset, 0, 3, 4) |
2783      __gen_ufixed(values->Sample0XOffset, 4, 7, 4) |
2784      __gen_ufixed(values->Sample1YOffset, 8, 11, 4) |
2785      __gen_ufixed(values->Sample1XOffset, 12, 15, 4) |
2786      __gen_ufixed(values->Sample2YOffset, 16, 19, 4) |
2787      __gen_ufixed(values->Sample2XOffset, 20, 23, 4) |
2788      __gen_ufixed(values->Sample3YOffset, 24, 27, 4) |
2789      __gen_ufixed(values->Sample3XOffset, 28, 31, 4);
2790
2791   dw[3] =
2792      __gen_ufixed(values->Sample4YOffset, 0, 3, 4) |
2793      __gen_ufixed(values->Sample4XOffset, 4, 7, 4) |
2794      __gen_ufixed(values->Sample5YOffset, 8, 11, 4) |
2795      __gen_ufixed(values->Sample5XOffset, 12, 15, 4) |
2796      __gen_ufixed(values->Sample6YOffset, 16, 19, 4) |
2797      __gen_ufixed(values->Sample6XOffset, 20, 23, 4) |
2798      __gen_ufixed(values->Sample7YOffset, 24, 27, 4) |
2799      __gen_ufixed(values->Sample7XOffset, 28, 31, 4);
2800}
2801
2802#define GFX7_3DSTATE_POLY_STIPPLE_OFFSET_length      2
2803#define GFX7_3DSTATE_POLY_STIPPLE_OFFSET_length_bias      2
2804#define GFX7_3DSTATE_POLY_STIPPLE_OFFSET_header \
2805   .DWordLength                         =      0,  \
2806   ._3DCommandSubOpcode                 =      6,  \
2807   ._3DCommandOpcode                    =      1,  \
2808   .CommandSubType                      =      3,  \
2809   .CommandType                         =      3
2810
2811struct GFX7_3DSTATE_POLY_STIPPLE_OFFSET {
2812   uint32_t                             DWordLength;
2813   uint32_t                             _3DCommandSubOpcode;
2814   uint32_t                             _3DCommandOpcode;
2815   uint32_t                             CommandSubType;
2816   uint32_t                             CommandType;
2817   uint32_t                             PolygonStippleYOffset;
2818   uint32_t                             PolygonStippleXOffset;
2819};
2820
2821static inline __attribute__((always_inline)) void
2822GFX7_3DSTATE_POLY_STIPPLE_OFFSET_pack(__attribute__((unused)) __gen_user_data *data,
2823                                      __attribute__((unused)) void * restrict dst,
2824                                      __attribute__((unused)) const struct GFX7_3DSTATE_POLY_STIPPLE_OFFSET * restrict values)
2825{
2826   uint32_t * restrict dw = (uint32_t * restrict) dst;
2827
2828   dw[0] =
2829      __gen_uint(values->DWordLength, 0, 7) |
2830      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2831      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2832      __gen_uint(values->CommandSubType, 27, 28) |
2833      __gen_uint(values->CommandType, 29, 31);
2834
2835   dw[1] =
2836      __gen_uint(values->PolygonStippleYOffset, 0, 4) |
2837      __gen_uint(values->PolygonStippleXOffset, 8, 12);
2838}
2839
2840#define GFX7_3DSTATE_POLY_STIPPLE_PATTERN_length     33
2841#define GFX7_3DSTATE_POLY_STIPPLE_PATTERN_length_bias      2
2842#define GFX7_3DSTATE_POLY_STIPPLE_PATTERN_header\
2843   .DWordLength                         =     31,  \
2844   ._3DCommandSubOpcode                 =      7,  \
2845   ._3DCommandOpcode                    =      1,  \
2846   .CommandSubType                      =      3,  \
2847   .CommandType                         =      3
2848
2849struct GFX7_3DSTATE_POLY_STIPPLE_PATTERN {
2850   uint32_t                             DWordLength;
2851   uint32_t                             _3DCommandSubOpcode;
2852   uint32_t                             _3DCommandOpcode;
2853   uint32_t                             CommandSubType;
2854   uint32_t                             CommandType;
2855   uint32_t                             PatternRow[32];
2856};
2857
2858static inline __attribute__((always_inline)) void
2859GFX7_3DSTATE_POLY_STIPPLE_PATTERN_pack(__attribute__((unused)) __gen_user_data *data,
2860                                       __attribute__((unused)) void * restrict dst,
2861                                       __attribute__((unused)) const struct GFX7_3DSTATE_POLY_STIPPLE_PATTERN * restrict values)
2862{
2863   uint32_t * restrict dw = (uint32_t * restrict) dst;
2864
2865   dw[0] =
2866      __gen_uint(values->DWordLength, 0, 7) |
2867      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2868      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2869      __gen_uint(values->CommandSubType, 27, 28) |
2870      __gen_uint(values->CommandType, 29, 31);
2871
2872   dw[1] =
2873      __gen_uint(values->PatternRow[0], 0, 31);
2874
2875   dw[2] =
2876      __gen_uint(values->PatternRow[1], 0, 31);
2877
2878   dw[3] =
2879      __gen_uint(values->PatternRow[2], 0, 31);
2880
2881   dw[4] =
2882      __gen_uint(values->PatternRow[3], 0, 31);
2883
2884   dw[5] =
2885      __gen_uint(values->PatternRow[4], 0, 31);
2886
2887   dw[6] =
2888      __gen_uint(values->PatternRow[5], 0, 31);
2889
2890   dw[7] =
2891      __gen_uint(values->PatternRow[6], 0, 31);
2892
2893   dw[8] =
2894      __gen_uint(values->PatternRow[7], 0, 31);
2895
2896   dw[9] =
2897      __gen_uint(values->PatternRow[8], 0, 31);
2898
2899   dw[10] =
2900      __gen_uint(values->PatternRow[9], 0, 31);
2901
2902   dw[11] =
2903      __gen_uint(values->PatternRow[10], 0, 31);
2904
2905   dw[12] =
2906      __gen_uint(values->PatternRow[11], 0, 31);
2907
2908   dw[13] =
2909      __gen_uint(values->PatternRow[12], 0, 31);
2910
2911   dw[14] =
2912      __gen_uint(values->PatternRow[13], 0, 31);
2913
2914   dw[15] =
2915      __gen_uint(values->PatternRow[14], 0, 31);
2916
2917   dw[16] =
2918      __gen_uint(values->PatternRow[15], 0, 31);
2919
2920   dw[17] =
2921      __gen_uint(values->PatternRow[16], 0, 31);
2922
2923   dw[18] =
2924      __gen_uint(values->PatternRow[17], 0, 31);
2925
2926   dw[19] =
2927      __gen_uint(values->PatternRow[18], 0, 31);
2928
2929   dw[20] =
2930      __gen_uint(values->PatternRow[19], 0, 31);
2931
2932   dw[21] =
2933      __gen_uint(values->PatternRow[20], 0, 31);
2934
2935   dw[22] =
2936      __gen_uint(values->PatternRow[21], 0, 31);
2937
2938   dw[23] =
2939      __gen_uint(values->PatternRow[22], 0, 31);
2940
2941   dw[24] =
2942      __gen_uint(values->PatternRow[23], 0, 31);
2943
2944   dw[25] =
2945      __gen_uint(values->PatternRow[24], 0, 31);
2946
2947   dw[26] =
2948      __gen_uint(values->PatternRow[25], 0, 31);
2949
2950   dw[27] =
2951      __gen_uint(values->PatternRow[26], 0, 31);
2952
2953   dw[28] =
2954      __gen_uint(values->PatternRow[27], 0, 31);
2955
2956   dw[29] =
2957      __gen_uint(values->PatternRow[28], 0, 31);
2958
2959   dw[30] =
2960      __gen_uint(values->PatternRow[29], 0, 31);
2961
2962   dw[31] =
2963      __gen_uint(values->PatternRow[30], 0, 31);
2964
2965   dw[32] =
2966      __gen_uint(values->PatternRow[31], 0, 31);
2967}
2968
2969#define GFX7_3DSTATE_PS_length                 8
2970#define GFX7_3DSTATE_PS_length_bias            2
2971#define GFX7_3DSTATE_PS_header                  \
2972   .DWordLength                         =      6,  \
2973   ._3DCommandSubOpcode                 =     32,  \
2974   ._3DCommandOpcode                    =      0,  \
2975   .CommandSubType                      =      3,  \
2976   .CommandType                         =      3
2977
2978struct GFX7_3DSTATE_PS {
2979   uint32_t                             DWordLength;
2980   uint32_t                             _3DCommandSubOpcode;
2981   uint32_t                             _3DCommandOpcode;
2982   uint32_t                             CommandSubType;
2983   uint32_t                             CommandType;
2984   uint64_t                             KernelStartPointer0;
2985   bool                                 SoftwareExceptionEnable;
2986   bool                                 MaskStackExceptionEnable;
2987   bool                                 IllegalOpcodeExceptionEnable;
2988   uint32_t                             RoundingMode;
2989#define RTNE                                     0
2990#define RU                                       1
2991#define RD                                       2
2992#define RTZ                                      3
2993   uint32_t                             FloatingPointMode;
2994#define IEEE745                                  0
2995#define Alt                                      1
2996   uint32_t                             BindingTableEntryCount;
2997   uint32_t                             DenormalMode;
2998#define FTZ                                      0
2999#define RET                                      1
3000   uint32_t                             SamplerCount;
3001   bool                                 VectorMaskEnable;
3002   bool                                 SingleProgramFlow;
3003   uint32_t                             PerThreadScratchSpace;
3004   __gen_address_type                   ScratchSpaceBasePointer;
3005   bool                                 _8PixelDispatchEnable;
3006   bool                                 _16PixelDispatchEnable;
3007   bool                                 _32PixelDispatchEnable;
3008   uint32_t                             PositionXYOffsetSelect;
3009#define POSOFFSET_NONE                           0
3010#define POSOFFSET_CENTROID                       2
3011#define POSOFFSET_SAMPLE                         3
3012   bool                                 RenderTargetResolveEnable;
3013   bool                                 DualSourceBlendEnable;
3014   bool                                 RenderTargetFastClearEnable;
3015   bool                                 oMaskPresenttoRenderTarget;
3016   bool                                 AttributeEnable;
3017   bool                                 PushConstantEnable;
3018   uint32_t                             MaximumNumberofThreads;
3019   uint32_t                             DispatchGRFStartRegisterForConstantSetupData2;
3020   uint32_t                             DispatchGRFStartRegisterForConstantSetupData1;
3021   uint32_t                             DispatchGRFStartRegisterForConstantSetupData0;
3022   uint64_t                             KernelStartPointer1;
3023   uint64_t                             KernelStartPointer2;
3024};
3025
3026static inline __attribute__((always_inline)) void
3027GFX7_3DSTATE_PS_pack(__attribute__((unused)) __gen_user_data *data,
3028                     __attribute__((unused)) void * restrict dst,
3029                     __attribute__((unused)) const struct GFX7_3DSTATE_PS * restrict values)
3030{
3031   uint32_t * restrict dw = (uint32_t * restrict) dst;
3032
3033   dw[0] =
3034      __gen_uint(values->DWordLength, 0, 7) |
3035      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3036      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3037      __gen_uint(values->CommandSubType, 27, 28) |
3038      __gen_uint(values->CommandType, 29, 31);
3039
3040   dw[1] =
3041      __gen_offset(values->KernelStartPointer0, 6, 31);
3042
3043   dw[2] =
3044      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
3045      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
3046      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
3047      __gen_uint(values->RoundingMode, 14, 15) |
3048      __gen_uint(values->FloatingPointMode, 16, 16) |
3049      __gen_uint(values->BindingTableEntryCount, 18, 25) |
3050      __gen_uint(values->DenormalMode, 26, 26) |
3051      __gen_uint(values->SamplerCount, 27, 29) |
3052      __gen_uint(values->VectorMaskEnable, 30, 30) |
3053      __gen_uint(values->SingleProgramFlow, 31, 31);
3054
3055   const uint32_t v3 =
3056      __gen_uint(values->PerThreadScratchSpace, 0, 3);
3057   dw[3] = __gen_address(data, &dw[3], values->ScratchSpaceBasePointer, v3, 10, 31);
3058
3059   dw[4] =
3060      __gen_uint(values->_8PixelDispatchEnable, 0, 0) |
3061      __gen_uint(values->_16PixelDispatchEnable, 1, 1) |
3062      __gen_uint(values->_32PixelDispatchEnable, 2, 2) |
3063      __gen_uint(values->PositionXYOffsetSelect, 3, 4) |
3064      __gen_uint(values->RenderTargetResolveEnable, 6, 6) |
3065      __gen_uint(values->DualSourceBlendEnable, 7, 7) |
3066      __gen_uint(values->RenderTargetFastClearEnable, 8, 8) |
3067      __gen_uint(values->oMaskPresenttoRenderTarget, 9, 9) |
3068      __gen_uint(values->AttributeEnable, 10, 10) |
3069      __gen_uint(values->PushConstantEnable, 11, 11) |
3070      __gen_uint(values->MaximumNumberofThreads, 24, 31);
3071
3072   dw[5] =
3073      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData2, 0, 6) |
3074      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData1, 8, 14) |
3075      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData0, 16, 22);
3076
3077   dw[6] =
3078      __gen_offset(values->KernelStartPointer1, 6, 31);
3079
3080   dw[7] =
3081      __gen_offset(values->KernelStartPointer2, 6, 31);
3082}
3083
3084#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_DS_length      2
3085#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_DS_length_bias      2
3086#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_DS_header\
3087   .DWordLength                         =      0,  \
3088   ._3DCommandSubOpcode                 =     20,  \
3089   ._3DCommandOpcode                    =      1,  \
3090   .CommandSubType                      =      3,  \
3091   .CommandType                         =      3
3092
3093struct GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_DS {
3094   uint32_t                             DWordLength;
3095   uint32_t                             _3DCommandSubOpcode;
3096   uint32_t                             _3DCommandOpcode;
3097   uint32_t                             CommandSubType;
3098   uint32_t                             CommandType;
3099   uint32_t                             ConstantBufferSize;
3100#define _0KB                                     0
3101   uint32_t                             ConstantBufferOffset;
3102#define _0KB                                     0
3103};
3104
3105static inline __attribute__((always_inline)) void
3106GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_DS_pack(__attribute__((unused)) __gen_user_data *data,
3107                                         __attribute__((unused)) void * restrict dst,
3108                                         __attribute__((unused)) const struct GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_DS * restrict values)
3109{
3110   uint32_t * restrict dw = (uint32_t * restrict) dst;
3111
3112   dw[0] =
3113      __gen_uint(values->DWordLength, 0, 7) |
3114      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3115      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3116      __gen_uint(values->CommandSubType, 27, 28) |
3117      __gen_uint(values->CommandType, 29, 31);
3118
3119   dw[1] =
3120      __gen_uint(values->ConstantBufferSize, 0, 4) |
3121      __gen_uint(values->ConstantBufferOffset, 16, 19);
3122}
3123
3124#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_GS_length      2
3125#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_GS_length_bias      2
3126#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_GS_header\
3127   .DWordLength                         =      0,  \
3128   ._3DCommandSubOpcode                 =     21,  \
3129   ._3DCommandOpcode                    =      1,  \
3130   .CommandSubType                      =      3,  \
3131   .CommandType                         =      3
3132
3133struct GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_GS {
3134   uint32_t                             DWordLength;
3135   uint32_t                             _3DCommandSubOpcode;
3136   uint32_t                             _3DCommandOpcode;
3137   uint32_t                             CommandSubType;
3138   uint32_t                             CommandType;
3139   uint32_t                             ConstantBufferSize;
3140#define _0KB                                     0
3141   uint32_t                             ConstantBufferOffset;
3142#define _0KB                                     0
3143};
3144
3145static inline __attribute__((always_inline)) void
3146GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_GS_pack(__attribute__((unused)) __gen_user_data *data,
3147                                         __attribute__((unused)) void * restrict dst,
3148                                         __attribute__((unused)) const struct GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_GS * restrict values)
3149{
3150   uint32_t * restrict dw = (uint32_t * restrict) dst;
3151
3152   dw[0] =
3153      __gen_uint(values->DWordLength, 0, 7) |
3154      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3155      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3156      __gen_uint(values->CommandSubType, 27, 28) |
3157      __gen_uint(values->CommandType, 29, 31);
3158
3159   dw[1] =
3160      __gen_uint(values->ConstantBufferSize, 0, 4) |
3161      __gen_uint(values->ConstantBufferOffset, 16, 19);
3162}
3163
3164#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_HS_length      2
3165#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_HS_length_bias      2
3166#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_HS_header\
3167   .DWordLength                         =      0,  \
3168   ._3DCommandSubOpcode                 =     19,  \
3169   ._3DCommandOpcode                    =      1,  \
3170   .CommandSubType                      =      3,  \
3171   .CommandType                         =      3
3172
3173struct GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_HS {
3174   uint32_t                             DWordLength;
3175   uint32_t                             _3DCommandSubOpcode;
3176   uint32_t                             _3DCommandOpcode;
3177   uint32_t                             CommandSubType;
3178   uint32_t                             CommandType;
3179   uint32_t                             ConstantBufferSize;
3180#define _0KB                                     0
3181   uint32_t                             ConstantBufferOffset;
3182#define _0KB                                     0
3183};
3184
3185static inline __attribute__((always_inline)) void
3186GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_HS_pack(__attribute__((unused)) __gen_user_data *data,
3187                                         __attribute__((unused)) void * restrict dst,
3188                                         __attribute__((unused)) const struct GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_HS * restrict values)
3189{
3190   uint32_t * restrict dw = (uint32_t * restrict) dst;
3191
3192   dw[0] =
3193      __gen_uint(values->DWordLength, 0, 7) |
3194      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3195      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3196      __gen_uint(values->CommandSubType, 27, 28) |
3197      __gen_uint(values->CommandType, 29, 31);
3198
3199   dw[1] =
3200      __gen_uint(values->ConstantBufferSize, 0, 4) |
3201      __gen_uint(values->ConstantBufferOffset, 16, 19);
3202}
3203
3204#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_PS_length      2
3205#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_PS_length_bias      2
3206#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_PS_header\
3207   .DWordLength                         =      0,  \
3208   ._3DCommandSubOpcode                 =     22,  \
3209   ._3DCommandOpcode                    =      1,  \
3210   .CommandSubType                      =      3,  \
3211   .CommandType                         =      3
3212
3213struct GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_PS {
3214   uint32_t                             DWordLength;
3215   uint32_t                             _3DCommandSubOpcode;
3216   uint32_t                             _3DCommandOpcode;
3217   uint32_t                             CommandSubType;
3218   uint32_t                             CommandType;
3219   uint32_t                             ConstantBufferSize;
3220#define _0KB                                     0
3221   uint32_t                             ConstantBufferOffset;
3222#define _0KB                                     0
3223};
3224
3225static inline __attribute__((always_inline)) void
3226GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_PS_pack(__attribute__((unused)) __gen_user_data *data,
3227                                         __attribute__((unused)) void * restrict dst,
3228                                         __attribute__((unused)) const struct GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_PS * restrict values)
3229{
3230   uint32_t * restrict dw = (uint32_t * restrict) dst;
3231
3232   dw[0] =
3233      __gen_uint(values->DWordLength, 0, 7) |
3234      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3235      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3236      __gen_uint(values->CommandSubType, 27, 28) |
3237      __gen_uint(values->CommandType, 29, 31);
3238
3239   dw[1] =
3240      __gen_uint(values->ConstantBufferSize, 0, 4) |
3241      __gen_uint(values->ConstantBufferOffset, 16, 19);
3242}
3243
3244#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_VS_length      2
3245#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_VS_length_bias      2
3246#define GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_VS_header\
3247   .DWordLength                         =      0,  \
3248   ._3DCommandSubOpcode                 =     18,  \
3249   ._3DCommandOpcode                    =      1,  \
3250   .CommandSubType                      =      3,  \
3251   .CommandType                         =      3
3252
3253struct GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_VS {
3254   uint32_t                             DWordLength;
3255   uint32_t                             _3DCommandSubOpcode;
3256   uint32_t                             _3DCommandOpcode;
3257   uint32_t                             CommandSubType;
3258   uint32_t                             CommandType;
3259   uint32_t                             ConstantBufferSize;
3260#define _0KB                                     0
3261   uint32_t                             ConstantBufferOffset;
3262#define _0KB                                     0
3263};
3264
3265static inline __attribute__((always_inline)) void
3266GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_VS_pack(__attribute__((unused)) __gen_user_data *data,
3267                                         __attribute__((unused)) void * restrict dst,
3268                                         __attribute__((unused)) const struct GFX7_3DSTATE_PUSH_CONSTANT_ALLOC_VS * restrict values)
3269{
3270   uint32_t * restrict dw = (uint32_t * restrict) dst;
3271
3272   dw[0] =
3273      __gen_uint(values->DWordLength, 0, 7) |
3274      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3275      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3276      __gen_uint(values->CommandSubType, 27, 28) |
3277      __gen_uint(values->CommandType, 29, 31);
3278
3279   dw[1] =
3280      __gen_uint(values->ConstantBufferSize, 0, 4) |
3281      __gen_uint(values->ConstantBufferOffset, 16, 19);
3282}
3283
3284#define GFX7_3DSTATE_SAMPLER_PALETTE_LOAD0_length_bias      2
3285#define GFX7_3DSTATE_SAMPLER_PALETTE_LOAD0_header\
3286   ._3DCommandSubOpcode                 =      2,  \
3287   ._3DCommandOpcode                    =      1,  \
3288   .CommandSubType                      =      3,  \
3289   .CommandType                         =      3
3290
3291struct GFX7_3DSTATE_SAMPLER_PALETTE_LOAD0 {
3292   uint32_t                             DWordLength;
3293   uint32_t                             _3DCommandSubOpcode;
3294   uint32_t                             _3DCommandOpcode;
3295   uint32_t                             CommandSubType;
3296   uint32_t                             CommandType;
3297   /* variable length fields follow */
3298};
3299
3300static inline __attribute__((always_inline)) void
3301GFX7_3DSTATE_SAMPLER_PALETTE_LOAD0_pack(__attribute__((unused)) __gen_user_data *data,
3302                                        __attribute__((unused)) void * restrict dst,
3303                                        __attribute__((unused)) const struct GFX7_3DSTATE_SAMPLER_PALETTE_LOAD0 * restrict values)
3304{
3305   uint32_t * restrict dw = (uint32_t * restrict) dst;
3306
3307   dw[0] =
3308      __gen_uint(values->DWordLength, 0, 7) |
3309      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3310      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3311      __gen_uint(values->CommandSubType, 27, 28) |
3312      __gen_uint(values->CommandType, 29, 31);
3313}
3314
3315#define GFX7_3DSTATE_SAMPLER_PALETTE_LOAD1_length_bias      2
3316#define GFX7_3DSTATE_SAMPLER_PALETTE_LOAD1_header\
3317   .DWordLength                         =      0,  \
3318   ._3DCommandSubOpcode                 =     12,  \
3319   ._3DCommandOpcode                    =      1,  \
3320   .CommandSubType                      =      3,  \
3321   .CommandType                         =      3
3322
3323struct GFX7_3DSTATE_SAMPLER_PALETTE_LOAD1 {
3324   uint32_t                             DWordLength;
3325   uint32_t                             _3DCommandSubOpcode;
3326   uint32_t                             _3DCommandOpcode;
3327   uint32_t                             CommandSubType;
3328   uint32_t                             CommandType;
3329   /* variable length fields follow */
3330};
3331
3332static inline __attribute__((always_inline)) void
3333GFX7_3DSTATE_SAMPLER_PALETTE_LOAD1_pack(__attribute__((unused)) __gen_user_data *data,
3334                                        __attribute__((unused)) void * restrict dst,
3335                                        __attribute__((unused)) const struct GFX7_3DSTATE_SAMPLER_PALETTE_LOAD1 * restrict values)
3336{
3337   uint32_t * restrict dw = (uint32_t * restrict) dst;
3338
3339   dw[0] =
3340      __gen_uint(values->DWordLength, 0, 7) |
3341      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3342      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3343      __gen_uint(values->CommandSubType, 27, 28) |
3344      __gen_uint(values->CommandType, 29, 31);
3345}
3346
3347#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_DS_length      2
3348#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_DS_length_bias      2
3349#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_DS_header\
3350   .DWordLength                         =      0,  \
3351   ._3DCommandSubOpcode                 =     45,  \
3352   ._3DCommandOpcode                    =      0,  \
3353   .CommandSubType                      =      3,  \
3354   .CommandType                         =      3
3355
3356struct GFX7_3DSTATE_SAMPLER_STATE_POINTERS_DS {
3357   uint32_t                             DWordLength;
3358   uint32_t                             _3DCommandSubOpcode;
3359   uint32_t                             _3DCommandOpcode;
3360   uint32_t                             CommandSubType;
3361   uint32_t                             CommandType;
3362   uint64_t                             PointertoDSSamplerState;
3363};
3364
3365static inline __attribute__((always_inline)) void
3366GFX7_3DSTATE_SAMPLER_STATE_POINTERS_DS_pack(__attribute__((unused)) __gen_user_data *data,
3367                                            __attribute__((unused)) void * restrict dst,
3368                                            __attribute__((unused)) const struct GFX7_3DSTATE_SAMPLER_STATE_POINTERS_DS * restrict values)
3369{
3370   uint32_t * restrict dw = (uint32_t * restrict) dst;
3371
3372   dw[0] =
3373      __gen_uint(values->DWordLength, 0, 7) |
3374      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3375      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3376      __gen_uint(values->CommandSubType, 27, 28) |
3377      __gen_uint(values->CommandType, 29, 31);
3378
3379   dw[1] =
3380      __gen_offset(values->PointertoDSSamplerState, 5, 31);
3381}
3382
3383#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_GS_length      2
3384#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_GS_length_bias      2
3385#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_GS_header\
3386   .DWordLength                         =      0,  \
3387   ._3DCommandSubOpcode                 =     46,  \
3388   ._3DCommandOpcode                    =      0,  \
3389   .CommandSubType                      =      3,  \
3390   .CommandType                         =      3
3391
3392struct GFX7_3DSTATE_SAMPLER_STATE_POINTERS_GS {
3393   uint32_t                             DWordLength;
3394   uint32_t                             _3DCommandSubOpcode;
3395   uint32_t                             _3DCommandOpcode;
3396   uint32_t                             CommandSubType;
3397   uint32_t                             CommandType;
3398   uint64_t                             PointertoGSSamplerState;
3399};
3400
3401static inline __attribute__((always_inline)) void
3402GFX7_3DSTATE_SAMPLER_STATE_POINTERS_GS_pack(__attribute__((unused)) __gen_user_data *data,
3403                                            __attribute__((unused)) void * restrict dst,
3404                                            __attribute__((unused)) const struct GFX7_3DSTATE_SAMPLER_STATE_POINTERS_GS * restrict values)
3405{
3406   uint32_t * restrict dw = (uint32_t * restrict) dst;
3407
3408   dw[0] =
3409      __gen_uint(values->DWordLength, 0, 7) |
3410      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3411      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3412      __gen_uint(values->CommandSubType, 27, 28) |
3413      __gen_uint(values->CommandType, 29, 31);
3414
3415   dw[1] =
3416      __gen_offset(values->PointertoGSSamplerState, 5, 31);
3417}
3418
3419#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_HS_length      2
3420#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_HS_length_bias      2
3421#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_HS_header\
3422   .DWordLength                         =      0,  \
3423   ._3DCommandSubOpcode                 =     44,  \
3424   ._3DCommandOpcode                    =      0,  \
3425   .CommandSubType                      =      3,  \
3426   .CommandType                         =      3
3427
3428struct GFX7_3DSTATE_SAMPLER_STATE_POINTERS_HS {
3429   uint32_t                             DWordLength;
3430   uint32_t                             _3DCommandSubOpcode;
3431   uint32_t                             _3DCommandOpcode;
3432   uint32_t                             CommandSubType;
3433   uint32_t                             CommandType;
3434   uint64_t                             PointertoHSSamplerState;
3435};
3436
3437static inline __attribute__((always_inline)) void
3438GFX7_3DSTATE_SAMPLER_STATE_POINTERS_HS_pack(__attribute__((unused)) __gen_user_data *data,
3439                                            __attribute__((unused)) void * restrict dst,
3440                                            __attribute__((unused)) const struct GFX7_3DSTATE_SAMPLER_STATE_POINTERS_HS * restrict values)
3441{
3442   uint32_t * restrict dw = (uint32_t * restrict) dst;
3443
3444   dw[0] =
3445      __gen_uint(values->DWordLength, 0, 7) |
3446      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3447      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3448      __gen_uint(values->CommandSubType, 27, 28) |
3449      __gen_uint(values->CommandType, 29, 31);
3450
3451   dw[1] =
3452      __gen_offset(values->PointertoHSSamplerState, 5, 31);
3453}
3454
3455#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_PS_length      2
3456#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_PS_length_bias      2
3457#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_PS_header\
3458   .DWordLength                         =      0,  \
3459   ._3DCommandSubOpcode                 =     47,  \
3460   ._3DCommandOpcode                    =      0,  \
3461   .CommandSubType                      =      3,  \
3462   .CommandType                         =      3
3463
3464struct GFX7_3DSTATE_SAMPLER_STATE_POINTERS_PS {
3465   uint32_t                             DWordLength;
3466   uint32_t                             _3DCommandSubOpcode;
3467   uint32_t                             _3DCommandOpcode;
3468   uint32_t                             CommandSubType;
3469   uint32_t                             CommandType;
3470   uint64_t                             PointertoPSSamplerState;
3471};
3472
3473static inline __attribute__((always_inline)) void
3474GFX7_3DSTATE_SAMPLER_STATE_POINTERS_PS_pack(__attribute__((unused)) __gen_user_data *data,
3475                                            __attribute__((unused)) void * restrict dst,
3476                                            __attribute__((unused)) const struct GFX7_3DSTATE_SAMPLER_STATE_POINTERS_PS * restrict values)
3477{
3478   uint32_t * restrict dw = (uint32_t * restrict) dst;
3479
3480   dw[0] =
3481      __gen_uint(values->DWordLength, 0, 7) |
3482      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3483      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3484      __gen_uint(values->CommandSubType, 27, 28) |
3485      __gen_uint(values->CommandType, 29, 31);
3486
3487   dw[1] =
3488      __gen_offset(values->PointertoPSSamplerState, 5, 31);
3489}
3490
3491#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_VS_length      2
3492#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_VS_length_bias      2
3493#define GFX7_3DSTATE_SAMPLER_STATE_POINTERS_VS_header\
3494   .DWordLength                         =      0,  \
3495   ._3DCommandSubOpcode                 =     43,  \
3496   ._3DCommandOpcode                    =      0,  \
3497   .CommandSubType                      =      3,  \
3498   .CommandType                         =      3
3499
3500struct GFX7_3DSTATE_SAMPLER_STATE_POINTERS_VS {
3501   uint32_t                             DWordLength;
3502   uint32_t                             _3DCommandSubOpcode;
3503   uint32_t                             _3DCommandOpcode;
3504   uint32_t                             CommandSubType;
3505   uint32_t                             CommandType;
3506   uint64_t                             PointertoVSSamplerState;
3507};
3508
3509static inline __attribute__((always_inline)) void
3510GFX7_3DSTATE_SAMPLER_STATE_POINTERS_VS_pack(__attribute__((unused)) __gen_user_data *data,
3511                                            __attribute__((unused)) void * restrict dst,
3512                                            __attribute__((unused)) const struct GFX7_3DSTATE_SAMPLER_STATE_POINTERS_VS * restrict values)
3513{
3514   uint32_t * restrict dw = (uint32_t * restrict) dst;
3515
3516   dw[0] =
3517      __gen_uint(values->DWordLength, 0, 7) |
3518      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3519      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3520      __gen_uint(values->CommandSubType, 27, 28) |
3521      __gen_uint(values->CommandType, 29, 31);
3522
3523   dw[1] =
3524      __gen_offset(values->PointertoVSSamplerState, 5, 31);
3525}
3526
3527#define GFX7_3DSTATE_SAMPLE_MASK_length        2
3528#define GFX7_3DSTATE_SAMPLE_MASK_length_bias      2
3529#define GFX7_3DSTATE_SAMPLE_MASK_header         \
3530   .DWordLength                         =      0,  \
3531   ._3DCommandSubOpcode                 =     24,  \
3532   ._3DCommandOpcode                    =      0,  \
3533   .CommandSubType                      =      3,  \
3534   .CommandType                         =      3
3535
3536struct GFX7_3DSTATE_SAMPLE_MASK {
3537   uint32_t                             DWordLength;
3538   uint32_t                             _3DCommandSubOpcode;
3539   uint32_t                             _3DCommandOpcode;
3540   uint32_t                             CommandSubType;
3541   uint32_t                             CommandType;
3542   uint32_t                             SampleMask;
3543};
3544
3545static inline __attribute__((always_inline)) void
3546GFX7_3DSTATE_SAMPLE_MASK_pack(__attribute__((unused)) __gen_user_data *data,
3547                              __attribute__((unused)) void * restrict dst,
3548                              __attribute__((unused)) const struct GFX7_3DSTATE_SAMPLE_MASK * restrict values)
3549{
3550   uint32_t * restrict dw = (uint32_t * restrict) dst;
3551
3552   dw[0] =
3553      __gen_uint(values->DWordLength, 0, 7) |
3554      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3555      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3556      __gen_uint(values->CommandSubType, 27, 28) |
3557      __gen_uint(values->CommandType, 29, 31);
3558
3559   dw[1] =
3560      __gen_uint(values->SampleMask, 0, 7);
3561}
3562
3563#define GFX7_3DSTATE_SBE_length               14
3564#define GFX7_3DSTATE_SBE_length_bias           2
3565#define GFX7_3DSTATE_SBE_header                 \
3566   .DWordLength                         =     12,  \
3567   ._3DCommandSubOpcode                 =     31,  \
3568   ._3DCommandOpcode                    =      0,  \
3569   .CommandSubType                      =      3,  \
3570   .CommandType                         =      3
3571
3572struct GFX7_3DSTATE_SBE {
3573   uint32_t                             DWordLength;
3574   uint32_t                             _3DCommandSubOpcode;
3575   uint32_t                             _3DCommandOpcode;
3576   uint32_t                             CommandSubType;
3577   uint32_t                             CommandType;
3578   uint32_t                             VertexURBEntryReadOffset;
3579   uint32_t                             VertexURBEntryReadLength;
3580   uint32_t                             PointSpriteTextureCoordinateOrigin;
3581#define UPPERLEFT                                0
3582#define LOWERLEFT                                1
3583   bool                                 AttributeSwizzleEnable;
3584   uint32_t                             NumberofSFOutputAttributes;
3585   uint32_t                             AttributeSwizzleControlMode;
3586#define SWIZ_0_15                                0
3587#define SWIZ_16_31                               1
3588   struct GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL Attribute[16];
3589   uint32_t                             PointSpriteTextureCoordinateEnable;
3590   uint32_t                             ConstantInterpolationEnable;
3591   uint32_t                             Attribute0WrapShortestEnables;
3592   uint32_t                             Attribute1WrapShortestEnables;
3593   uint32_t                             Attribute2WrapShortestEnables;
3594   uint32_t                             Attribute3WrapShortestEnables;
3595   uint32_t                             Attribute4WrapShortestEnables;
3596   uint32_t                             Attribute5WrapShortestEnables;
3597   uint32_t                             Attribute6WrapShortestEnables;
3598   uint32_t                             Attribute7WrapShortestEnables;
3599   uint32_t                             Attribute8WrapShortestEnables;
3600   uint32_t                             Attribute9WrapShortestEnables;
3601   uint32_t                             Attribute10WrapShortestEnables;
3602   uint32_t                             Attribute11WrapShortestEnables;
3603   uint32_t                             Attribute12WrapShortestEnables;
3604   uint32_t                             Attribute13WrapShortestEnables;
3605   uint32_t                             Attribute14WrapShortestEnables;
3606   uint32_t                             Attribute15WrapShortestEnables;
3607};
3608
3609static inline __attribute__((always_inline)) void
3610GFX7_3DSTATE_SBE_pack(__attribute__((unused)) __gen_user_data *data,
3611                      __attribute__((unused)) void * restrict dst,
3612                      __attribute__((unused)) const struct GFX7_3DSTATE_SBE * restrict values)
3613{
3614   uint32_t * restrict dw = (uint32_t * restrict) dst;
3615
3616   dw[0] =
3617      __gen_uint(values->DWordLength, 0, 7) |
3618      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3619      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3620      __gen_uint(values->CommandSubType, 27, 28) |
3621      __gen_uint(values->CommandType, 29, 31);
3622
3623   dw[1] =
3624      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
3625      __gen_uint(values->VertexURBEntryReadLength, 11, 15) |
3626      __gen_uint(values->PointSpriteTextureCoordinateOrigin, 20, 20) |
3627      __gen_uint(values->AttributeSwizzleEnable, 21, 21) |
3628      __gen_uint(values->NumberofSFOutputAttributes, 22, 27) |
3629      __gen_uint(values->AttributeSwizzleControlMode, 28, 28);
3630
3631   uint32_t v2_0;
3632   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v2_0, &values->Attribute[0]);
3633
3634   uint32_t v2_1;
3635   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v2_1, &values->Attribute[1]);
3636
3637   dw[2] =
3638      __gen_uint(v2_0, 0, 15) |
3639      __gen_uint(v2_1, 16, 31);
3640
3641   uint32_t v3_0;
3642   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v3_0, &values->Attribute[2]);
3643
3644   uint32_t v3_1;
3645   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v3_1, &values->Attribute[3]);
3646
3647   dw[3] =
3648      __gen_uint(v3_0, 0, 15) |
3649      __gen_uint(v3_1, 16, 31);
3650
3651   uint32_t v4_0;
3652   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v4_0, &values->Attribute[4]);
3653
3654   uint32_t v4_1;
3655   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v4_1, &values->Attribute[5]);
3656
3657   dw[4] =
3658      __gen_uint(v4_0, 0, 15) |
3659      __gen_uint(v4_1, 16, 31);
3660
3661   uint32_t v5_0;
3662   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v5_0, &values->Attribute[6]);
3663
3664   uint32_t v5_1;
3665   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v5_1, &values->Attribute[7]);
3666
3667   dw[5] =
3668      __gen_uint(v5_0, 0, 15) |
3669      __gen_uint(v5_1, 16, 31);
3670
3671   uint32_t v6_0;
3672   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v6_0, &values->Attribute[8]);
3673
3674   uint32_t v6_1;
3675   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v6_1, &values->Attribute[9]);
3676
3677   dw[6] =
3678      __gen_uint(v6_0, 0, 15) |
3679      __gen_uint(v6_1, 16, 31);
3680
3681   uint32_t v7_0;
3682   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v7_0, &values->Attribute[10]);
3683
3684   uint32_t v7_1;
3685   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v7_1, &values->Attribute[11]);
3686
3687   dw[7] =
3688      __gen_uint(v7_0, 0, 15) |
3689      __gen_uint(v7_1, 16, 31);
3690
3691   uint32_t v8_0;
3692   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v8_0, &values->Attribute[12]);
3693
3694   uint32_t v8_1;
3695   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v8_1, &values->Attribute[13]);
3696
3697   dw[8] =
3698      __gen_uint(v8_0, 0, 15) |
3699      __gen_uint(v8_1, 16, 31);
3700
3701   uint32_t v9_0;
3702   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v9_0, &values->Attribute[14]);
3703
3704   uint32_t v9_1;
3705   GFX7_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v9_1, &values->Attribute[15]);
3706
3707   dw[9] =
3708      __gen_uint(v9_0, 0, 15) |
3709      __gen_uint(v9_1, 16, 31);
3710
3711   dw[10] =
3712      __gen_uint(values->PointSpriteTextureCoordinateEnable, 0, 31);
3713
3714   dw[11] =
3715      __gen_uint(values->ConstantInterpolationEnable, 0, 31);
3716
3717   dw[12] =
3718      __gen_uint(values->Attribute0WrapShortestEnables, 0, 3) |
3719      __gen_uint(values->Attribute1WrapShortestEnables, 4, 7) |
3720      __gen_uint(values->Attribute2WrapShortestEnables, 8, 11) |
3721      __gen_uint(values->Attribute3WrapShortestEnables, 12, 15) |
3722      __gen_uint(values->Attribute4WrapShortestEnables, 16, 19) |
3723      __gen_uint(values->Attribute5WrapShortestEnables, 20, 23) |
3724      __gen_uint(values->Attribute6WrapShortestEnables, 24, 27) |
3725      __gen_uint(values->Attribute7WrapShortestEnables, 28, 31);
3726
3727   dw[13] =
3728      __gen_uint(values->Attribute8WrapShortestEnables, 0, 3) |
3729      __gen_uint(values->Attribute9WrapShortestEnables, 4, 7) |
3730      __gen_uint(values->Attribute10WrapShortestEnables, 8, 11) |
3731      __gen_uint(values->Attribute11WrapShortestEnables, 12, 15) |
3732      __gen_uint(values->Attribute12WrapShortestEnables, 16, 19) |
3733      __gen_uint(values->Attribute13WrapShortestEnables, 20, 23) |
3734      __gen_uint(values->Attribute14WrapShortestEnables, 24, 27) |
3735      __gen_uint(values->Attribute15WrapShortestEnables, 28, 31);
3736}
3737
3738#define GFX7_3DSTATE_SCISSOR_STATE_POINTERS_length      2
3739#define GFX7_3DSTATE_SCISSOR_STATE_POINTERS_length_bias      2
3740#define GFX7_3DSTATE_SCISSOR_STATE_POINTERS_header\
3741   .DWordLength                         =      0,  \
3742   ._3DCommandSubOpcode                 =     15,  \
3743   ._3DCommandOpcode                    =      0,  \
3744   .CommandSubType                      =      3,  \
3745   .CommandType                         =      3
3746
3747struct GFX7_3DSTATE_SCISSOR_STATE_POINTERS {
3748   uint32_t                             DWordLength;
3749   uint32_t                             _3DCommandSubOpcode;
3750   uint32_t                             _3DCommandOpcode;
3751   uint32_t                             CommandSubType;
3752   uint32_t                             CommandType;
3753   uint64_t                             ScissorRectPointer;
3754};
3755
3756static inline __attribute__((always_inline)) void
3757GFX7_3DSTATE_SCISSOR_STATE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
3758                                         __attribute__((unused)) void * restrict dst,
3759                                         __attribute__((unused)) const struct GFX7_3DSTATE_SCISSOR_STATE_POINTERS * restrict values)
3760{
3761   uint32_t * restrict dw = (uint32_t * restrict) dst;
3762
3763   dw[0] =
3764      __gen_uint(values->DWordLength, 0, 7) |
3765      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3766      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3767      __gen_uint(values->CommandSubType, 27, 28) |
3768      __gen_uint(values->CommandType, 29, 31);
3769
3770   dw[1] =
3771      __gen_offset(values->ScissorRectPointer, 5, 31);
3772}
3773
3774#define GFX7_3DSTATE_SF_length                 7
3775#define GFX7_3DSTATE_SF_length_bias            2
3776#define GFX7_3DSTATE_SF_header                  \
3777   .DWordLength                         =      5,  \
3778   ._3DCommandSubOpcode                 =     19,  \
3779   ._3DCommandOpcode                    =      0,  \
3780   .CommandSubType                      =      3,  \
3781   .CommandType                         =      3
3782
3783struct GFX7_3DSTATE_SF {
3784   uint32_t                             DWordLength;
3785   uint32_t                             _3DCommandSubOpcode;
3786   uint32_t                             _3DCommandOpcode;
3787   uint32_t                             CommandSubType;
3788   uint32_t                             CommandType;
3789   uint32_t                             FrontWinding;
3790   bool                                 ViewportTransformEnable;
3791   uint32_t                             BackFaceFillMode;
3792#define FILL_MODE_SOLID                          0
3793#define FILL_MODE_WIREFRAME                      1
3794#define FILL_MODE_POINT                          2
3795   uint32_t                             FrontFaceFillMode;
3796#define FILL_MODE_SOLID                          0
3797#define FILL_MODE_WIREFRAME                      1
3798#define FILL_MODE_POINT                          2
3799   bool                                 GlobalDepthOffsetEnablePoint;
3800   bool                                 GlobalDepthOffsetEnableWireframe;
3801   bool                                 GlobalDepthOffsetEnableSolid;
3802   bool                                 StatisticsEnable;
3803   bool                                 LegacyGlobalDepthBiasEnable;
3804   uint32_t                             DepthBufferSurfaceFormat;
3805#define D32_FLOAT_S8X24_UINT                     0
3806#define D32_FLOAT                                1
3807#define D24_UNORM_S8_UINT                        2
3808#define D24_UNORM_X8_UINT                        3
3809#define D16_UNORM                                5
3810   uint32_t                             MultisampleRasterizationMode;
3811#define MSRASTMODE_OFF_PIXEL                     0
3812#define MSRASTMODE_OFF_PATTERN                   1
3813#define MSRASTMODE_ON_PIXEL                      2
3814#define MSRASTMODE_ON_PATTERN                    3
3815   bool                                 ScissorRectangleEnable;
3816   uint32_t                             LineEndCapAntialiasingRegionWidth;
3817#define _05pixels                                0
3818#define _10pixels                                1
3819#define _20pixels                                2
3820#define _40pixels                                3
3821   float                                LineWidth;
3822   uint32_t                             CullMode;
3823#define CULLMODE_BOTH                            0
3824#define CULLMODE_NONE                            1
3825#define CULLMODE_FRONT                           2
3826#define CULLMODE_BACK                            3
3827   bool                                 AntialiasingEnable;
3828   float                                PointWidth;
3829   uint32_t                             PointWidthSource;
3830#define Vertex                                   0
3831#define State                                    1
3832   uint32_t                             VertexSubPixelPrecisionSelect;
3833#define _8Bit                                    0
3834#define _4Bit                                    1
3835   uint32_t                             AALineDistanceMode;
3836#define AALINEDISTANCE_TRUE                      1
3837   uint32_t                             TriangleFanProvokingVertexSelect;
3838#define Vertex0                                  0
3839#define Vertex1                                  1
3840#define Vertex2                                  2
3841   uint32_t                             LineStripListProvokingVertexSelect;
3842   uint32_t                             TriangleStripListProvokingVertexSelect;
3843#define Vertex0                                  0
3844#define Vertex1                                  1
3845#define Vertex2                                  2
3846   bool                                 LastPixelEnable;
3847   float                                GlobalDepthOffsetConstant;
3848   float                                GlobalDepthOffsetScale;
3849   float                                GlobalDepthOffsetClamp;
3850};
3851
3852static inline __attribute__((always_inline)) void
3853GFX7_3DSTATE_SF_pack(__attribute__((unused)) __gen_user_data *data,
3854                     __attribute__((unused)) void * restrict dst,
3855                     __attribute__((unused)) const struct GFX7_3DSTATE_SF * restrict values)
3856{
3857   uint32_t * restrict dw = (uint32_t * restrict) dst;
3858
3859   dw[0] =
3860      __gen_uint(values->DWordLength, 0, 7) |
3861      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3862      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3863      __gen_uint(values->CommandSubType, 27, 28) |
3864      __gen_uint(values->CommandType, 29, 31);
3865
3866   dw[1] =
3867      __gen_uint(values->FrontWinding, 0, 0) |
3868      __gen_uint(values->ViewportTransformEnable, 1, 1) |
3869      __gen_uint(values->BackFaceFillMode, 3, 4) |
3870      __gen_uint(values->FrontFaceFillMode, 5, 6) |
3871      __gen_uint(values->GlobalDepthOffsetEnablePoint, 7, 7) |
3872      __gen_uint(values->GlobalDepthOffsetEnableWireframe, 8, 8) |
3873      __gen_uint(values->GlobalDepthOffsetEnableSolid, 9, 9) |
3874      __gen_uint(values->StatisticsEnable, 10, 10) |
3875      __gen_uint(values->LegacyGlobalDepthBiasEnable, 11, 11) |
3876      __gen_uint(values->DepthBufferSurfaceFormat, 12, 14);
3877
3878   dw[2] =
3879      __gen_uint(values->MultisampleRasterizationMode, 8, 9) |
3880      __gen_uint(values->ScissorRectangleEnable, 11, 11) |
3881      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 16, 17) |
3882      __gen_ufixed(values->LineWidth, 18, 27, 7) |
3883      __gen_uint(values->CullMode, 29, 30) |
3884      __gen_uint(values->AntialiasingEnable, 31, 31);
3885
3886   dw[3] =
3887      __gen_ufixed(values->PointWidth, 0, 10, 3) |
3888      __gen_uint(values->PointWidthSource, 11, 11) |
3889      __gen_uint(values->VertexSubPixelPrecisionSelect, 12, 12) |
3890      __gen_uint(values->AALineDistanceMode, 14, 14) |
3891      __gen_uint(values->TriangleFanProvokingVertexSelect, 25, 26) |
3892      __gen_uint(values->LineStripListProvokingVertexSelect, 27, 28) |
3893      __gen_uint(values->TriangleStripListProvokingVertexSelect, 29, 30) |
3894      __gen_uint(values->LastPixelEnable, 31, 31);
3895
3896   dw[4] =
3897      __gen_float(values->GlobalDepthOffsetConstant);
3898
3899   dw[5] =
3900      __gen_float(values->GlobalDepthOffsetScale);
3901
3902   dw[6] =
3903      __gen_float(values->GlobalDepthOffsetClamp);
3904}
3905
3906#define GFX7_3DSTATE_SO_BUFFER_length          4
3907#define GFX7_3DSTATE_SO_BUFFER_length_bias      2
3908#define GFX7_3DSTATE_SO_BUFFER_header           \
3909   .DWordLength                         =      2,  \
3910   ._3DCommandSubOpcode                 =     24,  \
3911   ._3DCommandOpcode                    =      1,  \
3912   .CommandSubType                      =      3,  \
3913   .CommandType                         =      3
3914
3915struct GFX7_3DSTATE_SO_BUFFER {
3916   uint32_t                             DWordLength;
3917   uint32_t                             _3DCommandSubOpcode;
3918   uint32_t                             _3DCommandOpcode;
3919   uint32_t                             CommandSubType;
3920   uint32_t                             CommandType;
3921   uint32_t                             SurfacePitch;
3922   uint32_t                             MOCS;
3923   uint32_t                             SOBufferIndex;
3924   __gen_address_type                   SurfaceBaseAddress;
3925   __gen_address_type                   SurfaceEndAddress;
3926};
3927
3928static inline __attribute__((always_inline)) void
3929GFX7_3DSTATE_SO_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
3930                            __attribute__((unused)) void * restrict dst,
3931                            __attribute__((unused)) const struct GFX7_3DSTATE_SO_BUFFER * restrict values)
3932{
3933   uint32_t * restrict dw = (uint32_t * restrict) dst;
3934
3935   dw[0] =
3936      __gen_uint(values->DWordLength, 0, 7) |
3937      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3938      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3939      __gen_uint(values->CommandSubType, 27, 28) |
3940      __gen_uint(values->CommandType, 29, 31);
3941
3942   dw[1] =
3943      __gen_uint(values->SurfacePitch, 0, 11) |
3944      __gen_uint(values->MOCS, 25, 28) |
3945      __gen_uint(values->SOBufferIndex, 29, 30);
3946
3947   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 2, 31);
3948
3949   dw[3] = __gen_address(data, &dw[3], values->SurfaceEndAddress, 0, 2, 31);
3950}
3951
3952#define GFX7_3DSTATE_SO_DECL_LIST_length_bias      2
3953#define GFX7_3DSTATE_SO_DECL_LIST_header        \
3954   ._3DCommandSubOpcode                 =     23,  \
3955   ._3DCommandOpcode                    =      1,  \
3956   .CommandSubType                      =      3,  \
3957   .CommandType                         =      3
3958
3959struct GFX7_3DSTATE_SO_DECL_LIST {
3960   uint32_t                             DWordLength;
3961   uint32_t                             _3DCommandSubOpcode;
3962   uint32_t                             _3DCommandOpcode;
3963   uint32_t                             CommandSubType;
3964   uint32_t                             CommandType;
3965   uint32_t                             StreamtoBufferSelects0;
3966   uint32_t                             StreamtoBufferSelects1;
3967   uint32_t                             StreamtoBufferSelects2;
3968   uint32_t                             StreamtoBufferSelects3;
3969   uint32_t                             NumEntries0;
3970   uint32_t                             NumEntries1;
3971   uint32_t                             NumEntries2;
3972   uint32_t                             NumEntries3;
3973   /* variable length fields follow */
3974};
3975
3976static inline __attribute__((always_inline)) void
3977GFX7_3DSTATE_SO_DECL_LIST_pack(__attribute__((unused)) __gen_user_data *data,
3978                               __attribute__((unused)) void * restrict dst,
3979                               __attribute__((unused)) const struct GFX7_3DSTATE_SO_DECL_LIST * restrict values)
3980{
3981   uint32_t * restrict dw = (uint32_t * restrict) dst;
3982
3983   dw[0] =
3984      __gen_uint(values->DWordLength, 0, 8) |
3985      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3986      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3987      __gen_uint(values->CommandSubType, 27, 28) |
3988      __gen_uint(values->CommandType, 29, 31);
3989
3990   dw[1] =
3991      __gen_uint(values->StreamtoBufferSelects0, 0, 3) |
3992      __gen_uint(values->StreamtoBufferSelects1, 4, 7) |
3993      __gen_uint(values->StreamtoBufferSelects2, 8, 11) |
3994      __gen_uint(values->StreamtoBufferSelects3, 12, 15);
3995
3996   dw[2] =
3997      __gen_uint(values->NumEntries0, 0, 7) |
3998      __gen_uint(values->NumEntries1, 8, 15) |
3999      __gen_uint(values->NumEntries2, 16, 23) |
4000      __gen_uint(values->NumEntries3, 24, 31);
4001}
4002
4003#define GFX7_3DSTATE_STENCIL_BUFFER_length      3
4004#define GFX7_3DSTATE_STENCIL_BUFFER_length_bias      2
4005#define GFX7_3DSTATE_STENCIL_BUFFER_header      \
4006   .DWordLength                         =      1,  \
4007   ._3DCommandSubOpcode                 =      6,  \
4008   ._3DCommandOpcode                    =      0,  \
4009   .CommandSubType                      =      3,  \
4010   .CommandType                         =      3
4011
4012struct GFX7_3DSTATE_STENCIL_BUFFER {
4013   uint32_t                             DWordLength;
4014   uint32_t                             _3DCommandSubOpcode;
4015   uint32_t                             _3DCommandOpcode;
4016   uint32_t                             CommandSubType;
4017   uint32_t                             CommandType;
4018   uint32_t                             SurfacePitch;
4019   uint32_t                             MOCS;
4020   __gen_address_type                   SurfaceBaseAddress;
4021};
4022
4023static inline __attribute__((always_inline)) void
4024GFX7_3DSTATE_STENCIL_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
4025                                 __attribute__((unused)) void * restrict dst,
4026                                 __attribute__((unused)) const struct GFX7_3DSTATE_STENCIL_BUFFER * restrict values)
4027{
4028   uint32_t * restrict dw = (uint32_t * restrict) dst;
4029
4030   dw[0] =
4031      __gen_uint(values->DWordLength, 0, 7) |
4032      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4033      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4034      __gen_uint(values->CommandSubType, 27, 28) |
4035      __gen_uint(values->CommandType, 29, 31);
4036
4037   dw[1] =
4038      __gen_uint(values->SurfacePitch, 0, 16) |
4039      __gen_uint(values->MOCS, 25, 28);
4040
4041   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
4042}
4043
4044#define GFX7_3DSTATE_STREAMOUT_length          3
4045#define GFX7_3DSTATE_STREAMOUT_length_bias      2
4046#define GFX7_3DSTATE_STREAMOUT_header           \
4047   .DWordLength                         =      1,  \
4048   ._3DCommandSubOpcode                 =     30,  \
4049   ._3DCommandOpcode                    =      0,  \
4050   .CommandSubType                      =      3,  \
4051   .CommandType                         =      3
4052
4053struct GFX7_3DSTATE_STREAMOUT {
4054   uint32_t                             DWordLength;
4055   uint32_t                             _3DCommandSubOpcode;
4056   uint32_t                             _3DCommandOpcode;
4057   uint32_t                             CommandSubType;
4058   uint32_t                             CommandType;
4059   bool                                 SOBufferEnable0;
4060   bool                                 SOBufferEnable1;
4061   bool                                 SOBufferEnable2;
4062   bool                                 SOBufferEnable3;
4063   bool                                 SOStatisticsEnable;
4064   uint32_t                             ReorderMode;
4065#define LEADING                                  0
4066#define TRAILING                                 1
4067   uint32_t                             RenderStreamSelect;
4068   bool                                 RenderingDisable;
4069   bool                                 SOFunctionEnable;
4070   uint32_t                             Stream0VertexReadLength;
4071   uint32_t                             Stream0VertexReadOffset;
4072   uint32_t                             Stream1VertexReadLength;
4073   uint32_t                             Stream1VertexReadOffset;
4074   uint32_t                             Stream2VertexReadLength;
4075   uint32_t                             Stream2VertexReadOffset;
4076   uint32_t                             Stream3VertexReadLength;
4077   uint32_t                             Stream3VertexReadOffset;
4078};
4079
4080static inline __attribute__((always_inline)) void
4081GFX7_3DSTATE_STREAMOUT_pack(__attribute__((unused)) __gen_user_data *data,
4082                            __attribute__((unused)) void * restrict dst,
4083                            __attribute__((unused)) const struct GFX7_3DSTATE_STREAMOUT * restrict values)
4084{
4085   uint32_t * restrict dw = (uint32_t * restrict) dst;
4086
4087   dw[0] =
4088      __gen_uint(values->DWordLength, 0, 7) |
4089      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4090      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4091      __gen_uint(values->CommandSubType, 27, 28) |
4092      __gen_uint(values->CommandType, 29, 31);
4093
4094   dw[1] =
4095      __gen_uint(values->SOBufferEnable0, 8, 8) |
4096      __gen_uint(values->SOBufferEnable1, 9, 9) |
4097      __gen_uint(values->SOBufferEnable2, 10, 10) |
4098      __gen_uint(values->SOBufferEnable3, 11, 11) |
4099      __gen_uint(values->SOStatisticsEnable, 25, 25) |
4100      __gen_uint(values->ReorderMode, 26, 26) |
4101      __gen_uint(values->RenderStreamSelect, 27, 28) |
4102      __gen_uint(values->RenderingDisable, 30, 30) |
4103      __gen_uint(values->SOFunctionEnable, 31, 31);
4104
4105   dw[2] =
4106      __gen_uint(values->Stream0VertexReadLength, 0, 4) |
4107      __gen_uint(values->Stream0VertexReadOffset, 5, 5) |
4108      __gen_uint(values->Stream1VertexReadLength, 8, 12) |
4109      __gen_uint(values->Stream1VertexReadOffset, 13, 13) |
4110      __gen_uint(values->Stream2VertexReadLength, 16, 20) |
4111      __gen_uint(values->Stream2VertexReadOffset, 21, 21) |
4112      __gen_uint(values->Stream3VertexReadLength, 24, 28) |
4113      __gen_uint(values->Stream3VertexReadOffset, 29, 29);
4114}
4115
4116#define GFX7_3DSTATE_TE_length                 4
4117#define GFX7_3DSTATE_TE_length_bias            2
4118#define GFX7_3DSTATE_TE_header                  \
4119   .DWordLength                         =      2,  \
4120   ._3DCommandSubOpcode                 =     28,  \
4121   ._3DCommandOpcode                    =      0,  \
4122   .CommandSubType                      =      3,  \
4123   .CommandType                         =      3
4124
4125struct GFX7_3DSTATE_TE {
4126   uint32_t                             DWordLength;
4127   uint32_t                             _3DCommandSubOpcode;
4128   uint32_t                             _3DCommandOpcode;
4129   uint32_t                             CommandSubType;
4130   uint32_t                             CommandType;
4131   bool                                 TEEnable;
4132   uint32_t                             TEMode;
4133#define HW_TESS                                  0
4134#define SW_TESS                                  1
4135   uint32_t                             TEDomain;
4136#define QUAD                                     0
4137#define TRI                                      1
4138#define ISOLINE                                  2
4139   uint32_t                             OutputTopology;
4140#define OUTPUT_POINT                             0
4141#define OUTPUT_LINE                              1
4142#define OUTPUT_TRI_CW                            2
4143#define OUTPUT_TRI_CCW                           3
4144   uint32_t                             Partitioning;
4145#define INTEGER                                  0
4146#define ODD_FRACTIONAL                           1
4147#define EVEN_FRACTIONAL                          2
4148   float                                MaximumTessellationFactorOdd;
4149   float                                MaximumTessellationFactorNotOdd;
4150};
4151
4152static inline __attribute__((always_inline)) void
4153GFX7_3DSTATE_TE_pack(__attribute__((unused)) __gen_user_data *data,
4154                     __attribute__((unused)) void * restrict dst,
4155                     __attribute__((unused)) const struct GFX7_3DSTATE_TE * restrict values)
4156{
4157   uint32_t * restrict dw = (uint32_t * restrict) dst;
4158
4159   dw[0] =
4160      __gen_uint(values->DWordLength, 0, 7) |
4161      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4162      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4163      __gen_uint(values->CommandSubType, 27, 28) |
4164      __gen_uint(values->CommandType, 29, 31);
4165
4166   dw[1] =
4167      __gen_uint(values->TEEnable, 0, 0) |
4168      __gen_uint(values->TEMode, 1, 2) |
4169      __gen_uint(values->TEDomain, 4, 5) |
4170      __gen_uint(values->OutputTopology, 8, 9) |
4171      __gen_uint(values->Partitioning, 12, 13);
4172
4173   dw[2] =
4174      __gen_float(values->MaximumTessellationFactorOdd);
4175
4176   dw[3] =
4177      __gen_float(values->MaximumTessellationFactorNotOdd);
4178}
4179
4180#define GFX7_3DSTATE_URB_DS_length             2
4181#define GFX7_3DSTATE_URB_DS_length_bias        2
4182#define GFX7_3DSTATE_URB_DS_header              \
4183   .DWordLength                         =      0,  \
4184   ._3DCommandSubOpcode                 =     50,  \
4185   ._3DCommandOpcode                    =      0,  \
4186   .CommandSubType                      =      3,  \
4187   .CommandType                         =      3
4188
4189struct GFX7_3DSTATE_URB_DS {
4190   uint32_t                             DWordLength;
4191   uint32_t                             _3DCommandSubOpcode;
4192   uint32_t                             _3DCommandOpcode;
4193   uint32_t                             CommandSubType;
4194   uint32_t                             CommandType;
4195   uint32_t                             DSNumberofURBEntries;
4196   uint32_t                             DSURBEntryAllocationSize;
4197   uint32_t                             DSURBStartingAddress;
4198};
4199
4200static inline __attribute__((always_inline)) void
4201GFX7_3DSTATE_URB_DS_pack(__attribute__((unused)) __gen_user_data *data,
4202                         __attribute__((unused)) void * restrict dst,
4203                         __attribute__((unused)) const struct GFX7_3DSTATE_URB_DS * restrict values)
4204{
4205   uint32_t * restrict dw = (uint32_t * restrict) dst;
4206
4207   dw[0] =
4208      __gen_uint(values->DWordLength, 0, 7) |
4209      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4210      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4211      __gen_uint(values->CommandSubType, 27, 28) |
4212      __gen_uint(values->CommandType, 29, 31);
4213
4214   dw[1] =
4215      __gen_uint(values->DSNumberofURBEntries, 0, 15) |
4216      __gen_uint(values->DSURBEntryAllocationSize, 16, 24) |
4217      __gen_uint(values->DSURBStartingAddress, 25, 29);
4218}
4219
4220#define GFX7_3DSTATE_URB_GS_length             2
4221#define GFX7_3DSTATE_URB_GS_length_bias        2
4222#define GFX7_3DSTATE_URB_GS_header              \
4223   .DWordLength                         =      0,  \
4224   ._3DCommandSubOpcode                 =     51,  \
4225   ._3DCommandOpcode                    =      0,  \
4226   .CommandSubType                      =      3,  \
4227   .CommandType                         =      3
4228
4229struct GFX7_3DSTATE_URB_GS {
4230   uint32_t                             DWordLength;
4231   uint32_t                             _3DCommandSubOpcode;
4232   uint32_t                             _3DCommandOpcode;
4233   uint32_t                             CommandSubType;
4234   uint32_t                             CommandType;
4235   uint32_t                             GSNumberofURBEntries;
4236   uint32_t                             GSURBEntryAllocationSize;
4237   uint32_t                             GSURBStartingAddress;
4238};
4239
4240static inline __attribute__((always_inline)) void
4241GFX7_3DSTATE_URB_GS_pack(__attribute__((unused)) __gen_user_data *data,
4242                         __attribute__((unused)) void * restrict dst,
4243                         __attribute__((unused)) const struct GFX7_3DSTATE_URB_GS * restrict values)
4244{
4245   uint32_t * restrict dw = (uint32_t * restrict) dst;
4246
4247   dw[0] =
4248      __gen_uint(values->DWordLength, 0, 7) |
4249      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4250      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4251      __gen_uint(values->CommandSubType, 27, 28) |
4252      __gen_uint(values->CommandType, 29, 31);
4253
4254   dw[1] =
4255      __gen_uint(values->GSNumberofURBEntries, 0, 15) |
4256      __gen_uint(values->GSURBEntryAllocationSize, 16, 24) |
4257      __gen_uint(values->GSURBStartingAddress, 25, 29);
4258}
4259
4260#define GFX7_3DSTATE_URB_HS_length             2
4261#define GFX7_3DSTATE_URB_HS_length_bias        2
4262#define GFX7_3DSTATE_URB_HS_header              \
4263   .DWordLength                         =      0,  \
4264   ._3DCommandSubOpcode                 =     49,  \
4265   ._3DCommandOpcode                    =      0,  \
4266   .CommandSubType                      =      3,  \
4267   .CommandType                         =      3
4268
4269struct GFX7_3DSTATE_URB_HS {
4270   uint32_t                             DWordLength;
4271   uint32_t                             _3DCommandSubOpcode;
4272   uint32_t                             _3DCommandOpcode;
4273   uint32_t                             CommandSubType;
4274   uint32_t                             CommandType;
4275   uint32_t                             HSNumberofURBEntries;
4276   uint32_t                             HSURBEntryAllocationSize;
4277   uint32_t                             HSURBStartingAddress;
4278};
4279
4280static inline __attribute__((always_inline)) void
4281GFX7_3DSTATE_URB_HS_pack(__attribute__((unused)) __gen_user_data *data,
4282                         __attribute__((unused)) void * restrict dst,
4283                         __attribute__((unused)) const struct GFX7_3DSTATE_URB_HS * restrict values)
4284{
4285   uint32_t * restrict dw = (uint32_t * restrict) dst;
4286
4287   dw[0] =
4288      __gen_uint(values->DWordLength, 0, 7) |
4289      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4290      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4291      __gen_uint(values->CommandSubType, 27, 28) |
4292      __gen_uint(values->CommandType, 29, 31);
4293
4294   dw[1] =
4295      __gen_uint(values->HSNumberofURBEntries, 0, 15) |
4296      __gen_uint(values->HSURBEntryAllocationSize, 16, 24) |
4297      __gen_uint(values->HSURBStartingAddress, 25, 29);
4298}
4299
4300#define GFX7_3DSTATE_URB_VS_length             2
4301#define GFX7_3DSTATE_URB_VS_length_bias        2
4302#define GFX7_3DSTATE_URB_VS_header              \
4303   .DWordLength                         =      0,  \
4304   ._3DCommandSubOpcode                 =     48,  \
4305   ._3DCommandOpcode                    =      0,  \
4306   .CommandSubType                      =      3,  \
4307   .CommandType                         =      3
4308
4309struct GFX7_3DSTATE_URB_VS {
4310   uint32_t                             DWordLength;
4311   uint32_t                             _3DCommandSubOpcode;
4312   uint32_t                             _3DCommandOpcode;
4313   uint32_t                             CommandSubType;
4314   uint32_t                             CommandType;
4315   uint32_t                             VSNumberofURBEntries;
4316   uint32_t                             VSURBEntryAllocationSize;
4317   uint32_t                             VSURBStartingAddress;
4318};
4319
4320static inline __attribute__((always_inline)) void
4321GFX7_3DSTATE_URB_VS_pack(__attribute__((unused)) __gen_user_data *data,
4322                         __attribute__((unused)) void * restrict dst,
4323                         __attribute__((unused)) const struct GFX7_3DSTATE_URB_VS * restrict values)
4324{
4325   uint32_t * restrict dw = (uint32_t * restrict) dst;
4326
4327   dw[0] =
4328      __gen_uint(values->DWordLength, 0, 7) |
4329      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4330      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4331      __gen_uint(values->CommandSubType, 27, 28) |
4332      __gen_uint(values->CommandType, 29, 31);
4333
4334   dw[1] =
4335      __gen_uint(values->VSNumberofURBEntries, 0, 15) |
4336      __gen_uint(values->VSURBEntryAllocationSize, 16, 24) |
4337      __gen_uint(values->VSURBStartingAddress, 25, 29);
4338}
4339
4340#define GFX7_3DSTATE_VERTEX_BUFFERS_length_bias      2
4341#define GFX7_3DSTATE_VERTEX_BUFFERS_header      \
4342   .DWordLength                         =      3,  \
4343   ._3DCommandSubOpcode                 =      8,  \
4344   ._3DCommandOpcode                    =      0,  \
4345   .CommandSubType                      =      3,  \
4346   .CommandType                         =      3
4347
4348struct GFX7_3DSTATE_VERTEX_BUFFERS {
4349   uint32_t                             DWordLength;
4350   uint32_t                             _3DCommandSubOpcode;
4351   uint32_t                             _3DCommandOpcode;
4352   uint32_t                             CommandSubType;
4353   uint32_t                             CommandType;
4354   /* variable length fields follow */
4355};
4356
4357static inline __attribute__((always_inline)) void
4358GFX7_3DSTATE_VERTEX_BUFFERS_pack(__attribute__((unused)) __gen_user_data *data,
4359                                 __attribute__((unused)) void * restrict dst,
4360                                 __attribute__((unused)) const struct GFX7_3DSTATE_VERTEX_BUFFERS * restrict values)
4361{
4362   uint32_t * restrict dw = (uint32_t * restrict) dst;
4363
4364   dw[0] =
4365      __gen_uint(values->DWordLength, 0, 7) |
4366      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4367      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4368      __gen_uint(values->CommandSubType, 27, 28) |
4369      __gen_uint(values->CommandType, 29, 31);
4370}
4371
4372#define GFX7_3DSTATE_VERTEX_ELEMENTS_length_bias      2
4373#define GFX7_3DSTATE_VERTEX_ELEMENTS_header     \
4374   .DWordLength                         =      1,  \
4375   ._3DCommandSubOpcode                 =      9,  \
4376   ._3DCommandOpcode                    =      0,  \
4377   .CommandSubType                      =      3,  \
4378   .CommandType                         =      3
4379
4380struct GFX7_3DSTATE_VERTEX_ELEMENTS {
4381   uint32_t                             DWordLength;
4382   uint32_t                             _3DCommandSubOpcode;
4383   uint32_t                             _3DCommandOpcode;
4384   uint32_t                             CommandSubType;
4385   uint32_t                             CommandType;
4386   /* variable length fields follow */
4387};
4388
4389static inline __attribute__((always_inline)) void
4390GFX7_3DSTATE_VERTEX_ELEMENTS_pack(__attribute__((unused)) __gen_user_data *data,
4391                                  __attribute__((unused)) void * restrict dst,
4392                                  __attribute__((unused)) const struct GFX7_3DSTATE_VERTEX_ELEMENTS * restrict values)
4393{
4394   uint32_t * restrict dw = (uint32_t * restrict) dst;
4395
4396   dw[0] =
4397      __gen_uint(values->DWordLength, 0, 7) |
4398      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4399      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4400      __gen_uint(values->CommandSubType, 27, 28) |
4401      __gen_uint(values->CommandType, 29, 31);
4402}
4403
4404#define GFX7_3DSTATE_VF_STATISTICS_length      1
4405#define GFX7_3DSTATE_VF_STATISTICS_length_bias      1
4406#define GFX7_3DSTATE_VF_STATISTICS_header       \
4407   ._3DCommandSubOpcode                 =     11,  \
4408   ._3DCommandOpcode                    =      0,  \
4409   .CommandSubType                      =      1,  \
4410   .CommandType                         =      3
4411
4412struct GFX7_3DSTATE_VF_STATISTICS {
4413   bool                                 StatisticsEnable;
4414   uint32_t                             _3DCommandSubOpcode;
4415   uint32_t                             _3DCommandOpcode;
4416   uint32_t                             CommandSubType;
4417   uint32_t                             CommandType;
4418};
4419
4420static inline __attribute__((always_inline)) void
4421GFX7_3DSTATE_VF_STATISTICS_pack(__attribute__((unused)) __gen_user_data *data,
4422                                __attribute__((unused)) void * restrict dst,
4423                                __attribute__((unused)) const struct GFX7_3DSTATE_VF_STATISTICS * restrict values)
4424{
4425   uint32_t * restrict dw = (uint32_t * restrict) dst;
4426
4427   dw[0] =
4428      __gen_uint(values->StatisticsEnable, 0, 0) |
4429      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4430      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4431      __gen_uint(values->CommandSubType, 27, 28) |
4432      __gen_uint(values->CommandType, 29, 31);
4433}
4434
4435#define GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_CC_length      2
4436#define GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_CC_length_bias      2
4437#define GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_CC_header\
4438   .DWordLength                         =      0,  \
4439   ._3DCommandSubOpcode                 =     35,  \
4440   ._3DCommandOpcode                    =      0,  \
4441   .CommandSubType                      =      3,  \
4442   .CommandType                         =      3
4443
4444struct GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_CC {
4445   uint32_t                             DWordLength;
4446   uint32_t                             _3DCommandSubOpcode;
4447   uint32_t                             _3DCommandOpcode;
4448   uint32_t                             CommandSubType;
4449   uint32_t                             CommandType;
4450   uint64_t                             CCViewportPointer;
4451};
4452
4453static inline __attribute__((always_inline)) void
4454GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_CC_pack(__attribute__((unused)) __gen_user_data *data,
4455                                             __attribute__((unused)) void * restrict dst,
4456                                             __attribute__((unused)) const struct GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_CC * restrict values)
4457{
4458   uint32_t * restrict dw = (uint32_t * restrict) dst;
4459
4460   dw[0] =
4461      __gen_uint(values->DWordLength, 0, 7) |
4462      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4463      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4464      __gen_uint(values->CommandSubType, 27, 28) |
4465      __gen_uint(values->CommandType, 29, 31);
4466
4467   dw[1] =
4468      __gen_offset(values->CCViewportPointer, 5, 31);
4469}
4470
4471#define GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP_length      2
4472#define GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP_length_bias      2
4473#define GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP_header\
4474   .DWordLength                         =      0,  \
4475   ._3DCommandSubOpcode                 =     33,  \
4476   ._3DCommandOpcode                    =      0,  \
4477   .CommandSubType                      =      3,  \
4478   .CommandType                         =      3
4479
4480struct GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP {
4481   uint32_t                             DWordLength;
4482   uint32_t                             _3DCommandSubOpcode;
4483   uint32_t                             _3DCommandOpcode;
4484   uint32_t                             CommandSubType;
4485   uint32_t                             CommandType;
4486   uint64_t                             SFClipViewportPointer;
4487};
4488
4489static inline __attribute__((always_inline)) void
4490GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP_pack(__attribute__((unused)) __gen_user_data *data,
4491                                                  __attribute__((unused)) void * restrict dst,
4492                                                  __attribute__((unused)) const struct GFX7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP * restrict values)
4493{
4494   uint32_t * restrict dw = (uint32_t * restrict) dst;
4495
4496   dw[0] =
4497      __gen_uint(values->DWordLength, 0, 7) |
4498      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4499      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4500      __gen_uint(values->CommandSubType, 27, 28) |
4501      __gen_uint(values->CommandType, 29, 31);
4502
4503   dw[1] =
4504      __gen_offset(values->SFClipViewportPointer, 6, 31);
4505}
4506
4507#define GFX7_3DSTATE_VS_length                 6
4508#define GFX7_3DSTATE_VS_length_bias            2
4509#define GFX7_3DSTATE_VS_header                  \
4510   .DWordLength                         =      4,  \
4511   ._3DCommandSubOpcode                 =     16,  \
4512   ._3DCommandOpcode                    =      0,  \
4513   .CommandSubType                      =      3,  \
4514   .CommandType                         =      3
4515
4516struct GFX7_3DSTATE_VS {
4517   uint32_t                             DWordLength;
4518   uint32_t                             _3DCommandSubOpcode;
4519   uint32_t                             _3DCommandOpcode;
4520   uint32_t                             CommandSubType;
4521   uint32_t                             CommandType;
4522   uint64_t                             KernelStartPointer;
4523   bool                                 SoftwareExceptionEnable;
4524   bool                                 IllegalOpcodeExceptionEnable;
4525   uint32_t                             FloatingPointMode;
4526#define IEEE754                                  0
4527#define Alternate                                1
4528   uint32_t                             BindingTableEntryCount;
4529   uint32_t                             SamplerCount;
4530#define NoSamplers                               0
4531#define _14Samplers                              1
4532#define _58Samplers                              2
4533#define _912Samplers                             3
4534#define _1316Samplers                            4
4535   bool                                 VectorMaskEnable;
4536   bool                                 SingleVertexDispatch;
4537   uint32_t                             PerThreadScratchSpace;
4538   __gen_address_type                   ScratchSpaceBasePointer;
4539   uint32_t                             VertexURBEntryReadOffset;
4540   uint32_t                             VertexURBEntryReadLength;
4541   uint32_t                             DispatchGRFStartRegisterForURBData;
4542   bool                                 Enable;
4543   bool                                 VertexCacheDisable;
4544   bool                                 StatisticsEnable;
4545   uint32_t                             MaximumNumberofThreads;
4546};
4547
4548static inline __attribute__((always_inline)) void
4549GFX7_3DSTATE_VS_pack(__attribute__((unused)) __gen_user_data *data,
4550                     __attribute__((unused)) void * restrict dst,
4551                     __attribute__((unused)) const struct GFX7_3DSTATE_VS * restrict values)
4552{
4553   uint32_t * restrict dw = (uint32_t * restrict) dst;
4554
4555   dw[0] =
4556      __gen_uint(values->DWordLength, 0, 7) |
4557      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4558      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4559      __gen_uint(values->CommandSubType, 27, 28) |
4560      __gen_uint(values->CommandType, 29, 31);
4561
4562   dw[1] =
4563      __gen_offset(values->KernelStartPointer, 6, 31);
4564
4565   dw[2] =
4566      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
4567      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
4568      __gen_uint(values->FloatingPointMode, 16, 16) |
4569      __gen_uint(values->BindingTableEntryCount, 18, 25) |
4570      __gen_uint(values->SamplerCount, 27, 29) |
4571      __gen_uint(values->VectorMaskEnable, 30, 30) |
4572      __gen_uint(values->SingleVertexDispatch, 31, 31);
4573
4574   const uint32_t v3 =
4575      __gen_uint(values->PerThreadScratchSpace, 0, 3);
4576   dw[3] = __gen_address(data, &dw[3], values->ScratchSpaceBasePointer, v3, 10, 31);
4577
4578   dw[4] =
4579      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
4580      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
4581      __gen_uint(values->DispatchGRFStartRegisterForURBData, 20, 24);
4582
4583   dw[5] =
4584      __gen_uint(values->Enable, 0, 0) |
4585      __gen_uint(values->VertexCacheDisable, 1, 1) |
4586      __gen_uint(values->StatisticsEnable, 10, 10) |
4587      __gen_uint(values->MaximumNumberofThreads, 25, 31);
4588}
4589
4590#define GFX7_3DSTATE_WM_length                 3
4591#define GFX7_3DSTATE_WM_length_bias            2
4592#define GFX7_3DSTATE_WM_header                  \
4593   .DWordLength                         =      1,  \
4594   ._3DCommandSubOpcode                 =     20,  \
4595   ._3DCommandOpcode                    =      0,  \
4596   .CommandSubType                      =      3,  \
4597   .CommandType                         =      3
4598
4599struct GFX7_3DSTATE_WM {
4600   uint32_t                             DWordLength;
4601   uint32_t                             _3DCommandSubOpcode;
4602   uint32_t                             _3DCommandOpcode;
4603   uint32_t                             CommandSubType;
4604   uint32_t                             CommandType;
4605   uint32_t                             MultisampleRasterizationMode;
4606#define MSRASTMODE_OFF_PIXEL                     0
4607#define MSRASTMODE_OFF_PATTERN                   1
4608#define MSRASTMODE_ON_PIXEL                      2
4609#define MSRASTMODE_ON_PATTERN                    3
4610   uint32_t                             PointRasterizationRule;
4611#define RASTRULE_UPPER_LEFT                      0
4612#define RASTRULE_UPPER_RIGHT                     1
4613   bool                                 LineStippleEnable;
4614   bool                                 PolygonStippleEnable;
4615   uint32_t                             LineAntialiasingRegionWidth;
4616#define _05pixels                                0
4617#define _10pixels                                1
4618#define _20pixels                                2
4619#define _40pixels                                3
4620   uint32_t                             LineEndCapAntialiasingRegionWidth;
4621   bool                                 PixelShaderUsesInputCoverageMask;
4622   uint32_t                             BarycentricInterpolationMode;
4623#define BIM_PERSPECTIVE_PIXEL                    1
4624#define BIM_PERSPECTIVE_CENTROID                 2
4625#define BIM_PERSPECTIVE_SAMPLE                   4
4626#define BIM_LINEAR_PIXEL                         8
4627#define BIM_LINEAR_CENTROID                      16
4628#define BIM_LINEAR_SAMPLE                        32
4629   uint32_t                             PositionZWInterpolationMode;
4630#define INTERP_PIXEL                             0
4631#define INTERP_CENTROID                          2
4632#define INTERP_SAMPLE                            3
4633   bool                                 PixelShaderUsesSourceW;
4634   bool                                 PixelShaderUsesSourceDepth;
4635   uint32_t                             EarlyDepthStencilControl;
4636#define EDSC_NORMAL                              0
4637#define EDSC_PSEXEC                              1
4638#define EDSC_PREPS                               2
4639   uint32_t                             PixelShaderComputedDepthMode;
4640#define PSCDEPTH_OFF                             0
4641#define PSCDEPTH_ON                              1
4642#define PSCDEPTH_ON_GE                           2
4643#define PSCDEPTH_ON_LE                           3
4644   bool                                 PixelShaderKillsPixel;
4645   bool                                 LegacyDiamondLineRasterization;
4646   bool                                 HierarchicalDepthBufferResolveEnable;
4647   bool                                 DepthBufferResolveEnable;
4648   bool                                 ThreadDispatchEnable;
4649   bool                                 DepthBufferClear;
4650   bool                                 StatisticsEnable;
4651   uint32_t                             MultisampleDispatchMode;
4652#define MSDISPMODE_PERSAMPLE                     0
4653#define MSDISPMODE_PERPIXEL                      1
4654};
4655
4656static inline __attribute__((always_inline)) void
4657GFX7_3DSTATE_WM_pack(__attribute__((unused)) __gen_user_data *data,
4658                     __attribute__((unused)) void * restrict dst,
4659                     __attribute__((unused)) const struct GFX7_3DSTATE_WM * restrict values)
4660{
4661   uint32_t * restrict dw = (uint32_t * restrict) dst;
4662
4663   dw[0] =
4664      __gen_uint(values->DWordLength, 0, 7) |
4665      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4666      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4667      __gen_uint(values->CommandSubType, 27, 28) |
4668      __gen_uint(values->CommandType, 29, 31);
4669
4670   dw[1] =
4671      __gen_uint(values->MultisampleRasterizationMode, 0, 1) |
4672      __gen_uint(values->PointRasterizationRule, 2, 2) |
4673      __gen_uint(values->LineStippleEnable, 3, 3) |
4674      __gen_uint(values->PolygonStippleEnable, 4, 4) |
4675      __gen_uint(values->LineAntialiasingRegionWidth, 6, 7) |
4676      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 8, 9) |
4677      __gen_uint(values->PixelShaderUsesInputCoverageMask, 10, 10) |
4678      __gen_uint(values->BarycentricInterpolationMode, 11, 16) |
4679      __gen_uint(values->PositionZWInterpolationMode, 17, 18) |
4680      __gen_uint(values->PixelShaderUsesSourceW, 19, 19) |
4681      __gen_uint(values->PixelShaderUsesSourceDepth, 20, 20) |
4682      __gen_uint(values->EarlyDepthStencilControl, 21, 22) |
4683      __gen_uint(values->PixelShaderComputedDepthMode, 23, 24) |
4684      __gen_uint(values->PixelShaderKillsPixel, 25, 25) |
4685      __gen_uint(values->LegacyDiamondLineRasterization, 26, 26) |
4686      __gen_uint(values->HierarchicalDepthBufferResolveEnable, 27, 27) |
4687      __gen_uint(values->DepthBufferResolveEnable, 28, 28) |
4688      __gen_uint(values->ThreadDispatchEnable, 29, 29) |
4689      __gen_uint(values->DepthBufferClear, 30, 30) |
4690      __gen_uint(values->StatisticsEnable, 31, 31);
4691
4692   dw[2] =
4693      __gen_uint(values->MultisampleDispatchMode, 31, 31);
4694}
4695
4696#define GFX7_GPGPU_OBJECT_length               8
4697#define GFX7_GPGPU_OBJECT_length_bias          2
4698#define GFX7_GPGPU_OBJECT_header                \
4699   .DWordLength                         =      6,  \
4700   .SubOpcode                           =      4,  \
4701   .MediaCommandOpcode                  =      1,  \
4702   .Pipeline                            =      2,  \
4703   .CommandType                         =      3
4704
4705struct GFX7_GPGPU_OBJECT {
4706   uint32_t                             DWordLength;
4707   bool                                 PredicateEnable;
4708   uint32_t                             SubOpcode;
4709   uint32_t                             MediaCommandOpcode;
4710   uint32_t                             Pipeline;
4711   uint32_t                             CommandType;
4712   uint32_t                             InterfaceDescriptorOffset;
4713   uint32_t                             SharedLocalMemoryFixedOffset;
4714   uint32_t                             IndirectDataLength;
4715   uint32_t                             HalfSliceDestinationSelect;
4716#define HalfSlice1                               2
4717#define HalfSlice0                               1
4718#define EitherHalfSlice                          0
4719   uint32_t                             EndofThreadGroup;
4720   uint32_t                             SharedLocalMemoryOffset;
4721   uint64_t                             IndirectDataStartAddress;
4722   uint32_t                             ThreadGroupIDX;
4723   uint32_t                             ThreadGroupIDY;
4724   uint32_t                             ThreadGroupIDZ;
4725   uint32_t                             ExecutionMask;
4726};
4727
4728static inline __attribute__((always_inline)) void
4729GFX7_GPGPU_OBJECT_pack(__attribute__((unused)) __gen_user_data *data,
4730                       __attribute__((unused)) void * restrict dst,
4731                       __attribute__((unused)) const struct GFX7_GPGPU_OBJECT * restrict values)
4732{
4733   uint32_t * restrict dw = (uint32_t * restrict) dst;
4734
4735   dw[0] =
4736      __gen_uint(values->DWordLength, 0, 7) |
4737      __gen_uint(values->PredicateEnable, 8, 8) |
4738      __gen_uint(values->SubOpcode, 16, 23) |
4739      __gen_uint(values->MediaCommandOpcode, 24, 26) |
4740      __gen_uint(values->Pipeline, 27, 28) |
4741      __gen_uint(values->CommandType, 29, 31);
4742
4743   dw[1] =
4744      __gen_uint(values->InterfaceDescriptorOffset, 0, 4) |
4745      __gen_uint(values->SharedLocalMemoryFixedOffset, 7, 7);
4746
4747   dw[2] =
4748      __gen_uint(values->IndirectDataLength, 0, 16) |
4749      __gen_uint(values->HalfSliceDestinationSelect, 17, 18) |
4750      __gen_uint(values->EndofThreadGroup, 24, 24) |
4751      __gen_uint(values->SharedLocalMemoryOffset, 28, 31);
4752
4753   dw[3] =
4754      __gen_offset(values->IndirectDataStartAddress, 0, 31);
4755
4756   dw[4] =
4757      __gen_uint(values->ThreadGroupIDX, 0, 31);
4758
4759   dw[5] =
4760      __gen_uint(values->ThreadGroupIDY, 0, 31);
4761
4762   dw[6] =
4763      __gen_uint(values->ThreadGroupIDZ, 0, 31);
4764
4765   dw[7] =
4766      __gen_uint(values->ExecutionMask, 0, 31);
4767}
4768
4769#define GFX7_GPGPU_WALKER_length              11
4770#define GFX7_GPGPU_WALKER_length_bias          2
4771#define GFX7_GPGPU_WALKER_header                \
4772   .DWordLength                         =      9,  \
4773   .SubOpcodeA                          =      5,  \
4774   .MediaCommandOpcode                  =      1,  \
4775   .Pipeline                            =      2,  \
4776   .CommandType                         =      3
4777
4778struct GFX7_GPGPU_WALKER {
4779   uint32_t                             DWordLength;
4780   bool                                 PredicateEnable;
4781   bool                                 IndirectParameterEnable;
4782   uint32_t                             SubOpcodeA;
4783   uint32_t                             MediaCommandOpcode;
4784   uint32_t                             Pipeline;
4785   uint32_t                             CommandType;
4786   uint32_t                             InterfaceDescriptorOffset;
4787   uint32_t                             ThreadWidthCounterMaximum;
4788   uint32_t                             ThreadHeightCounterMaximum;
4789   uint32_t                             ThreadDepthCounterMaximum;
4790   uint32_t                             SIMDSize;
4791#define SIMD8                                    0
4792#define SIMD16                                   1
4793#define SIMD32                                   2
4794   uint32_t                             ThreadGroupIDStartingX;
4795   uint32_t                             ThreadGroupIDXDimension;
4796   uint32_t                             ThreadGroupIDStartingY;
4797   uint32_t                             ThreadGroupIDYDimension;
4798   uint32_t                             ThreadGroupIDStartingZ;
4799   uint32_t                             ThreadGroupIDZDimension;
4800   uint32_t                             RightExecutionMask;
4801   uint32_t                             BottomExecutionMask;
4802};
4803
4804static inline __attribute__((always_inline)) void
4805GFX7_GPGPU_WALKER_pack(__attribute__((unused)) __gen_user_data *data,
4806                       __attribute__((unused)) void * restrict dst,
4807                       __attribute__((unused)) const struct GFX7_GPGPU_WALKER * restrict values)
4808{
4809   uint32_t * restrict dw = (uint32_t * restrict) dst;
4810
4811   dw[0] =
4812      __gen_uint(values->DWordLength, 0, 7) |
4813      __gen_uint(values->PredicateEnable, 8, 8) |
4814      __gen_uint(values->IndirectParameterEnable, 10, 10) |
4815      __gen_uint(values->SubOpcodeA, 16, 23) |
4816      __gen_uint(values->MediaCommandOpcode, 24, 26) |
4817      __gen_uint(values->Pipeline, 27, 28) |
4818      __gen_uint(values->CommandType, 29, 31);
4819
4820   dw[1] =
4821      __gen_uint(values->InterfaceDescriptorOffset, 0, 4);
4822
4823   dw[2] =
4824      __gen_uint(values->ThreadWidthCounterMaximum, 0, 5) |
4825      __gen_uint(values->ThreadHeightCounterMaximum, 8, 13) |
4826      __gen_uint(values->ThreadDepthCounterMaximum, 16, 21) |
4827      __gen_uint(values->SIMDSize, 30, 31);
4828
4829   dw[3] =
4830      __gen_uint(values->ThreadGroupIDStartingX, 0, 31);
4831
4832   dw[4] =
4833      __gen_uint(values->ThreadGroupIDXDimension, 0, 31);
4834
4835   dw[5] =
4836      __gen_uint(values->ThreadGroupIDStartingY, 0, 31);
4837
4838   dw[6] =
4839      __gen_uint(values->ThreadGroupIDYDimension, 0, 31);
4840
4841   dw[7] =
4842      __gen_uint(values->ThreadGroupIDStartingZ, 0, 31);
4843
4844   dw[8] =
4845      __gen_uint(values->ThreadGroupIDZDimension, 0, 31);
4846
4847   dw[9] =
4848      __gen_uint(values->RightExecutionMask, 0, 31);
4849
4850   dw[10] =
4851      __gen_uint(values->BottomExecutionMask, 0, 31);
4852}
4853
4854#define GFX7_MEDIA_CURBE_LOAD_length           4
4855#define GFX7_MEDIA_CURBE_LOAD_length_bias      2
4856#define GFX7_MEDIA_CURBE_LOAD_header            \
4857   .DWordLength                         =      2,  \
4858   .SubOpcode                           =      1,  \
4859   .MediaCommandOpcode                  =      0,  \
4860   .Pipeline                            =      2,  \
4861   .CommandType                         =      3
4862
4863struct GFX7_MEDIA_CURBE_LOAD {
4864   uint32_t                             DWordLength;
4865   uint32_t                             SubOpcode;
4866   uint32_t                             MediaCommandOpcode;
4867   uint32_t                             Pipeline;
4868   uint32_t                             CommandType;
4869   uint32_t                             CURBETotalDataLength;
4870   uint32_t                             CURBEDataStartAddress;
4871};
4872
4873static inline __attribute__((always_inline)) void
4874GFX7_MEDIA_CURBE_LOAD_pack(__attribute__((unused)) __gen_user_data *data,
4875                           __attribute__((unused)) void * restrict dst,
4876                           __attribute__((unused)) const struct GFX7_MEDIA_CURBE_LOAD * restrict values)
4877{
4878   uint32_t * restrict dw = (uint32_t * restrict) dst;
4879
4880   dw[0] =
4881      __gen_uint(values->DWordLength, 0, 15) |
4882      __gen_uint(values->SubOpcode, 16, 23) |
4883      __gen_uint(values->MediaCommandOpcode, 24, 26) |
4884      __gen_uint(values->Pipeline, 27, 28) |
4885      __gen_uint(values->CommandType, 29, 31);
4886
4887   dw[1] = 0;
4888
4889   dw[2] =
4890      __gen_uint(values->CURBETotalDataLength, 0, 16);
4891
4892   dw[3] =
4893      __gen_uint(values->CURBEDataStartAddress, 0, 31);
4894}
4895
4896#define GFX7_MEDIA_INTERFACE_DESCRIPTOR_LOAD_length      4
4897#define GFX7_MEDIA_INTERFACE_DESCRIPTOR_LOAD_length_bias      2
4898#define GFX7_MEDIA_INTERFACE_DESCRIPTOR_LOAD_header\
4899   .DWordLength                         =      2,  \
4900   .SubOpcode                           =      2,  \
4901   .MediaCommandOpcode                  =      0,  \
4902   .Pipeline                            =      2,  \
4903   .CommandType                         =      3
4904
4905struct GFX7_MEDIA_INTERFACE_DESCRIPTOR_LOAD {
4906   uint32_t                             DWordLength;
4907   uint32_t                             SubOpcode;
4908   uint32_t                             MediaCommandOpcode;
4909   uint32_t                             Pipeline;
4910   uint32_t                             CommandType;
4911   uint32_t                             InterfaceDescriptorTotalLength;
4912   uint64_t                             InterfaceDescriptorDataStartAddress;
4913};
4914
4915static inline __attribute__((always_inline)) void
4916GFX7_MEDIA_INTERFACE_DESCRIPTOR_LOAD_pack(__attribute__((unused)) __gen_user_data *data,
4917                                          __attribute__((unused)) void * restrict dst,
4918                                          __attribute__((unused)) const struct GFX7_MEDIA_INTERFACE_DESCRIPTOR_LOAD * restrict values)
4919{
4920   uint32_t * restrict dw = (uint32_t * restrict) dst;
4921
4922   dw[0] =
4923      __gen_uint(values->DWordLength, 0, 15) |
4924      __gen_uint(values->SubOpcode, 16, 23) |
4925      __gen_uint(values->MediaCommandOpcode, 24, 26) |
4926      __gen_uint(values->Pipeline, 27, 28) |
4927      __gen_uint(values->CommandType, 29, 31);
4928
4929   dw[1] = 0;
4930
4931   dw[2] =
4932      __gen_uint(values->InterfaceDescriptorTotalLength, 0, 16);
4933
4934   dw[3] =
4935      __gen_offset(values->InterfaceDescriptorDataStartAddress, 0, 31);
4936}
4937
4938#define GFX7_MEDIA_OBJECT_length_bias          2
4939#define GFX7_MEDIA_OBJECT_header                \
4940   .DWordLength                         =      4,  \
4941   .MediaCommandSubOpcode               =      0,  \
4942   .MediaCommandOpcode                  =      1,  \
4943   .MediaCommandPipeline                =      2,  \
4944   .CommandType                         =      3
4945
4946struct GFX7_MEDIA_OBJECT {
4947   uint32_t                             DWordLength;
4948   uint32_t                             MediaCommandSubOpcode;
4949   uint32_t                             MediaCommandOpcode;
4950   uint32_t                             MediaCommandPipeline;
4951   uint32_t                             CommandType;
4952   uint32_t                             InterfaceDescriptorOffset;
4953   uint32_t                             IndirectDataLength;
4954   uint32_t                             HalfSliceDestinationSelect;
4955#define HalfSlice1                               2
4956#define HalfSlice0                               1
4957#define Eitherhalfslice                          0
4958   uint32_t                             UseScoreboard;
4959#define Notusingscoreboard                       0
4960#define Usingscoreboard                          1
4961   uint32_t                             ThreadSynchronization;
4962#define Nothreadsynchronization                  0
4963#define Threaddispatchissynchronizedbythespawnrootthreadmessage 1
4964   bool                                 ChildrenPresent;
4965   __gen_address_type                   IndirectDataStartAddress;
4966   uint32_t                             ScoreboardX;
4967   uint32_t                             ScoredboardY;
4968   uint32_t                             ScoreboardMask;
4969   uint32_t                             ScoreboardColor;
4970   /* variable length fields follow */
4971};
4972
4973static inline __attribute__((always_inline)) void
4974GFX7_MEDIA_OBJECT_pack(__attribute__((unused)) __gen_user_data *data,
4975                       __attribute__((unused)) void * restrict dst,
4976                       __attribute__((unused)) const struct GFX7_MEDIA_OBJECT * restrict values)
4977{
4978   uint32_t * restrict dw = (uint32_t * restrict) dst;
4979
4980   dw[0] =
4981      __gen_uint(values->DWordLength, 0, 15) |
4982      __gen_uint(values->MediaCommandSubOpcode, 16, 23) |
4983      __gen_uint(values->MediaCommandOpcode, 24, 26) |
4984      __gen_uint(values->MediaCommandPipeline, 27, 28) |
4985      __gen_uint(values->CommandType, 29, 31);
4986
4987   dw[1] =
4988      __gen_uint(values->InterfaceDescriptorOffset, 0, 4);
4989
4990   dw[2] =
4991      __gen_uint(values->IndirectDataLength, 0, 16) |
4992      __gen_uint(values->HalfSliceDestinationSelect, 17, 18) |
4993      __gen_uint(values->UseScoreboard, 21, 21) |
4994      __gen_uint(values->ThreadSynchronization, 24, 24) |
4995      __gen_uint(values->ChildrenPresent, 31, 31);
4996
4997   dw[3] = __gen_address(data, &dw[3], values->IndirectDataStartAddress, 0, 0, 31);
4998
4999   dw[4] =
5000      __gen_uint(values->ScoreboardX, 0, 8) |
5001      __gen_uint(values->ScoredboardY, 16, 24);
5002
5003   dw[5] =
5004      __gen_uint(values->ScoreboardMask, 0, 7) |
5005      __gen_uint(values->ScoreboardColor, 16, 19);
5006}
5007
5008#define GFX7_MEDIA_OBJECT_PRT_length          16
5009#define GFX7_MEDIA_OBJECT_PRT_length_bias      2
5010#define GFX7_MEDIA_OBJECT_PRT_header            \
5011   .DWordLength                         =     14,  \
5012   .SubOpcode                           =      2,  \
5013   .MediaCommandOpcode                  =      1,  \
5014   .Pipeline                            =      2,  \
5015   .CommandType                         =      3
5016
5017struct GFX7_MEDIA_OBJECT_PRT {
5018   uint32_t                             DWordLength;
5019   uint32_t                             SubOpcode;
5020   uint32_t                             MediaCommandOpcode;
5021   uint32_t                             Pipeline;
5022   uint32_t                             CommandType;
5023   uint32_t                             InterfaceDescriptorOffset;
5024   uint32_t                             PRT_FenceType;
5025#define Rootthreadqueue                          0
5026#define VFEstateflush                            1
5027   bool                                 PRT_FenceNeeded;
5028   bool                                 ChildrenPresent;
5029   uint32_t                             InlineData[12];
5030};
5031
5032static inline __attribute__((always_inline)) void
5033GFX7_MEDIA_OBJECT_PRT_pack(__attribute__((unused)) __gen_user_data *data,
5034                           __attribute__((unused)) void * restrict dst,
5035                           __attribute__((unused)) const struct GFX7_MEDIA_OBJECT_PRT * restrict values)
5036{
5037   uint32_t * restrict dw = (uint32_t * restrict) dst;
5038
5039   dw[0] =
5040      __gen_uint(values->DWordLength, 0, 15) |
5041      __gen_uint(values->SubOpcode, 16, 23) |
5042      __gen_uint(values->MediaCommandOpcode, 24, 26) |
5043      __gen_uint(values->Pipeline, 27, 28) |
5044      __gen_uint(values->CommandType, 29, 31);
5045
5046   dw[1] =
5047      __gen_uint(values->InterfaceDescriptorOffset, 0, 4);
5048
5049   dw[2] =
5050      __gen_uint(values->PRT_FenceType, 22, 22) |
5051      __gen_uint(values->PRT_FenceNeeded, 23, 23) |
5052      __gen_uint(values->ChildrenPresent, 31, 31);
5053
5054   dw[3] = 0;
5055
5056   dw[4] =
5057      __gen_uint(values->InlineData[0], 0, 31);
5058
5059   dw[5] =
5060      __gen_uint(values->InlineData[1], 0, 31);
5061
5062   dw[6] =
5063      __gen_uint(values->InlineData[2], 0, 31);
5064
5065   dw[7] =
5066      __gen_uint(values->InlineData[3], 0, 31);
5067
5068   dw[8] =
5069      __gen_uint(values->InlineData[4], 0, 31);
5070
5071   dw[9] =
5072      __gen_uint(values->InlineData[5], 0, 31);
5073
5074   dw[10] =
5075      __gen_uint(values->InlineData[6], 0, 31);
5076
5077   dw[11] =
5078      __gen_uint(values->InlineData[7], 0, 31);
5079
5080   dw[12] =
5081      __gen_uint(values->InlineData[8], 0, 31);
5082
5083   dw[13] =
5084      __gen_uint(values->InlineData[9], 0, 31);
5085
5086   dw[14] =
5087      __gen_uint(values->InlineData[10], 0, 31);
5088
5089   dw[15] =
5090      __gen_uint(values->InlineData[11], 0, 31);
5091}
5092
5093#define GFX7_MEDIA_OBJECT_WALKER_length_bias      2
5094#define GFX7_MEDIA_OBJECT_WALKER_header         \
5095   .DWordLength                         =     15,  \
5096   .SubOpcode                           =      3,  \
5097   .MediaCommandOpcode                  =      1,  \
5098   .Pipeline                            =      2,  \
5099   .CommandType                         =      3
5100
5101struct GFX7_MEDIA_OBJECT_WALKER {
5102   uint32_t                             DWordLength;
5103   uint32_t                             SubOpcode;
5104   uint32_t                             MediaCommandOpcode;
5105   uint32_t                             Pipeline;
5106   uint32_t                             CommandType;
5107   uint32_t                             InterfaceDescriptorOffset;
5108   uint32_t                             IndirectDataLength;
5109   uint32_t                             UseScoreboard;
5110#define Notusingscoreboard                       0
5111#define Usingscoreboard                          1
5112   uint32_t                             ThreadSynchronization;
5113#define Nothreadsynchronization                  0
5114#define Threaddispatchissynchronizedbythespawnrootthreadmessage 1
5115   uint32_t                             ChildrenPresent;
5116   uint64_t                             IndirectDataStartAddress;
5117   uint32_t                             ScoreboardMask;
5118   int32_t                              MidLoopUnitX;
5119   int32_t                              LocalMidLoopUnitY;
5120   uint32_t                             MiddleLoopExtraSteps;
5121   uint32_t                             ColorCountMinusOne;
5122   uint32_t                             Repel;
5123   uint32_t                             DualMode;
5124   uint32_t                             LocalLoopExecCount;
5125   uint32_t                             GlobalLoopExecCount;
5126   uint32_t                             BlockResolutionX;
5127   uint32_t                             BlockResolutionY;
5128   uint32_t                             LocalStartX;
5129   uint32_t                             LocalStartY;
5130   uint32_t                             LocalEndX;
5131   uint32_t                             LocalEndY;
5132   int32_t                              LocalOuterLoopStrideX;
5133   int32_t                              LocalOuterLoopStrideY;
5134   int32_t                              LocalInnerLoopUnitX;
5135   int32_t                              LocalInnerLoopUnitY;
5136   uint32_t                             GlobalResolutionX;
5137   uint32_t                             GlobalResolutionY;
5138   int32_t                              GlobalStartX;
5139   int32_t                              GlobalStartY;
5140   int32_t                              GlobalOuterLoopStrideX;
5141   int32_t                              GlobalOuterLoopStrideY;
5142   int32_t                              GlobalInnerLoopUnitX;
5143   int32_t                              GlobalInnerLoopUnitY;
5144   /* variable length fields follow */
5145};
5146
5147static inline __attribute__((always_inline)) void
5148GFX7_MEDIA_OBJECT_WALKER_pack(__attribute__((unused)) __gen_user_data *data,
5149                              __attribute__((unused)) void * restrict dst,
5150                              __attribute__((unused)) const struct GFX7_MEDIA_OBJECT_WALKER * restrict values)
5151{
5152   uint32_t * restrict dw = (uint32_t * restrict) dst;
5153
5154   dw[0] =
5155      __gen_uint(values->DWordLength, 0, 15) |
5156      __gen_uint(values->SubOpcode, 16, 23) |
5157      __gen_uint(values->MediaCommandOpcode, 24, 26) |
5158      __gen_uint(values->Pipeline, 27, 28) |
5159      __gen_uint(values->CommandType, 29, 31);
5160
5161   dw[1] =
5162      __gen_uint(values->InterfaceDescriptorOffset, 0, 4);
5163
5164   dw[2] =
5165      __gen_uint(values->IndirectDataLength, 0, 16) |
5166      __gen_uint(values->UseScoreboard, 21, 21) |
5167      __gen_uint(values->ThreadSynchronization, 24, 24) |
5168      __gen_uint(values->ChildrenPresent, 31, 31);
5169
5170   dw[3] =
5171      __gen_offset(values->IndirectDataStartAddress, 0, 31);
5172
5173   dw[4] = 0;
5174
5175   dw[5] =
5176      __gen_uint(values->ScoreboardMask, 0, 7);
5177
5178   dw[6] =
5179      __gen_sint(values->MidLoopUnitX, 8, 9) |
5180      __gen_sint(values->LocalMidLoopUnitY, 12, 13) |
5181      __gen_uint(values->MiddleLoopExtraSteps, 16, 20) |
5182      __gen_uint(values->ColorCountMinusOne, 24, 27) |
5183      __gen_uint(values->Repel, 30, 30) |
5184      __gen_uint(values->DualMode, 31, 31);
5185
5186   dw[7] =
5187      __gen_uint(values->LocalLoopExecCount, 0, 9) |
5188      __gen_uint(values->GlobalLoopExecCount, 16, 25);
5189
5190   dw[8] =
5191      __gen_uint(values->BlockResolutionX, 0, 8) |
5192      __gen_uint(values->BlockResolutionY, 16, 24);
5193
5194   dw[9] =
5195      __gen_uint(values->LocalStartX, 0, 8) |
5196      __gen_uint(values->LocalStartY, 16, 24);
5197
5198   dw[10] =
5199      __gen_uint(values->LocalEndX, 0, 8) |
5200      __gen_uint(values->LocalEndY, 16, 24);
5201
5202   dw[11] =
5203      __gen_sint(values->LocalOuterLoopStrideX, 0, 9) |
5204      __gen_sint(values->LocalOuterLoopStrideY, 16, 25);
5205
5206   dw[12] =
5207      __gen_sint(values->LocalInnerLoopUnitX, 0, 9) |
5208      __gen_sint(values->LocalInnerLoopUnitY, 16, 25);
5209
5210   dw[13] =
5211      __gen_uint(values->GlobalResolutionX, 0, 8) |
5212      __gen_uint(values->GlobalResolutionY, 16, 24);
5213
5214   dw[14] =
5215      __gen_sint(values->GlobalStartX, 0, 9) |
5216      __gen_sint(values->GlobalStartY, 16, 25);
5217
5218   dw[15] =
5219      __gen_sint(values->GlobalOuterLoopStrideX, 0, 9) |
5220      __gen_sint(values->GlobalOuterLoopStrideY, 16, 25);
5221
5222   dw[16] =
5223      __gen_sint(values->GlobalInnerLoopUnitX, 0, 9) |
5224      __gen_sint(values->GlobalInnerLoopUnitY, 16, 25);
5225}
5226
5227#define GFX7_MEDIA_STATE_FLUSH_length          2
5228#define GFX7_MEDIA_STATE_FLUSH_length_bias      2
5229#define GFX7_MEDIA_STATE_FLUSH_header           \
5230   .DWordLength                         =      0,  \
5231   .SubOpcode                           =      4,  \
5232   .MediaCommandOpcode                  =      0,  \
5233   .Pipeline                            =      2,  \
5234   .CommandType                         =      3
5235
5236struct GFX7_MEDIA_STATE_FLUSH {
5237   uint32_t                             DWordLength;
5238   uint32_t                             SubOpcode;
5239   uint32_t                             MediaCommandOpcode;
5240   uint32_t                             Pipeline;
5241   uint32_t                             CommandType;
5242   uint32_t                             InterfaceDescriptorOffset;
5243   uint32_t                             WatermarkRequired;
5244};
5245
5246static inline __attribute__((always_inline)) void
5247GFX7_MEDIA_STATE_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
5248                            __attribute__((unused)) void * restrict dst,
5249                            __attribute__((unused)) const struct GFX7_MEDIA_STATE_FLUSH * restrict values)
5250{
5251   uint32_t * restrict dw = (uint32_t * restrict) dst;
5252
5253   dw[0] =
5254      __gen_uint(values->DWordLength, 0, 15) |
5255      __gen_uint(values->SubOpcode, 16, 23) |
5256      __gen_uint(values->MediaCommandOpcode, 24, 26) |
5257      __gen_uint(values->Pipeline, 27, 28) |
5258      __gen_uint(values->CommandType, 29, 31);
5259
5260   dw[1] =
5261      __gen_uint(values->InterfaceDescriptorOffset, 0, 5) |
5262      __gen_uint(values->WatermarkRequired, 6, 6);
5263}
5264
5265#define GFX7_MEDIA_VFE_STATE_length            8
5266#define GFX7_MEDIA_VFE_STATE_length_bias       2
5267#define GFX7_MEDIA_VFE_STATE_header             \
5268   .DWordLength                         =      6,  \
5269   .SubOpcode                           =      0,  \
5270   .MediaCommandOpcode                  =      0,  \
5271   .Pipeline                            =      2,  \
5272   .CommandType                         =      3
5273
5274struct GFX7_MEDIA_VFE_STATE {
5275   uint32_t                             DWordLength;
5276   uint32_t                             SubOpcode;
5277   uint32_t                             MediaCommandOpcode;
5278   uint32_t                             Pipeline;
5279   uint32_t                             CommandType;
5280   uint32_t                             PerThreadScratchSpace;
5281   __gen_address_type                   ScratchSpaceBasePointer;
5282   bool                                 GPGPUMode;
5283   uint32_t                             GatewayMMIOAccessControl;
5284#define NoMMIOreadwriteallowed                   0
5285#define MMIOreadwritetoanyaddress                2
5286   uint32_t                             BypassGatewayControl;
5287#define MaintainingOpenGatewayForwardMsgCloseGatewayprotocollegacymode 0
5288#define BypassingOpenGatewayCloseGatewayprotocol 1
5289   uint32_t                             ResetGatewayTimer;
5290#define Maintainingtheexistingtimestampstate     0
5291#define Resettingrelativetimerandlatchingtheglobaltimestamp 1
5292   uint32_t                             NumberofURBEntries;
5293   uint32_t                             MaximumNumberofThreads;
5294   uint32_t                             CURBEAllocationSize;
5295   uint32_t                             URBEntryAllocationSize;
5296   uint32_t                             ScoreboardMask;
5297   uint32_t                             ScoreboardType;
5298#define StallingScoreboard                       0
5299#define NonStallingScoreboard                    1
5300   uint32_t                             ScoreboardEnable;
5301#define Scoreboarddisabled                       0
5302#define Scoreboardenabled                        1
5303   int32_t                              Scoreboard0DeltaX;
5304   int32_t                              Scoreboard0DeltaY;
5305   int32_t                              Scoreboard1DeltaX;
5306   int32_t                              Scoreboard1DeltaY;
5307   int32_t                              Scoreboard2DeltaX;
5308   int32_t                              Scoreboard2DeltaY;
5309   int32_t                              Scoreboard3DeltaX;
5310   int32_t                              Scoreboard3DeltaY;
5311   int32_t                              Scoreboard4DeltaX;
5312   int32_t                              Scoreboard4DeltaY;
5313   int32_t                              Scoreboard5DeltaX;
5314   int32_t                              Scoreboard5DeltaY;
5315   int32_t                              Scoreboard6DeltaX;
5316   int32_t                              Scoreboard6DeltaY;
5317   int32_t                              Scoreboard7DeltaX;
5318   int32_t                              Scoreboard7DeltaY;
5319};
5320
5321static inline __attribute__((always_inline)) void
5322GFX7_MEDIA_VFE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
5323                          __attribute__((unused)) void * restrict dst,
5324                          __attribute__((unused)) const struct GFX7_MEDIA_VFE_STATE * restrict values)
5325{
5326   uint32_t * restrict dw = (uint32_t * restrict) dst;
5327
5328   dw[0] =
5329      __gen_uint(values->DWordLength, 0, 15) |
5330      __gen_uint(values->SubOpcode, 16, 23) |
5331      __gen_uint(values->MediaCommandOpcode, 24, 26) |
5332      __gen_uint(values->Pipeline, 27, 28) |
5333      __gen_uint(values->CommandType, 29, 31);
5334
5335   const uint32_t v1 =
5336      __gen_uint(values->PerThreadScratchSpace, 0, 3);
5337   dw[1] = __gen_address(data, &dw[1], values->ScratchSpaceBasePointer, v1, 10, 31);
5338
5339   dw[2] =
5340      __gen_uint(values->GPGPUMode, 2, 2) |
5341      __gen_uint(values->GatewayMMIOAccessControl, 3, 4) |
5342      __gen_uint(values->BypassGatewayControl, 6, 6) |
5343      __gen_uint(values->ResetGatewayTimer, 7, 7) |
5344      __gen_uint(values->NumberofURBEntries, 8, 15) |
5345      __gen_uint(values->MaximumNumberofThreads, 16, 31);
5346
5347   dw[3] = 0;
5348
5349   dw[4] =
5350      __gen_uint(values->CURBEAllocationSize, 0, 15) |
5351      __gen_uint(values->URBEntryAllocationSize, 16, 31);
5352
5353   dw[5] =
5354      __gen_uint(values->ScoreboardMask, 0, 7) |
5355      __gen_uint(values->ScoreboardType, 30, 30) |
5356      __gen_uint(values->ScoreboardEnable, 31, 31);
5357
5358   dw[6] =
5359      __gen_sint(values->Scoreboard0DeltaX, 0, 3) |
5360      __gen_sint(values->Scoreboard0DeltaY, 4, 7) |
5361      __gen_sint(values->Scoreboard1DeltaX, 8, 11) |
5362      __gen_sint(values->Scoreboard1DeltaY, 12, 15) |
5363      __gen_sint(values->Scoreboard2DeltaX, 16, 19) |
5364      __gen_sint(values->Scoreboard2DeltaY, 20, 23) |
5365      __gen_sint(values->Scoreboard3DeltaX, 24, 27) |
5366      __gen_sint(values->Scoreboard3DeltaY, 28, 31);
5367
5368   dw[7] =
5369      __gen_sint(values->Scoreboard4DeltaX, 0, 3) |
5370      __gen_sint(values->Scoreboard4DeltaY, 4, 7) |
5371      __gen_sint(values->Scoreboard5DeltaX, 8, 11) |
5372      __gen_sint(values->Scoreboard5DeltaY, 12, 15) |
5373      __gen_sint(values->Scoreboard6DeltaX, 16, 19) |
5374      __gen_sint(values->Scoreboard6DeltaY, 20, 23) |
5375      __gen_sint(values->Scoreboard7DeltaX, 24, 27) |
5376      __gen_sint(values->Scoreboard7DeltaY, 28, 31);
5377}
5378
5379#define GFX7_MI_ARB_CHECK_length               1
5380#define GFX7_MI_ARB_CHECK_length_bias          1
5381#define GFX7_MI_ARB_CHECK_header                \
5382   .MICommandOpcode                     =      5,  \
5383   .CommandType                         =      0
5384
5385struct GFX7_MI_ARB_CHECK {
5386   uint32_t                             MICommandOpcode;
5387   uint32_t                             CommandType;
5388};
5389
5390static inline __attribute__((always_inline)) void
5391GFX7_MI_ARB_CHECK_pack(__attribute__((unused)) __gen_user_data *data,
5392                       __attribute__((unused)) void * restrict dst,
5393                       __attribute__((unused)) const struct GFX7_MI_ARB_CHECK * restrict values)
5394{
5395   uint32_t * restrict dw = (uint32_t * restrict) dst;
5396
5397   dw[0] =
5398      __gen_uint(values->MICommandOpcode, 23, 28) |
5399      __gen_uint(values->CommandType, 29, 31);
5400}
5401
5402#define GFX7_MI_ARB_ON_OFF_length              1
5403#define GFX7_MI_ARB_ON_OFF_length_bias         1
5404#define GFX7_MI_ARB_ON_OFF_header               \
5405   .MICommandOpcode                     =      8,  \
5406   .CommandType                         =      0
5407
5408struct GFX7_MI_ARB_ON_OFF {
5409   bool                                 ArbitrationEnable;
5410   uint32_t                             MICommandOpcode;
5411   uint32_t                             CommandType;
5412};
5413
5414static inline __attribute__((always_inline)) void
5415GFX7_MI_ARB_ON_OFF_pack(__attribute__((unused)) __gen_user_data *data,
5416                        __attribute__((unused)) void * restrict dst,
5417                        __attribute__((unused)) const struct GFX7_MI_ARB_ON_OFF * restrict values)
5418{
5419   uint32_t * restrict dw = (uint32_t * restrict) dst;
5420
5421   dw[0] =
5422      __gen_uint(values->ArbitrationEnable, 0, 0) |
5423      __gen_uint(values->MICommandOpcode, 23, 28) |
5424      __gen_uint(values->CommandType, 29, 31);
5425}
5426
5427#define GFX7_MI_BATCH_BUFFER_END_length        1
5428#define GFX7_MI_BATCH_BUFFER_END_length_bias      1
5429#define GFX7_MI_BATCH_BUFFER_END_header         \
5430   .MICommandOpcode                     =     10,  \
5431   .CommandType                         =      0
5432
5433struct GFX7_MI_BATCH_BUFFER_END {
5434   uint32_t                             MICommandOpcode;
5435   uint32_t                             CommandType;
5436};
5437
5438static inline __attribute__((always_inline)) void
5439GFX7_MI_BATCH_BUFFER_END_pack(__attribute__((unused)) __gen_user_data *data,
5440                              __attribute__((unused)) void * restrict dst,
5441                              __attribute__((unused)) const struct GFX7_MI_BATCH_BUFFER_END * restrict values)
5442{
5443   uint32_t * restrict dw = (uint32_t * restrict) dst;
5444
5445   dw[0] =
5446      __gen_uint(values->MICommandOpcode, 23, 28) |
5447      __gen_uint(values->CommandType, 29, 31);
5448}
5449
5450#define GFX7_MI_BATCH_BUFFER_START_length      2
5451#define GFX7_MI_BATCH_BUFFER_START_length_bias      2
5452#define GFX7_MI_BATCH_BUFFER_START_header       \
5453   .DWordLength                         =      0,  \
5454   .MICommandOpcode                     =     49,  \
5455   .CommandType                         =      0
5456
5457struct GFX7_MI_BATCH_BUFFER_START {
5458   uint32_t                             DWordLength;
5459   uint32_t                             AddressSpaceIndicator;
5460#define ASI_GGTT                                 0
5461#define ASI_PPGTT                                1
5462   bool                                 ClearCommandBufferEnable;
5463   uint32_t                             MICommandOpcode;
5464   uint32_t                             CommandType;
5465   __gen_address_type                   BatchBufferStartAddress;
5466};
5467
5468static inline __attribute__((always_inline)) void
5469GFX7_MI_BATCH_BUFFER_START_pack(__attribute__((unused)) __gen_user_data *data,
5470                                __attribute__((unused)) void * restrict dst,
5471                                __attribute__((unused)) const struct GFX7_MI_BATCH_BUFFER_START * restrict values)
5472{
5473   uint32_t * restrict dw = (uint32_t * restrict) dst;
5474
5475   dw[0] =
5476      __gen_uint(values->DWordLength, 0, 7) |
5477      __gen_uint(values->AddressSpaceIndicator, 8, 8) |
5478      __gen_uint(values->ClearCommandBufferEnable, 11, 11) |
5479      __gen_uint(values->MICommandOpcode, 23, 28) |
5480      __gen_uint(values->CommandType, 29, 31);
5481
5482   dw[1] = __gen_address(data, &dw[1], values->BatchBufferStartAddress, 0, 2, 31);
5483}
5484
5485#define GFX7_MI_CLFLUSH_length_bias            2
5486#define GFX7_MI_CLFLUSH_header                  \
5487   .DWordLength                         =      1,  \
5488   .MICommandOpcode                     =     39,  \
5489   .CommandType                         =      0
5490
5491struct GFX7_MI_CLFLUSH {
5492   uint32_t                             DWordLength;
5493   bool                                 UseGlobalGTT;
5494   uint32_t                             MICommandOpcode;
5495   uint32_t                             CommandType;
5496   uint32_t                             StartingCachelineOffset;
5497   __gen_address_type                   PageBaseAddress;
5498   __gen_address_type                   PageBaseAddressHigh;
5499   /* variable length fields follow */
5500};
5501
5502static inline __attribute__((always_inline)) void
5503GFX7_MI_CLFLUSH_pack(__attribute__((unused)) __gen_user_data *data,
5504                     __attribute__((unused)) void * restrict dst,
5505                     __attribute__((unused)) const struct GFX7_MI_CLFLUSH * restrict values)
5506{
5507   uint32_t * restrict dw = (uint32_t * restrict) dst;
5508
5509   dw[0] =
5510      __gen_uint(values->DWordLength, 0, 9) |
5511      __gen_uint(values->UseGlobalGTT, 22, 22) |
5512      __gen_uint(values->MICommandOpcode, 23, 28) |
5513      __gen_uint(values->CommandType, 29, 31);
5514
5515   const uint32_t v1 =
5516      __gen_uint(values->StartingCachelineOffset, 6, 11);
5517   dw[1] = __gen_address(data, &dw[1], values->PageBaseAddress, v1, 12, 31);
5518
5519   dw[2] = __gen_address(data, &dw[2], values->PageBaseAddressHigh, 0, 0, 15);
5520}
5521
5522#define GFX7_MI_CONDITIONAL_BATCH_BUFFER_END_length      2
5523#define GFX7_MI_CONDITIONAL_BATCH_BUFFER_END_length_bias      2
5524#define GFX7_MI_CONDITIONAL_BATCH_BUFFER_END_header\
5525   .DWordLength                         =      0,  \
5526   .CompareSemaphore                    =      0,  \
5527   .MICommandOpcode                     =     54,  \
5528   .CommandType                         =      0
5529
5530struct GFX7_MI_CONDITIONAL_BATCH_BUFFER_END {
5531   uint32_t                             DWordLength;
5532   uint32_t                             CompareSemaphore;
5533   bool                                 UseGlobalGTT;
5534   uint32_t                             MICommandOpcode;
5535   uint32_t                             CommandType;
5536   uint32_t                             CompareDataDword;
5537   __gen_address_type                   CompareAddress;
5538};
5539
5540static inline __attribute__((always_inline)) void
5541GFX7_MI_CONDITIONAL_BATCH_BUFFER_END_pack(__attribute__((unused)) __gen_user_data *data,
5542                                          __attribute__((unused)) void * restrict dst,
5543                                          __attribute__((unused)) const struct GFX7_MI_CONDITIONAL_BATCH_BUFFER_END * restrict values)
5544{
5545   uint32_t * restrict dw = (uint32_t * restrict) dst;
5546
5547   dw[0] =
5548      __gen_uint(values->DWordLength, 0, 7) |
5549      __gen_uint(values->CompareSemaphore, 21, 21) |
5550      __gen_uint(values->UseGlobalGTT, 22, 22) |
5551      __gen_uint(values->MICommandOpcode, 23, 28) |
5552      __gen_uint(values->CommandType, 29, 31);
5553
5554   dw[1] =
5555      __gen_uint(values->CompareDataDword, 0, 31);
5556}
5557
5558#define GFX7_MI_FLUSH_length                   1
5559#define GFX7_MI_FLUSH_length_bias              1
5560#define GFX7_MI_FLUSH_header                    \
5561   .MICommandOpcode                     =      4,  \
5562   .CommandType                         =      0
5563
5564struct GFX7_MI_FLUSH {
5565   uint32_t                             StateInstructionCacheInvalidate;
5566#define DontInvalidate                           0
5567#define Invalidate                               1
5568   uint32_t                             RenderCacheFlushInhibit;
5569#define Flush                                    0
5570#define DontFlush                                1
5571   uint32_t                             GlobalSnapshotCountReset;
5572#define DontReset                                0
5573#define Reset                                    1
5574   bool                                 GenericMediaStateClear;
5575   bool                                 IndirectStatePointersDisable;
5576   uint32_t                             MICommandOpcode;
5577   uint32_t                             CommandType;
5578};
5579
5580static inline __attribute__((always_inline)) void
5581GFX7_MI_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
5582                   __attribute__((unused)) void * restrict dst,
5583                   __attribute__((unused)) const struct GFX7_MI_FLUSH * restrict values)
5584{
5585   uint32_t * restrict dw = (uint32_t * restrict) dst;
5586
5587   dw[0] =
5588      __gen_uint(values->StateInstructionCacheInvalidate, 1, 1) |
5589      __gen_uint(values->RenderCacheFlushInhibit, 2, 2) |
5590      __gen_uint(values->GlobalSnapshotCountReset, 3, 3) |
5591      __gen_uint(values->GenericMediaStateClear, 4, 4) |
5592      __gen_uint(values->IndirectStatePointersDisable, 5, 5) |
5593      __gen_uint(values->MICommandOpcode, 23, 28) |
5594      __gen_uint(values->CommandType, 29, 31);
5595}
5596
5597#define GFX7_MI_LOAD_REGISTER_IMM_length       3
5598#define GFX7_MI_LOAD_REGISTER_IMM_length_bias      2
5599#define GFX7_MI_LOAD_REGISTER_IMM_header        \
5600   .DWordLength                         =      1,  \
5601   .MICommandOpcode                     =     34,  \
5602   .CommandType                         =      0
5603
5604struct GFX7_MI_LOAD_REGISTER_IMM {
5605   uint32_t                             DWordLength;
5606   uint32_t                             ByteWriteDisables;
5607   uint32_t                             MICommandOpcode;
5608   uint32_t                             CommandType;
5609   uint64_t                             RegisterOffset;
5610   uint32_t                             DataDWord;
5611   /* variable length fields follow */
5612};
5613
5614static inline __attribute__((always_inline)) void
5615GFX7_MI_LOAD_REGISTER_IMM_pack(__attribute__((unused)) __gen_user_data *data,
5616                               __attribute__((unused)) void * restrict dst,
5617                               __attribute__((unused)) const struct GFX7_MI_LOAD_REGISTER_IMM * restrict values)
5618{
5619   uint32_t * restrict dw = (uint32_t * restrict) dst;
5620
5621   dw[0] =
5622      __gen_uint(values->DWordLength, 0, 7) |
5623      __gen_uint(values->ByteWriteDisables, 8, 11) |
5624      __gen_uint(values->MICommandOpcode, 23, 28) |
5625      __gen_uint(values->CommandType, 29, 31);
5626
5627   dw[1] =
5628      __gen_offset(values->RegisterOffset, 2, 22);
5629
5630   dw[2] =
5631      __gen_uint(values->DataDWord, 0, 31);
5632}
5633
5634#define GFX7_MI_LOAD_REGISTER_MEM_length       3
5635#define GFX7_MI_LOAD_REGISTER_MEM_length_bias      2
5636#define GFX7_MI_LOAD_REGISTER_MEM_header        \
5637   .DWordLength                         =      1,  \
5638   .MICommandOpcode                     =     41,  \
5639   .CommandType                         =      0
5640
5641struct GFX7_MI_LOAD_REGISTER_MEM {
5642   uint32_t                             DWordLength;
5643   bool                                 AsyncModeEnable;
5644   bool                                 UseGlobalGTT;
5645   uint32_t                             MICommandOpcode;
5646   uint32_t                             CommandType;
5647   uint64_t                             RegisterAddress;
5648   __gen_address_type                   MemoryAddress;
5649};
5650
5651static inline __attribute__((always_inline)) void
5652GFX7_MI_LOAD_REGISTER_MEM_pack(__attribute__((unused)) __gen_user_data *data,
5653                               __attribute__((unused)) void * restrict dst,
5654                               __attribute__((unused)) const struct GFX7_MI_LOAD_REGISTER_MEM * restrict values)
5655{
5656   uint32_t * restrict dw = (uint32_t * restrict) dst;
5657
5658   dw[0] =
5659      __gen_uint(values->DWordLength, 0, 7) |
5660      __gen_uint(values->AsyncModeEnable, 21, 21) |
5661      __gen_uint(values->UseGlobalGTT, 22, 22) |
5662      __gen_uint(values->MICommandOpcode, 23, 28) |
5663      __gen_uint(values->CommandType, 29, 31);
5664
5665   dw[1] =
5666      __gen_offset(values->RegisterAddress, 2, 22);
5667
5668   dw[2] = __gen_address(data, &dw[2], values->MemoryAddress, 0, 2, 31);
5669}
5670
5671#define GFX7_MI_NOOP_length                    1
5672#define GFX7_MI_NOOP_length_bias               1
5673#define GFX7_MI_NOOP_header                     \
5674   .MICommandOpcode                     =      0,  \
5675   .CommandType                         =      0
5676
5677struct GFX7_MI_NOOP {
5678   uint32_t                             IdentificationNumber;
5679   bool                                 IdentificationNumberRegisterWriteEnable;
5680   uint32_t                             MICommandOpcode;
5681   uint32_t                             CommandType;
5682};
5683
5684static inline __attribute__((always_inline)) void
5685GFX7_MI_NOOP_pack(__attribute__((unused)) __gen_user_data *data,
5686                  __attribute__((unused)) void * restrict dst,
5687                  __attribute__((unused)) const struct GFX7_MI_NOOP * restrict values)
5688{
5689   uint32_t * restrict dw = (uint32_t * restrict) dst;
5690
5691   dw[0] =
5692      __gen_uint(values->IdentificationNumber, 0, 21) |
5693      __gen_uint(values->IdentificationNumberRegisterWriteEnable, 22, 22) |
5694      __gen_uint(values->MICommandOpcode, 23, 28) |
5695      __gen_uint(values->CommandType, 29, 31);
5696}
5697
5698#define GFX7_MI_PREDICATE_length               1
5699#define GFX7_MI_PREDICATE_length_bias          1
5700#define GFX7_MI_PREDICATE_header                \
5701   .MICommandOpcode                     =     12,  \
5702   .CommandType                         =      0
5703
5704struct GFX7_MI_PREDICATE {
5705   uint32_t                             CompareOperation;
5706#define COMPARE_TRUE                             0
5707#define COMPARE_FALSE                            1
5708#define COMPARE_SRCS_EQUAL                       2
5709#define COMPARE_DELTAS_EQUAL                     3
5710   uint32_t                             CombineOperation;
5711#define COMBINE_SET                              0
5712#define COMBINE_AND                              1
5713#define COMBINE_OR                               2
5714#define COMBINE_XOR                              3
5715   uint32_t                             LoadOperation;
5716#define LOAD_KEEP                                0
5717#define LOAD_LOAD                                2
5718#define LOAD_LOADINV                             3
5719   uint32_t                             MICommandOpcode;
5720   uint32_t                             CommandType;
5721};
5722
5723static inline __attribute__((always_inline)) void
5724GFX7_MI_PREDICATE_pack(__attribute__((unused)) __gen_user_data *data,
5725                       __attribute__((unused)) void * restrict dst,
5726                       __attribute__((unused)) const struct GFX7_MI_PREDICATE * restrict values)
5727{
5728   uint32_t * restrict dw = (uint32_t * restrict) dst;
5729
5730   dw[0] =
5731      __gen_uint(values->CompareOperation, 0, 1) |
5732      __gen_uint(values->CombineOperation, 3, 4) |
5733      __gen_uint(values->LoadOperation, 6, 7) |
5734      __gen_uint(values->MICommandOpcode, 23, 28) |
5735      __gen_uint(values->CommandType, 29, 31);
5736}
5737
5738#define GFX7_MI_REPORT_HEAD_length             1
5739#define GFX7_MI_REPORT_HEAD_length_bias        1
5740#define GFX7_MI_REPORT_HEAD_header              \
5741   .MICommandOpcode                     =      7,  \
5742   .CommandType                         =      0
5743
5744struct GFX7_MI_REPORT_HEAD {
5745   uint32_t                             MICommandOpcode;
5746   uint32_t                             CommandType;
5747};
5748
5749static inline __attribute__((always_inline)) void
5750GFX7_MI_REPORT_HEAD_pack(__attribute__((unused)) __gen_user_data *data,
5751                         __attribute__((unused)) void * restrict dst,
5752                         __attribute__((unused)) const struct GFX7_MI_REPORT_HEAD * restrict values)
5753{
5754   uint32_t * restrict dw = (uint32_t * restrict) dst;
5755
5756   dw[0] =
5757      __gen_uint(values->MICommandOpcode, 23, 28) |
5758      __gen_uint(values->CommandType, 29, 31);
5759}
5760
5761#define GFX7_MI_REPORT_PERF_COUNT_length       3
5762#define GFX7_MI_REPORT_PERF_COUNT_length_bias      2
5763#define GFX7_MI_REPORT_PERF_COUNT_header        \
5764   .DWordLength                         =      1,  \
5765   .MICommandOpcode                     =     40,  \
5766   .CommandType                         =      0
5767
5768struct GFX7_MI_REPORT_PERF_COUNT {
5769   uint32_t                             DWordLength;
5770   uint32_t                             MICommandOpcode;
5771   uint32_t                             CommandType;
5772   bool                                 UseGlobalGTT;
5773   __gen_address_type                   MemoryAddress;
5774   uint32_t                             ReportID;
5775};
5776
5777static inline __attribute__((always_inline)) void
5778GFX7_MI_REPORT_PERF_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
5779                               __attribute__((unused)) void * restrict dst,
5780                               __attribute__((unused)) const struct GFX7_MI_REPORT_PERF_COUNT * restrict values)
5781{
5782   uint32_t * restrict dw = (uint32_t * restrict) dst;
5783
5784   dw[0] =
5785      __gen_uint(values->DWordLength, 0, 5) |
5786      __gen_uint(values->MICommandOpcode, 23, 28) |
5787      __gen_uint(values->CommandType, 29, 31);
5788
5789   const uint32_t v1 =
5790      __gen_uint(values->UseGlobalGTT, 0, 0);
5791   dw[1] = __gen_address(data, &dw[1], values->MemoryAddress, v1, 6, 31);
5792
5793   dw[2] =
5794      __gen_uint(values->ReportID, 0, 31);
5795}
5796
5797#define GFX7_MI_SEMAPHORE_MBOX_length          3
5798#define GFX7_MI_SEMAPHORE_MBOX_length_bias      2
5799#define GFX7_MI_SEMAPHORE_MBOX_header           \
5800   .DWordLength                         =      1,  \
5801   .MICommandOpcode                     =     22,  \
5802   .CommandType                         =      0
5803
5804struct GFX7_MI_SEMAPHORE_MBOX {
5805   uint32_t                             DWordLength;
5806   uint32_t                             RegisterSelect;
5807#define RVSYNC                                   0
5808#define RBSYNC                                   2
5809#define UseGeneralRegisterSelect                 3
5810   uint32_t                             MICommandOpcode;
5811   uint32_t                             CommandType;
5812   uint32_t                             SemaphoreDataDword;
5813};
5814
5815static inline __attribute__((always_inline)) void
5816GFX7_MI_SEMAPHORE_MBOX_pack(__attribute__((unused)) __gen_user_data *data,
5817                            __attribute__((unused)) void * restrict dst,
5818                            __attribute__((unused)) const struct GFX7_MI_SEMAPHORE_MBOX * restrict values)
5819{
5820   uint32_t * restrict dw = (uint32_t * restrict) dst;
5821
5822   dw[0] =
5823      __gen_uint(values->DWordLength, 0, 7) |
5824      __gen_uint(values->RegisterSelect, 16, 17) |
5825      __gen_uint(values->MICommandOpcode, 23, 28) |
5826      __gen_uint(values->CommandType, 29, 31);
5827
5828   dw[1] =
5829      __gen_uint(values->SemaphoreDataDword, 0, 31);
5830
5831   dw[2] = 0;
5832}
5833
5834#define GFX7_MI_SET_CONTEXT_length             2
5835#define GFX7_MI_SET_CONTEXT_length_bias        2
5836#define GFX7_MI_SET_CONTEXT_header              \
5837   .DWordLength                         =      0,  \
5838   .MICommandOpcode                     =     24,  \
5839   .CommandType                         =      0
5840
5841struct GFX7_MI_SET_CONTEXT {
5842   uint32_t                             DWordLength;
5843   uint32_t                             MICommandOpcode;
5844   uint32_t                             CommandType;
5845   uint32_t                             RestoreInhibit;
5846   uint32_t                             ForceRestore;
5847   bool                                 ExtendedStateRestoreEnable;
5848   bool                                 ExtendedStateSaveEnable;
5849   uint32_t                             ReservedMustbe1;
5850   __gen_address_type                   LogicalContextAddress;
5851};
5852
5853static inline __attribute__((always_inline)) void
5854GFX7_MI_SET_CONTEXT_pack(__attribute__((unused)) __gen_user_data *data,
5855                         __attribute__((unused)) void * restrict dst,
5856                         __attribute__((unused)) const struct GFX7_MI_SET_CONTEXT * restrict values)
5857{
5858   uint32_t * restrict dw = (uint32_t * restrict) dst;
5859
5860   dw[0] =
5861      __gen_uint(values->DWordLength, 0, 7) |
5862      __gen_uint(values->MICommandOpcode, 23, 28) |
5863      __gen_uint(values->CommandType, 29, 31);
5864
5865   const uint32_t v1 =
5866      __gen_uint(values->RestoreInhibit, 0, 0) |
5867      __gen_uint(values->ForceRestore, 1, 1) |
5868      __gen_uint(values->ExtendedStateRestoreEnable, 2, 2) |
5869      __gen_uint(values->ExtendedStateSaveEnable, 3, 3) |
5870      __gen_uint(values->ReservedMustbe1, 8, 8);
5871   dw[1] = __gen_address(data, &dw[1], values->LogicalContextAddress, v1, 12, 31);
5872}
5873
5874#define GFX7_MI_STORE_DATA_IMM_length          4
5875#define GFX7_MI_STORE_DATA_IMM_length_bias      2
5876#define GFX7_MI_STORE_DATA_IMM_header           \
5877   .DWordLength                         =      2,  \
5878   .MICommandOpcode                     =     32,  \
5879   .CommandType                         =      0
5880
5881struct GFX7_MI_STORE_DATA_IMM {
5882   uint32_t                             DWordLength;
5883   bool                                 UseGlobalGTT;
5884   uint32_t                             MICommandOpcode;
5885   uint32_t                             CommandType;
5886   uint32_t                             CoreModeEnable;
5887   __gen_address_type                   Address;
5888   uint64_t                             ImmediateData;
5889};
5890
5891static inline __attribute__((always_inline)) void
5892GFX7_MI_STORE_DATA_IMM_pack(__attribute__((unused)) __gen_user_data *data,
5893                            __attribute__((unused)) void * restrict dst,
5894                            __attribute__((unused)) const struct GFX7_MI_STORE_DATA_IMM * restrict values)
5895{
5896   uint32_t * restrict dw = (uint32_t * restrict) dst;
5897
5898   dw[0] =
5899      __gen_uint(values->DWordLength, 0, 5) |
5900      __gen_uint(values->UseGlobalGTT, 22, 22) |
5901      __gen_uint(values->MICommandOpcode, 23, 28) |
5902      __gen_uint(values->CommandType, 29, 31);
5903
5904   dw[1] = 0;
5905
5906   const uint32_t v2 =
5907      __gen_uint(values->CoreModeEnable, 0, 0);
5908   dw[2] = __gen_address(data, &dw[2], values->Address, v2, 2, 31);
5909
5910   const uint64_t v3 =
5911      __gen_uint(values->ImmediateData, 0, 63);
5912   dw[3] = v3;
5913   dw[4] = v3 >> 32;
5914}
5915
5916#define GFX7_MI_STORE_DATA_INDEX_length        3
5917#define GFX7_MI_STORE_DATA_INDEX_length_bias      2
5918#define GFX7_MI_STORE_DATA_INDEX_header         \
5919   .DWordLength                         =      1,  \
5920   .MICommandOpcode                     =     33,  \
5921   .CommandType                         =      0
5922
5923struct GFX7_MI_STORE_DATA_INDEX {
5924   uint32_t                             DWordLength;
5925   uint32_t                             MICommandOpcode;
5926   uint32_t                             CommandType;
5927   uint32_t                             Offset;
5928   uint32_t                             DataDWord0;
5929   uint32_t                             DataDWord1;
5930};
5931
5932static inline __attribute__((always_inline)) void
5933GFX7_MI_STORE_DATA_INDEX_pack(__attribute__((unused)) __gen_user_data *data,
5934                              __attribute__((unused)) void * restrict dst,
5935                              __attribute__((unused)) const struct GFX7_MI_STORE_DATA_INDEX * restrict values)
5936{
5937   uint32_t * restrict dw = (uint32_t * restrict) dst;
5938
5939   dw[0] =
5940      __gen_uint(values->DWordLength, 0, 7) |
5941      __gen_uint(values->MICommandOpcode, 23, 28) |
5942      __gen_uint(values->CommandType, 29, 31);
5943
5944   dw[1] =
5945      __gen_uint(values->Offset, 2, 11);
5946
5947   dw[2] =
5948      __gen_uint(values->DataDWord0, 0, 31);
5949}
5950
5951#define GFX7_MI_STORE_REGISTER_MEM_length      3
5952#define GFX7_MI_STORE_REGISTER_MEM_length_bias      2
5953#define GFX7_MI_STORE_REGISTER_MEM_header       \
5954   .DWordLength                         =      1,  \
5955   .MICommandOpcode                     =     36,  \
5956   .CommandType                         =      0
5957
5958struct GFX7_MI_STORE_REGISTER_MEM {
5959   uint32_t                             DWordLength;
5960   bool                                 UseGlobalGTT;
5961   uint32_t                             MICommandOpcode;
5962   uint32_t                             CommandType;
5963   uint64_t                             RegisterAddress;
5964   __gen_address_type                   MemoryAddress;
5965};
5966
5967static inline __attribute__((always_inline)) void
5968GFX7_MI_STORE_REGISTER_MEM_pack(__attribute__((unused)) __gen_user_data *data,
5969                                __attribute__((unused)) void * restrict dst,
5970                                __attribute__((unused)) const struct GFX7_MI_STORE_REGISTER_MEM * restrict values)
5971{
5972   uint32_t * restrict dw = (uint32_t * restrict) dst;
5973
5974   dw[0] =
5975      __gen_uint(values->DWordLength, 0, 7) |
5976      __gen_uint(values->UseGlobalGTT, 22, 22) |
5977      __gen_uint(values->MICommandOpcode, 23, 28) |
5978      __gen_uint(values->CommandType, 29, 31);
5979
5980   dw[1] =
5981      __gen_offset(values->RegisterAddress, 2, 22);
5982
5983   dw[2] = __gen_address(data, &dw[2], values->MemoryAddress, 0, 2, 31);
5984}
5985
5986#define GFX7_MI_SUSPEND_FLUSH_length           1
5987#define GFX7_MI_SUSPEND_FLUSH_length_bias      1
5988#define GFX7_MI_SUSPEND_FLUSH_header            \
5989   .MICommandOpcode                     =     11,  \
5990   .CommandType                         =      0
5991
5992struct GFX7_MI_SUSPEND_FLUSH {
5993   bool                                 SuspendFlush;
5994   uint32_t                             MICommandOpcode;
5995   uint32_t                             CommandType;
5996};
5997
5998static inline __attribute__((always_inline)) void
5999GFX7_MI_SUSPEND_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
6000                           __attribute__((unused)) void * restrict dst,
6001                           __attribute__((unused)) const struct GFX7_MI_SUSPEND_FLUSH * restrict values)
6002{
6003   uint32_t * restrict dw = (uint32_t * restrict) dst;
6004
6005   dw[0] =
6006      __gen_uint(values->SuspendFlush, 0, 0) |
6007      __gen_uint(values->MICommandOpcode, 23, 28) |
6008      __gen_uint(values->CommandType, 29, 31);
6009}
6010
6011#define GFX7_MI_TOPOLOGY_FILTER_length         1
6012#define GFX7_MI_TOPOLOGY_FILTER_length_bias      1
6013#define GFX7_MI_TOPOLOGY_FILTER_header          \
6014   .MICommandOpcode                     =     13,  \
6015   .CommandType                         =      0
6016
6017struct GFX7_MI_TOPOLOGY_FILTER {
6018   enum GFX7_3D_Prim_Topo_Type          TopologyFilterValue;
6019   uint32_t                             MICommandOpcode;
6020   uint32_t                             CommandType;
6021};
6022
6023static inline __attribute__((always_inline)) void
6024GFX7_MI_TOPOLOGY_FILTER_pack(__attribute__((unused)) __gen_user_data *data,
6025                             __attribute__((unused)) void * restrict dst,
6026                             __attribute__((unused)) const struct GFX7_MI_TOPOLOGY_FILTER * restrict values)
6027{
6028   uint32_t * restrict dw = (uint32_t * restrict) dst;
6029
6030   dw[0] =
6031      __gen_uint(values->TopologyFilterValue, 0, 5) |
6032      __gen_uint(values->MICommandOpcode, 23, 28) |
6033      __gen_uint(values->CommandType, 29, 31);
6034}
6035
6036#define GFX7_MI_URB_CLEAR_length               2
6037#define GFX7_MI_URB_CLEAR_length_bias          2
6038#define GFX7_MI_URB_CLEAR_header                \
6039   .DWordLength                         =      0,  \
6040   .MICommandOpcode                     =     25,  \
6041   .CommandType                         =      0
6042
6043struct GFX7_MI_URB_CLEAR {
6044   uint32_t                             DWordLength;
6045   uint32_t                             MICommandOpcode;
6046   uint32_t                             CommandType;
6047   uint64_t                             URBAddress;
6048   uint32_t                             URBClearLength;
6049};
6050
6051static inline __attribute__((always_inline)) void
6052GFX7_MI_URB_CLEAR_pack(__attribute__((unused)) __gen_user_data *data,
6053                       __attribute__((unused)) void * restrict dst,
6054                       __attribute__((unused)) const struct GFX7_MI_URB_CLEAR * restrict values)
6055{
6056   uint32_t * restrict dw = (uint32_t * restrict) dst;
6057
6058   dw[0] =
6059      __gen_uint(values->DWordLength, 0, 7) |
6060      __gen_uint(values->MICommandOpcode, 23, 28) |
6061      __gen_uint(values->CommandType, 29, 31);
6062
6063   dw[1] =
6064      __gen_offset(values->URBAddress, 0, 13) |
6065      __gen_uint(values->URBClearLength, 16, 28);
6066}
6067
6068#define GFX7_MI_USER_INTERRUPT_length          1
6069#define GFX7_MI_USER_INTERRUPT_length_bias      1
6070#define GFX7_MI_USER_INTERRUPT_header           \
6071   .MICommandOpcode                     =      2,  \
6072   .CommandType                         =      0
6073
6074struct GFX7_MI_USER_INTERRUPT {
6075   uint32_t                             MICommandOpcode;
6076   uint32_t                             CommandType;
6077};
6078
6079static inline __attribute__((always_inline)) void
6080GFX7_MI_USER_INTERRUPT_pack(__attribute__((unused)) __gen_user_data *data,
6081                            __attribute__((unused)) void * restrict dst,
6082                            __attribute__((unused)) const struct GFX7_MI_USER_INTERRUPT * restrict values)
6083{
6084   uint32_t * restrict dw = (uint32_t * restrict) dst;
6085
6086   dw[0] =
6087      __gen_uint(values->MICommandOpcode, 23, 28) |
6088      __gen_uint(values->CommandType, 29, 31);
6089}
6090
6091#define GFX7_MI_WAIT_FOR_EVENT_length          1
6092#define GFX7_MI_WAIT_FOR_EVENT_length_bias      1
6093#define GFX7_MI_WAIT_FOR_EVENT_header           \
6094   .MICommandOpcode                     =      3,  \
6095   .CommandType                         =      0
6096
6097struct GFX7_MI_WAIT_FOR_EVENT {
6098   bool                                 DisplayPipeAScanLineWaitEnable;
6099   bool                                 DisplayPlaneAFlipPendingWaitEnable;
6100   bool                                 DisplaySpriteAFlipPendingWaitEnable;
6101   bool                                 DisplayPipeAVerticalBlankWaitEnable;
6102   bool                                 DisplayPipeAHorizontalBlankWaitEnable;
6103   bool                                 DisplayPipeBScanLineWaitEnable;
6104   bool                                 DisplayPlaneBFlipPendingWaitEnable;
6105   bool                                 DisplaySpriteBFlipPendingWaitEnable;
6106   bool                                 DisplayPipeBVerticalBlankWaitEnable;
6107   bool                                 DisplayPipeBHorizontalBlankWaitEnable;
6108   bool                                 DisplayPipeCScanLineWaitEnable;
6109   bool                                 DisplayPlaneCFlipPendingWaitEnable;
6110   uint32_t                             ConditionCodeWaitSelect;
6111#define Notenabled                               0
6112   bool                                 DisplaySpriteCFlipPendingWaitEnable;
6113   bool                                 DisplayPipeCVerticalBlankWaitEnable;
6114   bool                                 DisplayPipeCHorizontalBlankWaitEnable;
6115   uint32_t                             MICommandOpcode;
6116   uint32_t                             CommandType;
6117};
6118
6119static inline __attribute__((always_inline)) void
6120GFX7_MI_WAIT_FOR_EVENT_pack(__attribute__((unused)) __gen_user_data *data,
6121                            __attribute__((unused)) void * restrict dst,
6122                            __attribute__((unused)) const struct GFX7_MI_WAIT_FOR_EVENT * restrict values)
6123{
6124   uint32_t * restrict dw = (uint32_t * restrict) dst;
6125
6126   dw[0] =
6127      __gen_uint(values->DisplayPipeAScanLineWaitEnable, 0, 0) |
6128      __gen_uint(values->DisplayPlaneAFlipPendingWaitEnable, 1, 1) |
6129      __gen_uint(values->DisplaySpriteAFlipPendingWaitEnable, 2, 2) |
6130      __gen_uint(values->DisplayPipeAVerticalBlankWaitEnable, 3, 3) |
6131      __gen_uint(values->DisplayPipeAHorizontalBlankWaitEnable, 5, 5) |
6132      __gen_uint(values->DisplayPipeBScanLineWaitEnable, 8, 8) |
6133      __gen_uint(values->DisplayPlaneBFlipPendingWaitEnable, 9, 9) |
6134      __gen_uint(values->DisplaySpriteBFlipPendingWaitEnable, 10, 10) |
6135      __gen_uint(values->DisplayPipeBVerticalBlankWaitEnable, 11, 11) |
6136      __gen_uint(values->DisplayPipeBHorizontalBlankWaitEnable, 13, 13) |
6137      __gen_uint(values->DisplayPipeCScanLineWaitEnable, 14, 14) |
6138      __gen_uint(values->DisplayPlaneCFlipPendingWaitEnable, 15, 15) |
6139      __gen_uint(values->ConditionCodeWaitSelect, 16, 19) |
6140      __gen_uint(values->DisplaySpriteCFlipPendingWaitEnable, 20, 20) |
6141      __gen_uint(values->DisplayPipeCVerticalBlankWaitEnable, 21, 21) |
6142      __gen_uint(values->DisplayPipeCHorizontalBlankWaitEnable, 22, 22) |
6143      __gen_uint(values->MICommandOpcode, 23, 28) |
6144      __gen_uint(values->CommandType, 29, 31);
6145}
6146
6147#define GFX7_PIPELINE_SELECT_length            1
6148#define GFX7_PIPELINE_SELECT_length_bias       1
6149#define GFX7_PIPELINE_SELECT_header             \
6150   ._3DCommandSubOpcode                 =      4,  \
6151   ._3DCommandOpcode                    =      1,  \
6152   .CommandSubType                      =      1,  \
6153   .CommandType                         =      3
6154
6155struct GFX7_PIPELINE_SELECT {
6156   uint32_t                             PipelineSelection;
6157#define _3D                                      0
6158#define Media                                    1
6159#define GPGPU                                    2
6160   uint32_t                             _3DCommandSubOpcode;
6161   uint32_t                             _3DCommandOpcode;
6162   uint32_t                             CommandSubType;
6163   uint32_t                             CommandType;
6164};
6165
6166static inline __attribute__((always_inline)) void
6167GFX7_PIPELINE_SELECT_pack(__attribute__((unused)) __gen_user_data *data,
6168                          __attribute__((unused)) void * restrict dst,
6169                          __attribute__((unused)) const struct GFX7_PIPELINE_SELECT * restrict values)
6170{
6171   uint32_t * restrict dw = (uint32_t * restrict) dst;
6172
6173   dw[0] =
6174      __gen_uint(values->PipelineSelection, 0, 1) |
6175      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
6176      __gen_uint(values->_3DCommandOpcode, 24, 26) |
6177      __gen_uint(values->CommandSubType, 27, 28) |
6178      __gen_uint(values->CommandType, 29, 31);
6179}
6180
6181#define GFX7_PIPE_CONTROL_length               5
6182#define GFX7_PIPE_CONTROL_length_bias          2
6183#define GFX7_PIPE_CONTROL_header                \
6184   .DWordLength                         =      3,  \
6185   ._3DCommandSubOpcode                 =      0,  \
6186   ._3DCommandOpcode                    =      2,  \
6187   .CommandSubType                      =      3,  \
6188   .CommandType                         =      3
6189
6190struct GFX7_PIPE_CONTROL {
6191   uint32_t                             DWordLength;
6192   uint32_t                             _3DCommandSubOpcode;
6193   uint32_t                             _3DCommandOpcode;
6194   uint32_t                             CommandSubType;
6195   uint32_t                             CommandType;
6196   bool                                 DepthCacheFlushEnable;
6197   bool                                 StallAtPixelScoreboard;
6198   bool                                 StateCacheInvalidationEnable;
6199   bool                                 ConstantCacheInvalidationEnable;
6200   bool                                 VFCacheInvalidationEnable;
6201   bool                                 DCFlushEnable;
6202   bool                                 PipeControlFlushEnable;
6203   bool                                 NotifyEnable;
6204   bool                                 IndirectStatePointersDisable;
6205   bool                                 TextureCacheInvalidationEnable;
6206   bool                                 InstructionCacheInvalidateEnable;
6207   bool                                 RenderTargetCacheFlushEnable;
6208   bool                                 DepthStallEnable;
6209   uint32_t                             PostSyncOperation;
6210#define NoWrite                                  0
6211#define WriteImmediateData                       1
6212#define WritePSDepthCount                        2
6213#define WriteTimestamp                           3
6214   bool                                 GenericMediaStateClear;
6215   bool                                 TLBInvalidate;
6216   bool                                 GlobalSnapshotCountReset;
6217   bool                                 CommandStreamerStallEnable;
6218   uint32_t                             StoreDataIndex;
6219   uint32_t                             LRIPostSyncOperation;
6220#define NoLRIOperation                           0
6221#define MMIOWriteImmediateData                   1
6222   uint32_t                             DestinationAddressType;
6223#define DAT_PPGTT                                0
6224#define DAT_GGTT                                 1
6225   __gen_address_type                   Address;
6226   uint64_t                             ImmediateData;
6227};
6228
6229static inline __attribute__((always_inline)) void
6230GFX7_PIPE_CONTROL_pack(__attribute__((unused)) __gen_user_data *data,
6231                       __attribute__((unused)) void * restrict dst,
6232                       __attribute__((unused)) const struct GFX7_PIPE_CONTROL * restrict values)
6233{
6234   uint32_t * restrict dw = (uint32_t * restrict) dst;
6235
6236   dw[0] =
6237      __gen_uint(values->DWordLength, 0, 7) |
6238      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
6239      __gen_uint(values->_3DCommandOpcode, 24, 26) |
6240      __gen_uint(values->CommandSubType, 27, 28) |
6241      __gen_uint(values->CommandType, 29, 31);
6242
6243   dw[1] =
6244      __gen_uint(values->DepthCacheFlushEnable, 0, 0) |
6245      __gen_uint(values->StallAtPixelScoreboard, 1, 1) |
6246      __gen_uint(values->StateCacheInvalidationEnable, 2, 2) |
6247      __gen_uint(values->ConstantCacheInvalidationEnable, 3, 3) |
6248      __gen_uint(values->VFCacheInvalidationEnable, 4, 4) |
6249      __gen_uint(values->DCFlushEnable, 5, 5) |
6250      __gen_uint(values->PipeControlFlushEnable, 7, 7) |
6251      __gen_uint(values->NotifyEnable, 8, 8) |
6252      __gen_uint(values->IndirectStatePointersDisable, 9, 9) |
6253      __gen_uint(values->TextureCacheInvalidationEnable, 10, 10) |
6254      __gen_uint(values->InstructionCacheInvalidateEnable, 11, 11) |
6255      __gen_uint(values->RenderTargetCacheFlushEnable, 12, 12) |
6256      __gen_uint(values->DepthStallEnable, 13, 13) |
6257      __gen_uint(values->PostSyncOperation, 14, 15) |
6258      __gen_uint(values->GenericMediaStateClear, 16, 16) |
6259      __gen_uint(values->TLBInvalidate, 18, 18) |
6260      __gen_uint(values->GlobalSnapshotCountReset, 19, 19) |
6261      __gen_uint(values->CommandStreamerStallEnable, 20, 20) |
6262      __gen_uint(values->StoreDataIndex, 21, 21) |
6263      __gen_uint(values->LRIPostSyncOperation, 23, 23) |
6264      __gen_uint(values->DestinationAddressType, 24, 24);
6265
6266   dw[2] = __gen_address(data, &dw[2], values->Address, 0, 2, 31);
6267
6268   const uint64_t v3 =
6269      __gen_uint(values->ImmediateData, 0, 63);
6270   dw[3] = v3;
6271   dw[4] = v3 >> 32;
6272}
6273
6274#define GFX7_STATE_BASE_ADDRESS_length        10
6275#define GFX7_STATE_BASE_ADDRESS_length_bias      2
6276#define GFX7_STATE_BASE_ADDRESS_header          \
6277   .DWordLength                         =      8,  \
6278   ._3DCommandSubOpcode                 =      1,  \
6279   ._3DCommandOpcode                    =      1,  \
6280   .CommandSubType                      =      0,  \
6281   .CommandType                         =      3
6282
6283struct GFX7_STATE_BASE_ADDRESS {
6284   uint32_t                             DWordLength;
6285   uint32_t                             _3DCommandSubOpcode;
6286   uint32_t                             _3DCommandOpcode;
6287   uint32_t                             CommandSubType;
6288   uint32_t                             CommandType;
6289   bool                                 GeneralStateBaseAddressModifyEnable;
6290   uint32_t                             StatelessDataPortAccessForceWriteThru;
6291   uint32_t                             StatelessDataPortAccessMOCS;
6292   uint32_t                             GeneralStateMOCS;
6293   __gen_address_type                   GeneralStateBaseAddress;
6294   bool                                 SurfaceStateBaseAddressModifyEnable;
6295   uint32_t                             SurfaceStateMOCS;
6296   __gen_address_type                   SurfaceStateBaseAddress;
6297   bool                                 DynamicStateBaseAddressModifyEnable;
6298   uint32_t                             DynamicStateMOCS;
6299   __gen_address_type                   DynamicStateBaseAddress;
6300   bool                                 IndirectObjectBaseAddressModifyEnable;
6301   uint32_t                             IndirectObjectMOCS;
6302   __gen_address_type                   IndirectObjectBaseAddress;
6303   bool                                 InstructionBaseAddressModifyEnable;
6304   uint32_t                             InstructionMOCS;
6305   __gen_address_type                   InstructionBaseAddress;
6306   bool                                 GeneralStateAccessUpperBoundModifyEnable;
6307   __gen_address_type                   GeneralStateAccessUpperBound;
6308   bool                                 DynamicStateAccessUpperBoundModifyEnable;
6309   __gen_address_type                   DynamicStateAccessUpperBound;
6310   bool                                 IndirectObjectAccessUpperBoundModifyEnable;
6311   __gen_address_type                   IndirectObjectAccessUpperBound;
6312   bool                                 InstructionAccessUpperBoundModifyEnable;
6313   __gen_address_type                   InstructionAccessUpperBound;
6314};
6315
6316static inline __attribute__((always_inline)) void
6317GFX7_STATE_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data,
6318                             __attribute__((unused)) void * restrict dst,
6319                             __attribute__((unused)) const struct GFX7_STATE_BASE_ADDRESS * restrict values)
6320{
6321   uint32_t * restrict dw = (uint32_t * restrict) dst;
6322
6323   dw[0] =
6324      __gen_uint(values->DWordLength, 0, 7) |
6325      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
6326      __gen_uint(values->_3DCommandOpcode, 24, 26) |
6327      __gen_uint(values->CommandSubType, 27, 28) |
6328      __gen_uint(values->CommandType, 29, 31);
6329
6330   const uint32_t v1 =
6331      __gen_uint(values->GeneralStateBaseAddressModifyEnable, 0, 0) |
6332      __gen_uint(values->StatelessDataPortAccessForceWriteThru, 3, 3) |
6333      __gen_uint(values->StatelessDataPortAccessMOCS, 4, 7) |
6334      __gen_uint(values->GeneralStateMOCS, 8, 11);
6335   dw[1] = __gen_address(data, &dw[1], values->GeneralStateBaseAddress, v1, 12, 31);
6336
6337   const uint32_t v2 =
6338      __gen_uint(values->SurfaceStateBaseAddressModifyEnable, 0, 0) |
6339      __gen_uint(values->SurfaceStateMOCS, 8, 11);
6340   dw[2] = __gen_address(data, &dw[2], values->SurfaceStateBaseAddress, v2, 12, 31);
6341
6342   const uint32_t v3 =
6343      __gen_uint(values->DynamicStateBaseAddressModifyEnable, 0, 0) |
6344      __gen_uint(values->DynamicStateMOCS, 8, 11);
6345   dw[3] = __gen_address(data, &dw[3], values->DynamicStateBaseAddress, v3, 12, 31);
6346
6347   const uint32_t v4 =
6348      __gen_uint(values->IndirectObjectBaseAddressModifyEnable, 0, 0) |
6349      __gen_uint(values->IndirectObjectMOCS, 8, 11);
6350   dw[4] = __gen_address(data, &dw[4], values->IndirectObjectBaseAddress, v4, 12, 31);
6351
6352   const uint32_t v5 =
6353      __gen_uint(values->InstructionBaseAddressModifyEnable, 0, 0) |
6354      __gen_uint(values->InstructionMOCS, 8, 11);
6355   dw[5] = __gen_address(data, &dw[5], values->InstructionBaseAddress, v5, 12, 31);
6356
6357   const uint32_t v6 =
6358      __gen_uint(values->GeneralStateAccessUpperBoundModifyEnable, 0, 0);
6359   dw[6] = __gen_address(data, &dw[6], values->GeneralStateAccessUpperBound, v6, 12, 31);
6360
6361   const uint32_t v7 =
6362      __gen_uint(values->DynamicStateAccessUpperBoundModifyEnable, 0, 0);
6363   dw[7] = __gen_address(data, &dw[7], values->DynamicStateAccessUpperBound, v7, 12, 31);
6364
6365   const uint32_t v8 =
6366      __gen_uint(values->IndirectObjectAccessUpperBoundModifyEnable, 0, 0);
6367   dw[8] = __gen_address(data, &dw[8], values->IndirectObjectAccessUpperBound, v8, 12, 31);
6368
6369   const uint32_t v9 =
6370      __gen_uint(values->InstructionAccessUpperBoundModifyEnable, 0, 0);
6371   dw[9] = __gen_address(data, &dw[9], values->InstructionAccessUpperBound, v9, 12, 31);
6372}
6373
6374#define GFX7_STATE_PREFETCH_length             2
6375#define GFX7_STATE_PREFETCH_length_bias        2
6376#define GFX7_STATE_PREFETCH_header              \
6377   .DWordLength                         =      0,  \
6378   ._3DCommandSubOpcode                 =      3,  \
6379   ._3DCommandOpcode                    =      0,  \
6380   .CommandSubType                      =      0,  \
6381   .CommandType                         =      3
6382
6383struct GFX7_STATE_PREFETCH {
6384   uint32_t                             DWordLength;
6385   uint32_t                             _3DCommandSubOpcode;
6386   uint32_t                             _3DCommandOpcode;
6387   uint32_t                             CommandSubType;
6388   uint32_t                             CommandType;
6389   uint32_t                             PrefetchCount;
6390   __gen_address_type                   PrefetchPointer;
6391};
6392
6393static inline __attribute__((always_inline)) void
6394GFX7_STATE_PREFETCH_pack(__attribute__((unused)) __gen_user_data *data,
6395                         __attribute__((unused)) void * restrict dst,
6396                         __attribute__((unused)) const struct GFX7_STATE_PREFETCH * restrict values)
6397{
6398   uint32_t * restrict dw = (uint32_t * restrict) dst;
6399
6400   dw[0] =
6401      __gen_uint(values->DWordLength, 0, 7) |
6402      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
6403      __gen_uint(values->_3DCommandOpcode, 24, 26) |
6404      __gen_uint(values->CommandSubType, 27, 28) |
6405      __gen_uint(values->CommandType, 29, 31);
6406
6407   const uint32_t v1 =
6408      __gen_uint(values->PrefetchCount, 0, 2);
6409   dw[1] = __gen_address(data, &dw[1], values->PrefetchPointer, v1, 6, 31);
6410}
6411
6412#define GFX7_STATE_SIP_length                  2
6413#define GFX7_STATE_SIP_length_bias             2
6414#define GFX7_STATE_SIP_header                   \
6415   .DWordLength                         =      0,  \
6416   ._3DCommandSubOpcode                 =      2,  \
6417   ._3DCommandOpcode                    =      1,  \
6418   .CommandSubType                      =      0,  \
6419   .CommandType                         =      3
6420
6421struct GFX7_STATE_SIP {
6422   uint32_t                             DWordLength;
6423   uint32_t                             _3DCommandSubOpcode;
6424   uint32_t                             _3DCommandOpcode;
6425   uint32_t                             CommandSubType;
6426   uint32_t                             CommandType;
6427   uint64_t                             SystemInstructionPointer;
6428};
6429
6430static inline __attribute__((always_inline)) void
6431GFX7_STATE_SIP_pack(__attribute__((unused)) __gen_user_data *data,
6432                    __attribute__((unused)) void * restrict dst,
6433                    __attribute__((unused)) const struct GFX7_STATE_SIP * restrict values)
6434{
6435   uint32_t * restrict dw = (uint32_t * restrict) dst;
6436
6437   dw[0] =
6438      __gen_uint(values->DWordLength, 0, 7) |
6439      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
6440      __gen_uint(values->_3DCommandOpcode, 24, 26) |
6441      __gen_uint(values->CommandSubType, 27, 28) |
6442      __gen_uint(values->CommandType, 29, 31);
6443
6444   dw[1] =
6445      __gen_offset(values->SystemInstructionPointer, 4, 31);
6446}
6447
6448#define GFX7_SWTESS_BASE_ADDRESS_length        2
6449#define GFX7_SWTESS_BASE_ADDRESS_length_bias      2
6450#define GFX7_SWTESS_BASE_ADDRESS_header         \
6451   .DWordLength                         =      0,  \
6452   ._3DCommandSubOpcode                 =      3,  \
6453   ._3DCommandOpcode                    =      1,  \
6454   .CommandSubType                      =      0,  \
6455   .CommandType                         =      3
6456
6457struct GFX7_SWTESS_BASE_ADDRESS {
6458   uint32_t                             DWordLength;
6459   uint32_t                             _3DCommandSubOpcode;
6460   uint32_t                             _3DCommandOpcode;
6461   uint32_t                             CommandSubType;
6462   uint32_t                             CommandType;
6463   uint32_t                             SWTessellationMOCS;
6464   __gen_address_type                   SWTessellationBaseAddress;
6465};
6466
6467static inline __attribute__((always_inline)) void
6468GFX7_SWTESS_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data,
6469                              __attribute__((unused)) void * restrict dst,
6470                              __attribute__((unused)) const struct GFX7_SWTESS_BASE_ADDRESS * restrict values)
6471{
6472   uint32_t * restrict dw = (uint32_t * restrict) dst;
6473
6474   dw[0] =
6475      __gen_uint(values->DWordLength, 0, 7) |
6476      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
6477      __gen_uint(values->_3DCommandOpcode, 24, 26) |
6478      __gen_uint(values->CommandSubType, 27, 28) |
6479      __gen_uint(values->CommandType, 29, 31);
6480
6481   const uint32_t v1 =
6482      __gen_uint(values->SWTessellationMOCS, 8, 11);
6483   dw[1] = __gen_address(data, &dw[1], values->SWTessellationBaseAddress, v1, 12, 31);
6484}
6485
6486#define GFX7_BCS_FAULT_REG_num            0x4294
6487#define GFX7_BCS_FAULT_REG_length              1
6488struct GFX7_BCS_FAULT_REG {
6489   bool                                 ValidBit;
6490   uint32_t                             FaultType;
6491#define PageFault                                0
6492#define InvalidPDFault                           1
6493#define UnloadedPDFault                          2
6494#define InvalidandUnloadedPDfault                3
6495   uint32_t                             SRCIDofFault;
6496   uint32_t                             GTTSEL;
6497#define PPGTT                                    0
6498#define GGTT                                     1
6499   __gen_address_type                   VirtualAddressofFault;
6500};
6501
6502static inline __attribute__((always_inline)) void
6503GFX7_BCS_FAULT_REG_pack(__attribute__((unused)) __gen_user_data *data,
6504                        __attribute__((unused)) void * restrict dst,
6505                        __attribute__((unused)) const struct GFX7_BCS_FAULT_REG * restrict values)
6506{
6507   uint32_t * restrict dw = (uint32_t * restrict) dst;
6508
6509   const uint32_t v0 =
6510      __gen_uint(values->ValidBit, 0, 0) |
6511      __gen_uint(values->FaultType, 1, 2) |
6512      __gen_uint(values->SRCIDofFault, 3, 10) |
6513      __gen_uint(values->GTTSEL, 11, 11);
6514   dw[0] = __gen_address(data, &dw[0], values->VirtualAddressofFault, v0, 12, 31);
6515}
6516
6517#define GFX7_BCS_INSTDONE_num             0x2206c
6518#define GFX7_BCS_INSTDONE_length               1
6519struct GFX7_BCS_INSTDONE {
6520   bool                                 RingEnable;
6521   bool                                 BlitterIDLE;
6522   bool                                 GABIDLE;
6523   bool                                 BCSDone;
6524};
6525
6526static inline __attribute__((always_inline)) void
6527GFX7_BCS_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
6528                       __attribute__((unused)) void * restrict dst,
6529                       __attribute__((unused)) const struct GFX7_BCS_INSTDONE * restrict values)
6530{
6531   uint32_t * restrict dw = (uint32_t * restrict) dst;
6532
6533   dw[0] =
6534      __gen_uint(values->RingEnable, 0, 0) |
6535      __gen_uint(values->BlitterIDLE, 1, 1) |
6536      __gen_uint(values->GABIDLE, 2, 2) |
6537      __gen_uint(values->BCSDone, 3, 3);
6538}
6539
6540#define GFX7_BCS_RING_BUFFER_CTL_num      0x2203c
6541#define GFX7_BCS_RING_BUFFER_CTL_length        1
6542struct GFX7_BCS_RING_BUFFER_CTL {
6543   bool                                 RingBufferEnable;
6544   uint32_t                             AutomaticReportHeadPointer;
6545#define MI_AUTOREPORT_OFF                        0
6546#define MI_AUTOREPORT_64KB                       1
6547#define MI_AUTOREPORT_4KB                        2
6548#define MI_AUTOREPORT_128KB                      3
6549   bool                                 DisableRegisterAccesses;
6550   bool                                 SemaphoreWait;
6551   bool                                 RBWait;
6552   uint32_t                             BufferLengthinpages1;
6553};
6554
6555static inline __attribute__((always_inline)) void
6556GFX7_BCS_RING_BUFFER_CTL_pack(__attribute__((unused)) __gen_user_data *data,
6557                              __attribute__((unused)) void * restrict dst,
6558                              __attribute__((unused)) const struct GFX7_BCS_RING_BUFFER_CTL * restrict values)
6559{
6560   uint32_t * restrict dw = (uint32_t * restrict) dst;
6561
6562   dw[0] =
6563      __gen_uint(values->RingBufferEnable, 0, 0) |
6564      __gen_uint(values->AutomaticReportHeadPointer, 1, 2) |
6565      __gen_uint(values->DisableRegisterAccesses, 8, 8) |
6566      __gen_uint(values->SemaphoreWait, 10, 10) |
6567      __gen_uint(values->RBWait, 11, 11) |
6568      __gen_uint(values->BufferLengthinpages1, 12, 20);
6569}
6570
6571#define GFX7_CL_INVOCATION_COUNT_num      0x2338
6572#define GFX7_CL_INVOCATION_COUNT_length        2
6573struct GFX7_CL_INVOCATION_COUNT {
6574   uint64_t                             CLInvocationCountReport;
6575};
6576
6577static inline __attribute__((always_inline)) void
6578GFX7_CL_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
6579                              __attribute__((unused)) void * restrict dst,
6580                              __attribute__((unused)) const struct GFX7_CL_INVOCATION_COUNT * restrict values)
6581{
6582   uint32_t * restrict dw = (uint32_t * restrict) dst;
6583
6584   const uint64_t v0 =
6585      __gen_uint(values->CLInvocationCountReport, 0, 63);
6586   dw[0] = v0;
6587   dw[1] = v0 >> 32;
6588}
6589
6590#define GFX7_CL_PRIMITIVES_COUNT_num      0x2340
6591#define GFX7_CL_PRIMITIVES_COUNT_length        2
6592struct GFX7_CL_PRIMITIVES_COUNT {
6593   uint64_t                             CLPrimitivesCountReport;
6594};
6595
6596static inline __attribute__((always_inline)) void
6597GFX7_CL_PRIMITIVES_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
6598                              __attribute__((unused)) void * restrict dst,
6599                              __attribute__((unused)) const struct GFX7_CL_PRIMITIVES_COUNT * restrict values)
6600{
6601   uint32_t * restrict dw = (uint32_t * restrict) dst;
6602
6603   const uint64_t v0 =
6604      __gen_uint(values->CLPrimitivesCountReport, 0, 63);
6605   dw[0] = v0;
6606   dw[1] = v0 >> 32;
6607}
6608
6609#define GFX7_CS_INVOCATION_COUNT_num      0x2290
6610#define GFX7_CS_INVOCATION_COUNT_length        2
6611struct GFX7_CS_INVOCATION_COUNT {
6612   uint64_t                             CSInvocationCountReport;
6613};
6614
6615static inline __attribute__((always_inline)) void
6616GFX7_CS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
6617                              __attribute__((unused)) void * restrict dst,
6618                              __attribute__((unused)) const struct GFX7_CS_INVOCATION_COUNT * restrict values)
6619{
6620   uint32_t * restrict dw = (uint32_t * restrict) dst;
6621
6622   const uint64_t v0 =
6623      __gen_uint(values->CSInvocationCountReport, 0, 63);
6624   dw[0] = v0;
6625   dw[1] = v0 >> 32;
6626}
6627
6628#define GFX7_DS_INVOCATION_COUNT_num      0x2308
6629#define GFX7_DS_INVOCATION_COUNT_length        2
6630struct GFX7_DS_INVOCATION_COUNT {
6631   uint64_t                             DSInvocationCountReport;
6632};
6633
6634static inline __attribute__((always_inline)) void
6635GFX7_DS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
6636                              __attribute__((unused)) void * restrict dst,
6637                              __attribute__((unused)) const struct GFX7_DS_INVOCATION_COUNT * restrict values)
6638{
6639   uint32_t * restrict dw = (uint32_t * restrict) dst;
6640
6641   const uint64_t v0 =
6642      __gen_uint(values->DSInvocationCountReport, 0, 63);
6643   dw[0] = v0;
6644   dw[1] = v0 >> 32;
6645}
6646
6647#define GFX7_ERR_INT_num                  0x44040
6648#define GFX7_ERR_INT_length                    1
6649struct GFX7_ERR_INT {
6650   bool                                 PrimaryAGTTFaultStatus;
6651   bool                                 PrimaryBGTTFaultStatus;
6652   bool                                 SpriteAGTTFaultStatus;
6653   bool                                 SpriteBGTTFaultStatus;
6654   bool                                 CursorAGTTFaultStatus;
6655   bool                                 CursorBGTTFaultStatus;
6656   bool                                 Invalidpagetableentrydata;
6657   bool                                 InvalidGTTpagetableentry;
6658};
6659
6660static inline __attribute__((always_inline)) void
6661GFX7_ERR_INT_pack(__attribute__((unused)) __gen_user_data *data,
6662                  __attribute__((unused)) void * restrict dst,
6663                  __attribute__((unused)) const struct GFX7_ERR_INT * restrict values)
6664{
6665   uint32_t * restrict dw = (uint32_t * restrict) dst;
6666
6667   dw[0] =
6668      __gen_uint(values->PrimaryAGTTFaultStatus, 0, 0) |
6669      __gen_uint(values->PrimaryBGTTFaultStatus, 1, 1) |
6670      __gen_uint(values->SpriteAGTTFaultStatus, 2, 2) |
6671      __gen_uint(values->SpriteBGTTFaultStatus, 3, 3) |
6672      __gen_uint(values->CursorAGTTFaultStatus, 4, 4) |
6673      __gen_uint(values->CursorBGTTFaultStatus, 5, 5) |
6674      __gen_uint(values->Invalidpagetableentrydata, 6, 6) |
6675      __gen_uint(values->InvalidGTTpagetableentry, 7, 7);
6676}
6677
6678#define GFX7_GFX_ARB_ERROR_RPT_num        0x40a0
6679#define GFX7_GFX_ARB_ERROR_RPT_length          1
6680struct GFX7_GFX_ARB_ERROR_RPT {
6681   bool                                 TLBPageFaultError;
6682   bool                                 ContextPageFaultError;
6683   bool                                 InvalidPageDirectoryentryerror;
6684   bool                                 HardwareStatusPageFaultError;
6685   bool                                 TLBPageVTDTranslationError;
6686   bool                                 ContextPageVTDTranslationError;
6687   bool                                 PageDirectoryEntryVTDTranslationError;
6688   bool                                 HardwareStatusPageVTDTranslationError;
6689   bool                                 UnloadedPDError;
6690};
6691
6692static inline __attribute__((always_inline)) void
6693GFX7_GFX_ARB_ERROR_RPT_pack(__attribute__((unused)) __gen_user_data *data,
6694                            __attribute__((unused)) void * restrict dst,
6695                            __attribute__((unused)) const struct GFX7_GFX_ARB_ERROR_RPT * restrict values)
6696{
6697   uint32_t * restrict dw = (uint32_t * restrict) dst;
6698
6699   dw[0] =
6700      __gen_uint(values->TLBPageFaultError, 0, 0) |
6701      __gen_uint(values->ContextPageFaultError, 1, 1) |
6702      __gen_uint(values->InvalidPageDirectoryentryerror, 2, 2) |
6703      __gen_uint(values->HardwareStatusPageFaultError, 3, 3) |
6704      __gen_uint(values->TLBPageVTDTranslationError, 4, 4) |
6705      __gen_uint(values->ContextPageVTDTranslationError, 5, 5) |
6706      __gen_uint(values->PageDirectoryEntryVTDTranslationError, 6, 6) |
6707      __gen_uint(values->HardwareStatusPageVTDTranslationError, 7, 7) |
6708      __gen_uint(values->UnloadedPDError, 8, 8);
6709}
6710
6711#define GFX7_GS_INVOCATION_COUNT_num      0x2328
6712#define GFX7_GS_INVOCATION_COUNT_length        2
6713struct GFX7_GS_INVOCATION_COUNT {
6714   uint64_t                             GSInvocationCountReport;
6715};
6716
6717static inline __attribute__((always_inline)) void
6718GFX7_GS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
6719                              __attribute__((unused)) void * restrict dst,
6720                              __attribute__((unused)) const struct GFX7_GS_INVOCATION_COUNT * restrict values)
6721{
6722   uint32_t * restrict dw = (uint32_t * restrict) dst;
6723
6724   const uint64_t v0 =
6725      __gen_uint(values->GSInvocationCountReport, 0, 63);
6726   dw[0] = v0;
6727   dw[1] = v0 >> 32;
6728}
6729
6730#define GFX7_GS_PRIMITIVES_COUNT_num      0x2330
6731#define GFX7_GS_PRIMITIVES_COUNT_length        2
6732struct GFX7_GS_PRIMITIVES_COUNT {
6733   uint64_t                             GSPrimitivesCountReport;
6734};
6735
6736static inline __attribute__((always_inline)) void
6737GFX7_GS_PRIMITIVES_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
6738                              __attribute__((unused)) void * restrict dst,
6739                              __attribute__((unused)) const struct GFX7_GS_PRIMITIVES_COUNT * restrict values)
6740{
6741   uint32_t * restrict dw = (uint32_t * restrict) dst;
6742
6743   const uint64_t v0 =
6744      __gen_uint(values->GSPrimitivesCountReport, 0, 63);
6745   dw[0] = v0;
6746   dw[1] = v0 >> 32;
6747}
6748
6749#define GFX7_HS_INVOCATION_COUNT_num      0x2300
6750#define GFX7_HS_INVOCATION_COUNT_length        2
6751struct GFX7_HS_INVOCATION_COUNT {
6752   uint64_t                             HSInvocationCountReport;
6753};
6754
6755static inline __attribute__((always_inline)) void
6756GFX7_HS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
6757                              __attribute__((unused)) void * restrict dst,
6758                              __attribute__((unused)) const struct GFX7_HS_INVOCATION_COUNT * restrict values)
6759{
6760   uint32_t * restrict dw = (uint32_t * restrict) dst;
6761
6762   const uint64_t v0 =
6763      __gen_uint(values->HSInvocationCountReport, 0, 63);
6764   dw[0] = v0;
6765   dw[1] = v0 >> 32;
6766}
6767
6768#define GFX7_IA_PRIMITIVES_COUNT_num      0x2318
6769#define GFX7_IA_PRIMITIVES_COUNT_length        2
6770struct GFX7_IA_PRIMITIVES_COUNT {
6771   uint64_t                             IAPrimitivesCountReport;
6772};
6773
6774static inline __attribute__((always_inline)) void
6775GFX7_IA_PRIMITIVES_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
6776                              __attribute__((unused)) void * restrict dst,
6777                              __attribute__((unused)) const struct GFX7_IA_PRIMITIVES_COUNT * restrict values)
6778{
6779   uint32_t * restrict dw = (uint32_t * restrict) dst;
6780
6781   const uint64_t v0 =
6782      __gen_uint(values->IAPrimitivesCountReport, 0, 63);
6783   dw[0] = v0;
6784   dw[1] = v0 >> 32;
6785}
6786
6787#define GFX7_IA_VERTICES_COUNT_num        0x2310
6788#define GFX7_IA_VERTICES_COUNT_length          2
6789struct GFX7_IA_VERTICES_COUNT {
6790   uint64_t                             IAVerticesCountReport;
6791};
6792
6793static inline __attribute__((always_inline)) void
6794GFX7_IA_VERTICES_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
6795                            __attribute__((unused)) void * restrict dst,
6796                            __attribute__((unused)) const struct GFX7_IA_VERTICES_COUNT * restrict values)
6797{
6798   uint32_t * restrict dw = (uint32_t * restrict) dst;
6799
6800   const uint64_t v0 =
6801      __gen_uint(values->IAVerticesCountReport, 0, 63);
6802   dw[0] = v0;
6803   dw[1] = v0 >> 32;
6804}
6805
6806#define GFX7_INSTDONE_1_num               0x206c
6807#define GFX7_INSTDONE_1_length                 1
6808struct GFX7_INSTDONE_1 {
6809   bool                                 PRB0RingEnable;
6810   bool                                 VFGDone;
6811   bool                                 VSDone;
6812   bool                                 HSDone;
6813   bool                                 TEDone;
6814   bool                                 DSDone;
6815   bool                                 GSDone;
6816   bool                                 SOLDone;
6817   bool                                 CLDone;
6818   bool                                 SFDone;
6819   bool                                 TDGDone;
6820   bool                                 URBMDone;
6821   bool                                 SVGDone;
6822   bool                                 GAFSDone;
6823   bool                                 VFEDone;
6824   bool                                 TSGDone;
6825   bool                                 GAFMDone;
6826   bool                                 GAMDone;
6827   bool                                 SDEDone;
6828   bool                                 RCCFBCCSDone;
6829};
6830
6831static inline __attribute__((always_inline)) void
6832GFX7_INSTDONE_1_pack(__attribute__((unused)) __gen_user_data *data,
6833                     __attribute__((unused)) void * restrict dst,
6834                     __attribute__((unused)) const struct GFX7_INSTDONE_1 * restrict values)
6835{
6836   uint32_t * restrict dw = (uint32_t * restrict) dst;
6837
6838   dw[0] =
6839      __gen_uint(values->PRB0RingEnable, 0, 0) |
6840      __gen_uint(values->VFGDone, 1, 1) |
6841      __gen_uint(values->VSDone, 2, 2) |
6842      __gen_uint(values->HSDone, 3, 3) |
6843      __gen_uint(values->TEDone, 4, 4) |
6844      __gen_uint(values->DSDone, 5, 5) |
6845      __gen_uint(values->GSDone, 6, 6) |
6846      __gen_uint(values->SOLDone, 7, 7) |
6847      __gen_uint(values->CLDone, 8, 8) |
6848      __gen_uint(values->SFDone, 9, 9) |
6849      __gen_uint(values->TDGDone, 12, 12) |
6850      __gen_uint(values->URBMDone, 13, 13) |
6851      __gen_uint(values->SVGDone, 14, 14) |
6852      __gen_uint(values->GAFSDone, 15, 15) |
6853      __gen_uint(values->VFEDone, 16, 16) |
6854      __gen_uint(values->TSGDone, 17, 17) |
6855      __gen_uint(values->GAFMDone, 18, 18) |
6856      __gen_uint(values->GAMDone, 19, 19) |
6857      __gen_uint(values->SDEDone, 22, 22) |
6858      __gen_uint(values->RCCFBCCSDone, 23, 23);
6859}
6860
6861#define GFX7_INSTPM_num                   0x20c0
6862#define GFX7_INSTPM_length                     1
6863struct GFX7_INSTPM {
6864   bool                                 _3DStateInstructionDisable;
6865   bool                                 _3DRenderingInstructionDisable;
6866   bool                                 MediaInstructionDisable;
6867   bool                                 CONSTANT_BUFFERAddressOffsetDisable;
6868   bool                                 _3DStateInstructionDisableMask;
6869   bool                                 _3DRenderingInstructionDisableMask;
6870   bool                                 MediaInstructionDisableMask;
6871   bool                                 CONSTANT_BUFFERAddressOffsetDisableMask;
6872};
6873
6874static inline __attribute__((always_inline)) void
6875GFX7_INSTPM_pack(__attribute__((unused)) __gen_user_data *data,
6876                 __attribute__((unused)) void * restrict dst,
6877                 __attribute__((unused)) const struct GFX7_INSTPM * restrict values)
6878{
6879   uint32_t * restrict dw = (uint32_t * restrict) dst;
6880
6881   dw[0] =
6882      __gen_uint(values->_3DStateInstructionDisable, 1, 1) |
6883      __gen_uint(values->_3DRenderingInstructionDisable, 2, 2) |
6884      __gen_uint(values->MediaInstructionDisable, 3, 3) |
6885      __gen_uint(values->CONSTANT_BUFFERAddressOffsetDisable, 6, 6) |
6886      __gen_uint(values->_3DStateInstructionDisableMask, 17, 17) |
6887      __gen_uint(values->_3DRenderingInstructionDisableMask, 18, 18) |
6888      __gen_uint(values->MediaInstructionDisableMask, 19, 19) |
6889      __gen_uint(values->CONSTANT_BUFFERAddressOffsetDisableMask, 22, 22);
6890}
6891
6892#define GFX7_L3CNTLREG2_num               0xb020
6893#define GFX7_L3CNTLREG2_length                 1
6894struct GFX7_L3CNTLREG2 {
6895   bool                                 SLMEnable;
6896   uint32_t                             URBAllocation;
6897   bool                                 URBLowBandwidth;
6898   uint32_t                             ALLAllocation;
6899   uint32_t                             ROAllocation;
6900   bool                                 ROLowBandwidth;
6901   uint32_t                             DCAllocation;
6902   bool                                 DCLowBandwidth;
6903};
6904
6905static inline __attribute__((always_inline)) void
6906GFX7_L3CNTLREG2_pack(__attribute__((unused)) __gen_user_data *data,
6907                     __attribute__((unused)) void * restrict dst,
6908                     __attribute__((unused)) const struct GFX7_L3CNTLREG2 * restrict values)
6909{
6910   uint32_t * restrict dw = (uint32_t * restrict) dst;
6911
6912   dw[0] =
6913      __gen_uint(values->SLMEnable, 0, 0) |
6914      __gen_uint(values->URBAllocation, 1, 6) |
6915      __gen_uint(values->URBLowBandwidth, 7, 7) |
6916      __gen_uint(values->ALLAllocation, 8, 13) |
6917      __gen_uint(values->ROAllocation, 14, 19) |
6918      __gen_uint(values->ROLowBandwidth, 20, 20) |
6919      __gen_uint(values->DCAllocation, 21, 26) |
6920      __gen_uint(values->DCLowBandwidth, 27, 27);
6921}
6922
6923#define GFX7_L3CNTLREG3_num               0xb024
6924#define GFX7_L3CNTLREG3_length                 1
6925struct GFX7_L3CNTLREG3 {
6926   uint32_t                             ISAllocation;
6927   bool                                 ISLowBandwidth;
6928   uint32_t                             CAllocation;
6929   bool                                 CLowBandwidth;
6930   uint32_t                             TAllocation;
6931   bool                                 TLowBandwidth;
6932};
6933
6934static inline __attribute__((always_inline)) void
6935GFX7_L3CNTLREG3_pack(__attribute__((unused)) __gen_user_data *data,
6936                     __attribute__((unused)) void * restrict dst,
6937                     __attribute__((unused)) const struct GFX7_L3CNTLREG3 * restrict values)
6938{
6939   uint32_t * restrict dw = (uint32_t * restrict) dst;
6940
6941   dw[0] =
6942      __gen_uint(values->ISAllocation, 1, 6) |
6943      __gen_uint(values->ISLowBandwidth, 7, 7) |
6944      __gen_uint(values->CAllocation, 8, 13) |
6945      __gen_uint(values->CLowBandwidth, 14, 14) |
6946      __gen_uint(values->TAllocation, 15, 20) |
6947      __gen_uint(values->TLowBandwidth, 21, 21);
6948}
6949
6950#define GFX7_L3SQCREG1_num                0xb010
6951#define GFX7_L3SQCREG1_length                  1
6952struct GFX7_L3SQCREG1 {
6953   uint32_t                             L3SQGeneralPriorityCreditInitialization;
6954#define SQGPCI_DEFAULT                           7
6955#define BYT_SQGPCI_DEFAULT                       13
6956   uint32_t                             L3SQHighPriorityCreditInitialization;
6957#define SQHPCI_DEFAULT                           3
6958   bool                                 ConvertDC_UC;
6959   bool                                 ConvertIS_UC;
6960   bool                                 ConvertC_UC;
6961   bool                                 ConvertT_UC;
6962};
6963
6964static inline __attribute__((always_inline)) void
6965GFX7_L3SQCREG1_pack(__attribute__((unused)) __gen_user_data *data,
6966                    __attribute__((unused)) void * restrict dst,
6967                    __attribute__((unused)) const struct GFX7_L3SQCREG1 * restrict values)
6968{
6969   uint32_t * restrict dw = (uint32_t * restrict) dst;
6970
6971   dw[0] =
6972      __gen_uint(values->L3SQGeneralPriorityCreditInitialization, 20, 23) |
6973      __gen_uint(values->L3SQHighPriorityCreditInitialization, 16, 19) |
6974      __gen_uint(values->ConvertDC_UC, 24, 24) |
6975      __gen_uint(values->ConvertIS_UC, 25, 25) |
6976      __gen_uint(values->ConvertC_UC, 26, 26) |
6977      __gen_uint(values->ConvertT_UC, 27, 27);
6978}
6979
6980#define GFX7_PS_INVOCATION_COUNT_num      0x2348
6981#define GFX7_PS_INVOCATION_COUNT_length        2
6982struct GFX7_PS_INVOCATION_COUNT {
6983   uint64_t                             PSInvocationCountReport;
6984};
6985
6986static inline __attribute__((always_inline)) void
6987GFX7_PS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
6988                              __attribute__((unused)) void * restrict dst,
6989                              __attribute__((unused)) const struct GFX7_PS_INVOCATION_COUNT * restrict values)
6990{
6991   uint32_t * restrict dw = (uint32_t * restrict) dst;
6992
6993   const uint64_t v0 =
6994      __gen_uint(values->PSInvocationCountReport, 0, 63);
6995   dw[0] = v0;
6996   dw[1] = v0 >> 32;
6997}
6998
6999#define GFX7_RCS_FAULT_REG_num            0x4094
7000#define GFX7_RCS_FAULT_REG_length              1
7001struct GFX7_RCS_FAULT_REG {
7002   bool                                 ValidBit;
7003   uint32_t                             FaultType;
7004#define PageFault                                0
7005#define InvalidPDFault                           1
7006#define UnloadedPDFault                          2
7007#define InvalidandUnloadedPDfault                3
7008   uint32_t                             SRCIDofFault;
7009   uint32_t                             GTTSEL;
7010#define PPGTT                                    0
7011#define GGTT                                     1
7012   __gen_address_type                   VirtualAddressofFault;
7013};
7014
7015static inline __attribute__((always_inline)) void
7016GFX7_RCS_FAULT_REG_pack(__attribute__((unused)) __gen_user_data *data,
7017                        __attribute__((unused)) void * restrict dst,
7018                        __attribute__((unused)) const struct GFX7_RCS_FAULT_REG * restrict values)
7019{
7020   uint32_t * restrict dw = (uint32_t * restrict) dst;
7021
7022   const uint32_t v0 =
7023      __gen_uint(values->ValidBit, 0, 0) |
7024      __gen_uint(values->FaultType, 1, 2) |
7025      __gen_uint(values->SRCIDofFault, 3, 10) |
7026      __gen_uint(values->GTTSEL, 11, 11);
7027   dw[0] = __gen_address(data, &dw[0], values->VirtualAddressofFault, v0, 12, 31);
7028}
7029
7030#define GFX7_RCS_RING_BUFFER_CTL_num      0x203c
7031#define GFX7_RCS_RING_BUFFER_CTL_length        1
7032struct GFX7_RCS_RING_BUFFER_CTL {
7033   bool                                 RingBufferEnable;
7034   uint32_t                             AutomaticReportHeadPointer;
7035#define MI_AUTOREPORT_OFF                        0
7036#define MI_AUTOREPORT_64KBMI_AUTOREPORT_4KB      1
7037#define MI_AUTOREPORT_128KB                      3
7038   bool                                 SemaphoreWait;
7039   bool                                 RBWait;
7040   uint32_t                             BufferLengthinpages1;
7041};
7042
7043static inline __attribute__((always_inline)) void
7044GFX7_RCS_RING_BUFFER_CTL_pack(__attribute__((unused)) __gen_user_data *data,
7045                              __attribute__((unused)) void * restrict dst,
7046                              __attribute__((unused)) const struct GFX7_RCS_RING_BUFFER_CTL * restrict values)
7047{
7048   uint32_t * restrict dw = (uint32_t * restrict) dst;
7049
7050   dw[0] =
7051      __gen_uint(values->RingBufferEnable, 0, 0) |
7052      __gen_uint(values->AutomaticReportHeadPointer, 1, 2) |
7053      __gen_uint(values->SemaphoreWait, 10, 10) |
7054      __gen_uint(values->RBWait, 11, 11) |
7055      __gen_uint(values->BufferLengthinpages1, 12, 20);
7056}
7057
7058#define GFX7_ROW_INSTDONE_num             0xe164
7059#define GFX7_ROW_INSTDONE_length               1
7060struct GFX7_ROW_INSTDONE {
7061   bool                                 BCDone;
7062   bool                                 PSDDone;
7063   bool                                 DCDone;
7064   bool                                 DAPRDone;
7065   bool                                 TDLDone;
7066   bool                                 GWDone;
7067   bool                                 ICDone;
7068   bool                                 EU00DoneSS0;
7069   bool                                 EU01DoneSS0;
7070   bool                                 EU02DoneSS0;
7071   bool                                 EU03DoneSS0;
7072   bool                                 MA0DoneSS0;
7073   bool                                 EU10DoneSS0;
7074   bool                                 EU11DoneSS0;
7075   bool                                 EU12DoneSS0;
7076   bool                                 EU13DoneSS0;
7077   bool                                 MA1Done;
7078};
7079
7080static inline __attribute__((always_inline)) void
7081GFX7_ROW_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
7082                       __attribute__((unused)) void * restrict dst,
7083                       __attribute__((unused)) const struct GFX7_ROW_INSTDONE * restrict values)
7084{
7085   uint32_t * restrict dw = (uint32_t * restrict) dst;
7086
7087   dw[0] =
7088      __gen_uint(values->BCDone, 0, 0) |
7089      __gen_uint(values->PSDDone, 1, 1) |
7090      __gen_uint(values->DCDone, 2, 2) |
7091      __gen_uint(values->DAPRDone, 3, 3) |
7092      __gen_uint(values->TDLDone, 6, 6) |
7093      __gen_uint(values->GWDone, 8, 8) |
7094      __gen_uint(values->ICDone, 12, 12) |
7095      __gen_uint(values->EU00DoneSS0, 16, 16) |
7096      __gen_uint(values->EU01DoneSS0, 17, 17) |
7097      __gen_uint(values->EU02DoneSS0, 18, 18) |
7098      __gen_uint(values->EU03DoneSS0, 19, 19) |
7099      __gen_uint(values->MA0DoneSS0, 20, 20) |
7100      __gen_uint(values->EU10DoneSS0, 21, 21) |
7101      __gen_uint(values->EU11DoneSS0, 22, 22) |
7102      __gen_uint(values->EU12DoneSS0, 23, 23) |
7103      __gen_uint(values->EU13DoneSS0, 24, 24) |
7104      __gen_uint(values->MA1Done, 25, 25);
7105}
7106
7107#define GFX7_RPSTAT1_num                  0xa01c
7108#define GFX7_RPSTAT1_length                    1
7109struct GFX7_RPSTAT1 {
7110   uint32_t                             PreviousGTFrequency;
7111   uint32_t                             CurrentGTFrequency;
7112};
7113
7114static inline __attribute__((always_inline)) void
7115GFX7_RPSTAT1_pack(__attribute__((unused)) __gen_user_data *data,
7116                  __attribute__((unused)) void * restrict dst,
7117                  __attribute__((unused)) const struct GFX7_RPSTAT1 * restrict values)
7118{
7119   uint32_t * restrict dw = (uint32_t * restrict) dst;
7120
7121   dw[0] =
7122      __gen_uint(values->PreviousGTFrequency, 0, 6) |
7123      __gen_uint(values->CurrentGTFrequency, 7, 14);
7124}
7125
7126#define GFX7_SAMPLER_INSTDONE_num         0xe160
7127#define GFX7_SAMPLER_INSTDONE_length           1
7128struct GFX7_SAMPLER_INSTDONE {
7129   bool                                 VMEDone;
7130   bool                                 PL0Done;
7131   bool                                 SO0Done;
7132   bool                                 DG0Done;
7133   bool                                 FT0Done;
7134   bool                                 DM0Done;
7135   bool                                 SCDone;
7136   bool                                 FL0Done;
7137   bool                                 QCDone;
7138   bool                                 SVSMDone;
7139   bool                                 SI0Done;
7140   bool                                 MT0Done;
7141   bool                                 AVSDone;
7142   bool                                 IEFDone;
7143   bool                                 VDIDone;
7144   bool                                 SVSMARB3;
7145   bool                                 SVSMARB2;
7146   bool                                 SVSMARB1;
7147   bool                                 SVSMAdapter;
7148};
7149
7150static inline __attribute__((always_inline)) void
7151GFX7_SAMPLER_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
7152                           __attribute__((unused)) void * restrict dst,
7153                           __attribute__((unused)) const struct GFX7_SAMPLER_INSTDONE * restrict values)
7154{
7155   uint32_t * restrict dw = (uint32_t * restrict) dst;
7156
7157   dw[0] =
7158      __gen_uint(values->VMEDone, 0, 0) |
7159      __gen_uint(values->PL0Done, 1, 1) |
7160      __gen_uint(values->SO0Done, 2, 2) |
7161      __gen_uint(values->DG0Done, 3, 3) |
7162      __gen_uint(values->FT0Done, 4, 4) |
7163      __gen_uint(values->DM0Done, 5, 5) |
7164      __gen_uint(values->SCDone, 6, 6) |
7165      __gen_uint(values->FL0Done, 7, 7) |
7166      __gen_uint(values->QCDone, 8, 8) |
7167      __gen_uint(values->SVSMDone, 9, 9) |
7168      __gen_uint(values->SI0Done, 10, 10) |
7169      __gen_uint(values->MT0Done, 11, 11) |
7170      __gen_uint(values->AVSDone, 12, 12) |
7171      __gen_uint(values->IEFDone, 13, 13) |
7172      __gen_uint(values->VDIDone, 14, 14) |
7173      __gen_uint(values->SVSMARB3, 15, 15) |
7174      __gen_uint(values->SVSMARB2, 16, 16) |
7175      __gen_uint(values->SVSMARB1, 17, 17) |
7176      __gen_uint(values->SVSMAdapter, 18, 18);
7177}
7178
7179#define GFX7_SC_INSTDONE_num              0x7100
7180#define GFX7_SC_INSTDONE_length                1
7181struct GFX7_SC_INSTDONE {
7182   bool                                 SVLDone;
7183   bool                                 WMFEDone;
7184   bool                                 WMBEDone;
7185   bool                                 HIZDone;
7186   bool                                 STCDone;
7187   bool                                 IZDone;
7188   bool                                 SBEDone;
7189   bool                                 RCZDone;
7190   bool                                 RCCDone;
7191   bool                                 RCPBEDone;
7192   bool                                 RCPFEDone;
7193   bool                                 DAPBDone;
7194   bool                                 DAPRBEDone;
7195   bool                                 IECPDone;
7196   bool                                 SARBDone;
7197   bool                                 VSCDone;
7198};
7199
7200static inline __attribute__((always_inline)) void
7201GFX7_SC_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
7202                      __attribute__((unused)) void * restrict dst,
7203                      __attribute__((unused)) const struct GFX7_SC_INSTDONE * restrict values)
7204{
7205   uint32_t * restrict dw = (uint32_t * restrict) dst;
7206
7207   dw[0] =
7208      __gen_uint(values->SVLDone, 0, 0) |
7209      __gen_uint(values->WMFEDone, 1, 1) |
7210      __gen_uint(values->WMBEDone, 2, 2) |
7211      __gen_uint(values->HIZDone, 3, 3) |
7212      __gen_uint(values->STCDone, 4, 4) |
7213      __gen_uint(values->IZDone, 5, 5) |
7214      __gen_uint(values->SBEDone, 6, 6) |
7215      __gen_uint(values->RCZDone, 8, 8) |
7216      __gen_uint(values->RCCDone, 9, 9) |
7217      __gen_uint(values->RCPBEDone, 10, 10) |
7218      __gen_uint(values->RCPFEDone, 11, 11) |
7219      __gen_uint(values->DAPBDone, 12, 12) |
7220      __gen_uint(values->DAPRBEDone, 13, 13) |
7221      __gen_uint(values->IECPDone, 14, 14) |
7222      __gen_uint(values->SARBDone, 15, 15) |
7223      __gen_uint(values->VSCDone, 16, 16);
7224}
7225
7226#define GFX7_SO_NUM_PRIMS_WRITTEN0_num    0x5200
7227#define GFX7_SO_NUM_PRIMS_WRITTEN0_length      2
7228struct GFX7_SO_NUM_PRIMS_WRITTEN0 {
7229   uint64_t                             NumPrimsWrittenCount;
7230};
7231
7232static inline __attribute__((always_inline)) void
7233GFX7_SO_NUM_PRIMS_WRITTEN0_pack(__attribute__((unused)) __gen_user_data *data,
7234                                __attribute__((unused)) void * restrict dst,
7235                                __attribute__((unused)) const struct GFX7_SO_NUM_PRIMS_WRITTEN0 * restrict values)
7236{
7237   uint32_t * restrict dw = (uint32_t * restrict) dst;
7238
7239   const uint64_t v0 =
7240      __gen_uint(values->NumPrimsWrittenCount, 0, 63);
7241   dw[0] = v0;
7242   dw[1] = v0 >> 32;
7243}
7244
7245#define GFX7_SO_NUM_PRIMS_WRITTEN1_num    0x5208
7246#define GFX7_SO_NUM_PRIMS_WRITTEN1_length      2
7247struct GFX7_SO_NUM_PRIMS_WRITTEN1 {
7248   uint64_t                             NumPrimsWrittenCount;
7249};
7250
7251static inline __attribute__((always_inline)) void
7252GFX7_SO_NUM_PRIMS_WRITTEN1_pack(__attribute__((unused)) __gen_user_data *data,
7253                                __attribute__((unused)) void * restrict dst,
7254                                __attribute__((unused)) const struct GFX7_SO_NUM_PRIMS_WRITTEN1 * restrict values)
7255{
7256   uint32_t * restrict dw = (uint32_t * restrict) dst;
7257
7258   const uint64_t v0 =
7259      __gen_uint(values->NumPrimsWrittenCount, 0, 63);
7260   dw[0] = v0;
7261   dw[1] = v0 >> 32;
7262}
7263
7264#define GFX7_SO_NUM_PRIMS_WRITTEN2_num    0x5210
7265#define GFX7_SO_NUM_PRIMS_WRITTEN2_length      2
7266struct GFX7_SO_NUM_PRIMS_WRITTEN2 {
7267   uint64_t                             NumPrimsWrittenCount;
7268};
7269
7270static inline __attribute__((always_inline)) void
7271GFX7_SO_NUM_PRIMS_WRITTEN2_pack(__attribute__((unused)) __gen_user_data *data,
7272                                __attribute__((unused)) void * restrict dst,
7273                                __attribute__((unused)) const struct GFX7_SO_NUM_PRIMS_WRITTEN2 * restrict values)
7274{
7275   uint32_t * restrict dw = (uint32_t * restrict) dst;
7276
7277   const uint64_t v0 =
7278      __gen_uint(values->NumPrimsWrittenCount, 0, 63);
7279   dw[0] = v0;
7280   dw[1] = v0 >> 32;
7281}
7282
7283#define GFX7_SO_NUM_PRIMS_WRITTEN3_num    0x5218
7284#define GFX7_SO_NUM_PRIMS_WRITTEN3_length      2
7285struct GFX7_SO_NUM_PRIMS_WRITTEN3 {
7286   uint64_t                             NumPrimsWrittenCount;
7287};
7288
7289static inline __attribute__((always_inline)) void
7290GFX7_SO_NUM_PRIMS_WRITTEN3_pack(__attribute__((unused)) __gen_user_data *data,
7291                                __attribute__((unused)) void * restrict dst,
7292                                __attribute__((unused)) const struct GFX7_SO_NUM_PRIMS_WRITTEN3 * restrict values)
7293{
7294   uint32_t * restrict dw = (uint32_t * restrict) dst;
7295
7296   const uint64_t v0 =
7297      __gen_uint(values->NumPrimsWrittenCount, 0, 63);
7298   dw[0] = v0;
7299   dw[1] = v0 >> 32;
7300}
7301
7302#define GFX7_SO_PRIM_STORAGE_NEEDED0_num  0x5240
7303#define GFX7_SO_PRIM_STORAGE_NEEDED0_length      2
7304struct GFX7_SO_PRIM_STORAGE_NEEDED0 {
7305   uint64_t                             PrimStorageNeededCount;
7306};
7307
7308static inline __attribute__((always_inline)) void
7309GFX7_SO_PRIM_STORAGE_NEEDED0_pack(__attribute__((unused)) __gen_user_data *data,
7310                                  __attribute__((unused)) void * restrict dst,
7311                                  __attribute__((unused)) const struct GFX7_SO_PRIM_STORAGE_NEEDED0 * restrict values)
7312{
7313   uint32_t * restrict dw = (uint32_t * restrict) dst;
7314
7315   const uint64_t v0 =
7316      __gen_uint(values->PrimStorageNeededCount, 0, 63);
7317   dw[0] = v0;
7318   dw[1] = v0 >> 32;
7319}
7320
7321#define GFX7_SO_PRIM_STORAGE_NEEDED1_num  0x5248
7322#define GFX7_SO_PRIM_STORAGE_NEEDED1_length      2
7323struct GFX7_SO_PRIM_STORAGE_NEEDED1 {
7324   uint64_t                             PrimStorageNeededCount;
7325};
7326
7327static inline __attribute__((always_inline)) void
7328GFX7_SO_PRIM_STORAGE_NEEDED1_pack(__attribute__((unused)) __gen_user_data *data,
7329                                  __attribute__((unused)) void * restrict dst,
7330                                  __attribute__((unused)) const struct GFX7_SO_PRIM_STORAGE_NEEDED1 * restrict values)
7331{
7332   uint32_t * restrict dw = (uint32_t * restrict) dst;
7333
7334   const uint64_t v0 =
7335      __gen_uint(values->PrimStorageNeededCount, 0, 63);
7336   dw[0] = v0;
7337   dw[1] = v0 >> 32;
7338}
7339
7340#define GFX7_SO_PRIM_STORAGE_NEEDED2_num  0x5250
7341#define GFX7_SO_PRIM_STORAGE_NEEDED2_length      2
7342struct GFX7_SO_PRIM_STORAGE_NEEDED2 {
7343   uint64_t                             PrimStorageNeededCount;
7344};
7345
7346static inline __attribute__((always_inline)) void
7347GFX7_SO_PRIM_STORAGE_NEEDED2_pack(__attribute__((unused)) __gen_user_data *data,
7348                                  __attribute__((unused)) void * restrict dst,
7349                                  __attribute__((unused)) const struct GFX7_SO_PRIM_STORAGE_NEEDED2 * restrict values)
7350{
7351   uint32_t * restrict dw = (uint32_t * restrict) dst;
7352
7353   const uint64_t v0 =
7354      __gen_uint(values->PrimStorageNeededCount, 0, 63);
7355   dw[0] = v0;
7356   dw[1] = v0 >> 32;
7357}
7358
7359#define GFX7_SO_PRIM_STORAGE_NEEDED3_num  0x5258
7360#define GFX7_SO_PRIM_STORAGE_NEEDED3_length      2
7361struct GFX7_SO_PRIM_STORAGE_NEEDED3 {
7362   uint64_t                             PrimStorageNeededCount;
7363};
7364
7365static inline __attribute__((always_inline)) void
7366GFX7_SO_PRIM_STORAGE_NEEDED3_pack(__attribute__((unused)) __gen_user_data *data,
7367                                  __attribute__((unused)) void * restrict dst,
7368                                  __attribute__((unused)) const struct GFX7_SO_PRIM_STORAGE_NEEDED3 * restrict values)
7369{
7370   uint32_t * restrict dw = (uint32_t * restrict) dst;
7371
7372   const uint64_t v0 =
7373      __gen_uint(values->PrimStorageNeededCount, 0, 63);
7374   dw[0] = v0;
7375   dw[1] = v0 >> 32;
7376}
7377
7378#define GFX7_SO_WRITE_OFFSET0_num         0x5280
7379#define GFX7_SO_WRITE_OFFSET0_length           1
7380struct GFX7_SO_WRITE_OFFSET0 {
7381   uint64_t                             WriteOffset;
7382};
7383
7384static inline __attribute__((always_inline)) void
7385GFX7_SO_WRITE_OFFSET0_pack(__attribute__((unused)) __gen_user_data *data,
7386                           __attribute__((unused)) void * restrict dst,
7387                           __attribute__((unused)) const struct GFX7_SO_WRITE_OFFSET0 * restrict values)
7388{
7389   uint32_t * restrict dw = (uint32_t * restrict) dst;
7390
7391   dw[0] =
7392      __gen_offset(values->WriteOffset, 2, 31);
7393}
7394
7395#define GFX7_SO_WRITE_OFFSET1_num         0x5284
7396#define GFX7_SO_WRITE_OFFSET1_length           1
7397struct GFX7_SO_WRITE_OFFSET1 {
7398   uint64_t                             WriteOffset;
7399};
7400
7401static inline __attribute__((always_inline)) void
7402GFX7_SO_WRITE_OFFSET1_pack(__attribute__((unused)) __gen_user_data *data,
7403                           __attribute__((unused)) void * restrict dst,
7404                           __attribute__((unused)) const struct GFX7_SO_WRITE_OFFSET1 * restrict values)
7405{
7406   uint32_t * restrict dw = (uint32_t * restrict) dst;
7407
7408   dw[0] =
7409      __gen_offset(values->WriteOffset, 2, 31);
7410}
7411
7412#define GFX7_SO_WRITE_OFFSET2_num         0x5288
7413#define GFX7_SO_WRITE_OFFSET2_length           1
7414struct GFX7_SO_WRITE_OFFSET2 {
7415   uint64_t                             WriteOffset;
7416};
7417
7418static inline __attribute__((always_inline)) void
7419GFX7_SO_WRITE_OFFSET2_pack(__attribute__((unused)) __gen_user_data *data,
7420                           __attribute__((unused)) void * restrict dst,
7421                           __attribute__((unused)) const struct GFX7_SO_WRITE_OFFSET2 * restrict values)
7422{
7423   uint32_t * restrict dw = (uint32_t * restrict) dst;
7424
7425   dw[0] =
7426      __gen_offset(values->WriteOffset, 2, 31);
7427}
7428
7429#define GFX7_SO_WRITE_OFFSET3_num         0x528c
7430#define GFX7_SO_WRITE_OFFSET3_length           1
7431struct GFX7_SO_WRITE_OFFSET3 {
7432   uint64_t                             WriteOffset;
7433};
7434
7435static inline __attribute__((always_inline)) void
7436GFX7_SO_WRITE_OFFSET3_pack(__attribute__((unused)) __gen_user_data *data,
7437                           __attribute__((unused)) void * restrict dst,
7438                           __attribute__((unused)) const struct GFX7_SO_WRITE_OFFSET3 * restrict values)
7439{
7440   uint32_t * restrict dw = (uint32_t * restrict) dst;
7441
7442   dw[0] =
7443      __gen_offset(values->WriteOffset, 2, 31);
7444}
7445
7446#define GFX7_VCS_FAULT_REG_num            0x4194
7447#define GFX7_VCS_FAULT_REG_length              1
7448struct GFX7_VCS_FAULT_REG {
7449   bool                                 ValidBit;
7450   uint32_t                             FaultType;
7451#define PageFault                                0
7452#define InvalidPDFault                           1
7453#define UnloadedPDFault                          2
7454#define InvalidandUnloadedPDfault                3
7455   uint32_t                             SRCIDofFault;
7456   uint32_t                             GTTSEL;
7457#define PPGTT                                    0
7458#define GGTT                                     1
7459   __gen_address_type                   VirtualAddressofFault;
7460};
7461
7462static inline __attribute__((always_inline)) void
7463GFX7_VCS_FAULT_REG_pack(__attribute__((unused)) __gen_user_data *data,
7464                        __attribute__((unused)) void * restrict dst,
7465                        __attribute__((unused)) const struct GFX7_VCS_FAULT_REG * restrict values)
7466{
7467   uint32_t * restrict dw = (uint32_t * restrict) dst;
7468
7469   const uint32_t v0 =
7470      __gen_uint(values->ValidBit, 0, 0) |
7471      __gen_uint(values->FaultType, 1, 2) |
7472      __gen_uint(values->SRCIDofFault, 3, 10) |
7473      __gen_uint(values->GTTSEL, 11, 11);
7474   dw[0] = __gen_address(data, &dw[0], values->VirtualAddressofFault, v0, 12, 31);
7475}
7476
7477#define GFX7_VCS_INSTDONE_num             0x1206c
7478#define GFX7_VCS_INSTDONE_length               1
7479struct GFX7_VCS_INSTDONE {
7480   bool                                 RingEnable;
7481   bool                                 USBDone;
7482   bool                                 QRCDone;
7483   bool                                 SECDone;
7484   bool                                 MPCDone;
7485   bool                                 VFTDone;
7486   bool                                 BSPDone;
7487   bool                                 VLFDone;
7488   bool                                 VOPDone;
7489   bool                                 VMCDone;
7490   bool                                 VIPDone;
7491   bool                                 VITDone;
7492   bool                                 VDSDone;
7493   bool                                 VMXDone;
7494   bool                                 VCPDone;
7495   bool                                 VCDDone;
7496   bool                                 VADDone;
7497   bool                                 VMDDone;
7498   bool                                 VISDone;
7499   bool                                 VACDone;
7500   bool                                 VAMDone;
7501   bool                                 JPGDone;
7502   bool                                 VBPDone;
7503   bool                                 VHRDone;
7504   bool                                 VCIDone;
7505   bool                                 VCRDone;
7506   bool                                 VINDone;
7507   bool                                 VPRDone;
7508   bool                                 VTQDone;
7509   bool                                 VCSDone;
7510   bool                                 GACDone;
7511};
7512
7513static inline __attribute__((always_inline)) void
7514GFX7_VCS_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
7515                       __attribute__((unused)) void * restrict dst,
7516                       __attribute__((unused)) const struct GFX7_VCS_INSTDONE * restrict values)
7517{
7518   uint32_t * restrict dw = (uint32_t * restrict) dst;
7519
7520   dw[0] =
7521      __gen_uint(values->RingEnable, 0, 0) |
7522      __gen_uint(values->USBDone, 1, 1) |
7523      __gen_uint(values->QRCDone, 2, 2) |
7524      __gen_uint(values->SECDone, 3, 3) |
7525      __gen_uint(values->MPCDone, 4, 4) |
7526      __gen_uint(values->VFTDone, 5, 5) |
7527      __gen_uint(values->BSPDone, 6, 6) |
7528      __gen_uint(values->VLFDone, 7, 7) |
7529      __gen_uint(values->VOPDone, 8, 8) |
7530      __gen_uint(values->VMCDone, 9, 9) |
7531      __gen_uint(values->VIPDone, 10, 10) |
7532      __gen_uint(values->VITDone, 11, 11) |
7533      __gen_uint(values->VDSDone, 12, 12) |
7534      __gen_uint(values->VMXDone, 13, 13) |
7535      __gen_uint(values->VCPDone, 14, 14) |
7536      __gen_uint(values->VCDDone, 15, 15) |
7537      __gen_uint(values->VADDone, 16, 16) |
7538      __gen_uint(values->VMDDone, 17, 17) |
7539      __gen_uint(values->VISDone, 18, 18) |
7540      __gen_uint(values->VACDone, 19, 19) |
7541      __gen_uint(values->VAMDone, 20, 20) |
7542      __gen_uint(values->JPGDone, 21, 21) |
7543      __gen_uint(values->VBPDone, 22, 22) |
7544      __gen_uint(values->VHRDone, 23, 23) |
7545      __gen_uint(values->VCIDone, 24, 24) |
7546      __gen_uint(values->VCRDone, 25, 25) |
7547      __gen_uint(values->VINDone, 26, 26) |
7548      __gen_uint(values->VPRDone, 27, 27) |
7549      __gen_uint(values->VTQDone, 28, 28) |
7550      __gen_uint(values->VCSDone, 30, 30) |
7551      __gen_uint(values->GACDone, 31, 31);
7552}
7553
7554#define GFX7_VCS_RING_BUFFER_CTL_num      0x1203c
7555#define GFX7_VCS_RING_BUFFER_CTL_length        1
7556struct GFX7_VCS_RING_BUFFER_CTL {
7557   bool                                 RingBufferEnable;
7558   uint32_t                             AutomaticReportHeadPointer;
7559#define MI_AUTOREPORT_OFF                        0
7560#define MI_AUTOREPORT_64KB                       1
7561#define MI_AUTOREPORT_4KB                        2
7562#define MI_AUTOREPORT_128KB                      3
7563   bool                                 DisableRegisterAccesses;
7564   bool                                 SemaphoreWait;
7565   bool                                 RBWait;
7566   uint32_t                             BufferLengthinpages1;
7567};
7568
7569static inline __attribute__((always_inline)) void
7570GFX7_VCS_RING_BUFFER_CTL_pack(__attribute__((unused)) __gen_user_data *data,
7571                              __attribute__((unused)) void * restrict dst,
7572                              __attribute__((unused)) const struct GFX7_VCS_RING_BUFFER_CTL * restrict values)
7573{
7574   uint32_t * restrict dw = (uint32_t * restrict) dst;
7575
7576   dw[0] =
7577      __gen_uint(values->RingBufferEnable, 0, 0) |
7578      __gen_uint(values->AutomaticReportHeadPointer, 1, 2) |
7579      __gen_uint(values->DisableRegisterAccesses, 8, 8) |
7580      __gen_uint(values->SemaphoreWait, 10, 10) |
7581      __gen_uint(values->RBWait, 11, 11) |
7582      __gen_uint(values->BufferLengthinpages1, 12, 20);
7583}
7584
7585#define GFX7_VS_INVOCATION_COUNT_num      0x2320
7586#define GFX7_VS_INVOCATION_COUNT_length        2
7587struct GFX7_VS_INVOCATION_COUNT {
7588   uint64_t                             VSInvocationCountReport;
7589};
7590
7591static inline __attribute__((always_inline)) void
7592GFX7_VS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
7593                              __attribute__((unused)) void * restrict dst,
7594                              __attribute__((unused)) const struct GFX7_VS_INVOCATION_COUNT * restrict values)
7595{
7596   uint32_t * restrict dw = (uint32_t * restrict) dst;
7597
7598   const uint64_t v0 =
7599      __gen_uint(values->VSInvocationCountReport, 0, 63);
7600   dw[0] = v0;
7601   dw[1] = v0 >> 32;
7602}
7603
7604#endif /* GFX7_PACK_H */
7605