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 BDW.
26 *
27 * This file has been generated, do not hand edit.
28 */
29
30#ifndef GFX8_PACK_H
31#define GFX8_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 GFX8_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 GFX8_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 GFX8_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 GFX8_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 GFX8_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 GFX8_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 GFX8_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_PID                     =      7,
319};
320
321enum GFX8_ClearColor {
322   CC_ZERO                              =      0,
323   CC_ONE                               =      1,
324};
325
326enum GFX8_ShaderChannelSelect {
327   SCS_ZERO                             =      0,
328   SCS_ONE                              =      1,
329   SCS_RED                              =      4,
330   SCS_GREEN                            =      5,
331   SCS_BLUE                             =      6,
332   SCS_ALPHA                            =      7,
333};
334
335enum GFX8_TextureCoordinateMode {
336   TCM_WRAP                             =      0,
337   TCM_MIRROR                           =      1,
338   TCM_CLAMP                            =      2,
339   TCM_CUBE                             =      3,
340   TCM_CLAMP_BORDER                     =      4,
341   TCM_MIRROR_ONCE                      =      5,
342   TCM_HALF_BORDER                      =      6,
343};
344
345enum GFX8_WRAP_SHORTEST_ENABLE {
346   WSE_X                                =      1,
347   WSE_Y                                =      2,
348   WSE_XY                               =      3,
349   WSE_Z                                =      4,
350   WSE_XZ                               =      5,
351   WSE_YZ                               =      6,
352   WSE_XYZ                              =      7,
353   WSE_W                                =      8,
354   WSE_XW                               =      9,
355   WSE_YW                               =     10,
356   WSE_XYW                              =     11,
357   WSE_ZW                               =     12,
358   WSE_XZW                              =     13,
359   WSE_YZW                              =     14,
360   WSE_XYZW                             =     15,
361};
362
363#define GFX8_3DSTATE_CONSTANT_BODY_length     10
364struct GFX8_3DSTATE_CONSTANT_BODY {
365   uint32_t                             ReadLength[4];
366   __gen_address_type                   Buffer[4];
367};
368
369static inline __attribute__((always_inline)) void
370GFX8_3DSTATE_CONSTANT_BODY_pack(__attribute__((unused)) __gen_user_data *data,
371                                __attribute__((unused)) void * restrict dst,
372                                __attribute__((unused)) const struct GFX8_3DSTATE_CONSTANT_BODY * restrict values)
373{
374   uint32_t * restrict dw = (uint32_t * restrict) dst;
375
376   dw[0] =
377      __gen_uint(values->ReadLength[0], 0, 15) |
378      __gen_uint(values->ReadLength[1], 16, 31);
379
380   dw[1] =
381      __gen_uint(values->ReadLength[2], 0, 15) |
382      __gen_uint(values->ReadLength[3], 16, 31);
383
384   const uint64_t v2_address =
385      __gen_address(data, &dw[2], values->Buffer[0], 0, 5, 63);
386   dw[2] = v2_address;
387   dw[3] = v2_address >> 32;
388
389   const uint64_t v4_address =
390      __gen_address(data, &dw[4], values->Buffer[1], 0, 5, 63);
391   dw[4] = v4_address;
392   dw[5] = v4_address >> 32;
393
394   const uint64_t v6_address =
395      __gen_address(data, &dw[6], values->Buffer[2], 0, 5, 63);
396   dw[6] = v6_address;
397   dw[7] = v6_address >> 32;
398
399   const uint64_t v8_address =
400      __gen_address(data, &dw[8], values->Buffer[3], 0, 5, 63);
401   dw[8] = v8_address;
402   dw[9] = v8_address >> 32;
403}
404
405#define GFX8_BINDING_TABLE_EDIT_ENTRY_length      1
406struct GFX8_BINDING_TABLE_EDIT_ENTRY {
407   uint64_t                             SurfaceStatePointer;
408   uint32_t                             BindingTableIndex;
409};
410
411static inline __attribute__((always_inline)) void
412GFX8_BINDING_TABLE_EDIT_ENTRY_pack(__attribute__((unused)) __gen_user_data *data,
413                                   __attribute__((unused)) void * restrict dst,
414                                   __attribute__((unused)) const struct GFX8_BINDING_TABLE_EDIT_ENTRY * restrict values)
415{
416   uint32_t * restrict dw = (uint32_t * restrict) dst;
417
418   dw[0] =
419      __gen_offset(values->SurfaceStatePointer, 0, 15) |
420      __gen_uint(values->BindingTableIndex, 16, 23);
421}
422
423#define GFX8_BINDING_TABLE_STATE_length        1
424struct GFX8_BINDING_TABLE_STATE {
425   uint64_t                             SurfaceStatePointer;
426};
427
428static inline __attribute__((always_inline)) void
429GFX8_BINDING_TABLE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
430                              __attribute__((unused)) void * restrict dst,
431                              __attribute__((unused)) const struct GFX8_BINDING_TABLE_STATE * restrict values)
432{
433   uint32_t * restrict dw = (uint32_t * restrict) dst;
434
435   dw[0] =
436      __gen_offset(values->SurfaceStatePointer, 6, 31);
437}
438
439#define GFX8_BLEND_STATE_ENTRY_length          2
440struct GFX8_BLEND_STATE_ENTRY {
441   bool                                 WriteDisableBlue;
442   bool                                 WriteDisableGreen;
443   bool                                 WriteDisableRed;
444   bool                                 WriteDisableAlpha;
445   enum GFX8_3D_Color_Buffer_Blend_Function AlphaBlendFunction;
446   enum GFX8_3D_Color_Buffer_Blend_Factor DestinationAlphaBlendFactor;
447   enum GFX8_3D_Color_Buffer_Blend_Factor SourceAlphaBlendFactor;
448   enum GFX8_3D_Color_Buffer_Blend_Function ColorBlendFunction;
449   enum GFX8_3D_Color_Buffer_Blend_Factor DestinationBlendFactor;
450   enum GFX8_3D_Color_Buffer_Blend_Factor SourceBlendFactor;
451   bool                                 ColorBufferBlendEnable;
452   bool                                 PostBlendColorClampEnable;
453   bool                                 PreBlendColorClampEnable;
454   uint32_t                             ColorClampRange;
455#define COLORCLAMP_UNORM                         0
456#define COLORCLAMP_SNORM                         1
457#define COLORCLAMP_RTFORMAT                      2
458   bool                                 PreBlendSourceOnlyClampEnable;
459   enum GFX8_3D_Logic_Op_Function       LogicOpFunction;
460   bool                                 LogicOpEnable;
461};
462
463static inline __attribute__((always_inline)) void
464GFX8_BLEND_STATE_ENTRY_pack(__attribute__((unused)) __gen_user_data *data,
465                            __attribute__((unused)) void * restrict dst,
466                            __attribute__((unused)) const struct GFX8_BLEND_STATE_ENTRY * restrict values)
467{
468   uint32_t * restrict dw = (uint32_t * restrict) dst;
469
470   dw[0] =
471      __gen_uint(values->WriteDisableBlue, 0, 0) |
472      __gen_uint(values->WriteDisableGreen, 1, 1) |
473      __gen_uint(values->WriteDisableRed, 2, 2) |
474      __gen_uint(values->WriteDisableAlpha, 3, 3) |
475      __gen_uint(values->AlphaBlendFunction, 5, 7) |
476      __gen_uint(values->DestinationAlphaBlendFactor, 8, 12) |
477      __gen_uint(values->SourceAlphaBlendFactor, 13, 17) |
478      __gen_uint(values->ColorBlendFunction, 18, 20) |
479      __gen_uint(values->DestinationBlendFactor, 21, 25) |
480      __gen_uint(values->SourceBlendFactor, 26, 30) |
481      __gen_uint(values->ColorBufferBlendEnable, 31, 31);
482
483   dw[1] =
484      __gen_uint(values->PostBlendColorClampEnable, 0, 0) |
485      __gen_uint(values->PreBlendColorClampEnable, 1, 1) |
486      __gen_uint(values->ColorClampRange, 2, 3) |
487      __gen_uint(values->PreBlendSourceOnlyClampEnable, 4, 4) |
488      __gen_uint(values->LogicOpFunction, 27, 30) |
489      __gen_uint(values->LogicOpEnable, 31, 31);
490}
491
492#define GFX8_BLEND_STATE_length                1
493struct GFX8_BLEND_STATE {
494   uint32_t                             YDitherOffset;
495   uint32_t                             XDitherOffset;
496   bool                                 ColorDitherEnable;
497   enum GFX8_3D_Compare_Function        AlphaTestFunction;
498   bool                                 AlphaTestEnable;
499   bool                                 AlphaToCoverageDitherEnable;
500   bool                                 AlphaToOneEnable;
501   bool                                 IndependentAlphaBlendEnable;
502   bool                                 AlphaToCoverageEnable;
503   /* variable length fields follow */
504};
505
506static inline __attribute__((always_inline)) void
507GFX8_BLEND_STATE_pack(__attribute__((unused)) __gen_user_data *data,
508                      __attribute__((unused)) void * restrict dst,
509                      __attribute__((unused)) const struct GFX8_BLEND_STATE * restrict values)
510{
511   uint32_t * restrict dw = (uint32_t * restrict) dst;
512
513   dw[0] =
514      __gen_uint(values->YDitherOffset, 19, 20) |
515      __gen_uint(values->XDitherOffset, 21, 22) |
516      __gen_uint(values->ColorDitherEnable, 23, 23) |
517      __gen_uint(values->AlphaTestFunction, 24, 26) |
518      __gen_uint(values->AlphaTestEnable, 27, 27) |
519      __gen_uint(values->AlphaToCoverageDitherEnable, 28, 28) |
520      __gen_uint(values->AlphaToOneEnable, 29, 29) |
521      __gen_uint(values->IndependentAlphaBlendEnable, 30, 30) |
522      __gen_uint(values->AlphaToCoverageEnable, 31, 31);
523}
524
525#define GFX8_CC_VIEWPORT_length                2
526struct GFX8_CC_VIEWPORT {
527   float                                MinimumDepth;
528   float                                MaximumDepth;
529};
530
531static inline __attribute__((always_inline)) void
532GFX8_CC_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
533                      __attribute__((unused)) void * restrict dst,
534                      __attribute__((unused)) const struct GFX8_CC_VIEWPORT * restrict values)
535{
536   uint32_t * restrict dw = (uint32_t * restrict) dst;
537
538   dw[0] =
539      __gen_float(values->MinimumDepth);
540
541   dw[1] =
542      __gen_float(values->MaximumDepth);
543}
544
545#define GFX8_COLOR_CALC_STATE_length           6
546struct GFX8_COLOR_CALC_STATE {
547   uint32_t                             AlphaTestFormat;
548#define ALPHATEST_UNORM8                         0
549#define ALPHATEST_FLOAT32                        1
550   bool                                 RoundDisableFunctionDisable;
551   uint32_t                             BackfaceStencilReferenceValue;
552   uint32_t                             StencilReferenceValue;
553   uint32_t                             AlphaReferenceValueAsUNORM8;
554   float                                AlphaReferenceValueAsFLOAT32;
555   float                                BlendConstantColorRed;
556   float                                BlendConstantColorGreen;
557   float                                BlendConstantColorBlue;
558   float                                BlendConstantColorAlpha;
559};
560
561static inline __attribute__((always_inline)) void
562GFX8_COLOR_CALC_STATE_pack(__attribute__((unused)) __gen_user_data *data,
563                           __attribute__((unused)) void * restrict dst,
564                           __attribute__((unused)) const struct GFX8_COLOR_CALC_STATE * restrict values)
565{
566   uint32_t * restrict dw = (uint32_t * restrict) dst;
567
568   dw[0] =
569      __gen_uint(values->AlphaTestFormat, 0, 0) |
570      __gen_uint(values->RoundDisableFunctionDisable, 15, 15) |
571      __gen_uint(values->BackfaceStencilReferenceValue, 16, 23) |
572      __gen_uint(values->StencilReferenceValue, 24, 31);
573
574   dw[1] =
575      __gen_uint(values->AlphaReferenceValueAsUNORM8, 0, 31) |
576      __gen_float(values->AlphaReferenceValueAsFLOAT32);
577
578   dw[2] =
579      __gen_float(values->BlendConstantColorRed);
580
581   dw[3] =
582      __gen_float(values->BlendConstantColorGreen);
583
584   dw[4] =
585      __gen_float(values->BlendConstantColorBlue);
586
587   dw[5] =
588      __gen_float(values->BlendConstantColorAlpha);
589}
590
591#define GFX8_FILTER_COEFFICIENT_length         1
592struct GFX8_FILTER_COEFFICIENT {
593   float                                FilterCoefficient;
594};
595
596static inline __attribute__((always_inline)) void
597GFX8_FILTER_COEFFICIENT_pack(__attribute__((unused)) __gen_user_data *data,
598                             __attribute__((unused)) void * restrict dst,
599                             __attribute__((unused)) const struct GFX8_FILTER_COEFFICIENT * restrict values)
600{
601   uint32_t * restrict dw = (uint32_t * restrict) dst;
602
603   dw[0] =
604      __gen_sfixed(values->FilterCoefficient, 0, 7, 6);
605}
606
607#define GFX8_GATHER_CONSTANT_ENTRY_length      1
608struct GFX8_GATHER_CONSTANT_ENTRY {
609   uint32_t                             BindingTableIndexOffset;
610   uint32_t                             ChannelMask;
611   uint64_t                             ConstantBufferOffset;
612};
613
614static inline __attribute__((always_inline)) void
615GFX8_GATHER_CONSTANT_ENTRY_pack(__attribute__((unused)) __gen_user_data *data,
616                                __attribute__((unused)) void * restrict dst,
617                                __attribute__((unused)) const struct GFX8_GATHER_CONSTANT_ENTRY * restrict values)
618{
619   uint32_t * restrict dw = (uint32_t * restrict) dst;
620
621   dw[0] =
622      __gen_uint(values->BindingTableIndexOffset, 0, 3) |
623      __gen_uint(values->ChannelMask, 4, 7) |
624      __gen_offset(values->ConstantBufferOffset, 8, 15);
625}
626
627#define GFX8_INLINE_DATA_DESCRIPTION_FOR_MFD_AVC_BSD_OBJECT_length      3
628struct GFX8_INLINE_DATA_DESCRIPTION_FOR_MFD_AVC_BSD_OBJECT {
629   bool                                 MBErrorConcealmentPSliceWeightPredictionDisable;
630   bool                                 MBErrorConcealmentPSliceMotionVectorsOverrideDisable;
631   bool                                 MBErrorConcealmentBSpatialWeightPredictionDisable;
632   bool                                 MBErrorConcealmentBSpatialMotionVectorsOverrideDisable;
633   uint32_t                             MBErrorConcealmentBSpatialPredictionMode;
634   bool                                 MBHeaderErrorHandling;
635   bool                                 EntropyErrorHandling;
636   bool                                 MPRErrorHandling;
637   bool                                 BSDPrematureCompleteErrorHandling;
638   uint32_t                             ConcealmentPictureID;
639   bool                                 MBErrorConcealmentBTemporalWeightPredictionDisable;
640   bool                                 MBErrorConcealmentBTemporalMotionVectorsOverrideEnable;
641   uint32_t                             MBErrorConcealmentBTemporalPredictionMode;
642   bool                                 IntraPredMode4x48x8LumaErrorControl;
643   bool                                 InitCurrentMBNumber;
644   uint32_t                             ConcealmentMethod;
645   uint32_t                             FirstMBBitOffset;
646   bool                                 LastSlice;
647   bool                                 EmulationPreventionBytePresent;
648   bool                                 FixPrevMBSkipped;
649   uint32_t                             FirstMBByteOffsetofSliceDataorSliceHeader;
650   bool                                 IntraPredictionErrorControl;
651   bool                                 Intra8x84x4PredictionErrorConcealmentControl;
652   uint32_t                             BSliceTemporalInterConcealmentMode;
653   uint32_t                             BSliceSpatialInterConcealmentMode;
654   uint32_t                             BSliceInterDirectTypeConcealmentMode;
655   uint32_t                             BSliceConcealmentMode;
656#define IntraConcealment                         1
657#define InterConcealment                         0
658   uint32_t                             PSliceInterConcealmentMode;
659   uint32_t                             PSliceConcealmentMode;
660#define IntraConcealment                         1
661#define InterConcealment                         0
662   uint32_t                             ConcealmentReferencePictureFieldBit;
663   uint32_t                             ISliceConcealmentMode;
664#define IntraConcealment                         1
665#define InterConcealment                         0
666};
667
668static inline __attribute__((always_inline)) void
669GFX8_INLINE_DATA_DESCRIPTION_FOR_MFD_AVC_BSD_OBJECT_pack(__attribute__((unused)) __gen_user_data *data,
670                                                         __attribute__((unused)) void * restrict dst,
671                                                         __attribute__((unused)) const struct GFX8_INLINE_DATA_DESCRIPTION_FOR_MFD_AVC_BSD_OBJECT * restrict values)
672{
673   uint32_t * restrict dw = (uint32_t * restrict) dst;
674
675   dw[0] =
676      __gen_uint(values->MBErrorConcealmentPSliceWeightPredictionDisable, 0, 0) |
677      __gen_uint(values->MBErrorConcealmentPSliceMotionVectorsOverrideDisable, 1, 1) |
678      __gen_uint(values->MBErrorConcealmentBSpatialWeightPredictionDisable, 3, 3) |
679      __gen_uint(values->MBErrorConcealmentBSpatialMotionVectorsOverrideDisable, 4, 4) |
680      __gen_uint(values->MBErrorConcealmentBSpatialPredictionMode, 6, 7) |
681      __gen_uint(values->MBHeaderErrorHandling, 8, 8) |
682      __gen_uint(values->EntropyErrorHandling, 10, 10) |
683      __gen_uint(values->MPRErrorHandling, 12, 12) |
684      __gen_uint(values->BSDPrematureCompleteErrorHandling, 14, 14) |
685      __gen_uint(values->ConcealmentPictureID, 16, 21) |
686      __gen_uint(values->MBErrorConcealmentBTemporalWeightPredictionDisable, 24, 24) |
687      __gen_uint(values->MBErrorConcealmentBTemporalMotionVectorsOverrideEnable, 25, 25) |
688      __gen_uint(values->MBErrorConcealmentBTemporalPredictionMode, 27, 28) |
689      __gen_uint(values->IntraPredMode4x48x8LumaErrorControl, 29, 29) |
690      __gen_uint(values->InitCurrentMBNumber, 30, 30) |
691      __gen_uint(values->ConcealmentMethod, 31, 31);
692
693   dw[1] =
694      __gen_uint(values->FirstMBBitOffset, 0, 2) |
695      __gen_uint(values->LastSlice, 3, 3) |
696      __gen_uint(values->EmulationPreventionBytePresent, 4, 4) |
697      __gen_uint(values->FixPrevMBSkipped, 7, 7) |
698      __gen_uint(values->FirstMBByteOffsetofSliceDataorSliceHeader, 16, 31);
699
700   dw[2] =
701      __gen_uint(values->IntraPredictionErrorControl, 0, 0) |
702      __gen_uint(values->Intra8x84x4PredictionErrorConcealmentControl, 1, 1) |
703      __gen_uint(values->BSliceTemporalInterConcealmentMode, 4, 6) |
704      __gen_uint(values->BSliceSpatialInterConcealmentMode, 8, 10) |
705      __gen_uint(values->BSliceInterDirectTypeConcealmentMode, 12, 13) |
706      __gen_uint(values->BSliceConcealmentMode, 15, 15) |
707      __gen_uint(values->PSliceInterConcealmentMode, 16, 18) |
708      __gen_uint(values->PSliceConcealmentMode, 23, 23) |
709      __gen_uint(values->ConcealmentReferencePictureFieldBit, 24, 29) |
710      __gen_uint(values->ISliceConcealmentMode, 31, 31);
711}
712
713#define GFX8_INTERFACE_DESCRIPTOR_DATA_length      8
714struct GFX8_INTERFACE_DESCRIPTOR_DATA {
715   uint64_t                             KernelStartPointer;
716   bool                                 SoftwareExceptionEnable;
717   bool                                 MaskStackExceptionEnable;
718   bool                                 IllegalOpcodeExceptionEnable;
719   uint32_t                             FloatingPointMode;
720#define IEEE754                                  0
721#define Alternate                                1
722   uint32_t                             ThreadPriority;
723#define NormalPriority                           0
724#define HighPriority                             1
725   bool                                 SingleProgramFlow;
726   uint32_t                             DenormMode;
727#define Ftz                                      0
728#define SetByKernel                              1
729   uint32_t                             SamplerCount;
730#define Nosamplersused                           0
731#define Between1and4samplersused                 1
732#define Between5and8samplersused                 2
733#define Between9and12samplersused                3
734#define Between13and16samplersused               4
735   uint64_t                             SamplerStatePointer;
736   uint32_t                             BindingTableEntryCount;
737   uint64_t                             BindingTablePointer;
738   uint32_t                             ConstantURBEntryReadOffset;
739   uint32_t                             ConstantURBEntryReadLength;
740   uint32_t                             NumberofThreadsinGPGPUThreadGroup;
741   uint32_t                             SharedLocalMemorySize;
742#define Encodes0k                                0
743#define Encodes4k                                1
744#define Encodes8k                                2
745#define Encodes16k                               4
746#define Encodes32k                               8
747#define Encodes64k                               16
748   bool                                 BarrierEnable;
749   uint32_t                             RoundingMode;
750#define RTNE                                     0
751#define RU                                       1
752#define RD                                       2
753#define RTZ                                      3
754   uint32_t                             CrossThreadConstantDataReadLength;
755};
756
757static inline __attribute__((always_inline)) void
758GFX8_INTERFACE_DESCRIPTOR_DATA_pack(__attribute__((unused)) __gen_user_data *data,
759                                    __attribute__((unused)) void * restrict dst,
760                                    __attribute__((unused)) const struct GFX8_INTERFACE_DESCRIPTOR_DATA * restrict values)
761{
762   uint32_t * restrict dw = (uint32_t * restrict) dst;
763
764   const uint64_t v0 =
765      __gen_offset(values->KernelStartPointer, 6, 47);
766   dw[0] = v0;
767   dw[1] = v0 >> 32;
768
769   dw[2] =
770      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
771      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
772      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
773      __gen_uint(values->FloatingPointMode, 16, 16) |
774      __gen_uint(values->ThreadPriority, 17, 17) |
775      __gen_uint(values->SingleProgramFlow, 18, 18) |
776      __gen_uint(values->DenormMode, 19, 19);
777
778   dw[3] =
779      __gen_uint(values->SamplerCount, 2, 4) |
780      __gen_offset(values->SamplerStatePointer, 5, 31);
781
782   dw[4] =
783      __gen_uint(values->BindingTableEntryCount, 0, 4) |
784      __gen_offset(values->BindingTablePointer, 5, 15);
785
786   dw[5] =
787      __gen_uint(values->ConstantURBEntryReadOffset, 0, 15) |
788      __gen_uint(values->ConstantURBEntryReadLength, 16, 31);
789
790   dw[6] =
791      __gen_uint(values->NumberofThreadsinGPGPUThreadGroup, 0, 9) |
792      __gen_uint(values->SharedLocalMemorySize, 16, 20) |
793      __gen_uint(values->BarrierEnable, 21, 21) |
794      __gen_uint(values->RoundingMode, 22, 23);
795
796   dw[7] =
797      __gen_uint(values->CrossThreadConstantDataReadLength, 0, 7);
798}
799
800#define GFX8_MEMORYADDRESSATTRIBUTES_length      1
801struct GFX8_MEMORYADDRESSATTRIBUTES {
802   uint32_t                             AgeforQUADLRU;
803   uint32_t                             TargetCache;
804#define eLLCOnly                                 0
805#define LLCOnly                                  1
806#define LLCeLLC                                  2
807#define L3LLCeLLC                                3
808   uint32_t                             ArbitrationPriorityControl;
809};
810
811static inline __attribute__((always_inline)) void
812GFX8_MEMORYADDRESSATTRIBUTES_pack(__attribute__((unused)) __gen_user_data *data,
813                                  __attribute__((unused)) void * restrict dst,
814                                  __attribute__((unused)) const struct GFX8_MEMORYADDRESSATTRIBUTES * restrict values)
815{
816   uint32_t * restrict dw = (uint32_t * restrict) dst;
817
818   dw[0] =
819      __gen_uint(values->AgeforQUADLRU, 0, 1) |
820      __gen_uint(values->TargetCache, 3, 4) |
821      __gen_uint(values->ArbitrationPriorityControl, 7, 8);
822}
823
824#define GFX8_MEMORY_OBJECT_CONTROL_STATE_length      1
825struct GFX8_MEMORY_OBJECT_CONTROL_STATE {
826   uint32_t                             AgeforQUADLRU;
827   uint32_t                             TargetCache;
828#define eLLCOnlywheneDRAMispresentelsegetsallocatedinLLC 0
829#define LLCOnly                                  1
830#define LLCeLLCAllowed                           2
831#define L3DefertoPATforLLCeLLCselection          3
832   uint32_t                             MemoryTypeLLCeLLCCacheabilityControl;
833#define UCwithFenceifcoherentcycle               0
834#define UCUncacheable                            1
835#define WT                                       2
836#define WB                                       3
837};
838
839static inline __attribute__((always_inline)) void
840GFX8_MEMORY_OBJECT_CONTROL_STATE_pack(__attribute__((unused)) __gen_user_data *data,
841                                      __attribute__((unused)) void * restrict dst,
842                                      __attribute__((unused)) const struct GFX8_MEMORY_OBJECT_CONTROL_STATE * restrict values)
843{
844   uint32_t * restrict dw = (uint32_t * restrict) dst;
845
846   dw[0] =
847      __gen_uint(values->AgeforQUADLRU, 0, 1) |
848      __gen_uint(values->TargetCache, 3, 4) |
849      __gen_uint(values->MemoryTypeLLCeLLCCacheabilityControl, 5, 6);
850}
851
852#define GFX8_MFD_MPEG2_BSD_OBJECT_INLINE_DATA_DESCRIPTION_length      2
853struct GFX8_MFD_MPEG2_BSD_OBJECT_INLINE_DATA_DESCRIPTION {
854   uint32_t                             FirstMBBitOffset;
855   bool                                 LastMB;
856   bool                                 LastPicSlice;
857   uint32_t                             SliceConcealmentType;
858   uint32_t                             SliceConcealmentOverride;
859   uint32_t                             MBCount;
860   uint32_t                             SliceVerticalPosition;
861   uint32_t                             SliceHorizontalPosition;
862   uint32_t                             NextSliceHorizontalPosition;
863   uint32_t                             NextSliceVerticalPosition;
864   uint32_t                             QuantizerScaleCode;
865};
866
867static inline __attribute__((always_inline)) void
868GFX8_MFD_MPEG2_BSD_OBJECT_INLINE_DATA_DESCRIPTION_pack(__attribute__((unused)) __gen_user_data *data,
869                                                       __attribute__((unused)) void * restrict dst,
870                                                       __attribute__((unused)) const struct GFX8_MFD_MPEG2_BSD_OBJECT_INLINE_DATA_DESCRIPTION * restrict values)
871{
872   uint32_t * restrict dw = (uint32_t * restrict) dst;
873
874   dw[0] =
875      __gen_uint(values->FirstMBBitOffset, 0, 2) |
876      __gen_uint(values->LastMB, 3, 3) |
877      __gen_uint(values->LastPicSlice, 5, 5) |
878      __gen_uint(values->SliceConcealmentType, 6, 6) |
879      __gen_uint(values->SliceConcealmentOverride, 7, 7) |
880      __gen_uint(values->MBCount, 8, 15) |
881      __gen_uint(values->SliceVerticalPosition, 16, 23) |
882      __gen_uint(values->SliceHorizontalPosition, 24, 31);
883
884   dw[1] =
885      __gen_uint(values->NextSliceHorizontalPosition, 0, 7) |
886      __gen_uint(values->NextSliceVerticalPosition, 8, 16) |
887      __gen_uint(values->QuantizerScaleCode, 24, 28);
888}
889
890#define GFX8_MI_MATH_ALU_INSTRUCTION_length      1
891struct GFX8_MI_MATH_ALU_INSTRUCTION {
892   uint32_t                             Operand2;
893#define MI_ALU_REG0                              0
894#define MI_ALU_REG1                              1
895#define MI_ALU_REG2                              2
896#define MI_ALU_REG3                              3
897#define MI_ALU_REG4                              4
898#define MI_ALU_REG5                              5
899#define MI_ALU_REG6                              6
900#define MI_ALU_REG7                              7
901#define MI_ALU_REG8                              8
902#define MI_ALU_REG9                              9
903#define MI_ALU_REG10                             10
904#define MI_ALU_REG11                             11
905#define MI_ALU_REG12                             12
906#define MI_ALU_REG13                             13
907#define MI_ALU_REG14                             14
908#define MI_ALU_REG15                             15
909#define MI_ALU_SRCA                              32
910#define MI_ALU_SRCB                              33
911#define MI_ALU_ACCU                              49
912#define MI_ALU_ZF                                50
913#define MI_ALU_CF                                51
914   uint32_t                             Operand1;
915#define MI_ALU_REG0                              0
916#define MI_ALU_REG1                              1
917#define MI_ALU_REG2                              2
918#define MI_ALU_REG3                              3
919#define MI_ALU_REG4                              4
920#define MI_ALU_REG5                              5
921#define MI_ALU_REG6                              6
922#define MI_ALU_REG7                              7
923#define MI_ALU_REG8                              8
924#define MI_ALU_REG9                              9
925#define MI_ALU_REG10                             10
926#define MI_ALU_REG11                             11
927#define MI_ALU_REG12                             12
928#define MI_ALU_REG13                             13
929#define MI_ALU_REG14                             14
930#define MI_ALU_REG15                             15
931#define MI_ALU_SRCA                              32
932#define MI_ALU_SRCB                              33
933#define MI_ALU_ACCU                              49
934#define MI_ALU_ZF                                50
935#define MI_ALU_CF                                51
936   uint32_t                             ALUOpcode;
937#define MI_ALU_NOOP                              0
938#define MI_ALU_LOAD                              128
939#define MI_ALU_LOADINV                           1152
940#define MI_ALU_LOAD0                             129
941#define MI_ALU_LOAD1                             1153
942#define MI_ALU_ADD                               256
943#define MI_ALU_SUB                               257
944#define MI_ALU_AND                               258
945#define MI_ALU_OR                                259
946#define MI_ALU_XOR                               260
947#define MI_ALU_STORE                             384
948#define MI_ALU_STOREINV                          1408
949};
950
951static inline __attribute__((always_inline)) void
952GFX8_MI_MATH_ALU_INSTRUCTION_pack(__attribute__((unused)) __gen_user_data *data,
953                                  __attribute__((unused)) void * restrict dst,
954                                  __attribute__((unused)) const struct GFX8_MI_MATH_ALU_INSTRUCTION * restrict values)
955{
956   uint32_t * restrict dw = (uint32_t * restrict) dst;
957
958   dw[0] =
959      __gen_uint(values->Operand2, 0, 9) |
960      __gen_uint(values->Operand1, 10, 19) |
961      __gen_uint(values->ALUOpcode, 20, 31);
962}
963
964#define GFX8_PALETTE_ENTRY_length              1
965struct GFX8_PALETTE_ENTRY {
966   uint32_t                             Blue;
967   uint32_t                             Green;
968   uint32_t                             Red;
969   uint32_t                             Alpha;
970};
971
972static inline __attribute__((always_inline)) void
973GFX8_PALETTE_ENTRY_pack(__attribute__((unused)) __gen_user_data *data,
974                        __attribute__((unused)) void * restrict dst,
975                        __attribute__((unused)) const struct GFX8_PALETTE_ENTRY * restrict values)
976{
977   uint32_t * restrict dw = (uint32_t * restrict) dst;
978
979   dw[0] =
980      __gen_uint(values->Blue, 0, 7) |
981      __gen_uint(values->Green, 8, 15) |
982      __gen_uint(values->Red, 16, 23) |
983      __gen_uint(values->Alpha, 24, 31);
984}
985
986#define GFX8_RENDER_SURFACE_STATE_length      16
987struct GFX8_RENDER_SURFACE_STATE {
988   bool                                 CubeFaceEnablePositiveZ;
989   bool                                 CubeFaceEnableNegativeZ;
990   bool                                 CubeFaceEnablePositiveY;
991   bool                                 CubeFaceEnableNegativeY;
992   bool                                 CubeFaceEnablePositiveX;
993   bool                                 CubeFaceEnableNegativeX;
994   uint32_t                             MediaBoundaryPixelMode;
995#define NORMAL_MODE                              0
996#define PROGRESSIVE_FRAME                        2
997#define INTERLACED_FRAME                         3
998   uint32_t                             RenderCacheReadWriteMode;
999#define WriteOnlyCache                           0
1000#define ReadWriteCache                           1
1001   bool                                 SamplerL2BypassModeDisable;
1002   uint32_t                             VerticalLineStrideOffset;
1003   uint32_t                             VerticalLineStride;
1004   uint32_t                             TileMode;
1005#define LINEAR                                   0
1006#define WMAJOR                                   1
1007#define XMAJOR                                   2
1008#define YMAJOR                                   3
1009   uint32_t                             SurfaceHorizontalAlignment;
1010#define HALIGN_4                                 1
1011#define HALIGN_8                                 2
1012#define HALIGN_16                                3
1013   uint32_t                             SurfaceVerticalAlignment;
1014#define VALIGN_4                                 1
1015#define VALIGN_8                                 2
1016#define VALIGN_16                                3
1017   uint32_t                             SurfaceFormat;
1018   bool                                 SurfaceArray;
1019   uint32_t                             SurfaceType;
1020#define SURFTYPE_1D                              0
1021#define SURFTYPE_2D                              1
1022#define SURFTYPE_3D                              2
1023#define SURFTYPE_CUBE                            3
1024#define SURFTYPE_BUFFER                          4
1025#define SURFTYPE_STRBUF                          5
1026#define SURFTYPE_NULL                            7
1027   uint32_t                             SurfaceQPitch;
1028   float                                BaseMipLevel;
1029   uint32_t                             MOCS;
1030   uint32_t                             Width;
1031   uint32_t                             Height;
1032   uint32_t                             SurfacePitch;
1033   uint32_t                             Depth;
1034   uint32_t                             MultisamplePositionPaletteIndex;
1035   uint32_t                             NumberofMultisamples;
1036#define MULTISAMPLECOUNT_1                       0
1037#define MULTISAMPLECOUNT_2                       1
1038#define MULTISAMPLECOUNT_4                       2
1039#define MULTISAMPLECOUNT_8                       3
1040   uint32_t                             MultisampledSurfaceStorageFormat;
1041#define MSFMT_MSS                                0
1042#define MSFMT_DEPTH_STENCIL                      1
1043   uint32_t                             RenderTargetViewExtent;
1044   uint32_t                             MinimumArrayElement;
1045   uint32_t                             RenderTargetAndSampleUnormRotation;
1046#define _0DEG                                    0
1047#define _90DEG                                   1
1048#define _270DEG                                  3
1049   uint32_t                             MIPCountLOD;
1050   uint32_t                             SurfaceMinLOD;
1051   uint32_t                             CoherencyType;
1052#define GPUcoherent                              0
1053#define IAcoherent                               1
1054   bool                                 EWADisableForCube;
1055   uint32_t                             YOffset;
1056   uint32_t                             XOffset;
1057   uint32_t                             AuxiliarySurfaceMode;
1058#define AUX_NONE                                 0
1059#define AUX_MCS                                  1
1060#define AUX_APPEND                               2
1061#define AUX_HIZ                                  3
1062   uint32_t                             YOffsetforUorUVPlane;
1063   uint32_t                             AuxiliarySurfacePitch;
1064   uint32_t                             AuxiliarySurfaceQPitch;
1065   uint32_t                             XOffsetforUorUVPlane;
1066   bool                                 SeparateUVPlaneEnable;
1067   float                                ResourceMinLOD;
1068   enum GFX8_ShaderChannelSelect        ShaderChannelSelectAlpha;
1069   enum GFX8_ShaderChannelSelect        ShaderChannelSelectBlue;
1070   enum GFX8_ShaderChannelSelect        ShaderChannelSelectGreen;
1071   enum GFX8_ShaderChannelSelect        ShaderChannelSelectRed;
1072   enum GFX8_ClearColor                 AlphaClearColor;
1073   enum GFX8_ClearColor                 BlueClearColor;
1074   enum GFX8_ClearColor                 GreenClearColor;
1075   enum GFX8_ClearColor                 RedClearColor;
1076   __gen_address_type                   SurfaceBaseAddress;
1077   __gen_address_type                   AuxiliarySurfaceBaseAddress;
1078   uint32_t                             AuxiliaryTableIndexforMediaCompressedSurface;
1079   uint32_t                             YOffsetforVPlane;
1080   uint32_t                             XOffsetforVPlane;
1081};
1082
1083static inline __attribute__((always_inline)) void
1084GFX8_RENDER_SURFACE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1085                               __attribute__((unused)) void * restrict dst,
1086                               __attribute__((unused)) const struct GFX8_RENDER_SURFACE_STATE * restrict values)
1087{
1088   uint32_t * restrict dw = (uint32_t * restrict) dst;
1089
1090   dw[0] =
1091      __gen_uint(values->CubeFaceEnablePositiveZ, 0, 0) |
1092      __gen_uint(values->CubeFaceEnableNegativeZ, 1, 1) |
1093      __gen_uint(values->CubeFaceEnablePositiveY, 2, 2) |
1094      __gen_uint(values->CubeFaceEnableNegativeY, 3, 3) |
1095      __gen_uint(values->CubeFaceEnablePositiveX, 4, 4) |
1096      __gen_uint(values->CubeFaceEnableNegativeX, 5, 5) |
1097      __gen_uint(values->MediaBoundaryPixelMode, 6, 7) |
1098      __gen_uint(values->RenderCacheReadWriteMode, 8, 8) |
1099      __gen_uint(values->SamplerL2BypassModeDisable, 9, 9) |
1100      __gen_uint(values->VerticalLineStrideOffset, 10, 10) |
1101      __gen_uint(values->VerticalLineStride, 11, 11) |
1102      __gen_uint(values->TileMode, 12, 13) |
1103      __gen_uint(values->SurfaceHorizontalAlignment, 14, 15) |
1104      __gen_uint(values->SurfaceVerticalAlignment, 16, 17) |
1105      __gen_uint(values->SurfaceFormat, 18, 26) |
1106      __gen_uint(values->SurfaceArray, 28, 28) |
1107      __gen_uint(values->SurfaceType, 29, 31);
1108
1109   dw[1] =
1110      __gen_uint(values->SurfaceQPitch, 0, 14) |
1111      __gen_ufixed(values->BaseMipLevel, 19, 23, 1) |
1112      __gen_uint(values->MOCS, 24, 30);
1113
1114   dw[2] =
1115      __gen_uint(values->Width, 0, 13) |
1116      __gen_uint(values->Height, 16, 29);
1117
1118   dw[3] =
1119      __gen_uint(values->SurfacePitch, 0, 17) |
1120      __gen_uint(values->Depth, 21, 31);
1121
1122   dw[4] =
1123      __gen_uint(values->MultisamplePositionPaletteIndex, 0, 2) |
1124      __gen_uint(values->NumberofMultisamples, 3, 5) |
1125      __gen_uint(values->MultisampledSurfaceStorageFormat, 6, 6) |
1126      __gen_uint(values->RenderTargetViewExtent, 7, 17) |
1127      __gen_uint(values->MinimumArrayElement, 18, 28) |
1128      __gen_uint(values->RenderTargetAndSampleUnormRotation, 29, 30);
1129
1130   dw[5] =
1131      __gen_uint(values->MIPCountLOD, 0, 3) |
1132      __gen_uint(values->SurfaceMinLOD, 4, 7) |
1133      __gen_uint(values->CoherencyType, 14, 14) |
1134      __gen_uint(values->EWADisableForCube, 20, 20) |
1135      __gen_uint(values->YOffset, 21, 23) |
1136      __gen_uint(values->XOffset, 25, 31);
1137
1138   dw[6] =
1139      __gen_uint(values->AuxiliarySurfaceMode, 0, 2) |
1140      __gen_uint(values->YOffsetforUorUVPlane, 0, 13) |
1141      __gen_uint(values->AuxiliarySurfacePitch, 3, 11) |
1142      __gen_uint(values->AuxiliarySurfaceQPitch, 16, 30) |
1143      __gen_uint(values->XOffsetforUorUVPlane, 16, 29) |
1144      __gen_uint(values->SeparateUVPlaneEnable, 31, 31);
1145
1146   dw[7] =
1147      __gen_ufixed(values->ResourceMinLOD, 0, 11, 8) |
1148      __gen_uint(values->ShaderChannelSelectAlpha, 16, 18) |
1149      __gen_uint(values->ShaderChannelSelectBlue, 19, 21) |
1150      __gen_uint(values->ShaderChannelSelectGreen, 22, 24) |
1151      __gen_uint(values->ShaderChannelSelectRed, 25, 27) |
1152      __gen_uint(values->AlphaClearColor, 28, 28) |
1153      __gen_uint(values->BlueClearColor, 29, 29) |
1154      __gen_uint(values->GreenClearColor, 30, 30) |
1155      __gen_uint(values->RedClearColor, 31, 31);
1156
1157   const uint64_t v8_address =
1158      __gen_address(data, &dw[8], values->SurfaceBaseAddress, 0, 0, 63);
1159   dw[8] = v8_address;
1160   dw[9] = v8_address >> 32;
1161
1162   const uint64_t v10 =
1163      __gen_uint(values->AuxiliaryTableIndexforMediaCompressedSurface, 21, 31) |
1164      __gen_uint(values->YOffsetforVPlane, 32, 45) |
1165      __gen_uint(values->XOffsetforVPlane, 48, 61);
1166   const uint64_t v10_address =
1167      __gen_address(data, &dw[10], values->AuxiliarySurfaceBaseAddress, v10, 12, 63);
1168   dw[10] = v10_address;
1169   dw[11] = (v10_address >> 32) | (v10 >> 32);
1170
1171   dw[12] = 0;
1172
1173   dw[13] = 0;
1174
1175   dw[14] = 0;
1176
1177   dw[15] = 0;
1178}
1179
1180#define GFX8_SAMPLER_BORDER_COLOR_STATE_length      4
1181struct GFX8_SAMPLER_BORDER_COLOR_STATE {
1182   float                                BorderColorFloatRed;
1183   uint32_t                             BorderColor32bitRed;
1184   float                                BorderColorFloatGreen;
1185   uint32_t                             BorderColor32bitGreen;
1186   float                                BorderColorFloatBlue;
1187   uint32_t                             BorderColor32bitBlue;
1188   float                                BorderColorFloatAlpha;
1189   uint32_t                             BorderColor32bitAlpha;
1190};
1191
1192static inline __attribute__((always_inline)) void
1193GFX8_SAMPLER_BORDER_COLOR_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1194                                     __attribute__((unused)) void * restrict dst,
1195                                     __attribute__((unused)) const struct GFX8_SAMPLER_BORDER_COLOR_STATE * restrict values)
1196{
1197   uint32_t * restrict dw = (uint32_t * restrict) dst;
1198
1199   dw[0] =
1200      __gen_float(values->BorderColorFloatRed) |
1201      __gen_uint(values->BorderColor32bitRed, 0, 31);
1202
1203   dw[1] =
1204      __gen_float(values->BorderColorFloatGreen) |
1205      __gen_uint(values->BorderColor32bitGreen, 0, 31);
1206
1207   dw[2] =
1208      __gen_float(values->BorderColorFloatBlue) |
1209      __gen_uint(values->BorderColor32bitBlue, 0, 31);
1210
1211   dw[3] =
1212      __gen_float(values->BorderColorFloatAlpha) |
1213      __gen_uint(values->BorderColor32bitAlpha, 0, 31);
1214}
1215
1216#define GFX8_SAMPLER_STATE_length              4
1217struct GFX8_SAMPLER_STATE {
1218   uint32_t                             AnisotropicAlgorithm;
1219#define LEGACY                                   0
1220#define EWAApproximation                         1
1221   float                                TextureLODBias;
1222   uint32_t                             MinModeFilter;
1223#define MAPFILTER_NEAREST                        0
1224#define MAPFILTER_LINEAR                         1
1225#define MAPFILTER_ANISOTROPIC                    2
1226#define MAPFILTER_MONO                           6
1227   uint32_t                             MagModeFilter;
1228#define MAPFILTER_NEAREST                        0
1229#define MAPFILTER_LINEAR                         1
1230#define MAPFILTER_ANISOTROPIC                    2
1231#define MAPFILTER_MONO                           6
1232   uint32_t                             MipModeFilter;
1233#define MIPFILTER_NONE                           0
1234#define MIPFILTER_NEAREST                        1
1235#define MIPFILTER_LINEAR                         3
1236   float                                BaseMipLevel;
1237   uint32_t                             LODPreClampMode;
1238#define CLAMP_MODE_NONE                          0
1239#define CLAMP_MODE_OGL                           2
1240   uint32_t                             TextureBorderColorMode;
1241#define DX10OGL                                  0
1242#define DX9                                      1
1243   bool                                 SamplerDisable;
1244   uint32_t                             CubeSurfaceControlMode;
1245#define PROGRAMMED                               0
1246#define OVERRIDE                                 1
1247   uint32_t                             ShadowFunction;
1248#define PREFILTEROP_ALWAYS                       0
1249#define PREFILTEROP_NEVER                        1
1250#define PREFILTEROP_LESS                         2
1251#define PREFILTEROP_EQUAL                        3
1252#define PREFILTEROP_LEQUAL                       4
1253#define PREFILTEROP_GREATER                      5
1254#define PREFILTEROP_NOTEQUAL                     6
1255#define PREFILTEROP_GEQUAL                       7
1256   uint32_t                             ChromaKeyMode;
1257#define KEYFILTER_KILL_ON_ANY_MATCH              0
1258#define KEYFILTER_REPLACE_BLACK                  1
1259   uint32_t                             ChromaKeyIndex;
1260   bool                                 ChromaKeyEnable;
1261   float                                MaxLOD;
1262   float                                MinLOD;
1263   uint32_t                             LODClampMagnificationMode;
1264#define MIPNONE                                  0
1265#define MIPFILTER                                1
1266   uint64_t                             BorderColorPointer;
1267   enum GFX8_TextureCoordinateMode      TCZAddressControlMode;
1268   enum GFX8_TextureCoordinateMode      TCYAddressControlMode;
1269   enum GFX8_TextureCoordinateMode      TCXAddressControlMode;
1270   bool                                 NonnormalizedCoordinateEnable;
1271   uint32_t                             TrilinearFilterQuality;
1272#define FULL                                     0
1273#define HIGH                                     1
1274#define MED                                      2
1275#define LOW                                      3
1276   bool                                 RAddressMinFilterRoundingEnable;
1277   bool                                 RAddressMagFilterRoundingEnable;
1278   bool                                 VAddressMinFilterRoundingEnable;
1279   bool                                 VAddressMagFilterRoundingEnable;
1280   bool                                 UAddressMinFilterRoundingEnable;
1281   bool                                 UAddressMagFilterRoundingEnable;
1282   uint32_t                             MaximumAnisotropy;
1283#define RATIO21                                  0
1284#define RATIO41                                  1
1285#define RATIO61                                  2
1286#define RATIO81                                  3
1287#define RATIO101                                 4
1288#define RATIO121                                 5
1289#define RATIO141                                 6
1290#define RATIO161                                 7
1291};
1292
1293static inline __attribute__((always_inline)) void
1294GFX8_SAMPLER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1295                        __attribute__((unused)) void * restrict dst,
1296                        __attribute__((unused)) const struct GFX8_SAMPLER_STATE * restrict values)
1297{
1298   uint32_t * restrict dw = (uint32_t * restrict) dst;
1299
1300   dw[0] =
1301      __gen_uint(values->AnisotropicAlgorithm, 0, 0) |
1302      __gen_sfixed(values->TextureLODBias, 1, 13, 8) |
1303      __gen_uint(values->MinModeFilter, 14, 16) |
1304      __gen_uint(values->MagModeFilter, 17, 19) |
1305      __gen_uint(values->MipModeFilter, 20, 21) |
1306      __gen_ufixed(values->BaseMipLevel, 22, 26, 1) |
1307      __gen_uint(values->LODPreClampMode, 27, 28) |
1308      __gen_uint(values->TextureBorderColorMode, 29, 29) |
1309      __gen_uint(values->SamplerDisable, 31, 31);
1310
1311   dw[1] =
1312      __gen_uint(values->CubeSurfaceControlMode, 0, 0) |
1313      __gen_uint(values->ShadowFunction, 1, 3) |
1314      __gen_uint(values->ChromaKeyMode, 4, 4) |
1315      __gen_uint(values->ChromaKeyIndex, 5, 6) |
1316      __gen_uint(values->ChromaKeyEnable, 7, 7) |
1317      __gen_ufixed(values->MaxLOD, 8, 19, 8) |
1318      __gen_ufixed(values->MinLOD, 20, 31, 8);
1319
1320   dw[2] =
1321      __gen_uint(values->LODClampMagnificationMode, 0, 0) |
1322      __gen_offset(values->BorderColorPointer, 6, 23);
1323
1324   dw[3] =
1325      __gen_uint(values->TCZAddressControlMode, 0, 2) |
1326      __gen_uint(values->TCYAddressControlMode, 3, 5) |
1327      __gen_uint(values->TCXAddressControlMode, 6, 8) |
1328      __gen_uint(values->NonnormalizedCoordinateEnable, 10, 10) |
1329      __gen_uint(values->TrilinearFilterQuality, 11, 12) |
1330      __gen_uint(values->RAddressMinFilterRoundingEnable, 13, 13) |
1331      __gen_uint(values->RAddressMagFilterRoundingEnable, 14, 14) |
1332      __gen_uint(values->VAddressMinFilterRoundingEnable, 15, 15) |
1333      __gen_uint(values->VAddressMagFilterRoundingEnable, 16, 16) |
1334      __gen_uint(values->UAddressMinFilterRoundingEnable, 17, 17) |
1335      __gen_uint(values->UAddressMagFilterRoundingEnable, 18, 18) |
1336      __gen_uint(values->MaximumAnisotropy, 19, 21);
1337}
1338
1339#define GFX8_SAMPLER_STATE_8X8_AVS_COEFFICIENTS_length      8
1340struct GFX8_SAMPLER_STATE_8X8_AVS_COEFFICIENTS {
1341   float                                Table0XFilterCoefficientn0;
1342   float                                Table0YFilterCoefficientn0;
1343   float                                Table0XFilterCoefficientn1;
1344   float                                Table0YFilterCoefficientn1;
1345   float                                Table0XFilterCoefficientn2;
1346   float                                Table0YFilterCoefficientn2;
1347   float                                Table0XFilterCoefficientn3;
1348   float                                Table0YFilterCoefficientn3;
1349   float                                Table0XFilterCoefficientn4;
1350   float                                Table0YFilterCoefficientn4;
1351   float                                Table0XFilterCoefficientn5;
1352   float                                Table0YFilterCoefficientn5;
1353   float                                Table0XFilterCoefficientn6;
1354   float                                Table0YFilterCoefficientn6;
1355   float                                Table0XFilterCoefficientn7;
1356   float                                Table0YFilterCoefficientn7;
1357   float                                Table1XFilterCoefficientn2;
1358   float                                Table1XFilterCoefficientn3;
1359   float                                Table1XFilterCoefficientn4;
1360   float                                Table1XFilterCoefficientn5;
1361   float                                Table1YFilterCoefficientn2;
1362   float                                Table1YFilterCoefficientn3;
1363   float                                Table1YFilterCoefficientn4;
1364   float                                Table1YFilterCoefficientn5;
1365};
1366
1367static inline __attribute__((always_inline)) void
1368GFX8_SAMPLER_STATE_8X8_AVS_COEFFICIENTS_pack(__attribute__((unused)) __gen_user_data *data,
1369                                             __attribute__((unused)) void * restrict dst,
1370                                             __attribute__((unused)) const struct GFX8_SAMPLER_STATE_8X8_AVS_COEFFICIENTS * restrict values)
1371{
1372   uint32_t * restrict dw = (uint32_t * restrict) dst;
1373
1374   dw[0] =
1375      __gen_sfixed(values->Table0XFilterCoefficientn0, 0, 7, 6) |
1376      __gen_sfixed(values->Table0YFilterCoefficientn0, 8, 15, 6) |
1377      __gen_sfixed(values->Table0XFilterCoefficientn1, 16, 23, 6) |
1378      __gen_sfixed(values->Table0YFilterCoefficientn1, 24, 31, 6);
1379
1380   dw[1] =
1381      __gen_sfixed(values->Table0XFilterCoefficientn2, 0, 7, 6) |
1382      __gen_sfixed(values->Table0YFilterCoefficientn2, 8, 15, 6) |
1383      __gen_sfixed(values->Table0XFilterCoefficientn3, 16, 23, 6) |
1384      __gen_sfixed(values->Table0YFilterCoefficientn3, 24, 31, 6);
1385
1386   dw[2] =
1387      __gen_sfixed(values->Table0XFilterCoefficientn4, 0, 7, 6) |
1388      __gen_sfixed(values->Table0YFilterCoefficientn4, 8, 15, 6) |
1389      __gen_sfixed(values->Table0XFilterCoefficientn5, 16, 23, 6) |
1390      __gen_sfixed(values->Table0YFilterCoefficientn5, 24, 31, 6);
1391
1392   dw[3] =
1393      __gen_sfixed(values->Table0XFilterCoefficientn6, 0, 7, 6) |
1394      __gen_sfixed(values->Table0YFilterCoefficientn6, 8, 15, 6) |
1395      __gen_sfixed(values->Table0XFilterCoefficientn7, 16, 23, 6) |
1396      __gen_sfixed(values->Table0YFilterCoefficientn7, 24, 31, 6);
1397
1398   dw[4] =
1399      __gen_sfixed(values->Table1XFilterCoefficientn2, 16, 23, 6) |
1400      __gen_sfixed(values->Table1XFilterCoefficientn3, 24, 31, 6);
1401
1402   dw[5] =
1403      __gen_sfixed(values->Table1XFilterCoefficientn4, 0, 7, 6) |
1404      __gen_sfixed(values->Table1XFilterCoefficientn5, 8, 15, 6);
1405
1406   dw[6] =
1407      __gen_sfixed(values->Table1YFilterCoefficientn2, 16, 23, 6) |
1408      __gen_sfixed(values->Table1YFilterCoefficientn3, 24, 31, 6);
1409
1410   dw[7] =
1411      __gen_sfixed(values->Table1YFilterCoefficientn4, 0, 7, 6) |
1412      __gen_sfixed(values->Table1YFilterCoefficientn5, 8, 15, 6);
1413}
1414
1415#define GFX8_SCISSOR_RECT_length               2
1416struct GFX8_SCISSOR_RECT {
1417   uint32_t                             ScissorRectangleXMin;
1418   uint32_t                             ScissorRectangleYMin;
1419   uint32_t                             ScissorRectangleXMax;
1420   uint32_t                             ScissorRectangleYMax;
1421};
1422
1423static inline __attribute__((always_inline)) void
1424GFX8_SCISSOR_RECT_pack(__attribute__((unused)) __gen_user_data *data,
1425                       __attribute__((unused)) void * restrict dst,
1426                       __attribute__((unused)) const struct GFX8_SCISSOR_RECT * restrict values)
1427{
1428   uint32_t * restrict dw = (uint32_t * restrict) dst;
1429
1430   dw[0] =
1431      __gen_uint(values->ScissorRectangleXMin, 0, 15) |
1432      __gen_uint(values->ScissorRectangleYMin, 16, 31);
1433
1434   dw[1] =
1435      __gen_uint(values->ScissorRectangleXMax, 0, 15) |
1436      __gen_uint(values->ScissorRectangleYMax, 16, 31);
1437}
1438
1439#define GFX8_SF_CLIP_VIEWPORT_length          16
1440struct GFX8_SF_CLIP_VIEWPORT {
1441   float                                ViewportMatrixElementm00;
1442   float                                ViewportMatrixElementm11;
1443   float                                ViewportMatrixElementm22;
1444   float                                ViewportMatrixElementm30;
1445   float                                ViewportMatrixElementm31;
1446   float                                ViewportMatrixElementm32;
1447   float                                XMinClipGuardband;
1448   float                                XMaxClipGuardband;
1449   float                                YMinClipGuardband;
1450   float                                YMaxClipGuardband;
1451   float                                XMinViewPort;
1452   float                                XMaxViewPort;
1453   float                                YMinViewPort;
1454   float                                YMaxViewPort;
1455};
1456
1457static inline __attribute__((always_inline)) void
1458GFX8_SF_CLIP_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
1459                           __attribute__((unused)) void * restrict dst,
1460                           __attribute__((unused)) const struct GFX8_SF_CLIP_VIEWPORT * restrict values)
1461{
1462   uint32_t * restrict dw = (uint32_t * restrict) dst;
1463
1464   dw[0] =
1465      __gen_float(values->ViewportMatrixElementm00);
1466
1467   dw[1] =
1468      __gen_float(values->ViewportMatrixElementm11);
1469
1470   dw[2] =
1471      __gen_float(values->ViewportMatrixElementm22);
1472
1473   dw[3] =
1474      __gen_float(values->ViewportMatrixElementm30);
1475
1476   dw[4] =
1477      __gen_float(values->ViewportMatrixElementm31);
1478
1479   dw[5] =
1480      __gen_float(values->ViewportMatrixElementm32);
1481
1482   dw[6] = 0;
1483
1484   dw[7] = 0;
1485
1486   dw[8] =
1487      __gen_float(values->XMinClipGuardband);
1488
1489   dw[9] =
1490      __gen_float(values->XMaxClipGuardband);
1491
1492   dw[10] =
1493      __gen_float(values->YMinClipGuardband);
1494
1495   dw[11] =
1496      __gen_float(values->YMaxClipGuardband);
1497
1498   dw[12] =
1499      __gen_float(values->XMinViewPort);
1500
1501   dw[13] =
1502      __gen_float(values->XMaxViewPort);
1503
1504   dw[14] =
1505      __gen_float(values->YMinViewPort);
1506
1507   dw[15] =
1508      __gen_float(values->YMaxViewPort);
1509}
1510
1511#define GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_length      1
1512struct GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL {
1513   uint32_t                             SourceAttribute;
1514   uint32_t                             SwizzleSelect;
1515#define INPUTATTR                                0
1516#define INPUTATTR_FACING                         1
1517#define INPUTATTR_W                              2
1518#define INPUTATTR_FACING_W                       3
1519   uint32_t                             ConstantSource;
1520#define CONST_0000                               0
1521#define CONST_0001_FLOAT                         1
1522#define CONST_1111_FLOAT                         2
1523#define PRIM_ID                                  3
1524   uint32_t                             SwizzleControlMode;
1525   bool                                 ComponentOverrideX;
1526   bool                                 ComponentOverrideY;
1527   bool                                 ComponentOverrideZ;
1528   bool                                 ComponentOverrideW;
1529};
1530
1531static inline __attribute__((always_inline)) void
1532GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(__attribute__((unused)) __gen_user_data *data,
1533                                     __attribute__((unused)) void * restrict dst,
1534                                     __attribute__((unused)) const struct GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL * restrict values)
1535{
1536   uint32_t * restrict dw = (uint32_t * restrict) dst;
1537
1538   dw[0] =
1539      __gen_uint(values->SourceAttribute, 0, 4) |
1540      __gen_uint(values->SwizzleSelect, 6, 7) |
1541      __gen_uint(values->ConstantSource, 9, 10) |
1542      __gen_uint(values->SwizzleControlMode, 11, 11) |
1543      __gen_uint(values->ComponentOverrideX, 12, 12) |
1544      __gen_uint(values->ComponentOverrideY, 13, 13) |
1545      __gen_uint(values->ComponentOverrideZ, 14, 14) |
1546      __gen_uint(values->ComponentOverrideW, 15, 15);
1547}
1548
1549#define GFX8_SO_DECL_length                    1
1550struct GFX8_SO_DECL {
1551   uint32_t                             ComponentMask;
1552   uint32_t                             RegisterIndex;
1553   bool                                 HoleFlag;
1554   uint32_t                             OutputBufferSlot;
1555};
1556
1557static inline __attribute__((always_inline)) void
1558GFX8_SO_DECL_pack(__attribute__((unused)) __gen_user_data *data,
1559                  __attribute__((unused)) void * restrict dst,
1560                  __attribute__((unused)) const struct GFX8_SO_DECL * restrict values)
1561{
1562   uint32_t * restrict dw = (uint32_t * restrict) dst;
1563
1564   dw[0] =
1565      __gen_uint(values->ComponentMask, 0, 3) |
1566      __gen_uint(values->RegisterIndex, 4, 9) |
1567      __gen_uint(values->HoleFlag, 11, 11) |
1568      __gen_uint(values->OutputBufferSlot, 12, 13);
1569}
1570
1571#define GFX8_SO_DECL_ENTRY_length              2
1572struct GFX8_SO_DECL_ENTRY {
1573   struct GFX8_SO_DECL                  Stream0Decl;
1574   struct GFX8_SO_DECL                  Stream1Decl;
1575   struct GFX8_SO_DECL                  Stream2Decl;
1576   struct GFX8_SO_DECL                  Stream3Decl;
1577};
1578
1579static inline __attribute__((always_inline)) void
1580GFX8_SO_DECL_ENTRY_pack(__attribute__((unused)) __gen_user_data *data,
1581                        __attribute__((unused)) void * restrict dst,
1582                        __attribute__((unused)) const struct GFX8_SO_DECL_ENTRY * restrict values)
1583{
1584   uint32_t * restrict dw = (uint32_t * restrict) dst;
1585
1586   uint32_t v0_0;
1587   GFX8_SO_DECL_pack(data, &v0_0, &values->Stream0Decl);
1588
1589   uint32_t v0_1;
1590   GFX8_SO_DECL_pack(data, &v0_1, &values->Stream1Decl);
1591
1592   dw[0] =
1593      __gen_uint(v0_0, 0, 15) |
1594      __gen_uint(v0_1, 16, 31);
1595
1596   uint32_t v1_0;
1597   GFX8_SO_DECL_pack(data, &v1_0, &values->Stream2Decl);
1598
1599   uint32_t v1_1;
1600   GFX8_SO_DECL_pack(data, &v1_1, &values->Stream3Decl);
1601
1602   dw[1] =
1603      __gen_uint(v1_0, 0, 15) |
1604      __gen_uint(v1_1, 16, 31);
1605}
1606
1607#define GFX8_VERTEX_BUFFER_STATE_length        4
1608struct GFX8_VERTEX_BUFFER_STATE {
1609   uint32_t                             BufferPitch;
1610   bool                                 NullVertexBuffer;
1611   bool                                 AddressModifyEnable;
1612   uint32_t                             MOCS;
1613   uint32_t                             VertexBufferIndex;
1614   __gen_address_type                   BufferStartingAddress;
1615   uint32_t                             BufferSize;
1616};
1617
1618static inline __attribute__((always_inline)) void
1619GFX8_VERTEX_BUFFER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1620                              __attribute__((unused)) void * restrict dst,
1621                              __attribute__((unused)) const struct GFX8_VERTEX_BUFFER_STATE * restrict values)
1622{
1623   uint32_t * restrict dw = (uint32_t * restrict) dst;
1624
1625   dw[0] =
1626      __gen_uint(values->BufferPitch, 0, 11) |
1627      __gen_uint(values->NullVertexBuffer, 13, 13) |
1628      __gen_uint(values->AddressModifyEnable, 14, 14) |
1629      __gen_uint(values->MOCS, 16, 22) |
1630      __gen_uint(values->VertexBufferIndex, 26, 31);
1631
1632   const uint64_t v1_address =
1633      __gen_address(data, &dw[1], values->BufferStartingAddress, 0, 0, 63);
1634   dw[1] = v1_address;
1635   dw[2] = v1_address >> 32;
1636
1637   dw[3] =
1638      __gen_uint(values->BufferSize, 0, 31);
1639}
1640
1641#define GFX8_VERTEX_ELEMENT_STATE_length       2
1642struct GFX8_VERTEX_ELEMENT_STATE {
1643   uint32_t                             SourceElementOffset;
1644   bool                                 EdgeFlagEnable;
1645   uint32_t                             SourceElementFormat;
1646   bool                                 Valid;
1647   uint32_t                             VertexBufferIndex;
1648   enum GFX8_3D_Vertex_Component_Control Component3Control;
1649   enum GFX8_3D_Vertex_Component_Control Component2Control;
1650   enum GFX8_3D_Vertex_Component_Control Component1Control;
1651   enum GFX8_3D_Vertex_Component_Control Component0Control;
1652};
1653
1654static inline __attribute__((always_inline)) void
1655GFX8_VERTEX_ELEMENT_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1656                               __attribute__((unused)) void * restrict dst,
1657                               __attribute__((unused)) const struct GFX8_VERTEX_ELEMENT_STATE * restrict values)
1658{
1659   uint32_t * restrict dw = (uint32_t * restrict) dst;
1660
1661   dw[0] =
1662      __gen_uint(values->SourceElementOffset, 0, 11) |
1663      __gen_uint(values->EdgeFlagEnable, 15, 15) |
1664      __gen_uint(values->SourceElementFormat, 16, 24) |
1665      __gen_uint(values->Valid, 25, 25) |
1666      __gen_uint(values->VertexBufferIndex, 26, 31);
1667
1668   dw[1] =
1669      __gen_uint(values->Component3Control, 16, 18) |
1670      __gen_uint(values->Component2Control, 20, 22) |
1671      __gen_uint(values->Component1Control, 24, 26) |
1672      __gen_uint(values->Component0Control, 28, 30);
1673}
1674
1675#define GFX8_3DPRIMITIVE_length                7
1676#define GFX8_3DPRIMITIVE_length_bias           2
1677#define GFX8_3DPRIMITIVE_header                 \
1678   .DWordLength                         =      5,  \
1679   ._3DCommandSubOpcode                 =      0,  \
1680   ._3DCommandOpcode                    =      3,  \
1681   .CommandSubType                      =      3,  \
1682   .CommandType                         =      3
1683
1684struct GFX8_3DPRIMITIVE {
1685   uint32_t                             DWordLength;
1686   bool                                 PredicateEnable;
1687   bool                                 UAVCoherencyRequired;
1688   bool                                 IndirectParameterEnable;
1689   uint32_t                             _3DCommandSubOpcode;
1690   uint32_t                             _3DCommandOpcode;
1691   uint32_t                             CommandSubType;
1692   uint32_t                             CommandType;
1693   enum GFX8_3D_Prim_Topo_Type          PrimitiveTopologyType;
1694   uint32_t                             VertexAccessType;
1695#define SEQUENTIAL                               0
1696#define RANDOM                                   1
1697   bool                                 EndOffsetEnable;
1698   uint32_t                             VertexCountPerInstance;
1699   uint32_t                             StartVertexLocation;
1700   uint32_t                             InstanceCount;
1701   uint32_t                             StartInstanceLocation;
1702   int32_t                              BaseVertexLocation;
1703};
1704
1705static inline __attribute__((always_inline)) void
1706GFX8_3DPRIMITIVE_pack(__attribute__((unused)) __gen_user_data *data,
1707                      __attribute__((unused)) void * restrict dst,
1708                      __attribute__((unused)) const struct GFX8_3DPRIMITIVE * restrict values)
1709{
1710   uint32_t * restrict dw = (uint32_t * restrict) dst;
1711
1712   dw[0] =
1713      __gen_uint(values->DWordLength, 0, 7) |
1714      __gen_uint(values->PredicateEnable, 8, 8) |
1715      __gen_uint(values->UAVCoherencyRequired, 9, 9) |
1716      __gen_uint(values->IndirectParameterEnable, 10, 10) |
1717      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1718      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1719      __gen_uint(values->CommandSubType, 27, 28) |
1720      __gen_uint(values->CommandType, 29, 31);
1721
1722   dw[1] =
1723      __gen_uint(values->PrimitiveTopologyType, 0, 5) |
1724      __gen_uint(values->VertexAccessType, 8, 8) |
1725      __gen_uint(values->EndOffsetEnable, 9, 9);
1726
1727   dw[2] =
1728      __gen_uint(values->VertexCountPerInstance, 0, 31);
1729
1730   dw[3] =
1731      __gen_uint(values->StartVertexLocation, 0, 31);
1732
1733   dw[4] =
1734      __gen_uint(values->InstanceCount, 0, 31);
1735
1736   dw[5] =
1737      __gen_uint(values->StartInstanceLocation, 0, 31);
1738
1739   dw[6] =
1740      __gen_sint(values->BaseVertexLocation, 0, 31);
1741}
1742
1743#define GFX8_3DSTATE_AA_LINE_PARAMETERS_length      3
1744#define GFX8_3DSTATE_AA_LINE_PARAMETERS_length_bias      2
1745#define GFX8_3DSTATE_AA_LINE_PARAMETERS_header  \
1746   .DWordLength                         =      1,  \
1747   ._3DCommandSubOpcode                 =     10,  \
1748   ._3DCommandOpcode                    =      1,  \
1749   .CommandSubType                      =      3,  \
1750   .CommandType                         =      3
1751
1752struct GFX8_3DSTATE_AA_LINE_PARAMETERS {
1753   uint32_t                             DWordLength;
1754   uint32_t                             _3DCommandSubOpcode;
1755   uint32_t                             _3DCommandOpcode;
1756   uint32_t                             CommandSubType;
1757   uint32_t                             CommandType;
1758   float                                AACoverageSlope;
1759   float                                AAPointCoverageSlope;
1760   float                                AACoverageBias;
1761   float                                AAPointCoverageBias;
1762   float                                AACoverageEndCapSlope;
1763   float                                AAPointCoverageEndCapSlope;
1764   float                                AACoverageEndCapBias;
1765   float                                AAPointCoverageEndCapBias;
1766};
1767
1768static inline __attribute__((always_inline)) void
1769GFX8_3DSTATE_AA_LINE_PARAMETERS_pack(__attribute__((unused)) __gen_user_data *data,
1770                                     __attribute__((unused)) void * restrict dst,
1771                                     __attribute__((unused)) const struct GFX8_3DSTATE_AA_LINE_PARAMETERS * restrict values)
1772{
1773   uint32_t * restrict dw = (uint32_t * restrict) dst;
1774
1775   dw[0] =
1776      __gen_uint(values->DWordLength, 0, 7) |
1777      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1778      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1779      __gen_uint(values->CommandSubType, 27, 28) |
1780      __gen_uint(values->CommandType, 29, 31);
1781
1782   dw[1] =
1783      __gen_ufixed(values->AACoverageSlope, 0, 7, 8) |
1784      __gen_ufixed(values->AAPointCoverageSlope, 8, 15, 8) |
1785      __gen_ufixed(values->AACoverageBias, 16, 23, 8) |
1786      __gen_ufixed(values->AAPointCoverageBias, 24, 31, 8);
1787
1788   dw[2] =
1789      __gen_ufixed(values->AACoverageEndCapSlope, 0, 7, 8) |
1790      __gen_ufixed(values->AAPointCoverageEndCapSlope, 8, 15, 8) |
1791      __gen_ufixed(values->AACoverageEndCapBias, 16, 23, 8) |
1792      __gen_ufixed(values->AAPointCoverageEndCapBias, 24, 31, 8);
1793}
1794
1795#define GFX8_3DSTATE_BINDING_TABLE_EDIT_DS_length_bias      2
1796#define GFX8_3DSTATE_BINDING_TABLE_EDIT_DS_header\
1797   .DWordLength                         =      0,  \
1798   ._3DCommandSubOpcode                 =     70,  \
1799   ._3DCommandOpcode                    =      0,  \
1800   .CommandSubType                      =      3,  \
1801   .CommandType                         =      3
1802
1803struct GFX8_3DSTATE_BINDING_TABLE_EDIT_DS {
1804   uint32_t                             DWordLength;
1805   uint32_t                             _3DCommandSubOpcode;
1806   uint32_t                             _3DCommandOpcode;
1807   uint32_t                             CommandSubType;
1808   uint32_t                             CommandType;
1809   uint32_t                             BindingTableEditTarget;
1810#define AllCores                                 3
1811#define Core1                                    2
1812#define Core0                                    1
1813   uint32_t                             BindingTableBlockClear;
1814   /* variable length fields follow */
1815};
1816
1817static inline __attribute__((always_inline)) void
1818GFX8_3DSTATE_BINDING_TABLE_EDIT_DS_pack(__attribute__((unused)) __gen_user_data *data,
1819                                        __attribute__((unused)) void * restrict dst,
1820                                        __attribute__((unused)) const struct GFX8_3DSTATE_BINDING_TABLE_EDIT_DS * restrict values)
1821{
1822   uint32_t * restrict dw = (uint32_t * restrict) dst;
1823
1824   dw[0] =
1825      __gen_uint(values->DWordLength, 0, 8) |
1826      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1827      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1828      __gen_uint(values->CommandSubType, 27, 28) |
1829      __gen_uint(values->CommandType, 29, 31);
1830
1831   dw[1] =
1832      __gen_uint(values->BindingTableEditTarget, 0, 1) |
1833      __gen_uint(values->BindingTableBlockClear, 16, 31);
1834}
1835
1836#define GFX8_3DSTATE_BINDING_TABLE_EDIT_GS_length_bias      2
1837#define GFX8_3DSTATE_BINDING_TABLE_EDIT_GS_header\
1838   .DWordLength                         =      0,  \
1839   ._3DCommandSubOpcode                 =     68,  \
1840   ._3DCommandOpcode                    =      0,  \
1841   .CommandSubType                      =      3,  \
1842   .CommandType                         =      3
1843
1844struct GFX8_3DSTATE_BINDING_TABLE_EDIT_GS {
1845   uint32_t                             DWordLength;
1846   uint32_t                             _3DCommandSubOpcode;
1847   uint32_t                             _3DCommandOpcode;
1848   uint32_t                             CommandSubType;
1849   uint32_t                             CommandType;
1850   uint32_t                             BindingTableEditTarget;
1851#define AllCores                                 3
1852#define Core1                                    2
1853#define Core0                                    1
1854   uint32_t                             BindingTableBlockClear;
1855   /* variable length fields follow */
1856};
1857
1858static inline __attribute__((always_inline)) void
1859GFX8_3DSTATE_BINDING_TABLE_EDIT_GS_pack(__attribute__((unused)) __gen_user_data *data,
1860                                        __attribute__((unused)) void * restrict dst,
1861                                        __attribute__((unused)) const struct GFX8_3DSTATE_BINDING_TABLE_EDIT_GS * restrict values)
1862{
1863   uint32_t * restrict dw = (uint32_t * restrict) dst;
1864
1865   dw[0] =
1866      __gen_uint(values->DWordLength, 0, 8) |
1867      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1868      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1869      __gen_uint(values->CommandSubType, 27, 28) |
1870      __gen_uint(values->CommandType, 29, 31);
1871
1872   dw[1] =
1873      __gen_uint(values->BindingTableEditTarget, 0, 1) |
1874      __gen_uint(values->BindingTableBlockClear, 16, 31);
1875}
1876
1877#define GFX8_3DSTATE_BINDING_TABLE_EDIT_HS_length_bias      2
1878#define GFX8_3DSTATE_BINDING_TABLE_EDIT_HS_header\
1879   .DWordLength                         =      0,  \
1880   ._3DCommandSubOpcode                 =     69,  \
1881   ._3DCommandOpcode                    =      0,  \
1882   .CommandSubType                      =      3,  \
1883   .CommandType                         =      3
1884
1885struct GFX8_3DSTATE_BINDING_TABLE_EDIT_HS {
1886   uint32_t                             DWordLength;
1887   uint32_t                             _3DCommandSubOpcode;
1888   uint32_t                             _3DCommandOpcode;
1889   uint32_t                             CommandSubType;
1890   uint32_t                             CommandType;
1891   uint32_t                             BindingTableEditTarget;
1892#define AllCores                                 3
1893#define Core1                                    2
1894#define Core0                                    1
1895   uint32_t                             BindingTableBlockClear;
1896   /* variable length fields follow */
1897};
1898
1899static inline __attribute__((always_inline)) void
1900GFX8_3DSTATE_BINDING_TABLE_EDIT_HS_pack(__attribute__((unused)) __gen_user_data *data,
1901                                        __attribute__((unused)) void * restrict dst,
1902                                        __attribute__((unused)) const struct GFX8_3DSTATE_BINDING_TABLE_EDIT_HS * restrict values)
1903{
1904   uint32_t * restrict dw = (uint32_t * restrict) dst;
1905
1906   dw[0] =
1907      __gen_uint(values->DWordLength, 0, 8) |
1908      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1909      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1910      __gen_uint(values->CommandSubType, 27, 28) |
1911      __gen_uint(values->CommandType, 29, 31);
1912
1913   dw[1] =
1914      __gen_uint(values->BindingTableEditTarget, 0, 1) |
1915      __gen_uint(values->BindingTableBlockClear, 16, 31);
1916}
1917
1918#define GFX8_3DSTATE_BINDING_TABLE_EDIT_PS_length_bias      2
1919#define GFX8_3DSTATE_BINDING_TABLE_EDIT_PS_header\
1920   .DWordLength                         =      0,  \
1921   ._3DCommandSubOpcode                 =     71,  \
1922   ._3DCommandOpcode                    =      0,  \
1923   .CommandSubType                      =      3,  \
1924   .CommandType                         =      3
1925
1926struct GFX8_3DSTATE_BINDING_TABLE_EDIT_PS {
1927   uint32_t                             DWordLength;
1928   uint32_t                             _3DCommandSubOpcode;
1929   uint32_t                             _3DCommandOpcode;
1930   uint32_t                             CommandSubType;
1931   uint32_t                             CommandType;
1932   uint32_t                             BindingTableEditTarget;
1933#define AllCores                                 3
1934#define Core1                                    2
1935#define Core0                                    1
1936   uint32_t                             BindingTableBlockClear;
1937   /* variable length fields follow */
1938};
1939
1940static inline __attribute__((always_inline)) void
1941GFX8_3DSTATE_BINDING_TABLE_EDIT_PS_pack(__attribute__((unused)) __gen_user_data *data,
1942                                        __attribute__((unused)) void * restrict dst,
1943                                        __attribute__((unused)) const struct GFX8_3DSTATE_BINDING_TABLE_EDIT_PS * restrict values)
1944{
1945   uint32_t * restrict dw = (uint32_t * restrict) dst;
1946
1947   dw[0] =
1948      __gen_uint(values->DWordLength, 0, 8) |
1949      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1950      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1951      __gen_uint(values->CommandSubType, 27, 28) |
1952      __gen_uint(values->CommandType, 29, 31);
1953
1954   dw[1] =
1955      __gen_uint(values->BindingTableEditTarget, 0, 1) |
1956      __gen_uint(values->BindingTableBlockClear, 16, 31);
1957}
1958
1959#define GFX8_3DSTATE_BINDING_TABLE_EDIT_VS_length_bias      2
1960#define GFX8_3DSTATE_BINDING_TABLE_EDIT_VS_header\
1961   .DWordLength                         =      0,  \
1962   ._3DCommandSubOpcode                 =     67,  \
1963   ._3DCommandOpcode                    =      0,  \
1964   .CommandSubType                      =      3,  \
1965   .CommandType                         =      3
1966
1967struct GFX8_3DSTATE_BINDING_TABLE_EDIT_VS {
1968   uint32_t                             DWordLength;
1969   uint32_t                             _3DCommandSubOpcode;
1970   uint32_t                             _3DCommandOpcode;
1971   uint32_t                             CommandSubType;
1972   uint32_t                             CommandType;
1973   uint32_t                             BindingTableEditTarget;
1974#define AllCores                                 3
1975#define Core1                                    2
1976#define Core0                                    1
1977   uint32_t                             BindingTableBlockClear;
1978   /* variable length fields follow */
1979};
1980
1981static inline __attribute__((always_inline)) void
1982GFX8_3DSTATE_BINDING_TABLE_EDIT_VS_pack(__attribute__((unused)) __gen_user_data *data,
1983                                        __attribute__((unused)) void * restrict dst,
1984                                        __attribute__((unused)) const struct GFX8_3DSTATE_BINDING_TABLE_EDIT_VS * restrict values)
1985{
1986   uint32_t * restrict dw = (uint32_t * restrict) dst;
1987
1988   dw[0] =
1989      __gen_uint(values->DWordLength, 0, 8) |
1990      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1991      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1992      __gen_uint(values->CommandSubType, 27, 28) |
1993      __gen_uint(values->CommandType, 29, 31);
1994
1995   dw[1] =
1996      __gen_uint(values->BindingTableEditTarget, 0, 1) |
1997      __gen_uint(values->BindingTableBlockClear, 16, 31);
1998}
1999
2000#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_DS_length      2
2001#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_DS_length_bias      2
2002#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_DS_header\
2003   .DWordLength                         =      0,  \
2004   ._3DCommandSubOpcode                 =     40,  \
2005   ._3DCommandOpcode                    =      0,  \
2006   .CommandSubType                      =      3,  \
2007   .CommandType                         =      3
2008
2009struct GFX8_3DSTATE_BINDING_TABLE_POINTERS_DS {
2010   uint32_t                             DWordLength;
2011   uint32_t                             _3DCommandSubOpcode;
2012   uint32_t                             _3DCommandOpcode;
2013   uint32_t                             CommandSubType;
2014   uint32_t                             CommandType;
2015   uint64_t                             PointertoDSBindingTable;
2016};
2017
2018static inline __attribute__((always_inline)) void
2019GFX8_3DSTATE_BINDING_TABLE_POINTERS_DS_pack(__attribute__((unused)) __gen_user_data *data,
2020                                            __attribute__((unused)) void * restrict dst,
2021                                            __attribute__((unused)) const struct GFX8_3DSTATE_BINDING_TABLE_POINTERS_DS * restrict values)
2022{
2023   uint32_t * restrict dw = (uint32_t * restrict) dst;
2024
2025   dw[0] =
2026      __gen_uint(values->DWordLength, 0, 7) |
2027      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2028      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2029      __gen_uint(values->CommandSubType, 27, 28) |
2030      __gen_uint(values->CommandType, 29, 31);
2031
2032   dw[1] =
2033      __gen_offset(values->PointertoDSBindingTable, 5, 15);
2034}
2035
2036#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_GS_length      2
2037#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_GS_length_bias      2
2038#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_GS_header\
2039   .DWordLength                         =      0,  \
2040   ._3DCommandSubOpcode                 =     41,  \
2041   ._3DCommandOpcode                    =      0,  \
2042   .CommandSubType                      =      3,  \
2043   .CommandType                         =      3
2044
2045struct GFX8_3DSTATE_BINDING_TABLE_POINTERS_GS {
2046   uint32_t                             DWordLength;
2047   uint32_t                             _3DCommandSubOpcode;
2048   uint32_t                             _3DCommandOpcode;
2049   uint32_t                             CommandSubType;
2050   uint32_t                             CommandType;
2051   uint64_t                             PointertoGSBindingTable;
2052};
2053
2054static inline __attribute__((always_inline)) void
2055GFX8_3DSTATE_BINDING_TABLE_POINTERS_GS_pack(__attribute__((unused)) __gen_user_data *data,
2056                                            __attribute__((unused)) void * restrict dst,
2057                                            __attribute__((unused)) const struct GFX8_3DSTATE_BINDING_TABLE_POINTERS_GS * restrict values)
2058{
2059   uint32_t * restrict dw = (uint32_t * restrict) dst;
2060
2061   dw[0] =
2062      __gen_uint(values->DWordLength, 0, 7) |
2063      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2064      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2065      __gen_uint(values->CommandSubType, 27, 28) |
2066      __gen_uint(values->CommandType, 29, 31);
2067
2068   dw[1] =
2069      __gen_offset(values->PointertoGSBindingTable, 5, 15);
2070}
2071
2072#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_HS_length      2
2073#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_HS_length_bias      2
2074#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_HS_header\
2075   .DWordLength                         =      0,  \
2076   ._3DCommandSubOpcode                 =     39,  \
2077   ._3DCommandOpcode                    =      0,  \
2078   .CommandSubType                      =      3,  \
2079   .CommandType                         =      3
2080
2081struct GFX8_3DSTATE_BINDING_TABLE_POINTERS_HS {
2082   uint32_t                             DWordLength;
2083   uint32_t                             _3DCommandSubOpcode;
2084   uint32_t                             _3DCommandOpcode;
2085   uint32_t                             CommandSubType;
2086   uint32_t                             CommandType;
2087   uint64_t                             PointertoHSBindingTable;
2088};
2089
2090static inline __attribute__((always_inline)) void
2091GFX8_3DSTATE_BINDING_TABLE_POINTERS_HS_pack(__attribute__((unused)) __gen_user_data *data,
2092                                            __attribute__((unused)) void * restrict dst,
2093                                            __attribute__((unused)) const struct GFX8_3DSTATE_BINDING_TABLE_POINTERS_HS * restrict values)
2094{
2095   uint32_t * restrict dw = (uint32_t * restrict) dst;
2096
2097   dw[0] =
2098      __gen_uint(values->DWordLength, 0, 7) |
2099      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2100      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2101      __gen_uint(values->CommandSubType, 27, 28) |
2102      __gen_uint(values->CommandType, 29, 31);
2103
2104   dw[1] =
2105      __gen_offset(values->PointertoHSBindingTable, 5, 15);
2106}
2107
2108#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_PS_length      2
2109#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_PS_length_bias      2
2110#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_PS_header\
2111   .DWordLength                         =      0,  \
2112   ._3DCommandSubOpcode                 =     42,  \
2113   ._3DCommandOpcode                    =      0,  \
2114   .CommandSubType                      =      3,  \
2115   .CommandType                         =      3
2116
2117struct GFX8_3DSTATE_BINDING_TABLE_POINTERS_PS {
2118   uint32_t                             DWordLength;
2119   uint32_t                             _3DCommandSubOpcode;
2120   uint32_t                             _3DCommandOpcode;
2121   uint32_t                             CommandSubType;
2122   uint32_t                             CommandType;
2123   uint64_t                             PointertoPSBindingTable;
2124};
2125
2126static inline __attribute__((always_inline)) void
2127GFX8_3DSTATE_BINDING_TABLE_POINTERS_PS_pack(__attribute__((unused)) __gen_user_data *data,
2128                                            __attribute__((unused)) void * restrict dst,
2129                                            __attribute__((unused)) const struct GFX8_3DSTATE_BINDING_TABLE_POINTERS_PS * restrict values)
2130{
2131   uint32_t * restrict dw = (uint32_t * restrict) dst;
2132
2133   dw[0] =
2134      __gen_uint(values->DWordLength, 0, 7) |
2135      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2136      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2137      __gen_uint(values->CommandSubType, 27, 28) |
2138      __gen_uint(values->CommandType, 29, 31);
2139
2140   dw[1] =
2141      __gen_offset(values->PointertoPSBindingTable, 5, 15);
2142}
2143
2144#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_VS_length      2
2145#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_VS_length_bias      2
2146#define GFX8_3DSTATE_BINDING_TABLE_POINTERS_VS_header\
2147   .DWordLength                         =      0,  \
2148   ._3DCommandSubOpcode                 =     38,  \
2149   ._3DCommandOpcode                    =      0,  \
2150   .CommandSubType                      =      3,  \
2151   .CommandType                         =      3
2152
2153struct GFX8_3DSTATE_BINDING_TABLE_POINTERS_VS {
2154   uint32_t                             DWordLength;
2155   uint32_t                             _3DCommandSubOpcode;
2156   uint32_t                             _3DCommandOpcode;
2157   uint32_t                             CommandSubType;
2158   uint32_t                             CommandType;
2159   uint64_t                             PointertoVSBindingTable;
2160};
2161
2162static inline __attribute__((always_inline)) void
2163GFX8_3DSTATE_BINDING_TABLE_POINTERS_VS_pack(__attribute__((unused)) __gen_user_data *data,
2164                                            __attribute__((unused)) void * restrict dst,
2165                                            __attribute__((unused)) const struct GFX8_3DSTATE_BINDING_TABLE_POINTERS_VS * restrict values)
2166{
2167   uint32_t * restrict dw = (uint32_t * restrict) dst;
2168
2169   dw[0] =
2170      __gen_uint(values->DWordLength, 0, 7) |
2171      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2172      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2173      __gen_uint(values->CommandSubType, 27, 28) |
2174      __gen_uint(values->CommandType, 29, 31);
2175
2176   dw[1] =
2177      __gen_offset(values->PointertoVSBindingTable, 5, 15);
2178}
2179
2180#define GFX8_3DSTATE_BINDING_TABLE_POOL_ALLOC_length      4
2181#define GFX8_3DSTATE_BINDING_TABLE_POOL_ALLOC_length_bias      2
2182#define GFX8_3DSTATE_BINDING_TABLE_POOL_ALLOC_header\
2183   .DWordLength                         =      2,  \
2184   ._3DCommandSubOpcode                 =     25,  \
2185   ._3DCommandOpcode                    =      1,  \
2186   .CommandSubType                      =      3,  \
2187   .CommandType                         =      3
2188
2189struct GFX8_3DSTATE_BINDING_TABLE_POOL_ALLOC {
2190   uint32_t                             DWordLength;
2191   uint32_t                             _3DCommandSubOpcode;
2192   uint32_t                             _3DCommandOpcode;
2193   uint32_t                             CommandSubType;
2194   uint32_t                             CommandType;
2195   uint32_t                             MOCS;
2196   bool                                 BindingTablePoolEnable;
2197   __gen_address_type                   BindingTablePoolBaseAddress;
2198   uint32_t                             BindingTablePoolBufferSize;
2199#define NoValidData                              0
2200};
2201
2202static inline __attribute__((always_inline)) void
2203GFX8_3DSTATE_BINDING_TABLE_POOL_ALLOC_pack(__attribute__((unused)) __gen_user_data *data,
2204                                           __attribute__((unused)) void * restrict dst,
2205                                           __attribute__((unused)) const struct GFX8_3DSTATE_BINDING_TABLE_POOL_ALLOC * restrict values)
2206{
2207   uint32_t * restrict dw = (uint32_t * restrict) dst;
2208
2209   dw[0] =
2210      __gen_uint(values->DWordLength, 0, 7) |
2211      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2212      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2213      __gen_uint(values->CommandSubType, 27, 28) |
2214      __gen_uint(values->CommandType, 29, 31);
2215
2216   const uint64_t v1 =
2217      __gen_uint(values->MOCS, 0, 6) |
2218      __gen_uint(values->BindingTablePoolEnable, 11, 11);
2219   const uint64_t v1_address =
2220      __gen_address(data, &dw[1], values->BindingTablePoolBaseAddress, v1, 12, 63);
2221   dw[1] = v1_address;
2222   dw[2] = (v1_address >> 32) | (v1 >> 32);
2223
2224   dw[3] =
2225      __gen_uint(values->BindingTablePoolBufferSize, 12, 31);
2226}
2227
2228#define GFX8_3DSTATE_BLEND_STATE_POINTERS_length      2
2229#define GFX8_3DSTATE_BLEND_STATE_POINTERS_length_bias      2
2230#define GFX8_3DSTATE_BLEND_STATE_POINTERS_header\
2231   .DWordLength                         =      0,  \
2232   ._3DCommandSubOpcode                 =     36,  \
2233   ._3DCommandOpcode                    =      0,  \
2234   .CommandSubType                      =      3,  \
2235   .CommandType                         =      3
2236
2237struct GFX8_3DSTATE_BLEND_STATE_POINTERS {
2238   uint32_t                             DWordLength;
2239   uint32_t                             _3DCommandSubOpcode;
2240   uint32_t                             _3DCommandOpcode;
2241   uint32_t                             CommandSubType;
2242   uint32_t                             CommandType;
2243   bool                                 BlendStatePointerValid;
2244   uint64_t                             BlendStatePointer;
2245};
2246
2247static inline __attribute__((always_inline)) void
2248GFX8_3DSTATE_BLEND_STATE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
2249                                       __attribute__((unused)) void * restrict dst,
2250                                       __attribute__((unused)) const struct GFX8_3DSTATE_BLEND_STATE_POINTERS * restrict values)
2251{
2252   uint32_t * restrict dw = (uint32_t * restrict) dst;
2253
2254   dw[0] =
2255      __gen_uint(values->DWordLength, 0, 7) |
2256      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2257      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2258      __gen_uint(values->CommandSubType, 27, 28) |
2259      __gen_uint(values->CommandType, 29, 31);
2260
2261   dw[1] =
2262      __gen_uint(values->BlendStatePointerValid, 0, 0) |
2263      __gen_offset(values->BlendStatePointer, 6, 31);
2264}
2265
2266#define GFX8_3DSTATE_CC_STATE_POINTERS_length      2
2267#define GFX8_3DSTATE_CC_STATE_POINTERS_length_bias      2
2268#define GFX8_3DSTATE_CC_STATE_POINTERS_header   \
2269   .DWordLength                         =      0,  \
2270   ._3DCommandSubOpcode                 =     14,  \
2271   ._3DCommandOpcode                    =      0,  \
2272   .CommandSubType                      =      3,  \
2273   .CommandType                         =      3
2274
2275struct GFX8_3DSTATE_CC_STATE_POINTERS {
2276   uint32_t                             DWordLength;
2277   uint32_t                             _3DCommandSubOpcode;
2278   uint32_t                             _3DCommandOpcode;
2279   uint32_t                             CommandSubType;
2280   uint32_t                             CommandType;
2281   bool                                 ColorCalcStatePointerValid;
2282   uint64_t                             ColorCalcStatePointer;
2283};
2284
2285static inline __attribute__((always_inline)) void
2286GFX8_3DSTATE_CC_STATE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
2287                                    __attribute__((unused)) void * restrict dst,
2288                                    __attribute__((unused)) const struct GFX8_3DSTATE_CC_STATE_POINTERS * restrict values)
2289{
2290   uint32_t * restrict dw = (uint32_t * restrict) dst;
2291
2292   dw[0] =
2293      __gen_uint(values->DWordLength, 0, 7) |
2294      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2295      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2296      __gen_uint(values->CommandSubType, 27, 28) |
2297      __gen_uint(values->CommandType, 29, 31);
2298
2299   dw[1] =
2300      __gen_uint(values->ColorCalcStatePointerValid, 0, 0) |
2301      __gen_offset(values->ColorCalcStatePointer, 6, 31);
2302}
2303
2304#define GFX8_3DSTATE_CHROMA_KEY_length         4
2305#define GFX8_3DSTATE_CHROMA_KEY_length_bias      2
2306#define GFX8_3DSTATE_CHROMA_KEY_header          \
2307   .DWordLength                         =      2,  \
2308   ._3DCommandSubOpcode                 =      4,  \
2309   ._3DCommandOpcode                    =      1,  \
2310   .CommandSubType                      =      3,  \
2311   .CommandType                         =      3
2312
2313struct GFX8_3DSTATE_CHROMA_KEY {
2314   uint32_t                             DWordLength;
2315   uint32_t                             _3DCommandSubOpcode;
2316   uint32_t                             _3DCommandOpcode;
2317   uint32_t                             CommandSubType;
2318   uint32_t                             CommandType;
2319   uint32_t                             ChromaKeyTableIndex;
2320   uint32_t                             ChromaKeyLowValue;
2321   uint32_t                             ChromaKeyHighValue;
2322};
2323
2324static inline __attribute__((always_inline)) void
2325GFX8_3DSTATE_CHROMA_KEY_pack(__attribute__((unused)) __gen_user_data *data,
2326                             __attribute__((unused)) void * restrict dst,
2327                             __attribute__((unused)) const struct GFX8_3DSTATE_CHROMA_KEY * restrict values)
2328{
2329   uint32_t * restrict dw = (uint32_t * restrict) dst;
2330
2331   dw[0] =
2332      __gen_uint(values->DWordLength, 0, 7) |
2333      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2334      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2335      __gen_uint(values->CommandSubType, 27, 28) |
2336      __gen_uint(values->CommandType, 29, 31);
2337
2338   dw[1] =
2339      __gen_uint(values->ChromaKeyTableIndex, 30, 31);
2340
2341   dw[2] =
2342      __gen_uint(values->ChromaKeyLowValue, 0, 31);
2343
2344   dw[3] =
2345      __gen_uint(values->ChromaKeyHighValue, 0, 31);
2346}
2347
2348#define GFX8_3DSTATE_CLEAR_PARAMS_length       3
2349#define GFX8_3DSTATE_CLEAR_PARAMS_length_bias      2
2350#define GFX8_3DSTATE_CLEAR_PARAMS_header        \
2351   .DWordLength                         =      1,  \
2352   ._3DCommandSubOpcode                 =      4,  \
2353   ._3DCommandOpcode                    =      0,  \
2354   .CommandSubType                      =      3,  \
2355   .CommandType                         =      3
2356
2357struct GFX8_3DSTATE_CLEAR_PARAMS {
2358   uint32_t                             DWordLength;
2359   uint32_t                             _3DCommandSubOpcode;
2360   uint32_t                             _3DCommandOpcode;
2361   uint32_t                             CommandSubType;
2362   uint32_t                             CommandType;
2363   float                                DepthClearValue;
2364   bool                                 DepthClearValueValid;
2365};
2366
2367static inline __attribute__((always_inline)) void
2368GFX8_3DSTATE_CLEAR_PARAMS_pack(__attribute__((unused)) __gen_user_data *data,
2369                               __attribute__((unused)) void * restrict dst,
2370                               __attribute__((unused)) const struct GFX8_3DSTATE_CLEAR_PARAMS * restrict values)
2371{
2372   uint32_t * restrict dw = (uint32_t * restrict) dst;
2373
2374   dw[0] =
2375      __gen_uint(values->DWordLength, 0, 7) |
2376      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2377      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2378      __gen_uint(values->CommandSubType, 27, 28) |
2379      __gen_uint(values->CommandType, 29, 31);
2380
2381   dw[1] =
2382      __gen_float(values->DepthClearValue);
2383
2384   dw[2] =
2385      __gen_uint(values->DepthClearValueValid, 0, 0);
2386}
2387
2388#define GFX8_3DSTATE_CLIP_length               4
2389#define GFX8_3DSTATE_CLIP_length_bias          2
2390#define GFX8_3DSTATE_CLIP_header                \
2391   .DWordLength                         =      2,  \
2392   ._3DCommandSubOpcode                 =     18,  \
2393   ._3DCommandOpcode                    =      0,  \
2394   .CommandSubType                      =      3,  \
2395   .CommandType                         =      3
2396
2397struct GFX8_3DSTATE_CLIP {
2398   uint32_t                             DWordLength;
2399   uint32_t                             _3DCommandSubOpcode;
2400   uint32_t                             _3DCommandOpcode;
2401   uint32_t                             CommandSubType;
2402   uint32_t                             CommandType;
2403   uint32_t                             UserClipDistanceCullTestEnableBitmask;
2404   bool                                 StatisticsEnable;
2405   bool                                 ForceClipMode;
2406   bool                                 ForceUserClipDistanceClipTestEnableBitmask;
2407   bool                                 EarlyCullEnable;
2408   uint32_t                             VertexSubPixelPrecisionSelect;
2409#define _8Bit                                    0
2410#define _4Bit                                    1
2411   bool                                 ForceUserClipDistanceCullTestEnableBitmask;
2412   uint32_t                             TriangleFanProvokingVertexSelect;
2413   uint32_t                             LineStripListProvokingVertexSelect;
2414   uint32_t                             TriangleStripListProvokingVertexSelect;
2415   bool                                 NonPerspectiveBarycentricEnable;
2416   bool                                 PerspectiveDivideDisable;
2417   uint32_t                             ClipMode;
2418#define CLIPMODE_NORMAL                          0
2419#define CLIPMODE_REJECT_ALL                      3
2420#define CLIPMODE_ACCEPT_ALL                      4
2421   uint32_t                             UserClipDistanceClipTestEnableBitmask;
2422   bool                                 GuardbandClipTestEnable;
2423   bool                                 ViewportXYClipTestEnable;
2424   uint32_t                             APIMode;
2425#define APIMODE_OGL                              0
2426#define APIMODE_D3D                              1
2427   bool                                 ClipEnable;
2428   uint32_t                             MaximumVPIndex;
2429   bool                                 ForceZeroRTAIndexEnable;
2430   float                                MaximumPointWidth;
2431   float                                MinimumPointWidth;
2432};
2433
2434static inline __attribute__((always_inline)) void
2435GFX8_3DSTATE_CLIP_pack(__attribute__((unused)) __gen_user_data *data,
2436                       __attribute__((unused)) void * restrict dst,
2437                       __attribute__((unused)) const struct GFX8_3DSTATE_CLIP * restrict values)
2438{
2439   uint32_t * restrict dw = (uint32_t * restrict) dst;
2440
2441   dw[0] =
2442      __gen_uint(values->DWordLength, 0, 7) |
2443      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2444      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2445      __gen_uint(values->CommandSubType, 27, 28) |
2446      __gen_uint(values->CommandType, 29, 31);
2447
2448   dw[1] =
2449      __gen_uint(values->UserClipDistanceCullTestEnableBitmask, 0, 7) |
2450      __gen_uint(values->StatisticsEnable, 10, 10) |
2451      __gen_uint(values->ForceClipMode, 16, 16) |
2452      __gen_uint(values->ForceUserClipDistanceClipTestEnableBitmask, 17, 17) |
2453      __gen_uint(values->EarlyCullEnable, 18, 18) |
2454      __gen_uint(values->VertexSubPixelPrecisionSelect, 19, 19) |
2455      __gen_uint(values->ForceUserClipDistanceCullTestEnableBitmask, 20, 20);
2456
2457   dw[2] =
2458      __gen_uint(values->TriangleFanProvokingVertexSelect, 0, 1) |
2459      __gen_uint(values->LineStripListProvokingVertexSelect, 2, 3) |
2460      __gen_uint(values->TriangleStripListProvokingVertexSelect, 4, 5) |
2461      __gen_uint(values->NonPerspectiveBarycentricEnable, 8, 8) |
2462      __gen_uint(values->PerspectiveDivideDisable, 9, 9) |
2463      __gen_uint(values->ClipMode, 13, 15) |
2464      __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 16, 23) |
2465      __gen_uint(values->GuardbandClipTestEnable, 26, 26) |
2466      __gen_uint(values->ViewportXYClipTestEnable, 28, 28) |
2467      __gen_uint(values->APIMode, 30, 30) |
2468      __gen_uint(values->ClipEnable, 31, 31);
2469
2470   dw[3] =
2471      __gen_uint(values->MaximumVPIndex, 0, 3) |
2472      __gen_uint(values->ForceZeroRTAIndexEnable, 5, 5) |
2473      __gen_ufixed(values->MaximumPointWidth, 6, 16, 3) |
2474      __gen_ufixed(values->MinimumPointWidth, 17, 27, 3);
2475}
2476
2477#define GFX8_3DSTATE_CONSTANT_DS_length       11
2478#define GFX8_3DSTATE_CONSTANT_DS_length_bias      2
2479#define GFX8_3DSTATE_CONSTANT_DS_header         \
2480   .DWordLength                         =      9,  \
2481   ._3DCommandSubOpcode                 =     26,  \
2482   ._3DCommandOpcode                    =      0,  \
2483   .CommandSubType                      =      3,  \
2484   .CommandType                         =      3
2485
2486struct GFX8_3DSTATE_CONSTANT_DS {
2487   uint32_t                             DWordLength;
2488   uint32_t                             MOCS;
2489   uint32_t                             _3DCommandSubOpcode;
2490   uint32_t                             _3DCommandOpcode;
2491   uint32_t                             CommandSubType;
2492   uint32_t                             CommandType;
2493   struct GFX8_3DSTATE_CONSTANT_BODY    ConstantBody;
2494};
2495
2496static inline __attribute__((always_inline)) void
2497GFX8_3DSTATE_CONSTANT_DS_pack(__attribute__((unused)) __gen_user_data *data,
2498                              __attribute__((unused)) void * restrict dst,
2499                              __attribute__((unused)) const struct GFX8_3DSTATE_CONSTANT_DS * restrict values)
2500{
2501   uint32_t * restrict dw = (uint32_t * restrict) dst;
2502
2503   dw[0] =
2504      __gen_uint(values->DWordLength, 0, 7) |
2505      __gen_uint(values->MOCS, 8, 14) |
2506      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2507      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2508      __gen_uint(values->CommandSubType, 27, 28) |
2509      __gen_uint(values->CommandType, 29, 31);
2510
2511   GFX8_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
2512}
2513
2514#define GFX8_3DSTATE_CONSTANT_GS_length       11
2515#define GFX8_3DSTATE_CONSTANT_GS_length_bias      2
2516#define GFX8_3DSTATE_CONSTANT_GS_header         \
2517   .DWordLength                         =      9,  \
2518   ._3DCommandSubOpcode                 =     22,  \
2519   ._3DCommandOpcode                    =      0,  \
2520   .CommandSubType                      =      3,  \
2521   .CommandType                         =      3
2522
2523struct GFX8_3DSTATE_CONSTANT_GS {
2524   uint32_t                             DWordLength;
2525   uint32_t                             MOCS;
2526   uint32_t                             _3DCommandSubOpcode;
2527   uint32_t                             _3DCommandOpcode;
2528   uint32_t                             CommandSubType;
2529   uint32_t                             CommandType;
2530   struct GFX8_3DSTATE_CONSTANT_BODY    ConstantBody;
2531};
2532
2533static inline __attribute__((always_inline)) void
2534GFX8_3DSTATE_CONSTANT_GS_pack(__attribute__((unused)) __gen_user_data *data,
2535                              __attribute__((unused)) void * restrict dst,
2536                              __attribute__((unused)) const struct GFX8_3DSTATE_CONSTANT_GS * restrict values)
2537{
2538   uint32_t * restrict dw = (uint32_t * restrict) dst;
2539
2540   dw[0] =
2541      __gen_uint(values->DWordLength, 0, 7) |
2542      __gen_uint(values->MOCS, 8, 14) |
2543      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2544      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2545      __gen_uint(values->CommandSubType, 27, 28) |
2546      __gen_uint(values->CommandType, 29, 31);
2547
2548   GFX8_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
2549}
2550
2551#define GFX8_3DSTATE_CONSTANT_HS_length       11
2552#define GFX8_3DSTATE_CONSTANT_HS_length_bias      2
2553#define GFX8_3DSTATE_CONSTANT_HS_header         \
2554   .DWordLength                         =      9,  \
2555   ._3DCommandSubOpcode                 =     25,  \
2556   ._3DCommandOpcode                    =      0,  \
2557   .CommandSubType                      =      3,  \
2558   .CommandType                         =      3
2559
2560struct GFX8_3DSTATE_CONSTANT_HS {
2561   uint32_t                             DWordLength;
2562   uint32_t                             MOCS;
2563   uint32_t                             _3DCommandSubOpcode;
2564   uint32_t                             _3DCommandOpcode;
2565   uint32_t                             CommandSubType;
2566   uint32_t                             CommandType;
2567   struct GFX8_3DSTATE_CONSTANT_BODY    ConstantBody;
2568};
2569
2570static inline __attribute__((always_inline)) void
2571GFX8_3DSTATE_CONSTANT_HS_pack(__attribute__((unused)) __gen_user_data *data,
2572                              __attribute__((unused)) void * restrict dst,
2573                              __attribute__((unused)) const struct GFX8_3DSTATE_CONSTANT_HS * restrict values)
2574{
2575   uint32_t * restrict dw = (uint32_t * restrict) dst;
2576
2577   dw[0] =
2578      __gen_uint(values->DWordLength, 0, 7) |
2579      __gen_uint(values->MOCS, 8, 14) |
2580      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2581      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2582      __gen_uint(values->CommandSubType, 27, 28) |
2583      __gen_uint(values->CommandType, 29, 31);
2584
2585   GFX8_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
2586}
2587
2588#define GFX8_3DSTATE_CONSTANT_PS_length       11
2589#define GFX8_3DSTATE_CONSTANT_PS_length_bias      2
2590#define GFX8_3DSTATE_CONSTANT_PS_header         \
2591   .DWordLength                         =      9,  \
2592   ._3DCommandSubOpcode                 =     23,  \
2593   ._3DCommandOpcode                    =      0,  \
2594   .CommandSubType                      =      3,  \
2595   .CommandType                         =      3
2596
2597struct GFX8_3DSTATE_CONSTANT_PS {
2598   uint32_t                             DWordLength;
2599   uint32_t                             MOCS;
2600   uint32_t                             _3DCommandSubOpcode;
2601   uint32_t                             _3DCommandOpcode;
2602   uint32_t                             CommandSubType;
2603   uint32_t                             CommandType;
2604   struct GFX8_3DSTATE_CONSTANT_BODY    ConstantBody;
2605};
2606
2607static inline __attribute__((always_inline)) void
2608GFX8_3DSTATE_CONSTANT_PS_pack(__attribute__((unused)) __gen_user_data *data,
2609                              __attribute__((unused)) void * restrict dst,
2610                              __attribute__((unused)) const struct GFX8_3DSTATE_CONSTANT_PS * restrict values)
2611{
2612   uint32_t * restrict dw = (uint32_t * restrict) dst;
2613
2614   dw[0] =
2615      __gen_uint(values->DWordLength, 0, 7) |
2616      __gen_uint(values->MOCS, 8, 14) |
2617      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2618      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2619      __gen_uint(values->CommandSubType, 27, 28) |
2620      __gen_uint(values->CommandType, 29, 31);
2621
2622   GFX8_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
2623}
2624
2625#define GFX8_3DSTATE_CONSTANT_VS_length       11
2626#define GFX8_3DSTATE_CONSTANT_VS_length_bias      2
2627#define GFX8_3DSTATE_CONSTANT_VS_header         \
2628   .DWordLength                         =      9,  \
2629   ._3DCommandSubOpcode                 =     21,  \
2630   ._3DCommandOpcode                    =      0,  \
2631   .CommandSubType                      =      3,  \
2632   .CommandType                         =      3
2633
2634struct GFX8_3DSTATE_CONSTANT_VS {
2635   uint32_t                             DWordLength;
2636   uint32_t                             MOCS;
2637   uint32_t                             _3DCommandSubOpcode;
2638   uint32_t                             _3DCommandOpcode;
2639   uint32_t                             CommandSubType;
2640   uint32_t                             CommandType;
2641   struct GFX8_3DSTATE_CONSTANT_BODY    ConstantBody;
2642};
2643
2644static inline __attribute__((always_inline)) void
2645GFX8_3DSTATE_CONSTANT_VS_pack(__attribute__((unused)) __gen_user_data *data,
2646                              __attribute__((unused)) void * restrict dst,
2647                              __attribute__((unused)) const struct GFX8_3DSTATE_CONSTANT_VS * restrict values)
2648{
2649   uint32_t * restrict dw = (uint32_t * restrict) dst;
2650
2651   dw[0] =
2652      __gen_uint(values->DWordLength, 0, 7) |
2653      __gen_uint(values->MOCS, 8, 14) |
2654      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2655      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2656      __gen_uint(values->CommandSubType, 27, 28) |
2657      __gen_uint(values->CommandType, 29, 31);
2658
2659   GFX8_3DSTATE_CONSTANT_BODY_pack(data, &dw[1], &values->ConstantBody);
2660}
2661
2662#define GFX8_3DSTATE_DEPTH_BUFFER_length       8
2663#define GFX8_3DSTATE_DEPTH_BUFFER_length_bias      2
2664#define GFX8_3DSTATE_DEPTH_BUFFER_header        \
2665   .DWordLength                         =      6,  \
2666   ._3DCommandSubOpcode                 =      5,  \
2667   ._3DCommandOpcode                    =      0,  \
2668   .CommandSubType                      =      3,  \
2669   .CommandType                         =      3
2670
2671struct GFX8_3DSTATE_DEPTH_BUFFER {
2672   uint32_t                             DWordLength;
2673   uint32_t                             _3DCommandSubOpcode;
2674   uint32_t                             _3DCommandOpcode;
2675   uint32_t                             CommandSubType;
2676   uint32_t                             CommandType;
2677   uint32_t                             SurfacePitch;
2678   uint32_t                             SurfaceFormat;
2679#define D32_FLOAT                                1
2680#define D24_UNORM_X8_UINT                        3
2681#define D16_UNORM                                5
2682   bool                                 HierarchicalDepthBufferEnable;
2683   bool                                 StencilWriteEnable;
2684   bool                                 DepthWriteEnable;
2685   uint32_t                             SurfaceType;
2686#define SURFTYPE_1D                              0
2687#define SURFTYPE_2D                              1
2688#define SURFTYPE_3D                              2
2689#define SURFTYPE_CUBE                            3
2690#define SURFTYPE_NULL                            7
2691   __gen_address_type                   SurfaceBaseAddress;
2692   uint32_t                             LOD;
2693   uint32_t                             Width;
2694   uint32_t                             Height;
2695   uint32_t                             MOCS;
2696   uint32_t                             MinimumArrayElement;
2697   uint32_t                             Depth;
2698   uint32_t                             SurfaceQPitch;
2699   uint32_t                             RenderTargetViewExtent;
2700};
2701
2702static inline __attribute__((always_inline)) void
2703GFX8_3DSTATE_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2704                               __attribute__((unused)) void * restrict dst,
2705                               __attribute__((unused)) const struct GFX8_3DSTATE_DEPTH_BUFFER * restrict values)
2706{
2707   uint32_t * restrict dw = (uint32_t * restrict) dst;
2708
2709   dw[0] =
2710      __gen_uint(values->DWordLength, 0, 7) |
2711      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2712      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2713      __gen_uint(values->CommandSubType, 27, 28) |
2714      __gen_uint(values->CommandType, 29, 31);
2715
2716   dw[1] =
2717      __gen_uint(values->SurfacePitch, 0, 17) |
2718      __gen_uint(values->SurfaceFormat, 18, 20) |
2719      __gen_uint(values->HierarchicalDepthBufferEnable, 22, 22) |
2720      __gen_uint(values->StencilWriteEnable, 27, 27) |
2721      __gen_uint(values->DepthWriteEnable, 28, 28) |
2722      __gen_uint(values->SurfaceType, 29, 31);
2723
2724   const uint64_t v2_address =
2725      __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 63);
2726   dw[2] = v2_address;
2727   dw[3] = v2_address >> 32;
2728
2729   dw[4] =
2730      __gen_uint(values->LOD, 0, 3) |
2731      __gen_uint(values->Width, 4, 17) |
2732      __gen_uint(values->Height, 18, 31);
2733
2734   dw[5] =
2735      __gen_uint(values->MOCS, 0, 6) |
2736      __gen_uint(values->MinimumArrayElement, 10, 20) |
2737      __gen_uint(values->Depth, 21, 31);
2738
2739   dw[6] = 0;
2740
2741   dw[7] =
2742      __gen_uint(values->SurfaceQPitch, 0, 14) |
2743      __gen_uint(values->RenderTargetViewExtent, 21, 31);
2744}
2745
2746#define GFX8_3DSTATE_DRAWING_RECTANGLE_length      4
2747#define GFX8_3DSTATE_DRAWING_RECTANGLE_length_bias      2
2748#define GFX8_3DSTATE_DRAWING_RECTANGLE_header   \
2749   .DWordLength                         =      2,  \
2750   ._3DCommandSubOpcode                 =      0,  \
2751   ._3DCommandOpcode                    =      1,  \
2752   .CommandSubType                      =      3,  \
2753   .CommandType                         =      3
2754
2755struct GFX8_3DSTATE_DRAWING_RECTANGLE {
2756   uint32_t                             DWordLength;
2757   uint32_t                             CoreModeSelect;
2758#define Legacy                                   0
2759#define Core0Enabled                             1
2760#define Core1Enabled                             2
2761   uint32_t                             _3DCommandSubOpcode;
2762   uint32_t                             _3DCommandOpcode;
2763   uint32_t                             CommandSubType;
2764   uint32_t                             CommandType;
2765   uint32_t                             ClippedDrawingRectangleXMin;
2766   uint32_t                             ClippedDrawingRectangleYMin;
2767   uint32_t                             ClippedDrawingRectangleXMax;
2768   uint32_t                             ClippedDrawingRectangleYMax;
2769   int32_t                              DrawingRectangleOriginX;
2770   int32_t                              DrawingRectangleOriginY;
2771};
2772
2773static inline __attribute__((always_inline)) void
2774GFX8_3DSTATE_DRAWING_RECTANGLE_pack(__attribute__((unused)) __gen_user_data *data,
2775                                    __attribute__((unused)) void * restrict dst,
2776                                    __attribute__((unused)) const struct GFX8_3DSTATE_DRAWING_RECTANGLE * restrict values)
2777{
2778   uint32_t * restrict dw = (uint32_t * restrict) dst;
2779
2780   dw[0] =
2781      __gen_uint(values->DWordLength, 0, 7) |
2782      __gen_uint(values->CoreModeSelect, 14, 15) |
2783      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2784      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2785      __gen_uint(values->CommandSubType, 27, 28) |
2786      __gen_uint(values->CommandType, 29, 31);
2787
2788   dw[1] =
2789      __gen_uint(values->ClippedDrawingRectangleXMin, 0, 15) |
2790      __gen_uint(values->ClippedDrawingRectangleYMin, 16, 31);
2791
2792   dw[2] =
2793      __gen_uint(values->ClippedDrawingRectangleXMax, 0, 15) |
2794      __gen_uint(values->ClippedDrawingRectangleYMax, 16, 31);
2795
2796   dw[3] =
2797      __gen_sint(values->DrawingRectangleOriginX, 0, 15) |
2798      __gen_sint(values->DrawingRectangleOriginY, 16, 31);
2799}
2800
2801#define GFX8_3DSTATE_DS_length                 9
2802#define GFX8_3DSTATE_DS_length_bias            2
2803#define GFX8_3DSTATE_DS_header                  \
2804   .DWordLength                         =      7,  \
2805   ._3DCommandSubOpcode                 =     29,  \
2806   ._3DCommandOpcode                    =      0,  \
2807   .CommandSubType                      =      3,  \
2808   .CommandType                         =      3
2809
2810struct GFX8_3DSTATE_DS {
2811   uint32_t                             DWordLength;
2812   uint32_t                             _3DCommandSubOpcode;
2813   uint32_t                             _3DCommandOpcode;
2814   uint32_t                             CommandSubType;
2815   uint32_t                             CommandType;
2816   uint64_t                             KernelStartPointer;
2817   bool                                 SoftwareExceptionEnable;
2818   bool                                 IllegalOpcodeExceptionEnable;
2819   bool                                 AccessesUAV;
2820   uint32_t                             FloatingPointMode;
2821#define IEEE754                                  0
2822#define Alternate                                1
2823   uint32_t                             ThreadDispatchPriority;
2824#define High                                     1
2825   uint32_t                             BindingTableEntryCount;
2826   uint32_t                             SamplerCount;
2827#define NoSamplers                               0
2828#define _14Samplers                              1
2829#define _58Samplers                              2
2830#define _912Samplers                             3
2831#define _1316Samplers                            4
2832   bool                                 VectorMaskEnable;
2833   uint32_t                             SingleDomainPointDispatch;
2834   uint32_t                             PerThreadScratchSpace;
2835   __gen_address_type                   ScratchSpaceBasePointer;
2836   uint32_t                             PatchURBEntryReadOffset;
2837   uint32_t                             PatchURBEntryReadLength;
2838   uint32_t                             DispatchGRFStartRegisterForURBData;
2839   bool                                 Enable;
2840   bool                                 CacheDisable;
2841   bool                                 ComputeWCoordinateEnable;
2842   uint32_t                             DispatchMode;
2843#define DISPATCH_MODE_SIMD4X2                    0
2844#define DISPATCH_MODE_SIMD8_SINGLE_PATCH         1
2845   bool                                 StatisticsEnable;
2846   uint32_t                             MaximumNumberofThreads;
2847   uint32_t                             UserClipDistanceCullTestEnableBitmask;
2848   uint32_t                             UserClipDistanceClipTestEnableBitmask;
2849   uint32_t                             VertexURBEntryOutputLength;
2850   uint32_t                             VertexURBEntryOutputReadOffset;
2851};
2852
2853static inline __attribute__((always_inline)) void
2854GFX8_3DSTATE_DS_pack(__attribute__((unused)) __gen_user_data *data,
2855                     __attribute__((unused)) void * restrict dst,
2856                     __attribute__((unused)) const struct GFX8_3DSTATE_DS * restrict values)
2857{
2858   uint32_t * restrict dw = (uint32_t * restrict) dst;
2859
2860   dw[0] =
2861      __gen_uint(values->DWordLength, 0, 7) |
2862      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2863      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2864      __gen_uint(values->CommandSubType, 27, 28) |
2865      __gen_uint(values->CommandType, 29, 31);
2866
2867   const uint64_t v1 =
2868      __gen_offset(values->KernelStartPointer, 6, 63);
2869   dw[1] = v1;
2870   dw[2] = v1 >> 32;
2871
2872   dw[3] =
2873      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
2874      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
2875      __gen_uint(values->AccessesUAV, 14, 14) |
2876      __gen_uint(values->FloatingPointMode, 16, 16) |
2877      __gen_uint(values->ThreadDispatchPriority, 17, 17) |
2878      __gen_uint(values->BindingTableEntryCount, 18, 25) |
2879      __gen_uint(values->SamplerCount, 27, 29) |
2880      __gen_uint(values->VectorMaskEnable, 30, 30) |
2881      __gen_uint(values->SingleDomainPointDispatch, 31, 31);
2882
2883   const uint64_t v4 =
2884      __gen_uint(values->PerThreadScratchSpace, 0, 3);
2885   const uint64_t v4_address =
2886      __gen_address(data, &dw[4], values->ScratchSpaceBasePointer, v4, 10, 63);
2887   dw[4] = v4_address;
2888   dw[5] = (v4_address >> 32) | (v4 >> 32);
2889
2890   dw[6] =
2891      __gen_uint(values->PatchURBEntryReadOffset, 4, 9) |
2892      __gen_uint(values->PatchURBEntryReadLength, 11, 17) |
2893      __gen_uint(values->DispatchGRFStartRegisterForURBData, 20, 24);
2894
2895   dw[7] =
2896      __gen_uint(values->Enable, 0, 0) |
2897      __gen_uint(values->CacheDisable, 1, 1) |
2898      __gen_uint(values->ComputeWCoordinateEnable, 2, 2) |
2899      __gen_uint(values->DispatchMode, 3, 3) |
2900      __gen_uint(values->StatisticsEnable, 10, 10) |
2901      __gen_uint(values->MaximumNumberofThreads, 21, 29);
2902
2903   dw[8] =
2904      __gen_uint(values->UserClipDistanceCullTestEnableBitmask, 0, 7) |
2905      __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 8, 15) |
2906      __gen_uint(values->VertexURBEntryOutputLength, 16, 20) |
2907      __gen_uint(values->VertexURBEntryOutputReadOffset, 21, 26);
2908}
2909
2910#define GFX8_3DSTATE_GATHER_CONSTANT_DS_length_bias      2
2911#define GFX8_3DSTATE_GATHER_CONSTANT_DS_header  \
2912   .DWordLength                         =      1,  \
2913   ._3DCommandSubOpcode                 =     55,  \
2914   ._3DCommandOpcode                    =      0,  \
2915   .CommandSubType                      =      3,  \
2916   .CommandType                         =      3
2917
2918struct GFX8_3DSTATE_GATHER_CONSTANT_DS {
2919   uint32_t                             DWordLength;
2920   uint32_t                             _3DCommandSubOpcode;
2921   uint32_t                             _3DCommandOpcode;
2922   uint32_t                             CommandSubType;
2923   uint32_t                             CommandType;
2924   uint32_t                             ConstantBufferBindingTableBlock;
2925   uint32_t                             ConstantBufferValid;
2926   bool                                 ConstantBufferDx9GenerateStall;
2927   uint64_t                             GatherBufferOffset;
2928   /* variable length fields follow */
2929};
2930
2931static inline __attribute__((always_inline)) void
2932GFX8_3DSTATE_GATHER_CONSTANT_DS_pack(__attribute__((unused)) __gen_user_data *data,
2933                                     __attribute__((unused)) void * restrict dst,
2934                                     __attribute__((unused)) const struct GFX8_3DSTATE_GATHER_CONSTANT_DS * restrict values)
2935{
2936   uint32_t * restrict dw = (uint32_t * restrict) dst;
2937
2938   dw[0] =
2939      __gen_uint(values->DWordLength, 0, 7) |
2940      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2941      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2942      __gen_uint(values->CommandSubType, 27, 28) |
2943      __gen_uint(values->CommandType, 29, 31);
2944
2945   dw[1] =
2946      __gen_uint(values->ConstantBufferBindingTableBlock, 12, 15) |
2947      __gen_uint(values->ConstantBufferValid, 16, 31);
2948
2949   dw[2] =
2950      __gen_uint(values->ConstantBufferDx9GenerateStall, 5, 5) |
2951      __gen_offset(values->GatherBufferOffset, 6, 22);
2952}
2953
2954#define GFX8_3DSTATE_GATHER_CONSTANT_GS_length_bias      2
2955#define GFX8_3DSTATE_GATHER_CONSTANT_GS_header  \
2956   .DWordLength                         =      1,  \
2957   ._3DCommandSubOpcode                 =     53,  \
2958   ._3DCommandOpcode                    =      0,  \
2959   .CommandSubType                      =      3,  \
2960   .CommandType                         =      3
2961
2962struct GFX8_3DSTATE_GATHER_CONSTANT_GS {
2963   uint32_t                             DWordLength;
2964   uint32_t                             _3DCommandSubOpcode;
2965   uint32_t                             _3DCommandOpcode;
2966   uint32_t                             CommandSubType;
2967   uint32_t                             CommandType;
2968   uint32_t                             ConstantBufferBindingTableBlock;
2969   uint32_t                             ConstantBufferValid;
2970   bool                                 ConstantBufferDx9GenerateStall;
2971   uint64_t                             GatherBufferOffset;
2972   /* variable length fields follow */
2973};
2974
2975static inline __attribute__((always_inline)) void
2976GFX8_3DSTATE_GATHER_CONSTANT_GS_pack(__attribute__((unused)) __gen_user_data *data,
2977                                     __attribute__((unused)) void * restrict dst,
2978                                     __attribute__((unused)) const struct GFX8_3DSTATE_GATHER_CONSTANT_GS * restrict values)
2979{
2980   uint32_t * restrict dw = (uint32_t * restrict) dst;
2981
2982   dw[0] =
2983      __gen_uint(values->DWordLength, 0, 7) |
2984      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2985      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2986      __gen_uint(values->CommandSubType, 27, 28) |
2987      __gen_uint(values->CommandType, 29, 31);
2988
2989   dw[1] =
2990      __gen_uint(values->ConstantBufferBindingTableBlock, 12, 15) |
2991      __gen_uint(values->ConstantBufferValid, 16, 31);
2992
2993   dw[2] =
2994      __gen_uint(values->ConstantBufferDx9GenerateStall, 5, 5) |
2995      __gen_offset(values->GatherBufferOffset, 6, 22);
2996}
2997
2998#define GFX8_3DSTATE_GATHER_CONSTANT_HS_length_bias      2
2999#define GFX8_3DSTATE_GATHER_CONSTANT_HS_header  \
3000   .DWordLength                         =      1,  \
3001   ._3DCommandSubOpcode                 =     54,  \
3002   ._3DCommandOpcode                    =      0,  \
3003   .CommandSubType                      =      3,  \
3004   .CommandType                         =      3
3005
3006struct GFX8_3DSTATE_GATHER_CONSTANT_HS {
3007   uint32_t                             DWordLength;
3008   uint32_t                             _3DCommandSubOpcode;
3009   uint32_t                             _3DCommandOpcode;
3010   uint32_t                             CommandSubType;
3011   uint32_t                             CommandType;
3012   uint32_t                             ConstantBufferBindingTableBlock;
3013   uint32_t                             ConstantBufferValid;
3014   bool                                 ConstantBufferDx9GenerateStall;
3015   uint64_t                             GatherBufferOffset;
3016   /* variable length fields follow */
3017};
3018
3019static inline __attribute__((always_inline)) void
3020GFX8_3DSTATE_GATHER_CONSTANT_HS_pack(__attribute__((unused)) __gen_user_data *data,
3021                                     __attribute__((unused)) void * restrict dst,
3022                                     __attribute__((unused)) const struct GFX8_3DSTATE_GATHER_CONSTANT_HS * restrict values)
3023{
3024   uint32_t * restrict dw = (uint32_t * restrict) dst;
3025
3026   dw[0] =
3027      __gen_uint(values->DWordLength, 0, 7) |
3028      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3029      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3030      __gen_uint(values->CommandSubType, 27, 28) |
3031      __gen_uint(values->CommandType, 29, 31);
3032
3033   dw[1] =
3034      __gen_uint(values->ConstantBufferBindingTableBlock, 12, 15) |
3035      __gen_uint(values->ConstantBufferValid, 16, 31);
3036
3037   dw[2] =
3038      __gen_uint(values->ConstantBufferDx9GenerateStall, 5, 5) |
3039      __gen_offset(values->GatherBufferOffset, 6, 22);
3040}
3041
3042#define GFX8_3DSTATE_GATHER_CONSTANT_PS_length_bias      2
3043#define GFX8_3DSTATE_GATHER_CONSTANT_PS_header  \
3044   .DWordLength                         =      1,  \
3045   ._3DCommandSubOpcode                 =     56,  \
3046   ._3DCommandOpcode                    =      0,  \
3047   .CommandSubType                      =      3,  \
3048   .CommandType                         =      3
3049
3050struct GFX8_3DSTATE_GATHER_CONSTANT_PS {
3051   uint32_t                             DWordLength;
3052   uint32_t                             _3DCommandSubOpcode;
3053   uint32_t                             _3DCommandOpcode;
3054   uint32_t                             CommandSubType;
3055   uint32_t                             CommandType;
3056   uint32_t                             ConstantBufferBindingTableBlock;
3057   uint32_t                             ConstantBufferValid;
3058   bool                                 ConstantBufferDx9Enable;
3059   bool                                 ConstantBufferDx9GenerateStall;
3060   uint64_t                             GatherBufferOffset;
3061   /* variable length fields follow */
3062};
3063
3064static inline __attribute__((always_inline)) void
3065GFX8_3DSTATE_GATHER_CONSTANT_PS_pack(__attribute__((unused)) __gen_user_data *data,
3066                                     __attribute__((unused)) void * restrict dst,
3067                                     __attribute__((unused)) const struct GFX8_3DSTATE_GATHER_CONSTANT_PS * restrict values)
3068{
3069   uint32_t * restrict dw = (uint32_t * restrict) dst;
3070
3071   dw[0] =
3072      __gen_uint(values->DWordLength, 0, 7) |
3073      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3074      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3075      __gen_uint(values->CommandSubType, 27, 28) |
3076      __gen_uint(values->CommandType, 29, 31);
3077
3078   dw[1] =
3079      __gen_uint(values->ConstantBufferBindingTableBlock, 12, 15) |
3080      __gen_uint(values->ConstantBufferValid, 16, 31);
3081
3082   dw[2] =
3083      __gen_uint(values->ConstantBufferDx9Enable, 4, 4) |
3084      __gen_uint(values->ConstantBufferDx9GenerateStall, 5, 5) |
3085      __gen_offset(values->GatherBufferOffset, 6, 22);
3086}
3087
3088#define GFX8_3DSTATE_GATHER_CONSTANT_VS_length_bias      2
3089#define GFX8_3DSTATE_GATHER_CONSTANT_VS_header  \
3090   .DWordLength                         =      0,  \
3091   ._3DCommandSubOpcode                 =     52,  \
3092   ._3DCommandOpcode                    =      0,  \
3093   .CommandSubType                      =      3,  \
3094   .CommandType                         =      3
3095
3096struct GFX8_3DSTATE_GATHER_CONSTANT_VS {
3097   uint32_t                             DWordLength;
3098   uint32_t                             _3DCommandSubOpcode;
3099   uint32_t                             _3DCommandOpcode;
3100   uint32_t                             CommandSubType;
3101   uint32_t                             CommandType;
3102   uint32_t                             ConstantBufferBindingTableBlock;
3103   uint32_t                             ConstantBufferValid;
3104   bool                                 ConstantBufferDx9Enable;
3105   bool                                 ConstantBufferDx9GenerateStall;
3106   uint64_t                             GatherBufferOffset;
3107   /* variable length fields follow */
3108};
3109
3110static inline __attribute__((always_inline)) void
3111GFX8_3DSTATE_GATHER_CONSTANT_VS_pack(__attribute__((unused)) __gen_user_data *data,
3112                                     __attribute__((unused)) void * restrict dst,
3113                                     __attribute__((unused)) const struct GFX8_3DSTATE_GATHER_CONSTANT_VS * restrict values)
3114{
3115   uint32_t * restrict dw = (uint32_t * restrict) dst;
3116
3117   dw[0] =
3118      __gen_uint(values->DWordLength, 0, 7) |
3119      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3120      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3121      __gen_uint(values->CommandSubType, 27, 28) |
3122      __gen_uint(values->CommandType, 29, 31);
3123
3124   dw[1] =
3125      __gen_uint(values->ConstantBufferBindingTableBlock, 12, 15) |
3126      __gen_uint(values->ConstantBufferValid, 16, 31);
3127
3128   dw[2] =
3129      __gen_uint(values->ConstantBufferDx9Enable, 4, 4) |
3130      __gen_uint(values->ConstantBufferDx9GenerateStall, 5, 5) |
3131      __gen_offset(values->GatherBufferOffset, 6, 22);
3132}
3133
3134#define GFX8_3DSTATE_GATHER_POOL_ALLOC_length      4
3135#define GFX8_3DSTATE_GATHER_POOL_ALLOC_length_bias      2
3136#define GFX8_3DSTATE_GATHER_POOL_ALLOC_header   \
3137   .DWordLength                         =      2,  \
3138   ._3DCommandSubOpcode                 =     26,  \
3139   ._3DCommandOpcode                    =      1,  \
3140   .CommandSubType                      =      3,  \
3141   .CommandType                         =      3
3142
3143struct GFX8_3DSTATE_GATHER_POOL_ALLOC {
3144   uint32_t                             DWordLength;
3145   uint32_t                             _3DCommandSubOpcode;
3146   uint32_t                             _3DCommandOpcode;
3147   uint32_t                             CommandSubType;
3148   uint32_t                             CommandType;
3149   uint32_t                             MOCS;
3150   bool                                 GatherPoolEnable;
3151   __gen_address_type                   GatherPoolBaseAddress;
3152   uint32_t                             GatherPoolBufferSize;
3153};
3154
3155static inline __attribute__((always_inline)) void
3156GFX8_3DSTATE_GATHER_POOL_ALLOC_pack(__attribute__((unused)) __gen_user_data *data,
3157                                    __attribute__((unused)) void * restrict dst,
3158                                    __attribute__((unused)) const struct GFX8_3DSTATE_GATHER_POOL_ALLOC * restrict values)
3159{
3160   uint32_t * restrict dw = (uint32_t * restrict) dst;
3161
3162   dw[0] =
3163      __gen_uint(values->DWordLength, 0, 7) |
3164      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3165      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3166      __gen_uint(values->CommandSubType, 27, 28) |
3167      __gen_uint(values->CommandType, 29, 31);
3168
3169   const uint64_t v1 =
3170      __gen_uint(values->MOCS, 0, 6) |
3171      __gen_uint(values->GatherPoolEnable, 11, 11);
3172   const uint64_t v1_address =
3173      __gen_address(data, &dw[1], values->GatherPoolBaseAddress, v1, 12, 63);
3174   dw[1] = v1_address;
3175   dw[2] = (v1_address >> 32) | (v1 >> 32);
3176
3177   dw[3] =
3178      __gen_uint(values->GatherPoolBufferSize, 12, 31);
3179}
3180
3181#define GFX8_3DSTATE_GS_length                10
3182#define GFX8_3DSTATE_GS_length_bias            2
3183#define GFX8_3DSTATE_GS_header                  \
3184   .DWordLength                         =      8,  \
3185   ._3DCommandSubOpcode                 =     17,  \
3186   ._3DCommandOpcode                    =      0,  \
3187   .CommandSubType                      =      3,  \
3188   .CommandType                         =      3
3189
3190struct GFX8_3DSTATE_GS {
3191   uint32_t                             DWordLength;
3192   uint32_t                             _3DCommandSubOpcode;
3193   uint32_t                             _3DCommandOpcode;
3194   uint32_t                             CommandSubType;
3195   uint32_t                             CommandType;
3196   uint64_t                             KernelStartPointer;
3197   uint32_t                             ExpectedVertexCount;
3198   bool                                 SoftwareExceptionEnable;
3199   bool                                 MaskStackExceptionEnable;
3200   bool                                 AccessesUAV;
3201   bool                                 IllegalOpcodeExceptionEnable;
3202   uint32_t                             FloatingPointMode;
3203#define IEEE754                                  0
3204#define Alternate                                1
3205   uint32_t                             ThreadDispatchPriority;
3206#define High                                     1
3207   uint32_t                             BindingTableEntryCount;
3208   uint32_t                             SamplerCount;
3209#define NoSamplers                               0
3210#define _14Samplers                              1
3211#define _58Samplers                              2
3212#define _912Samplers                             3
3213#define _1316Samplers                            4
3214   bool                                 VectorMaskEnable;
3215   bool                                 SingleProgramFlow;
3216   uint32_t                             PerThreadScratchSpace;
3217   __gen_address_type                   ScratchSpaceBasePointer;
3218   uint32_t                             DispatchGRFStartRegisterForURBData;
3219   uint32_t                             VertexURBEntryReadOffset;
3220   bool                                 IncludeVertexHandles;
3221   uint32_t                             VertexURBEntryReadLength;
3222   enum GFX8_3D_Prim_Topo_Type          OutputTopology;
3223   uint32_t                             OutputVertexSize;
3224   bool                                 Enable;
3225   bool                                 DiscardAdjacency;
3226   uint32_t                             ReorderMode;
3227#define LEADING                                  0
3228#define TRAILING                                 1
3229   uint32_t                             Hint;
3230   bool                                 IncludePrimitiveID;
3231   uint32_t                             InvocationsIncrementValue;
3232   bool                                 StatisticsEnable;
3233   uint32_t                             DispatchMode;
3234#define DISPATCH_MODE_DualInstance               1
3235#define DISPATCH_MODE_DualObject                 2
3236#define DISPATCH_MODE_SIMD8                      3
3237   uint32_t                             DefaultStreamId;
3238   uint32_t                             InstanceControl;
3239   uint32_t                             ControlDataHeaderSize;
3240   uint32_t                             MaximumNumberofThreads;
3241   uint32_t                             StaticOutputVertexCount;
3242   bool                                 StaticOutput;
3243   uint32_t                             ControlDataFormat;
3244#define CUT                                      0
3245#define SID                                      1
3246   uint32_t                             UserClipDistanceCullTestEnableBitmask;
3247   uint32_t                             UserClipDistanceClipTestEnableBitmask;
3248   uint32_t                             VertexURBEntryOutputLength;
3249   uint32_t                             VertexURBEntryOutputReadOffset;
3250};
3251
3252static inline __attribute__((always_inline)) void
3253GFX8_3DSTATE_GS_pack(__attribute__((unused)) __gen_user_data *data,
3254                     __attribute__((unused)) void * restrict dst,
3255                     __attribute__((unused)) const struct GFX8_3DSTATE_GS * restrict values)
3256{
3257   uint32_t * restrict dw = (uint32_t * restrict) dst;
3258
3259   dw[0] =
3260      __gen_uint(values->DWordLength, 0, 7) |
3261      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3262      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3263      __gen_uint(values->CommandSubType, 27, 28) |
3264      __gen_uint(values->CommandType, 29, 31);
3265
3266   const uint64_t v1 =
3267      __gen_offset(values->KernelStartPointer, 6, 63);
3268   dw[1] = v1;
3269   dw[2] = v1 >> 32;
3270
3271   dw[3] =
3272      __gen_uint(values->ExpectedVertexCount, 0, 5) |
3273      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
3274      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
3275      __gen_uint(values->AccessesUAV, 12, 12) |
3276      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
3277      __gen_uint(values->FloatingPointMode, 16, 16) |
3278      __gen_uint(values->ThreadDispatchPriority, 17, 17) |
3279      __gen_uint(values->BindingTableEntryCount, 18, 25) |
3280      __gen_uint(values->SamplerCount, 27, 29) |
3281      __gen_uint(values->VectorMaskEnable, 30, 30) |
3282      __gen_uint(values->SingleProgramFlow, 31, 31);
3283
3284   const uint64_t v4 =
3285      __gen_uint(values->PerThreadScratchSpace, 0, 3);
3286   const uint64_t v4_address =
3287      __gen_address(data, &dw[4], values->ScratchSpaceBasePointer, v4, 10, 63);
3288   dw[4] = v4_address;
3289   dw[5] = (v4_address >> 32) | (v4 >> 32);
3290
3291   dw[6] =
3292      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
3293      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
3294      __gen_uint(values->IncludeVertexHandles, 10, 10) |
3295      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
3296      __gen_uint(values->OutputTopology, 17, 22) |
3297      __gen_uint(values->OutputVertexSize, 23, 28);
3298
3299   dw[7] =
3300      __gen_uint(values->Enable, 0, 0) |
3301      __gen_uint(values->DiscardAdjacency, 1, 1) |
3302      __gen_uint(values->ReorderMode, 2, 2) |
3303      __gen_uint(values->Hint, 3, 3) |
3304      __gen_uint(values->IncludePrimitiveID, 4, 4) |
3305      __gen_uint(values->InvocationsIncrementValue, 5, 9) |
3306      __gen_uint(values->StatisticsEnable, 10, 10) |
3307      __gen_uint(values->DispatchMode, 11, 12) |
3308      __gen_uint(values->DefaultStreamId, 13, 14) |
3309      __gen_uint(values->InstanceControl, 15, 19) |
3310      __gen_uint(values->ControlDataHeaderSize, 20, 23) |
3311      __gen_uint(values->MaximumNumberofThreads, 24, 31);
3312
3313   dw[8] =
3314      __gen_uint(values->StaticOutputVertexCount, 16, 26) |
3315      __gen_uint(values->StaticOutput, 30, 30) |
3316      __gen_uint(values->ControlDataFormat, 31, 31);
3317
3318   dw[9] =
3319      __gen_uint(values->UserClipDistanceCullTestEnableBitmask, 0, 7) |
3320      __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 8, 15) |
3321      __gen_uint(values->VertexURBEntryOutputLength, 16, 20) |
3322      __gen_uint(values->VertexURBEntryOutputReadOffset, 21, 26);
3323}
3324
3325#define GFX8_3DSTATE_HIER_DEPTH_BUFFER_length      5
3326#define GFX8_3DSTATE_HIER_DEPTH_BUFFER_length_bias      2
3327#define GFX8_3DSTATE_HIER_DEPTH_BUFFER_header   \
3328   .DWordLength                         =      3,  \
3329   ._3DCommandSubOpcode                 =      7,  \
3330   ._3DCommandOpcode                    =      0,  \
3331   .CommandSubType                      =      3,  \
3332   .CommandType                         =      3
3333
3334struct GFX8_3DSTATE_HIER_DEPTH_BUFFER {
3335   uint32_t                             DWordLength;
3336   uint32_t                             _3DCommandSubOpcode;
3337   uint32_t                             _3DCommandOpcode;
3338   uint32_t                             CommandSubType;
3339   uint32_t                             CommandType;
3340   uint32_t                             SurfacePitch;
3341   uint32_t                             MOCS;
3342   __gen_address_type                   SurfaceBaseAddress;
3343   uint32_t                             SurfaceQPitch;
3344};
3345
3346static inline __attribute__((always_inline)) void
3347GFX8_3DSTATE_HIER_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
3348                                    __attribute__((unused)) void * restrict dst,
3349                                    __attribute__((unused)) const struct GFX8_3DSTATE_HIER_DEPTH_BUFFER * restrict values)
3350{
3351   uint32_t * restrict dw = (uint32_t * restrict) dst;
3352
3353   dw[0] =
3354      __gen_uint(values->DWordLength, 0, 7) |
3355      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3356      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3357      __gen_uint(values->CommandSubType, 27, 28) |
3358      __gen_uint(values->CommandType, 29, 31);
3359
3360   dw[1] =
3361      __gen_uint(values->SurfacePitch, 0, 16) |
3362      __gen_uint(values->MOCS, 25, 31);
3363
3364   const uint64_t v2_address =
3365      __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 63);
3366   dw[2] = v2_address;
3367   dw[3] = v2_address >> 32;
3368
3369   dw[4] =
3370      __gen_uint(values->SurfaceQPitch, 0, 14);
3371}
3372
3373#define GFX8_3DSTATE_HS_length                 9
3374#define GFX8_3DSTATE_HS_length_bias            2
3375#define GFX8_3DSTATE_HS_header                  \
3376   .DWordLength                         =      7,  \
3377   ._3DCommandSubOpcode                 =     27,  \
3378   ._3DCommandOpcode                    =      0,  \
3379   .CommandSubType                      =      3,  \
3380   .CommandType                         =      3
3381
3382struct GFX8_3DSTATE_HS {
3383   uint32_t                             DWordLength;
3384   uint32_t                             _3DCommandSubOpcode;
3385   uint32_t                             _3DCommandOpcode;
3386   uint32_t                             CommandSubType;
3387   uint32_t                             CommandType;
3388   bool                                 SoftwareExceptionEnable;
3389   bool                                 IllegalOpcodeExceptionEnable;
3390   uint32_t                             FloatingPointMode;
3391#define IEEE754                                  0
3392#define alternate                                1
3393   uint32_t                             ThreadDispatchPriority;
3394#define High                                     1
3395   uint32_t                             BindingTableEntryCount;
3396   uint32_t                             SamplerCount;
3397#define NoSamplers                               0
3398#define _14Samplers                              1
3399#define _58Samplers                              2
3400#define _912Samplers                             3
3401#define _1316Samplers                            4
3402   uint32_t                             InstanceCount;
3403   uint32_t                             MaximumNumberofThreads;
3404   bool                                 StatisticsEnable;
3405   bool                                 Enable;
3406   uint64_t                             KernelStartPointer;
3407   uint32_t                             PerThreadScratchSpace;
3408   __gen_address_type                   ScratchSpaceBasePointer;
3409   uint32_t                             VertexURBEntryReadOffset;
3410   uint32_t                             VertexURBEntryReadLength;
3411   uint32_t                             DispatchGRFStartRegisterForURBData;
3412   bool                                 IncludeVertexHandles;
3413   bool                                 AccessesUAV;
3414   bool                                 VectorMaskEnable;
3415   bool                                 SingleProgramFlow;
3416};
3417
3418static inline __attribute__((always_inline)) void
3419GFX8_3DSTATE_HS_pack(__attribute__((unused)) __gen_user_data *data,
3420                     __attribute__((unused)) void * restrict dst,
3421                     __attribute__((unused)) const struct GFX8_3DSTATE_HS * restrict values)
3422{
3423   uint32_t * restrict dw = (uint32_t * restrict) dst;
3424
3425   dw[0] =
3426      __gen_uint(values->DWordLength, 0, 7) |
3427      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3428      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3429      __gen_uint(values->CommandSubType, 27, 28) |
3430      __gen_uint(values->CommandType, 29, 31);
3431
3432   dw[1] =
3433      __gen_uint(values->SoftwareExceptionEnable, 12, 12) |
3434      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
3435      __gen_uint(values->FloatingPointMode, 16, 16) |
3436      __gen_uint(values->ThreadDispatchPriority, 17, 17) |
3437      __gen_uint(values->BindingTableEntryCount, 18, 25) |
3438      __gen_uint(values->SamplerCount, 27, 29);
3439
3440   dw[2] =
3441      __gen_uint(values->InstanceCount, 0, 3) |
3442      __gen_uint(values->MaximumNumberofThreads, 8, 16) |
3443      __gen_uint(values->StatisticsEnable, 29, 29) |
3444      __gen_uint(values->Enable, 31, 31);
3445
3446   const uint64_t v3 =
3447      __gen_offset(values->KernelStartPointer, 6, 63);
3448   dw[3] = v3;
3449   dw[4] = v3 >> 32;
3450
3451   const uint64_t v5 =
3452      __gen_uint(values->PerThreadScratchSpace, 0, 3);
3453   const uint64_t v5_address =
3454      __gen_address(data, &dw[5], values->ScratchSpaceBasePointer, v5, 10, 63);
3455   dw[5] = v5_address;
3456   dw[6] = (v5_address >> 32) | (v5 >> 32);
3457
3458   dw[7] =
3459      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
3460      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
3461      __gen_uint(values->DispatchGRFStartRegisterForURBData, 19, 23) |
3462      __gen_uint(values->IncludeVertexHandles, 24, 24) |
3463      __gen_uint(values->AccessesUAV, 25, 25) |
3464      __gen_uint(values->VectorMaskEnable, 26, 26) |
3465      __gen_uint(values->SingleProgramFlow, 27, 27);
3466
3467   dw[8] = 0;
3468}
3469
3470#define GFX8_3DSTATE_INDEX_BUFFER_length       5
3471#define GFX8_3DSTATE_INDEX_BUFFER_length_bias      2
3472#define GFX8_3DSTATE_INDEX_BUFFER_header        \
3473   .DWordLength                         =      3,  \
3474   ._3DCommandSubOpcode                 =     10,  \
3475   ._3DCommandOpcode                    =      0,  \
3476   .CommandSubType                      =      3,  \
3477   .CommandType                         =      3
3478
3479struct GFX8_3DSTATE_INDEX_BUFFER {
3480   uint32_t                             DWordLength;
3481   uint32_t                             _3DCommandSubOpcode;
3482   uint32_t                             _3DCommandOpcode;
3483   uint32_t                             CommandSubType;
3484   uint32_t                             CommandType;
3485   uint32_t                             MOCS;
3486   uint32_t                             IndexFormat;
3487#define INDEX_BYTE                               0
3488#define INDEX_WORD                               1
3489#define INDEX_DWORD                              2
3490   __gen_address_type                   BufferStartingAddress;
3491   uint32_t                             BufferSize;
3492};
3493
3494static inline __attribute__((always_inline)) void
3495GFX8_3DSTATE_INDEX_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
3496                               __attribute__((unused)) void * restrict dst,
3497                               __attribute__((unused)) const struct GFX8_3DSTATE_INDEX_BUFFER * restrict values)
3498{
3499   uint32_t * restrict dw = (uint32_t * restrict) dst;
3500
3501   dw[0] =
3502      __gen_uint(values->DWordLength, 0, 7) |
3503      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3504      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3505      __gen_uint(values->CommandSubType, 27, 28) |
3506      __gen_uint(values->CommandType, 29, 31);
3507
3508   dw[1] =
3509      __gen_uint(values->MOCS, 0, 6) |
3510      __gen_uint(values->IndexFormat, 8, 9);
3511
3512   const uint64_t v2_address =
3513      __gen_address(data, &dw[2], values->BufferStartingAddress, 0, 0, 63);
3514   dw[2] = v2_address;
3515   dw[3] = v2_address >> 32;
3516
3517   dw[4] =
3518      __gen_uint(values->BufferSize, 0, 31);
3519}
3520
3521#define GFX8_3DSTATE_LINE_STIPPLE_length       3
3522#define GFX8_3DSTATE_LINE_STIPPLE_length_bias      2
3523#define GFX8_3DSTATE_LINE_STIPPLE_header        \
3524   .DWordLength                         =      1,  \
3525   ._3DCommandSubOpcode                 =      8,  \
3526   ._3DCommandOpcode                    =      1,  \
3527   .CommandSubType                      =      3,  \
3528   .CommandType                         =      3
3529
3530struct GFX8_3DSTATE_LINE_STIPPLE {
3531   uint32_t                             DWordLength;
3532   uint32_t                             _3DCommandSubOpcode;
3533   uint32_t                             _3DCommandOpcode;
3534   uint32_t                             CommandSubType;
3535   uint32_t                             CommandType;
3536   uint32_t                             LineStipplePattern;
3537   uint32_t                             CurrentStippleIndex;
3538   uint32_t                             CurrentRepeatCounter;
3539   bool                                 ModifyEnableCurrentRepeatCounterCurrentStippleIndex;
3540   uint32_t                             LineStippleRepeatCount;
3541   float                                LineStippleInverseRepeatCount;
3542};
3543
3544static inline __attribute__((always_inline)) void
3545GFX8_3DSTATE_LINE_STIPPLE_pack(__attribute__((unused)) __gen_user_data *data,
3546                               __attribute__((unused)) void * restrict dst,
3547                               __attribute__((unused)) const struct GFX8_3DSTATE_LINE_STIPPLE * restrict values)
3548{
3549   uint32_t * restrict dw = (uint32_t * restrict) dst;
3550
3551   dw[0] =
3552      __gen_uint(values->DWordLength, 0, 7) |
3553      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3554      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3555      __gen_uint(values->CommandSubType, 27, 28) |
3556      __gen_uint(values->CommandType, 29, 31);
3557
3558   dw[1] =
3559      __gen_uint(values->LineStipplePattern, 0, 15) |
3560      __gen_uint(values->CurrentStippleIndex, 16, 19) |
3561      __gen_uint(values->CurrentRepeatCounter, 21, 29) |
3562      __gen_uint(values->ModifyEnableCurrentRepeatCounterCurrentStippleIndex, 31, 31);
3563
3564   dw[2] =
3565      __gen_uint(values->LineStippleRepeatCount, 0, 8) |
3566      __gen_ufixed(values->LineStippleInverseRepeatCount, 15, 31, 16);
3567}
3568
3569#define GFX8_3DSTATE_MONOFILTER_SIZE_length      2
3570#define GFX8_3DSTATE_MONOFILTER_SIZE_length_bias      2
3571#define GFX8_3DSTATE_MONOFILTER_SIZE_header     \
3572   .DWordLength                         =      0,  \
3573   ._3DCommandSubOpcode                 =     17,  \
3574   ._3DCommandOpcode                    =      1,  \
3575   .CommandSubType                      =      3,  \
3576   .CommandType                         =      3
3577
3578struct GFX8_3DSTATE_MONOFILTER_SIZE {
3579   uint32_t                             DWordLength;
3580   uint32_t                             _3DCommandSubOpcode;
3581   uint32_t                             _3DCommandOpcode;
3582   uint32_t                             CommandSubType;
3583   uint32_t                             CommandType;
3584   uint32_t                             MonochromeFilterHeight;
3585   uint32_t                             MonochromeFilterWidth;
3586};
3587
3588static inline __attribute__((always_inline)) void
3589GFX8_3DSTATE_MONOFILTER_SIZE_pack(__attribute__((unused)) __gen_user_data *data,
3590                                  __attribute__((unused)) void * restrict dst,
3591                                  __attribute__((unused)) const struct GFX8_3DSTATE_MONOFILTER_SIZE * restrict values)
3592{
3593   uint32_t * restrict dw = (uint32_t * restrict) dst;
3594
3595   dw[0] =
3596      __gen_uint(values->DWordLength, 0, 7) |
3597      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3598      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3599      __gen_uint(values->CommandSubType, 27, 28) |
3600      __gen_uint(values->CommandType, 29, 31);
3601
3602   dw[1] =
3603      __gen_uint(values->MonochromeFilterHeight, 0, 2) |
3604      __gen_uint(values->MonochromeFilterWidth, 3, 5);
3605}
3606
3607#define GFX8_3DSTATE_MULTISAMPLE_length        2
3608#define GFX8_3DSTATE_MULTISAMPLE_length_bias      2
3609#define GFX8_3DSTATE_MULTISAMPLE_header         \
3610   .DWordLength                         =      0,  \
3611   ._3DCommandSubOpcode                 =     13,  \
3612   ._3DCommandOpcode                    =      0,  \
3613   .CommandSubType                      =      3,  \
3614   .CommandType                         =      3
3615
3616struct GFX8_3DSTATE_MULTISAMPLE {
3617   uint32_t                             DWordLength;
3618   uint32_t                             _3DCommandSubOpcode;
3619   uint32_t                             _3DCommandOpcode;
3620   uint32_t                             CommandSubType;
3621   uint32_t                             CommandType;
3622   uint32_t                             NumberofMultisamples;
3623   uint32_t                             PixelLocation;
3624#define CENTER                                   0
3625#define UL_CORNER                                1
3626   bool                                 PixelPositionOffsetEnable;
3627};
3628
3629static inline __attribute__((always_inline)) void
3630GFX8_3DSTATE_MULTISAMPLE_pack(__attribute__((unused)) __gen_user_data *data,
3631                              __attribute__((unused)) void * restrict dst,
3632                              __attribute__((unused)) const struct GFX8_3DSTATE_MULTISAMPLE * restrict values)
3633{
3634   uint32_t * restrict dw = (uint32_t * restrict) dst;
3635
3636   dw[0] =
3637      __gen_uint(values->DWordLength, 0, 7) |
3638      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3639      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3640      __gen_uint(values->CommandSubType, 27, 28) |
3641      __gen_uint(values->CommandType, 29, 31);
3642
3643   dw[1] =
3644      __gen_uint(values->NumberofMultisamples, 1, 3) |
3645      __gen_uint(values->PixelLocation, 4, 4) |
3646      __gen_uint(values->PixelPositionOffsetEnable, 5, 5);
3647}
3648
3649#define GFX8_3DSTATE_POLY_STIPPLE_OFFSET_length      2
3650#define GFX8_3DSTATE_POLY_STIPPLE_OFFSET_length_bias      2
3651#define GFX8_3DSTATE_POLY_STIPPLE_OFFSET_header \
3652   .DWordLength                         =      0,  \
3653   ._3DCommandSubOpcode                 =      6,  \
3654   ._3DCommandOpcode                    =      1,  \
3655   .CommandSubType                      =      3,  \
3656   .CommandType                         =      3
3657
3658struct GFX8_3DSTATE_POLY_STIPPLE_OFFSET {
3659   uint32_t                             DWordLength;
3660   uint32_t                             _3DCommandSubOpcode;
3661   uint32_t                             _3DCommandOpcode;
3662   uint32_t                             CommandSubType;
3663   uint32_t                             CommandType;
3664   uint32_t                             PolygonStippleYOffset;
3665   uint32_t                             PolygonStippleXOffset;
3666};
3667
3668static inline __attribute__((always_inline)) void
3669GFX8_3DSTATE_POLY_STIPPLE_OFFSET_pack(__attribute__((unused)) __gen_user_data *data,
3670                                      __attribute__((unused)) void * restrict dst,
3671                                      __attribute__((unused)) const struct GFX8_3DSTATE_POLY_STIPPLE_OFFSET * restrict values)
3672{
3673   uint32_t * restrict dw = (uint32_t * restrict) dst;
3674
3675   dw[0] =
3676      __gen_uint(values->DWordLength, 0, 7) |
3677      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3678      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3679      __gen_uint(values->CommandSubType, 27, 28) |
3680      __gen_uint(values->CommandType, 29, 31);
3681
3682   dw[1] =
3683      __gen_uint(values->PolygonStippleYOffset, 0, 4) |
3684      __gen_uint(values->PolygonStippleXOffset, 8, 12);
3685}
3686
3687#define GFX8_3DSTATE_POLY_STIPPLE_PATTERN_length     33
3688#define GFX8_3DSTATE_POLY_STIPPLE_PATTERN_length_bias      2
3689#define GFX8_3DSTATE_POLY_STIPPLE_PATTERN_header\
3690   .DWordLength                         =     31,  \
3691   ._3DCommandSubOpcode                 =      7,  \
3692   ._3DCommandOpcode                    =      1,  \
3693   .CommandSubType                      =      3,  \
3694   .CommandType                         =      3
3695
3696struct GFX8_3DSTATE_POLY_STIPPLE_PATTERN {
3697   uint32_t                             DWordLength;
3698   uint32_t                             _3DCommandSubOpcode;
3699   uint32_t                             _3DCommandOpcode;
3700   uint32_t                             CommandSubType;
3701   uint32_t                             CommandType;
3702   uint32_t                             PatternRow[32];
3703};
3704
3705static inline __attribute__((always_inline)) void
3706GFX8_3DSTATE_POLY_STIPPLE_PATTERN_pack(__attribute__((unused)) __gen_user_data *data,
3707                                       __attribute__((unused)) void * restrict dst,
3708                                       __attribute__((unused)) const struct GFX8_3DSTATE_POLY_STIPPLE_PATTERN * restrict values)
3709{
3710   uint32_t * restrict dw = (uint32_t * restrict) dst;
3711
3712   dw[0] =
3713      __gen_uint(values->DWordLength, 0, 7) |
3714      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3715      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3716      __gen_uint(values->CommandSubType, 27, 28) |
3717      __gen_uint(values->CommandType, 29, 31);
3718
3719   dw[1] =
3720      __gen_uint(values->PatternRow[0], 0, 31);
3721
3722   dw[2] =
3723      __gen_uint(values->PatternRow[1], 0, 31);
3724
3725   dw[3] =
3726      __gen_uint(values->PatternRow[2], 0, 31);
3727
3728   dw[4] =
3729      __gen_uint(values->PatternRow[3], 0, 31);
3730
3731   dw[5] =
3732      __gen_uint(values->PatternRow[4], 0, 31);
3733
3734   dw[6] =
3735      __gen_uint(values->PatternRow[5], 0, 31);
3736
3737   dw[7] =
3738      __gen_uint(values->PatternRow[6], 0, 31);
3739
3740   dw[8] =
3741      __gen_uint(values->PatternRow[7], 0, 31);
3742
3743   dw[9] =
3744      __gen_uint(values->PatternRow[8], 0, 31);
3745
3746   dw[10] =
3747      __gen_uint(values->PatternRow[9], 0, 31);
3748
3749   dw[11] =
3750      __gen_uint(values->PatternRow[10], 0, 31);
3751
3752   dw[12] =
3753      __gen_uint(values->PatternRow[11], 0, 31);
3754
3755   dw[13] =
3756      __gen_uint(values->PatternRow[12], 0, 31);
3757
3758   dw[14] =
3759      __gen_uint(values->PatternRow[13], 0, 31);
3760
3761   dw[15] =
3762      __gen_uint(values->PatternRow[14], 0, 31);
3763
3764   dw[16] =
3765      __gen_uint(values->PatternRow[15], 0, 31);
3766
3767   dw[17] =
3768      __gen_uint(values->PatternRow[16], 0, 31);
3769
3770   dw[18] =
3771      __gen_uint(values->PatternRow[17], 0, 31);
3772
3773   dw[19] =
3774      __gen_uint(values->PatternRow[18], 0, 31);
3775
3776   dw[20] =
3777      __gen_uint(values->PatternRow[19], 0, 31);
3778
3779   dw[21] =
3780      __gen_uint(values->PatternRow[20], 0, 31);
3781
3782   dw[22] =
3783      __gen_uint(values->PatternRow[21], 0, 31);
3784
3785   dw[23] =
3786      __gen_uint(values->PatternRow[22], 0, 31);
3787
3788   dw[24] =
3789      __gen_uint(values->PatternRow[23], 0, 31);
3790
3791   dw[25] =
3792      __gen_uint(values->PatternRow[24], 0, 31);
3793
3794   dw[26] =
3795      __gen_uint(values->PatternRow[25], 0, 31);
3796
3797   dw[27] =
3798      __gen_uint(values->PatternRow[26], 0, 31);
3799
3800   dw[28] =
3801      __gen_uint(values->PatternRow[27], 0, 31);
3802
3803   dw[29] =
3804      __gen_uint(values->PatternRow[28], 0, 31);
3805
3806   dw[30] =
3807      __gen_uint(values->PatternRow[29], 0, 31);
3808
3809   dw[31] =
3810      __gen_uint(values->PatternRow[30], 0, 31);
3811
3812   dw[32] =
3813      __gen_uint(values->PatternRow[31], 0, 31);
3814}
3815
3816#define GFX8_3DSTATE_PS_length                12
3817#define GFX8_3DSTATE_PS_length_bias            2
3818#define GFX8_3DSTATE_PS_header                  \
3819   .DWordLength                         =     10,  \
3820   ._3DCommandSubOpcode                 =     32,  \
3821   ._3DCommandOpcode                    =      0,  \
3822   .CommandSubType                      =      3,  \
3823   .CommandType                         =      3
3824
3825struct GFX8_3DSTATE_PS {
3826   uint32_t                             DWordLength;
3827   uint32_t                             _3DCommandSubOpcode;
3828   uint32_t                             _3DCommandOpcode;
3829   uint32_t                             CommandSubType;
3830   uint32_t                             CommandType;
3831   uint64_t                             KernelStartPointer0;
3832   bool                                 SoftwareExceptionEnable;
3833   bool                                 MaskStackExceptionEnable;
3834   bool                                 IllegalOpcodeExceptionEnable;
3835   uint32_t                             RoundingMode;
3836#define RTNE                                     0
3837#define RU                                       1
3838#define RD                                       2
3839#define RTZ                                      3
3840   uint32_t                             FloatingPointMode;
3841#define IEEE754                                  0
3842#define Alternate                                1
3843   uint32_t                             ThreadDispatchPriority;
3844#define High                                     1
3845   uint32_t                             BindingTableEntryCount;
3846   uint32_t                             SinglePrecisionDenormalMode;
3847#define FlushedtoZero                            0
3848#define Retained                                 1
3849   uint32_t                             SamplerCount;
3850#define NoSamplers                               0
3851#define _14Samplers                              1
3852#define _58Samplers                              2
3853#define _912Samplers                             3
3854#define _1316Samplers                            4
3855   bool                                 VectorMaskEnable;
3856   bool                                 SingleProgramFlow;
3857   uint32_t                             PerThreadScratchSpace;
3858   __gen_address_type                   ScratchSpaceBasePointer;
3859   bool                                 _8PixelDispatchEnable;
3860   bool                                 _16PixelDispatchEnable;
3861   bool                                 _32PixelDispatchEnable;
3862   uint32_t                             PositionXYOffsetSelect;
3863#define POSOFFSET_NONE                           0
3864#define POSOFFSET_CENTROID                       2
3865#define POSOFFSET_SAMPLE                         3
3866   bool                                 RenderTargetResolveEnable;
3867   bool                                 RenderTargetFastClearEnable;
3868   bool                                 PushConstantEnable;
3869   uint32_t                             MaximumNumberofThreadsPerPSD;
3870   uint32_t                             DispatchGRFStartRegisterForConstantSetupData2;
3871   uint32_t                             DispatchGRFStartRegisterForConstantSetupData1;
3872   uint32_t                             DispatchGRFStartRegisterForConstantSetupData0;
3873   uint64_t                             KernelStartPointer1;
3874   uint64_t                             KernelStartPointer2;
3875};
3876
3877static inline __attribute__((always_inline)) void
3878GFX8_3DSTATE_PS_pack(__attribute__((unused)) __gen_user_data *data,
3879                     __attribute__((unused)) void * restrict dst,
3880                     __attribute__((unused)) const struct GFX8_3DSTATE_PS * restrict values)
3881{
3882   uint32_t * restrict dw = (uint32_t * restrict) dst;
3883
3884   dw[0] =
3885      __gen_uint(values->DWordLength, 0, 7) |
3886      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3887      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3888      __gen_uint(values->CommandSubType, 27, 28) |
3889      __gen_uint(values->CommandType, 29, 31);
3890
3891   const uint64_t v1 =
3892      __gen_offset(values->KernelStartPointer0, 6, 63);
3893   dw[1] = v1;
3894   dw[2] = v1 >> 32;
3895
3896   dw[3] =
3897      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
3898      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
3899      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
3900      __gen_uint(values->RoundingMode, 14, 15) |
3901      __gen_uint(values->FloatingPointMode, 16, 16) |
3902      __gen_uint(values->ThreadDispatchPriority, 17, 17) |
3903      __gen_uint(values->BindingTableEntryCount, 18, 25) |
3904      __gen_uint(values->SinglePrecisionDenormalMode, 26, 26) |
3905      __gen_uint(values->SamplerCount, 27, 29) |
3906      __gen_uint(values->VectorMaskEnable, 30, 30) |
3907      __gen_uint(values->SingleProgramFlow, 31, 31);
3908
3909   const uint64_t v4 =
3910      __gen_uint(values->PerThreadScratchSpace, 0, 3);
3911   const uint64_t v4_address =
3912      __gen_address(data, &dw[4], values->ScratchSpaceBasePointer, v4, 10, 63);
3913   dw[4] = v4_address;
3914   dw[5] = (v4_address >> 32) | (v4 >> 32);
3915
3916   dw[6] =
3917      __gen_uint(values->_8PixelDispatchEnable, 0, 0) |
3918      __gen_uint(values->_16PixelDispatchEnable, 1, 1) |
3919      __gen_uint(values->_32PixelDispatchEnable, 2, 2) |
3920      __gen_uint(values->PositionXYOffsetSelect, 3, 4) |
3921      __gen_uint(values->RenderTargetResolveEnable, 6, 6) |
3922      __gen_uint(values->RenderTargetFastClearEnable, 8, 8) |
3923      __gen_uint(values->PushConstantEnable, 11, 11) |
3924      __gen_uint(values->MaximumNumberofThreadsPerPSD, 23, 31);
3925
3926   dw[7] =
3927      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData2, 0, 6) |
3928      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData1, 8, 14) |
3929      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData0, 16, 22);
3930
3931   const uint64_t v8 =
3932      __gen_offset(values->KernelStartPointer1, 6, 63);
3933   dw[8] = v8;
3934   dw[9] = v8 >> 32;
3935
3936   const uint64_t v10 =
3937      __gen_offset(values->KernelStartPointer2, 6, 63);
3938   dw[10] = v10;
3939   dw[11] = v10 >> 32;
3940}
3941
3942#define GFX8_3DSTATE_PS_BLEND_length           2
3943#define GFX8_3DSTATE_PS_BLEND_length_bias      2
3944#define GFX8_3DSTATE_PS_BLEND_header            \
3945   .DWordLength                         =      0,  \
3946   ._3DCommandSubOpcode                 =     77,  \
3947   ._3DCommandOpcode                    =      0,  \
3948   .CommandSubType                      =      3,  \
3949   .CommandType                         =      3
3950
3951struct GFX8_3DSTATE_PS_BLEND {
3952   uint32_t                             DWordLength;
3953   uint32_t                             _3DCommandSubOpcode;
3954   uint32_t                             _3DCommandOpcode;
3955   uint32_t                             CommandSubType;
3956   uint32_t                             CommandType;
3957   bool                                 IndependentAlphaBlendEnable;
3958   bool                                 AlphaTestEnable;
3959   uint32_t                             DestinationBlendFactor;
3960   uint32_t                             SourceBlendFactor;
3961   uint32_t                             DestinationAlphaBlendFactor;
3962   uint32_t                             SourceAlphaBlendFactor;
3963   bool                                 ColorBufferBlendEnable;
3964   bool                                 HasWriteableRT;
3965   bool                                 AlphaToCoverageEnable;
3966};
3967
3968static inline __attribute__((always_inline)) void
3969GFX8_3DSTATE_PS_BLEND_pack(__attribute__((unused)) __gen_user_data *data,
3970                           __attribute__((unused)) void * restrict dst,
3971                           __attribute__((unused)) const struct GFX8_3DSTATE_PS_BLEND * restrict values)
3972{
3973   uint32_t * restrict dw = (uint32_t * restrict) dst;
3974
3975   dw[0] =
3976      __gen_uint(values->DWordLength, 0, 7) |
3977      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
3978      __gen_uint(values->_3DCommandOpcode, 24, 26) |
3979      __gen_uint(values->CommandSubType, 27, 28) |
3980      __gen_uint(values->CommandType, 29, 31);
3981
3982   dw[1] =
3983      __gen_uint(values->IndependentAlphaBlendEnable, 7, 7) |
3984      __gen_uint(values->AlphaTestEnable, 8, 8) |
3985      __gen_uint(values->DestinationBlendFactor, 9, 13) |
3986      __gen_uint(values->SourceBlendFactor, 14, 18) |
3987      __gen_uint(values->DestinationAlphaBlendFactor, 19, 23) |
3988      __gen_uint(values->SourceAlphaBlendFactor, 24, 28) |
3989      __gen_uint(values->ColorBufferBlendEnable, 29, 29) |
3990      __gen_uint(values->HasWriteableRT, 30, 30) |
3991      __gen_uint(values->AlphaToCoverageEnable, 31, 31);
3992}
3993
3994#define GFX8_3DSTATE_PS_EXTRA_length           2
3995#define GFX8_3DSTATE_PS_EXTRA_length_bias      2
3996#define GFX8_3DSTATE_PS_EXTRA_header            \
3997   .DWordLength                         =      0,  \
3998   ._3DCommandSubOpcode                 =     79,  \
3999   ._3DCommandOpcode                    =      0,  \
4000   .CommandSubType                      =      3,  \
4001   .CommandType                         =      3
4002
4003struct GFX8_3DSTATE_PS_EXTRA {
4004   uint32_t                             DWordLength;
4005   uint32_t                             _3DCommandSubOpcode;
4006   uint32_t                             _3DCommandOpcode;
4007   uint32_t                             CommandSubType;
4008   uint32_t                             CommandType;
4009   bool                                 PixelShaderUsesInputCoverageMask;
4010   bool                                 PixelShaderHasUAV;
4011   bool                                 PixelShaderIsPerSample;
4012   bool                                 PixelShaderDisablesAlphaToCoverage;
4013   bool                                 AttributeEnable;
4014   bool                                 PixelShaderUsesSourceW;
4015   bool                                 PixelShaderUsesSourceDepth;
4016   bool                                 ForceComputedDepth;
4017   uint32_t                             PixelShaderComputedDepthMode;
4018#define PSCDEPTH_OFF                             0
4019#define PSCDEPTH_ON                              1
4020#define PSCDEPTH_ON_GE                           2
4021#define PSCDEPTH_ON_LE                           3
4022   bool                                 PixelShaderKillsPixel;
4023   bool                                 oMaskPresenttoRenderTarget;
4024   bool                                 PixelShaderDoesnotwritetoRT;
4025   bool                                 PixelShaderValid;
4026};
4027
4028static inline __attribute__((always_inline)) void
4029GFX8_3DSTATE_PS_EXTRA_pack(__attribute__((unused)) __gen_user_data *data,
4030                           __attribute__((unused)) void * restrict dst,
4031                           __attribute__((unused)) const struct GFX8_3DSTATE_PS_EXTRA * restrict values)
4032{
4033   uint32_t * restrict dw = (uint32_t * restrict) dst;
4034
4035   dw[0] =
4036      __gen_uint(values->DWordLength, 0, 7) |
4037      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4038      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4039      __gen_uint(values->CommandSubType, 27, 28) |
4040      __gen_uint(values->CommandType, 29, 31);
4041
4042   dw[1] =
4043      __gen_uint(values->PixelShaderUsesInputCoverageMask, 1, 1) |
4044      __gen_uint(values->PixelShaderHasUAV, 2, 2) |
4045      __gen_uint(values->PixelShaderIsPerSample, 6, 6) |
4046      __gen_uint(values->PixelShaderDisablesAlphaToCoverage, 7, 7) |
4047      __gen_uint(values->AttributeEnable, 8, 8) |
4048      __gen_uint(values->PixelShaderUsesSourceW, 23, 23) |
4049      __gen_uint(values->PixelShaderUsesSourceDepth, 24, 24) |
4050      __gen_uint(values->ForceComputedDepth, 25, 25) |
4051      __gen_uint(values->PixelShaderComputedDepthMode, 26, 27) |
4052      __gen_uint(values->PixelShaderKillsPixel, 28, 28) |
4053      __gen_uint(values->oMaskPresenttoRenderTarget, 29, 29) |
4054      __gen_uint(values->PixelShaderDoesnotwritetoRT, 30, 30) |
4055      __gen_uint(values->PixelShaderValid, 31, 31);
4056}
4057
4058#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_DS_length      2
4059#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_DS_length_bias      2
4060#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_DS_header\
4061   .DWordLength                         =      0,  \
4062   ._3DCommandSubOpcode                 =     20,  \
4063   ._3DCommandOpcode                    =      1,  \
4064   .CommandSubType                      =      3,  \
4065   .CommandType                         =      3
4066
4067struct GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_DS {
4068   uint32_t                             DWordLength;
4069   uint32_t                             _3DCommandSubOpcode;
4070   uint32_t                             _3DCommandOpcode;
4071   uint32_t                             CommandSubType;
4072   uint32_t                             CommandType;
4073   uint32_t                             ConstantBufferSize;
4074   uint32_t                             ConstantBufferOffset;
4075};
4076
4077static inline __attribute__((always_inline)) void
4078GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_DS_pack(__attribute__((unused)) __gen_user_data *data,
4079                                         __attribute__((unused)) void * restrict dst,
4080                                         __attribute__((unused)) const struct GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_DS * restrict values)
4081{
4082   uint32_t * restrict dw = (uint32_t * restrict) dst;
4083
4084   dw[0] =
4085      __gen_uint(values->DWordLength, 0, 7) |
4086      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4087      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4088      __gen_uint(values->CommandSubType, 27, 28) |
4089      __gen_uint(values->CommandType, 29, 31);
4090
4091   dw[1] =
4092      __gen_uint(values->ConstantBufferSize, 0, 5) |
4093      __gen_uint(values->ConstantBufferOffset, 16, 20);
4094}
4095
4096#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_GS_length      2
4097#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_GS_length_bias      2
4098#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_GS_header\
4099   .DWordLength                         =      0,  \
4100   ._3DCommandSubOpcode                 =     21,  \
4101   ._3DCommandOpcode                    =      1,  \
4102   .CommandSubType                      =      3,  \
4103   .CommandType                         =      3
4104
4105struct GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_GS {
4106   uint32_t                             DWordLength;
4107   uint32_t                             _3DCommandSubOpcode;
4108   uint32_t                             _3DCommandOpcode;
4109   uint32_t                             CommandSubType;
4110   uint32_t                             CommandType;
4111   uint32_t                             ConstantBufferSize;
4112   uint32_t                             ConstantBufferOffset;
4113};
4114
4115static inline __attribute__((always_inline)) void
4116GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_GS_pack(__attribute__((unused)) __gen_user_data *data,
4117                                         __attribute__((unused)) void * restrict dst,
4118                                         __attribute__((unused)) const struct GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_GS * restrict values)
4119{
4120   uint32_t * restrict dw = (uint32_t * restrict) dst;
4121
4122   dw[0] =
4123      __gen_uint(values->DWordLength, 0, 7) |
4124      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4125      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4126      __gen_uint(values->CommandSubType, 27, 28) |
4127      __gen_uint(values->CommandType, 29, 31);
4128
4129   dw[1] =
4130      __gen_uint(values->ConstantBufferSize, 0, 5) |
4131      __gen_uint(values->ConstantBufferOffset, 16, 20);
4132}
4133
4134#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_HS_length      2
4135#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_HS_length_bias      2
4136#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_HS_header\
4137   .DWordLength                         =      0,  \
4138   ._3DCommandSubOpcode                 =     19,  \
4139   ._3DCommandOpcode                    =      1,  \
4140   .CommandSubType                      =      3,  \
4141   .CommandType                         =      3
4142
4143struct GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_HS {
4144   uint32_t                             DWordLength;
4145   uint32_t                             _3DCommandSubOpcode;
4146   uint32_t                             _3DCommandOpcode;
4147   uint32_t                             CommandSubType;
4148   uint32_t                             CommandType;
4149   uint32_t                             ConstantBufferSize;
4150   uint32_t                             ConstantBufferOffset;
4151};
4152
4153static inline __attribute__((always_inline)) void
4154GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_HS_pack(__attribute__((unused)) __gen_user_data *data,
4155                                         __attribute__((unused)) void * restrict dst,
4156                                         __attribute__((unused)) const struct GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_HS * restrict values)
4157{
4158   uint32_t * restrict dw = (uint32_t * restrict) dst;
4159
4160   dw[0] =
4161      __gen_uint(values->DWordLength, 0, 7) |
4162      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4163      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4164      __gen_uint(values->CommandSubType, 27, 28) |
4165      __gen_uint(values->CommandType, 29, 31);
4166
4167   dw[1] =
4168      __gen_uint(values->ConstantBufferSize, 0, 5) |
4169      __gen_uint(values->ConstantBufferOffset, 16, 20);
4170}
4171
4172#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_PS_length      2
4173#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_PS_length_bias      2
4174#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_PS_header\
4175   .DWordLength                         =      0,  \
4176   ._3DCommandSubOpcode                 =     22,  \
4177   ._3DCommandOpcode                    =      1,  \
4178   .CommandSubType                      =      3,  \
4179   .CommandType                         =      3
4180
4181struct GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_PS {
4182   uint32_t                             DWordLength;
4183   uint32_t                             _3DCommandSubOpcode;
4184   uint32_t                             _3DCommandOpcode;
4185   uint32_t                             CommandSubType;
4186   uint32_t                             CommandType;
4187   uint32_t                             ConstantBufferSize;
4188   uint32_t                             ConstantBufferOffset;
4189};
4190
4191static inline __attribute__((always_inline)) void
4192GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_PS_pack(__attribute__((unused)) __gen_user_data *data,
4193                                         __attribute__((unused)) void * restrict dst,
4194                                         __attribute__((unused)) const struct GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_PS * restrict values)
4195{
4196   uint32_t * restrict dw = (uint32_t * restrict) dst;
4197
4198   dw[0] =
4199      __gen_uint(values->DWordLength, 0, 7) |
4200      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4201      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4202      __gen_uint(values->CommandSubType, 27, 28) |
4203      __gen_uint(values->CommandType, 29, 31);
4204
4205   dw[1] =
4206      __gen_uint(values->ConstantBufferSize, 0, 5) |
4207      __gen_uint(values->ConstantBufferOffset, 16, 20);
4208}
4209
4210#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_VS_length      2
4211#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_VS_length_bias      2
4212#define GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_VS_header\
4213   .DWordLength                         =      0,  \
4214   ._3DCommandSubOpcode                 =     18,  \
4215   ._3DCommandOpcode                    =      1,  \
4216   .CommandSubType                      =      3,  \
4217   .CommandType                         =      3
4218
4219struct GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_VS {
4220   uint32_t                             DWordLength;
4221   uint32_t                             _3DCommandSubOpcode;
4222   uint32_t                             _3DCommandOpcode;
4223   uint32_t                             CommandSubType;
4224   uint32_t                             CommandType;
4225   uint32_t                             ConstantBufferSize;
4226   uint32_t                             ConstantBufferOffset;
4227};
4228
4229static inline __attribute__((always_inline)) void
4230GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_VS_pack(__attribute__((unused)) __gen_user_data *data,
4231                                         __attribute__((unused)) void * restrict dst,
4232                                         __attribute__((unused)) const struct GFX8_3DSTATE_PUSH_CONSTANT_ALLOC_VS * restrict values)
4233{
4234   uint32_t * restrict dw = (uint32_t * restrict) dst;
4235
4236   dw[0] =
4237      __gen_uint(values->DWordLength, 0, 7) |
4238      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4239      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4240      __gen_uint(values->CommandSubType, 27, 28) |
4241      __gen_uint(values->CommandType, 29, 31);
4242
4243   dw[1] =
4244      __gen_uint(values->ConstantBufferSize, 0, 5) |
4245      __gen_uint(values->ConstantBufferOffset, 16, 20);
4246}
4247
4248#define GFX8_3DSTATE_RASTER_length             5
4249#define GFX8_3DSTATE_RASTER_length_bias        2
4250#define GFX8_3DSTATE_RASTER_header              \
4251   .DWordLength                         =      3,  \
4252   ._3DCommandSubOpcode                 =     80,  \
4253   ._3DCommandOpcode                    =      0,  \
4254   .CommandSubType                      =      3,  \
4255   .CommandType                         =      3
4256
4257struct GFX8_3DSTATE_RASTER {
4258   uint32_t                             DWordLength;
4259   uint32_t                             _3DCommandSubOpcode;
4260   uint32_t                             _3DCommandOpcode;
4261   uint32_t                             CommandSubType;
4262   uint32_t                             CommandType;
4263   bool                                 ViewportZClipTestEnable;
4264   bool                                 ScissorRectangleEnable;
4265   bool                                 AntialiasingEnable;
4266   uint32_t                             BackFaceFillMode;
4267#define FILL_MODE_SOLID                          0
4268#define FILL_MODE_WIREFRAME                      1
4269#define FILL_MODE_POINT                          2
4270   uint32_t                             FrontFaceFillMode;
4271#define FILL_MODE_SOLID                          0
4272#define FILL_MODE_WIREFRAME                      1
4273#define FILL_MODE_POINT                          2
4274   bool                                 GlobalDepthOffsetEnablePoint;
4275   bool                                 GlobalDepthOffsetEnableWireframe;
4276   bool                                 GlobalDepthOffsetEnableSolid;
4277   uint32_t                             DXMultisampleRasterizationMode;
4278#define MSRASTMODE_OFF_PIXEL                     0
4279#define MSRASTMODE_OFF_PATTERN                   1
4280#define MSRASTMODE_ON_PIXEL                      2
4281#define MSRASTMODE_ON_PATTERN                    3
4282   bool                                 DXMultisampleRasterizationEnable;
4283   bool                                 SmoothPointEnable;
4284   uint32_t                             ForceMultisampling;
4285   uint32_t                             CullMode;
4286#define CULLMODE_BOTH                            0
4287#define CULLMODE_NONE                            1
4288#define CULLMODE_FRONT                           2
4289#define CULLMODE_BACK                            3
4290   uint32_t                             ForcedSampleCount;
4291#define FSC_NUMRASTSAMPLES_0                     0
4292#define FSC_NUMRASTSAMPLES_1                     1
4293#define FSC_NUMRASTSAMPLES_2                     2
4294#define FSC_NUMRASTSAMPLES_4                     3
4295#define FSC_NUMRASTSAMPLES_8                     4
4296#define FSC_NUMRASTSAMPLES_16                    5
4297   uint32_t                             FrontWinding;
4298#define Clockwise                                0
4299#define CounterClockwise                         1
4300   uint32_t                             APIMode;
4301#define DX9OGL                                   0
4302#define DX100                                    1
4303#define DX101                                    2
4304   float                                GlobalDepthOffsetConstant;
4305   float                                GlobalDepthOffsetScale;
4306   float                                GlobalDepthOffsetClamp;
4307};
4308
4309static inline __attribute__((always_inline)) void
4310GFX8_3DSTATE_RASTER_pack(__attribute__((unused)) __gen_user_data *data,
4311                         __attribute__((unused)) void * restrict dst,
4312                         __attribute__((unused)) const struct GFX8_3DSTATE_RASTER * restrict values)
4313{
4314   uint32_t * restrict dw = (uint32_t * restrict) dst;
4315
4316   dw[0] =
4317      __gen_uint(values->DWordLength, 0, 7) |
4318      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4319      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4320      __gen_uint(values->CommandSubType, 27, 28) |
4321      __gen_uint(values->CommandType, 29, 31);
4322
4323   dw[1] =
4324      __gen_uint(values->ViewportZClipTestEnable, 0, 0) |
4325      __gen_uint(values->ScissorRectangleEnable, 1, 1) |
4326      __gen_uint(values->AntialiasingEnable, 2, 2) |
4327      __gen_uint(values->BackFaceFillMode, 3, 4) |
4328      __gen_uint(values->FrontFaceFillMode, 5, 6) |
4329      __gen_uint(values->GlobalDepthOffsetEnablePoint, 7, 7) |
4330      __gen_uint(values->GlobalDepthOffsetEnableWireframe, 8, 8) |
4331      __gen_uint(values->GlobalDepthOffsetEnableSolid, 9, 9) |
4332      __gen_uint(values->DXMultisampleRasterizationMode, 10, 11) |
4333      __gen_uint(values->DXMultisampleRasterizationEnable, 12, 12) |
4334      __gen_uint(values->SmoothPointEnable, 13, 13) |
4335      __gen_uint(values->ForceMultisampling, 14, 14) |
4336      __gen_uint(values->CullMode, 16, 17) |
4337      __gen_uint(values->ForcedSampleCount, 18, 20) |
4338      __gen_uint(values->FrontWinding, 21, 21) |
4339      __gen_uint(values->APIMode, 22, 23);
4340
4341   dw[2] =
4342      __gen_float(values->GlobalDepthOffsetConstant);
4343
4344   dw[3] =
4345      __gen_float(values->GlobalDepthOffsetScale);
4346
4347   dw[4] =
4348      __gen_float(values->GlobalDepthOffsetClamp);
4349}
4350
4351#define GFX8_3DSTATE_SAMPLER_PALETTE_LOAD0_length_bias      2
4352#define GFX8_3DSTATE_SAMPLER_PALETTE_LOAD0_header\
4353   ._3DCommandSubOpcode                 =      2,  \
4354   ._3DCommandOpcode                    =      1,  \
4355   .CommandSubType                      =      3,  \
4356   .CommandType                         =      3
4357
4358struct GFX8_3DSTATE_SAMPLER_PALETTE_LOAD0 {
4359   uint32_t                             DWordLength;
4360   uint32_t                             _3DCommandSubOpcode;
4361   uint32_t                             _3DCommandOpcode;
4362   uint32_t                             CommandSubType;
4363   uint32_t                             CommandType;
4364   /* variable length fields follow */
4365};
4366
4367static inline __attribute__((always_inline)) void
4368GFX8_3DSTATE_SAMPLER_PALETTE_LOAD0_pack(__attribute__((unused)) __gen_user_data *data,
4369                                        __attribute__((unused)) void * restrict dst,
4370                                        __attribute__((unused)) const struct GFX8_3DSTATE_SAMPLER_PALETTE_LOAD0 * restrict values)
4371{
4372   uint32_t * restrict dw = (uint32_t * restrict) dst;
4373
4374   dw[0] =
4375      __gen_uint(values->DWordLength, 0, 7) |
4376      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4377      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4378      __gen_uint(values->CommandSubType, 27, 28) |
4379      __gen_uint(values->CommandType, 29, 31);
4380}
4381
4382#define GFX8_3DSTATE_SAMPLER_PALETTE_LOAD1_length_bias      2
4383#define GFX8_3DSTATE_SAMPLER_PALETTE_LOAD1_header\
4384   .DWordLength                         =      0,  \
4385   ._3DCommandSubOpcode                 =     12,  \
4386   ._3DCommandOpcode                    =      1,  \
4387   .CommandSubType                      =      3,  \
4388   .CommandType                         =      3
4389
4390struct GFX8_3DSTATE_SAMPLER_PALETTE_LOAD1 {
4391   uint32_t                             DWordLength;
4392   uint32_t                             _3DCommandSubOpcode;
4393   uint32_t                             _3DCommandOpcode;
4394   uint32_t                             CommandSubType;
4395   uint32_t                             CommandType;
4396   /* variable length fields follow */
4397};
4398
4399static inline __attribute__((always_inline)) void
4400GFX8_3DSTATE_SAMPLER_PALETTE_LOAD1_pack(__attribute__((unused)) __gen_user_data *data,
4401                                        __attribute__((unused)) void * restrict dst,
4402                                        __attribute__((unused)) const struct GFX8_3DSTATE_SAMPLER_PALETTE_LOAD1 * restrict values)
4403{
4404   uint32_t * restrict dw = (uint32_t * restrict) dst;
4405
4406   dw[0] =
4407      __gen_uint(values->DWordLength, 0, 7) |
4408      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4409      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4410      __gen_uint(values->CommandSubType, 27, 28) |
4411      __gen_uint(values->CommandType, 29, 31);
4412}
4413
4414#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_DS_length      2
4415#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_DS_length_bias      2
4416#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_DS_header\
4417   .DWordLength                         =      0,  \
4418   ._3DCommandSubOpcode                 =     45,  \
4419   ._3DCommandOpcode                    =      0,  \
4420   .CommandSubType                      =      3,  \
4421   .CommandType                         =      3
4422
4423struct GFX8_3DSTATE_SAMPLER_STATE_POINTERS_DS {
4424   uint32_t                             DWordLength;
4425   uint32_t                             _3DCommandSubOpcode;
4426   uint32_t                             _3DCommandOpcode;
4427   uint32_t                             CommandSubType;
4428   uint32_t                             CommandType;
4429   uint64_t                             PointertoDSSamplerState;
4430};
4431
4432static inline __attribute__((always_inline)) void
4433GFX8_3DSTATE_SAMPLER_STATE_POINTERS_DS_pack(__attribute__((unused)) __gen_user_data *data,
4434                                            __attribute__((unused)) void * restrict dst,
4435                                            __attribute__((unused)) const struct GFX8_3DSTATE_SAMPLER_STATE_POINTERS_DS * restrict values)
4436{
4437   uint32_t * restrict dw = (uint32_t * restrict) dst;
4438
4439   dw[0] =
4440      __gen_uint(values->DWordLength, 0, 7) |
4441      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4442      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4443      __gen_uint(values->CommandSubType, 27, 28) |
4444      __gen_uint(values->CommandType, 29, 31);
4445
4446   dw[1] =
4447      __gen_offset(values->PointertoDSSamplerState, 5, 31);
4448}
4449
4450#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_GS_length      2
4451#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_GS_length_bias      2
4452#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_GS_header\
4453   .DWordLength                         =      0,  \
4454   ._3DCommandSubOpcode                 =     46,  \
4455   ._3DCommandOpcode                    =      0,  \
4456   .CommandSubType                      =      3,  \
4457   .CommandType                         =      3
4458
4459struct GFX8_3DSTATE_SAMPLER_STATE_POINTERS_GS {
4460   uint32_t                             DWordLength;
4461   uint32_t                             _3DCommandSubOpcode;
4462   uint32_t                             _3DCommandOpcode;
4463   uint32_t                             CommandSubType;
4464   uint32_t                             CommandType;
4465   uint64_t                             PointertoGSSamplerState;
4466};
4467
4468static inline __attribute__((always_inline)) void
4469GFX8_3DSTATE_SAMPLER_STATE_POINTERS_GS_pack(__attribute__((unused)) __gen_user_data *data,
4470                                            __attribute__((unused)) void * restrict dst,
4471                                            __attribute__((unused)) const struct GFX8_3DSTATE_SAMPLER_STATE_POINTERS_GS * restrict values)
4472{
4473   uint32_t * restrict dw = (uint32_t * restrict) dst;
4474
4475   dw[0] =
4476      __gen_uint(values->DWordLength, 0, 7) |
4477      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4478      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4479      __gen_uint(values->CommandSubType, 27, 28) |
4480      __gen_uint(values->CommandType, 29, 31);
4481
4482   dw[1] =
4483      __gen_offset(values->PointertoGSSamplerState, 5, 31);
4484}
4485
4486#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_HS_length      2
4487#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_HS_length_bias      2
4488#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_HS_header\
4489   .DWordLength                         =      0,  \
4490   ._3DCommandSubOpcode                 =     44,  \
4491   ._3DCommandOpcode                    =      0,  \
4492   .CommandSubType                      =      3,  \
4493   .CommandType                         =      3
4494
4495struct GFX8_3DSTATE_SAMPLER_STATE_POINTERS_HS {
4496   uint32_t                             DWordLength;
4497   uint32_t                             _3DCommandSubOpcode;
4498   uint32_t                             _3DCommandOpcode;
4499   uint32_t                             CommandSubType;
4500   uint32_t                             CommandType;
4501   uint64_t                             PointertoHSSamplerState;
4502};
4503
4504static inline __attribute__((always_inline)) void
4505GFX8_3DSTATE_SAMPLER_STATE_POINTERS_HS_pack(__attribute__((unused)) __gen_user_data *data,
4506                                            __attribute__((unused)) void * restrict dst,
4507                                            __attribute__((unused)) const struct GFX8_3DSTATE_SAMPLER_STATE_POINTERS_HS * restrict values)
4508{
4509   uint32_t * restrict dw = (uint32_t * restrict) dst;
4510
4511   dw[0] =
4512      __gen_uint(values->DWordLength, 0, 7) |
4513      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4514      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4515      __gen_uint(values->CommandSubType, 27, 28) |
4516      __gen_uint(values->CommandType, 29, 31);
4517
4518   dw[1] =
4519      __gen_offset(values->PointertoHSSamplerState, 5, 31);
4520}
4521
4522#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_PS_length      2
4523#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_PS_length_bias      2
4524#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_PS_header\
4525   .DWordLength                         =      0,  \
4526   ._3DCommandSubOpcode                 =     47,  \
4527   ._3DCommandOpcode                    =      0,  \
4528   .CommandSubType                      =      3,  \
4529   .CommandType                         =      3
4530
4531struct GFX8_3DSTATE_SAMPLER_STATE_POINTERS_PS {
4532   uint32_t                             DWordLength;
4533   uint32_t                             _3DCommandSubOpcode;
4534   uint32_t                             _3DCommandOpcode;
4535   uint32_t                             CommandSubType;
4536   uint32_t                             CommandType;
4537   uint64_t                             PointertoPSSamplerState;
4538};
4539
4540static inline __attribute__((always_inline)) void
4541GFX8_3DSTATE_SAMPLER_STATE_POINTERS_PS_pack(__attribute__((unused)) __gen_user_data *data,
4542                                            __attribute__((unused)) void * restrict dst,
4543                                            __attribute__((unused)) const struct GFX8_3DSTATE_SAMPLER_STATE_POINTERS_PS * restrict values)
4544{
4545   uint32_t * restrict dw = (uint32_t * restrict) dst;
4546
4547   dw[0] =
4548      __gen_uint(values->DWordLength, 0, 7) |
4549      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4550      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4551      __gen_uint(values->CommandSubType, 27, 28) |
4552      __gen_uint(values->CommandType, 29, 31);
4553
4554   dw[1] =
4555      __gen_offset(values->PointertoPSSamplerState, 5, 31);
4556}
4557
4558#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_VS_length      2
4559#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_VS_length_bias      2
4560#define GFX8_3DSTATE_SAMPLER_STATE_POINTERS_VS_header\
4561   .DWordLength                         =      0,  \
4562   ._3DCommandSubOpcode                 =     43,  \
4563   ._3DCommandOpcode                    =      0,  \
4564   .CommandSubType                      =      3,  \
4565   .CommandType                         =      3
4566
4567struct GFX8_3DSTATE_SAMPLER_STATE_POINTERS_VS {
4568   uint32_t                             DWordLength;
4569   uint32_t                             _3DCommandSubOpcode;
4570   uint32_t                             _3DCommandOpcode;
4571   uint32_t                             CommandSubType;
4572   uint32_t                             CommandType;
4573   uint64_t                             PointertoVSSamplerState;
4574};
4575
4576static inline __attribute__((always_inline)) void
4577GFX8_3DSTATE_SAMPLER_STATE_POINTERS_VS_pack(__attribute__((unused)) __gen_user_data *data,
4578                                            __attribute__((unused)) void * restrict dst,
4579                                            __attribute__((unused)) const struct GFX8_3DSTATE_SAMPLER_STATE_POINTERS_VS * restrict values)
4580{
4581   uint32_t * restrict dw = (uint32_t * restrict) dst;
4582
4583   dw[0] =
4584      __gen_uint(values->DWordLength, 0, 7) |
4585      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4586      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4587      __gen_uint(values->CommandSubType, 27, 28) |
4588      __gen_uint(values->CommandType, 29, 31);
4589
4590   dw[1] =
4591      __gen_offset(values->PointertoVSSamplerState, 5, 31);
4592}
4593
4594#define GFX8_3DSTATE_SAMPLE_MASK_length        2
4595#define GFX8_3DSTATE_SAMPLE_MASK_length_bias      2
4596#define GFX8_3DSTATE_SAMPLE_MASK_header         \
4597   .DWordLength                         =      0,  \
4598   ._3DCommandSubOpcode                 =     24,  \
4599   ._3DCommandOpcode                    =      0,  \
4600   .CommandSubType                      =      3,  \
4601   .CommandType                         =      3
4602
4603struct GFX8_3DSTATE_SAMPLE_MASK {
4604   uint32_t                             DWordLength;
4605   uint32_t                             _3DCommandSubOpcode;
4606   uint32_t                             _3DCommandOpcode;
4607   uint32_t                             CommandSubType;
4608   uint32_t                             CommandType;
4609   uint32_t                             SampleMask;
4610};
4611
4612static inline __attribute__((always_inline)) void
4613GFX8_3DSTATE_SAMPLE_MASK_pack(__attribute__((unused)) __gen_user_data *data,
4614                              __attribute__((unused)) void * restrict dst,
4615                              __attribute__((unused)) const struct GFX8_3DSTATE_SAMPLE_MASK * restrict values)
4616{
4617   uint32_t * restrict dw = (uint32_t * restrict) dst;
4618
4619   dw[0] =
4620      __gen_uint(values->DWordLength, 0, 7) |
4621      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4622      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4623      __gen_uint(values->CommandSubType, 27, 28) |
4624      __gen_uint(values->CommandType, 29, 31);
4625
4626   dw[1] =
4627      __gen_uint(values->SampleMask, 0, 15);
4628}
4629
4630#define GFX8_3DSTATE_SAMPLE_PATTERN_length      9
4631#define GFX8_3DSTATE_SAMPLE_PATTERN_length_bias      2
4632#define GFX8_3DSTATE_SAMPLE_PATTERN_header      \
4633   .DWordLength                         =      7,  \
4634   ._3DCommandSubOpcode                 =     28,  \
4635   ._3DCommandOpcode                    =      1,  \
4636   .CommandSubType                      =      3,  \
4637   .CommandType                         =      3
4638
4639struct GFX8_3DSTATE_SAMPLE_PATTERN {
4640   uint32_t                             DWordLength;
4641   uint32_t                             _3DCommandSubOpcode;
4642   uint32_t                             _3DCommandOpcode;
4643   uint32_t                             CommandSubType;
4644   uint32_t                             CommandType;
4645   float                                _8xSample4YOffset;
4646   float                                _8xSample4XOffset;
4647   float                                _8xSample5YOffset;
4648   float                                _8xSample5XOffset;
4649   float                                _8xSample6YOffset;
4650   float                                _8xSample6XOffset;
4651   float                                _8xSample7YOffset;
4652   float                                _8xSample7XOffset;
4653   float                                _8xSample0YOffset;
4654   float                                _8xSample0XOffset;
4655   float                                _8xSample1YOffset;
4656   float                                _8xSample1XOffset;
4657   float                                _8xSample2YOffset;
4658   float                                _8xSample2XOffset;
4659   float                                _8xSample3YOffset;
4660   float                                _8xSample3XOffset;
4661   float                                _4xSample0YOffset;
4662   float                                _4xSample0XOffset;
4663   float                                _4xSample1YOffset;
4664   float                                _4xSample1XOffset;
4665   float                                _4xSample2YOffset;
4666   float                                _4xSample2XOffset;
4667   float                                _4xSample3YOffset;
4668   float                                _4xSample3XOffset;
4669   float                                _2xSample0YOffset;
4670   float                                _2xSample0XOffset;
4671   float                                _2xSample1YOffset;
4672   float                                _2xSample1XOffset;
4673   float                                _1xSample0YOffset;
4674   float                                _1xSample0XOffset;
4675};
4676
4677static inline __attribute__((always_inline)) void
4678GFX8_3DSTATE_SAMPLE_PATTERN_pack(__attribute__((unused)) __gen_user_data *data,
4679                                 __attribute__((unused)) void * restrict dst,
4680                                 __attribute__((unused)) const struct GFX8_3DSTATE_SAMPLE_PATTERN * restrict values)
4681{
4682   uint32_t * restrict dw = (uint32_t * restrict) dst;
4683
4684   dw[0] =
4685      __gen_uint(values->DWordLength, 0, 7) |
4686      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4687      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4688      __gen_uint(values->CommandSubType, 27, 28) |
4689      __gen_uint(values->CommandType, 29, 31);
4690
4691   dw[1] = 0;
4692
4693   dw[2] = 0;
4694
4695   dw[3] = 0;
4696
4697   dw[4] = 0;
4698
4699   dw[5] =
4700      __gen_ufixed(values->_8xSample4YOffset, 0, 3, 4) |
4701      __gen_ufixed(values->_8xSample4XOffset, 4, 7, 4) |
4702      __gen_ufixed(values->_8xSample5YOffset, 8, 11, 4) |
4703      __gen_ufixed(values->_8xSample5XOffset, 12, 15, 4) |
4704      __gen_ufixed(values->_8xSample6YOffset, 16, 19, 4) |
4705      __gen_ufixed(values->_8xSample6XOffset, 20, 23, 4) |
4706      __gen_ufixed(values->_8xSample7YOffset, 24, 27, 4) |
4707      __gen_ufixed(values->_8xSample7XOffset, 28, 31, 4);
4708
4709   dw[6] =
4710      __gen_ufixed(values->_8xSample0YOffset, 0, 3, 4) |
4711      __gen_ufixed(values->_8xSample0XOffset, 4, 7, 4) |
4712      __gen_ufixed(values->_8xSample1YOffset, 8, 11, 4) |
4713      __gen_ufixed(values->_8xSample1XOffset, 12, 15, 4) |
4714      __gen_ufixed(values->_8xSample2YOffset, 16, 19, 4) |
4715      __gen_ufixed(values->_8xSample2XOffset, 20, 23, 4) |
4716      __gen_ufixed(values->_8xSample3YOffset, 24, 27, 4) |
4717      __gen_ufixed(values->_8xSample3XOffset, 28, 31, 4);
4718
4719   dw[7] =
4720      __gen_ufixed(values->_4xSample0YOffset, 0, 3, 4) |
4721      __gen_ufixed(values->_4xSample0XOffset, 4, 7, 4) |
4722      __gen_ufixed(values->_4xSample1YOffset, 8, 11, 4) |
4723      __gen_ufixed(values->_4xSample1XOffset, 12, 15, 4) |
4724      __gen_ufixed(values->_4xSample2YOffset, 16, 19, 4) |
4725      __gen_ufixed(values->_4xSample2XOffset, 20, 23, 4) |
4726      __gen_ufixed(values->_4xSample3YOffset, 24, 27, 4) |
4727      __gen_ufixed(values->_4xSample3XOffset, 28, 31, 4);
4728
4729   dw[8] =
4730      __gen_ufixed(values->_2xSample0YOffset, 0, 3, 4) |
4731      __gen_ufixed(values->_2xSample0XOffset, 4, 7, 4) |
4732      __gen_ufixed(values->_2xSample1YOffset, 8, 11, 4) |
4733      __gen_ufixed(values->_2xSample1XOffset, 12, 15, 4) |
4734      __gen_ufixed(values->_1xSample0YOffset, 16, 19, 4) |
4735      __gen_ufixed(values->_1xSample0XOffset, 20, 23, 4);
4736}
4737
4738#define GFX8_3DSTATE_SBE_length                4
4739#define GFX8_3DSTATE_SBE_length_bias           2
4740#define GFX8_3DSTATE_SBE_header                 \
4741   .DWordLength                         =      2,  \
4742   ._3DCommandSubOpcode                 =     31,  \
4743   ._3DCommandOpcode                    =      0,  \
4744   .CommandSubType                      =      3,  \
4745   .CommandType                         =      3
4746
4747struct GFX8_3DSTATE_SBE {
4748   uint32_t                             DWordLength;
4749   uint32_t                             _3DCommandSubOpcode;
4750   uint32_t                             _3DCommandOpcode;
4751   uint32_t                             CommandSubType;
4752   uint32_t                             CommandType;
4753   uint32_t                             PrimitiveIDOverrideAttributeSelect;
4754   uint32_t                             VertexURBEntryReadOffset;
4755   uint32_t                             VertexURBEntryReadLength;
4756   bool                                 PrimitiveIDOverrideComponentX;
4757   bool                                 PrimitiveIDOverrideComponentY;
4758   bool                                 PrimitiveIDOverrideComponentZ;
4759   bool                                 PrimitiveIDOverrideComponentW;
4760   uint32_t                             PointSpriteTextureCoordinateOrigin;
4761#define UPPERLEFT                                0
4762#define LOWERLEFT                                1
4763   bool                                 AttributeSwizzleEnable;
4764   uint32_t                             NumberofSFOutputAttributes;
4765   bool                                 ForceVertexURBEntryReadOffset;
4766   bool                                 ForceVertexURBEntryReadLength;
4767   uint32_t                             PointSpriteTextureCoordinateEnable;
4768   uint32_t                             ConstantInterpolationEnable;
4769};
4770
4771static inline __attribute__((always_inline)) void
4772GFX8_3DSTATE_SBE_pack(__attribute__((unused)) __gen_user_data *data,
4773                      __attribute__((unused)) void * restrict dst,
4774                      __attribute__((unused)) const struct GFX8_3DSTATE_SBE * restrict values)
4775{
4776   uint32_t * restrict dw = (uint32_t * restrict) dst;
4777
4778   dw[0] =
4779      __gen_uint(values->DWordLength, 0, 7) |
4780      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4781      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4782      __gen_uint(values->CommandSubType, 27, 28) |
4783      __gen_uint(values->CommandType, 29, 31);
4784
4785   dw[1] =
4786      __gen_uint(values->PrimitiveIDOverrideAttributeSelect, 0, 4) |
4787      __gen_uint(values->VertexURBEntryReadOffset, 5, 10) |
4788      __gen_uint(values->VertexURBEntryReadLength, 11, 15) |
4789      __gen_uint(values->PrimitiveIDOverrideComponentX, 16, 16) |
4790      __gen_uint(values->PrimitiveIDOverrideComponentY, 17, 17) |
4791      __gen_uint(values->PrimitiveIDOverrideComponentZ, 18, 18) |
4792      __gen_uint(values->PrimitiveIDOverrideComponentW, 19, 19) |
4793      __gen_uint(values->PointSpriteTextureCoordinateOrigin, 20, 20) |
4794      __gen_uint(values->AttributeSwizzleEnable, 21, 21) |
4795      __gen_uint(values->NumberofSFOutputAttributes, 22, 27) |
4796      __gen_uint(values->ForceVertexURBEntryReadOffset, 28, 28) |
4797      __gen_uint(values->ForceVertexURBEntryReadLength, 29, 29);
4798
4799   dw[2] =
4800      __gen_uint(values->PointSpriteTextureCoordinateEnable, 0, 31);
4801
4802   dw[3] =
4803      __gen_uint(values->ConstantInterpolationEnable, 0, 31);
4804}
4805
4806#define GFX8_3DSTATE_SBE_SWIZ_length          11
4807#define GFX8_3DSTATE_SBE_SWIZ_length_bias      2
4808#define GFX8_3DSTATE_SBE_SWIZ_header            \
4809   .DWordLength                         =      9,  \
4810   ._3DCommandSubOpcode                 =     81,  \
4811   ._3DCommandOpcode                    =      0,  \
4812   .CommandSubType                      =      3,  \
4813   .CommandType                         =      3
4814
4815struct GFX8_3DSTATE_SBE_SWIZ {
4816   uint32_t                             DWordLength;
4817   uint32_t                             _3DCommandSubOpcode;
4818   uint32_t                             _3DCommandOpcode;
4819   uint32_t                             CommandSubType;
4820   uint32_t                             CommandType;
4821   struct GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL Attribute[16];
4822   uint32_t                             AttributeWrapShortestEnables[16];
4823};
4824
4825static inline __attribute__((always_inline)) void
4826GFX8_3DSTATE_SBE_SWIZ_pack(__attribute__((unused)) __gen_user_data *data,
4827                           __attribute__((unused)) void * restrict dst,
4828                           __attribute__((unused)) const struct GFX8_3DSTATE_SBE_SWIZ * restrict values)
4829{
4830   uint32_t * restrict dw = (uint32_t * restrict) dst;
4831
4832   dw[0] =
4833      __gen_uint(values->DWordLength, 0, 7) |
4834      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4835      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4836      __gen_uint(values->CommandSubType, 27, 28) |
4837      __gen_uint(values->CommandType, 29, 31);
4838
4839   uint32_t v1_0;
4840   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v1_0, &values->Attribute[0]);
4841
4842   uint32_t v1_1;
4843   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v1_1, &values->Attribute[1]);
4844
4845   dw[1] =
4846      __gen_uint(v1_0, 0, 15) |
4847      __gen_uint(v1_1, 16, 31);
4848
4849   uint32_t v2_0;
4850   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v2_0, &values->Attribute[2]);
4851
4852   uint32_t v2_1;
4853   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v2_1, &values->Attribute[3]);
4854
4855   dw[2] =
4856      __gen_uint(v2_0, 0, 15) |
4857      __gen_uint(v2_1, 16, 31);
4858
4859   uint32_t v3_0;
4860   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v3_0, &values->Attribute[4]);
4861
4862   uint32_t v3_1;
4863   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v3_1, &values->Attribute[5]);
4864
4865   dw[3] =
4866      __gen_uint(v3_0, 0, 15) |
4867      __gen_uint(v3_1, 16, 31);
4868
4869   uint32_t v4_0;
4870   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v4_0, &values->Attribute[6]);
4871
4872   uint32_t v4_1;
4873   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v4_1, &values->Attribute[7]);
4874
4875   dw[4] =
4876      __gen_uint(v4_0, 0, 15) |
4877      __gen_uint(v4_1, 16, 31);
4878
4879   uint32_t v5_0;
4880   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v5_0, &values->Attribute[8]);
4881
4882   uint32_t v5_1;
4883   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v5_1, &values->Attribute[9]);
4884
4885   dw[5] =
4886      __gen_uint(v5_0, 0, 15) |
4887      __gen_uint(v5_1, 16, 31);
4888
4889   uint32_t v6_0;
4890   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v6_0, &values->Attribute[10]);
4891
4892   uint32_t v6_1;
4893   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v6_1, &values->Attribute[11]);
4894
4895   dw[6] =
4896      __gen_uint(v6_0, 0, 15) |
4897      __gen_uint(v6_1, 16, 31);
4898
4899   uint32_t v7_0;
4900   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v7_0, &values->Attribute[12]);
4901
4902   uint32_t v7_1;
4903   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v7_1, &values->Attribute[13]);
4904
4905   dw[7] =
4906      __gen_uint(v7_0, 0, 15) |
4907      __gen_uint(v7_1, 16, 31);
4908
4909   uint32_t v8_0;
4910   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v8_0, &values->Attribute[14]);
4911
4912   uint32_t v8_1;
4913   GFX8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &v8_1, &values->Attribute[15]);
4914
4915   dw[8] =
4916      __gen_uint(v8_0, 0, 15) |
4917      __gen_uint(v8_1, 16, 31);
4918
4919   dw[9] =
4920      __gen_uint(values->AttributeWrapShortestEnables[0], 0, 3) |
4921      __gen_uint(values->AttributeWrapShortestEnables[1], 4, 7) |
4922      __gen_uint(values->AttributeWrapShortestEnables[2], 8, 11) |
4923      __gen_uint(values->AttributeWrapShortestEnables[3], 12, 15) |
4924      __gen_uint(values->AttributeWrapShortestEnables[4], 16, 19) |
4925      __gen_uint(values->AttributeWrapShortestEnables[5], 20, 23) |
4926      __gen_uint(values->AttributeWrapShortestEnables[6], 24, 27) |
4927      __gen_uint(values->AttributeWrapShortestEnables[7], 28, 31);
4928
4929   dw[10] =
4930      __gen_uint(values->AttributeWrapShortestEnables[8], 0, 3) |
4931      __gen_uint(values->AttributeWrapShortestEnables[9], 4, 7) |
4932      __gen_uint(values->AttributeWrapShortestEnables[10], 8, 11) |
4933      __gen_uint(values->AttributeWrapShortestEnables[11], 12, 15) |
4934      __gen_uint(values->AttributeWrapShortestEnables[12], 16, 19) |
4935      __gen_uint(values->AttributeWrapShortestEnables[13], 20, 23) |
4936      __gen_uint(values->AttributeWrapShortestEnables[14], 24, 27) |
4937      __gen_uint(values->AttributeWrapShortestEnables[15], 28, 31);
4938}
4939
4940#define GFX8_3DSTATE_SCISSOR_STATE_POINTERS_length      2
4941#define GFX8_3DSTATE_SCISSOR_STATE_POINTERS_length_bias      2
4942#define GFX8_3DSTATE_SCISSOR_STATE_POINTERS_header\
4943   .DWordLength                         =      0,  \
4944   ._3DCommandSubOpcode                 =     15,  \
4945   ._3DCommandOpcode                    =      0,  \
4946   .CommandSubType                      =      3,  \
4947   .CommandType                         =      3
4948
4949struct GFX8_3DSTATE_SCISSOR_STATE_POINTERS {
4950   uint32_t                             DWordLength;
4951   uint32_t                             _3DCommandSubOpcode;
4952   uint32_t                             _3DCommandOpcode;
4953   uint32_t                             CommandSubType;
4954   uint32_t                             CommandType;
4955   uint64_t                             ScissorRectPointer;
4956};
4957
4958static inline __attribute__((always_inline)) void
4959GFX8_3DSTATE_SCISSOR_STATE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
4960                                         __attribute__((unused)) void * restrict dst,
4961                                         __attribute__((unused)) const struct GFX8_3DSTATE_SCISSOR_STATE_POINTERS * restrict values)
4962{
4963   uint32_t * restrict dw = (uint32_t * restrict) dst;
4964
4965   dw[0] =
4966      __gen_uint(values->DWordLength, 0, 7) |
4967      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
4968      __gen_uint(values->_3DCommandOpcode, 24, 26) |
4969      __gen_uint(values->CommandSubType, 27, 28) |
4970      __gen_uint(values->CommandType, 29, 31);
4971
4972   dw[1] =
4973      __gen_offset(values->ScissorRectPointer, 5, 31);
4974}
4975
4976#define GFX8_3DSTATE_SF_length                 4
4977#define GFX8_3DSTATE_SF_length_bias            2
4978#define GFX8_3DSTATE_SF_header                  \
4979   .DWordLength                         =      2,  \
4980   ._3DCommandSubOpcode                 =     19,  \
4981   ._3DCommandOpcode                    =      0,  \
4982   .CommandSubType                      =      3,  \
4983   .CommandType                         =      3
4984
4985struct GFX8_3DSTATE_SF {
4986   uint32_t                             DWordLength;
4987   uint32_t                             _3DCommandSubOpcode;
4988   uint32_t                             _3DCommandOpcode;
4989   uint32_t                             CommandSubType;
4990   uint32_t                             CommandType;
4991   bool                                 ViewportTransformEnable;
4992   bool                                 StatisticsEnable;
4993   bool                                 LegacyGlobalDepthBiasEnable;
4994   float                                CHVLineWidth;
4995   uint32_t                             LineEndCapAntialiasingRegionWidth;
4996#define _05pixels                                0
4997#define _10pixels                                1
4998#define _20pixels                                2
4999#define _40pixels                                3
5000   float                                LineWidth;
5001   float                                PointWidth;
5002   uint32_t                             PointWidthSource;
5003#define Vertex                                   0
5004#define State                                    1
5005   uint32_t                             VertexSubPixelPrecisionSelect;
5006#define _8Bit                                    0
5007#define _4Bit                                    1
5008   bool                                 SmoothPointEnable;
5009   uint32_t                             AALineDistanceMode;
5010#define AALINEDISTANCE_TRUE                      1
5011   uint32_t                             TriangleFanProvokingVertexSelect;
5012   uint32_t                             LineStripListProvokingVertexSelect;
5013   uint32_t                             TriangleStripListProvokingVertexSelect;
5014   bool                                 LastPixelEnable;
5015};
5016
5017static inline __attribute__((always_inline)) void
5018GFX8_3DSTATE_SF_pack(__attribute__((unused)) __gen_user_data *data,
5019                     __attribute__((unused)) void * restrict dst,
5020                     __attribute__((unused)) const struct GFX8_3DSTATE_SF * restrict values)
5021{
5022   uint32_t * restrict dw = (uint32_t * restrict) dst;
5023
5024   dw[0] =
5025      __gen_uint(values->DWordLength, 0, 7) |
5026      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5027      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5028      __gen_uint(values->CommandSubType, 27, 28) |
5029      __gen_uint(values->CommandType, 29, 31);
5030
5031   dw[1] =
5032      __gen_uint(values->ViewportTransformEnable, 1, 1) |
5033      __gen_uint(values->StatisticsEnable, 10, 10) |
5034      __gen_uint(values->LegacyGlobalDepthBiasEnable, 11, 11) |
5035      __gen_ufixed(values->CHVLineWidth, 12, 29, 7);
5036
5037   dw[2] =
5038      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 16, 17) |
5039      __gen_ufixed(values->LineWidth, 18, 27, 7);
5040
5041   dw[3] =
5042      __gen_ufixed(values->PointWidth, 0, 10, 3) |
5043      __gen_uint(values->PointWidthSource, 11, 11) |
5044      __gen_uint(values->VertexSubPixelPrecisionSelect, 12, 12) |
5045      __gen_uint(values->SmoothPointEnable, 13, 13) |
5046      __gen_uint(values->AALineDistanceMode, 14, 14) |
5047      __gen_uint(values->TriangleFanProvokingVertexSelect, 25, 26) |
5048      __gen_uint(values->LineStripListProvokingVertexSelect, 27, 28) |
5049      __gen_uint(values->TriangleStripListProvokingVertexSelect, 29, 30) |
5050      __gen_uint(values->LastPixelEnable, 31, 31);
5051}
5052
5053#define GFX8_3DSTATE_SO_BUFFER_length          8
5054#define GFX8_3DSTATE_SO_BUFFER_length_bias      2
5055#define GFX8_3DSTATE_SO_BUFFER_header           \
5056   .DWordLength                         =      6,  \
5057   ._3DCommandSubOpcode                 =     24,  \
5058   ._3DCommandOpcode                    =      1,  \
5059   .CommandSubType                      =      3,  \
5060   .CommandType                         =      3
5061
5062struct GFX8_3DSTATE_SO_BUFFER {
5063   uint32_t                             DWordLength;
5064   uint32_t                             _3DCommandSubOpcode;
5065   uint32_t                             _3DCommandOpcode;
5066   uint32_t                             CommandSubType;
5067   uint32_t                             CommandType;
5068   bool                                 StreamOutputBufferOffsetAddressEnable;
5069   bool                                 StreamOffsetWriteEnable;
5070   uint32_t                             MOCS;
5071   uint32_t                             SOBufferIndex;
5072   bool                                 SOBufferEnable;
5073   __gen_address_type                   SurfaceBaseAddress;
5074   uint32_t                             SurfaceSize;
5075   __gen_address_type                   StreamOutputBufferOffsetAddress;
5076   uint32_t                             StreamOffset;
5077};
5078
5079static inline __attribute__((always_inline)) void
5080GFX8_3DSTATE_SO_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
5081                            __attribute__((unused)) void * restrict dst,
5082                            __attribute__((unused)) const struct GFX8_3DSTATE_SO_BUFFER * restrict values)
5083{
5084   uint32_t * restrict dw = (uint32_t * restrict) dst;
5085
5086   dw[0] =
5087      __gen_uint(values->DWordLength, 0, 7) |
5088      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5089      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5090      __gen_uint(values->CommandSubType, 27, 28) |
5091      __gen_uint(values->CommandType, 29, 31);
5092
5093   dw[1] =
5094      __gen_uint(values->StreamOutputBufferOffsetAddressEnable, 20, 20) |
5095      __gen_uint(values->StreamOffsetWriteEnable, 21, 21) |
5096      __gen_uint(values->MOCS, 22, 28) |
5097      __gen_uint(values->SOBufferIndex, 29, 30) |
5098      __gen_uint(values->SOBufferEnable, 31, 31);
5099
5100   const uint64_t v2_address =
5101      __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 2, 47);
5102   dw[2] = v2_address;
5103   dw[3] = v2_address >> 32;
5104
5105   dw[4] =
5106      __gen_uint(values->SurfaceSize, 0, 29);
5107
5108   const uint64_t v5_address =
5109      __gen_address(data, &dw[5], values->StreamOutputBufferOffsetAddress, 0, 2, 47);
5110   dw[5] = v5_address;
5111   dw[6] = v5_address >> 32;
5112
5113   dw[7] =
5114      __gen_uint(values->StreamOffset, 0, 31);
5115}
5116
5117#define GFX8_3DSTATE_SO_DECL_LIST_length_bias      2
5118#define GFX8_3DSTATE_SO_DECL_LIST_header        \
5119   ._3DCommandSubOpcode                 =     23,  \
5120   ._3DCommandOpcode                    =      1,  \
5121   .CommandSubType                      =      3,  \
5122   .CommandType                         =      3
5123
5124struct GFX8_3DSTATE_SO_DECL_LIST {
5125   uint32_t                             DWordLength;
5126   uint32_t                             _3DCommandSubOpcode;
5127   uint32_t                             _3DCommandOpcode;
5128   uint32_t                             CommandSubType;
5129   uint32_t                             CommandType;
5130   uint32_t                             StreamtoBufferSelects0;
5131   uint32_t                             StreamtoBufferSelects1;
5132   uint32_t                             StreamtoBufferSelects2;
5133   uint32_t                             StreamtoBufferSelects3;
5134   uint32_t                             NumEntries0;
5135   uint32_t                             NumEntries1;
5136   uint32_t                             NumEntries2;
5137   uint32_t                             NumEntries3;
5138   /* variable length fields follow */
5139};
5140
5141static inline __attribute__((always_inline)) void
5142GFX8_3DSTATE_SO_DECL_LIST_pack(__attribute__((unused)) __gen_user_data *data,
5143                               __attribute__((unused)) void * restrict dst,
5144                               __attribute__((unused)) const struct GFX8_3DSTATE_SO_DECL_LIST * restrict values)
5145{
5146   uint32_t * restrict dw = (uint32_t * restrict) dst;
5147
5148   dw[0] =
5149      __gen_uint(values->DWordLength, 0, 8) |
5150      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5151      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5152      __gen_uint(values->CommandSubType, 27, 28) |
5153      __gen_uint(values->CommandType, 29, 31);
5154
5155   dw[1] =
5156      __gen_uint(values->StreamtoBufferSelects0, 0, 3) |
5157      __gen_uint(values->StreamtoBufferSelects1, 4, 7) |
5158      __gen_uint(values->StreamtoBufferSelects2, 8, 11) |
5159      __gen_uint(values->StreamtoBufferSelects3, 12, 15);
5160
5161   dw[2] =
5162      __gen_uint(values->NumEntries0, 0, 7) |
5163      __gen_uint(values->NumEntries1, 8, 15) |
5164      __gen_uint(values->NumEntries2, 16, 23) |
5165      __gen_uint(values->NumEntries3, 24, 31);
5166}
5167
5168#define GFX8_3DSTATE_STENCIL_BUFFER_length      5
5169#define GFX8_3DSTATE_STENCIL_BUFFER_length_bias      2
5170#define GFX8_3DSTATE_STENCIL_BUFFER_header      \
5171   .DWordLength                         =      3,  \
5172   ._3DCommandSubOpcode                 =      6,  \
5173   ._3DCommandOpcode                    =      0,  \
5174   .CommandSubType                      =      3,  \
5175   .CommandType                         =      3
5176
5177struct GFX8_3DSTATE_STENCIL_BUFFER {
5178   uint32_t                             DWordLength;
5179   uint32_t                             _3DCommandSubOpcode;
5180   uint32_t                             _3DCommandOpcode;
5181   uint32_t                             CommandSubType;
5182   uint32_t                             CommandType;
5183   uint32_t                             SurfacePitch;
5184   uint32_t                             MOCS;
5185   bool                                 StencilBufferEnable;
5186   __gen_address_type                   SurfaceBaseAddress;
5187   uint32_t                             SurfaceQPitch;
5188};
5189
5190static inline __attribute__((always_inline)) void
5191GFX8_3DSTATE_STENCIL_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
5192                                 __attribute__((unused)) void * restrict dst,
5193                                 __attribute__((unused)) const struct GFX8_3DSTATE_STENCIL_BUFFER * restrict values)
5194{
5195   uint32_t * restrict dw = (uint32_t * restrict) dst;
5196
5197   dw[0] =
5198      __gen_uint(values->DWordLength, 0, 7) |
5199      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5200      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5201      __gen_uint(values->CommandSubType, 27, 28) |
5202      __gen_uint(values->CommandType, 29, 31);
5203
5204   dw[1] =
5205      __gen_uint(values->SurfacePitch, 0, 16) |
5206      __gen_uint(values->MOCS, 22, 28) |
5207      __gen_uint(values->StencilBufferEnable, 31, 31);
5208
5209   const uint64_t v2_address =
5210      __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 63);
5211   dw[2] = v2_address;
5212   dw[3] = v2_address >> 32;
5213
5214   dw[4] =
5215      __gen_uint(values->SurfaceQPitch, 0, 14);
5216}
5217
5218#define GFX8_3DSTATE_STREAMOUT_length          5
5219#define GFX8_3DSTATE_STREAMOUT_length_bias      2
5220#define GFX8_3DSTATE_STREAMOUT_header           \
5221   .DWordLength                         =      3,  \
5222   ._3DCommandSubOpcode                 =     30,  \
5223   ._3DCommandOpcode                    =      0,  \
5224   .CommandSubType                      =      3,  \
5225   .CommandType                         =      3
5226
5227struct GFX8_3DSTATE_STREAMOUT {
5228   uint32_t                             DWordLength;
5229   uint32_t                             _3DCommandSubOpcode;
5230   uint32_t                             _3DCommandOpcode;
5231   uint32_t                             CommandSubType;
5232   uint32_t                             CommandType;
5233   uint32_t                             ForceRendering;
5234#define Resreved                                 1
5235#define Force_Off                                2
5236#define Force_on                                 3
5237   bool                                 SOStatisticsEnable;
5238   uint32_t                             ReorderMode;
5239#define LEADING                                  0
5240#define TRAILING                                 1
5241   uint32_t                             RenderStreamSelect;
5242   bool                                 RenderingDisable;
5243   bool                                 SOFunctionEnable;
5244   uint32_t                             Stream0VertexReadLength;
5245   uint32_t                             Stream0VertexReadOffset;
5246   uint32_t                             Stream1VertexReadLength;
5247   uint32_t                             Stream1VertexReadOffset;
5248   uint32_t                             Stream2VertexReadLength;
5249   uint32_t                             Stream2VertexReadOffset;
5250   uint32_t                             Stream3VertexReadLength;
5251   uint32_t                             Stream3VertexReadOffset;
5252   uint32_t                             Buffer0SurfacePitch;
5253   uint32_t                             Buffer1SurfacePitch;
5254   uint32_t                             Buffer2SurfacePitch;
5255   uint32_t                             Buffer3SurfacePitch;
5256};
5257
5258static inline __attribute__((always_inline)) void
5259GFX8_3DSTATE_STREAMOUT_pack(__attribute__((unused)) __gen_user_data *data,
5260                            __attribute__((unused)) void * restrict dst,
5261                            __attribute__((unused)) const struct GFX8_3DSTATE_STREAMOUT * restrict values)
5262{
5263   uint32_t * restrict dw = (uint32_t * restrict) dst;
5264
5265   dw[0] =
5266      __gen_uint(values->DWordLength, 0, 7) |
5267      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5268      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5269      __gen_uint(values->CommandSubType, 27, 28) |
5270      __gen_uint(values->CommandType, 29, 31);
5271
5272   dw[1] =
5273      __gen_uint(values->ForceRendering, 23, 24) |
5274      __gen_uint(values->SOStatisticsEnable, 25, 25) |
5275      __gen_uint(values->ReorderMode, 26, 26) |
5276      __gen_uint(values->RenderStreamSelect, 27, 28) |
5277      __gen_uint(values->RenderingDisable, 30, 30) |
5278      __gen_uint(values->SOFunctionEnable, 31, 31);
5279
5280   dw[2] =
5281      __gen_uint(values->Stream0VertexReadLength, 0, 4) |
5282      __gen_uint(values->Stream0VertexReadOffset, 5, 5) |
5283      __gen_uint(values->Stream1VertexReadLength, 8, 12) |
5284      __gen_uint(values->Stream1VertexReadOffset, 13, 13) |
5285      __gen_uint(values->Stream2VertexReadLength, 16, 20) |
5286      __gen_uint(values->Stream2VertexReadOffset, 21, 21) |
5287      __gen_uint(values->Stream3VertexReadLength, 24, 28) |
5288      __gen_uint(values->Stream3VertexReadOffset, 29, 29);
5289
5290   dw[3] =
5291      __gen_uint(values->Buffer0SurfacePitch, 0, 11) |
5292      __gen_uint(values->Buffer1SurfacePitch, 16, 27);
5293
5294   dw[4] =
5295      __gen_uint(values->Buffer2SurfacePitch, 0, 11) |
5296      __gen_uint(values->Buffer3SurfacePitch, 16, 27);
5297}
5298
5299#define GFX8_3DSTATE_TE_length                 4
5300#define GFX8_3DSTATE_TE_length_bias            2
5301#define GFX8_3DSTATE_TE_header                  \
5302   .DWordLength                         =      2,  \
5303   ._3DCommandSubOpcode                 =     28,  \
5304   ._3DCommandOpcode                    =      0,  \
5305   .CommandSubType                      =      3,  \
5306   .CommandType                         =      3
5307
5308struct GFX8_3DSTATE_TE {
5309   uint32_t                             DWordLength;
5310   uint32_t                             _3DCommandSubOpcode;
5311   uint32_t                             _3DCommandOpcode;
5312   uint32_t                             CommandSubType;
5313   uint32_t                             CommandType;
5314   bool                                 TEEnable;
5315   uint32_t                             TEMode;
5316#define HW_TESS                                  0
5317#define SW_TESS                                  1
5318   uint32_t                             TEDomain;
5319#define QUAD                                     0
5320#define TRI                                      1
5321#define ISOLINE                                  2
5322   uint32_t                             OutputTopology;
5323#define OUTPUT_POINT                             0
5324#define OUTPUT_LINE                              1
5325#define OUTPUT_TRI_CW                            2
5326#define OUTPUT_TRI_CCW                           3
5327   uint32_t                             Partitioning;
5328#define INTEGER                                  0
5329#define ODD_FRACTIONAL                           1
5330#define EVEN_FRACTIONAL                          2
5331   float                                MaximumTessellationFactorOdd;
5332   float                                MaximumTessellationFactorNotOdd;
5333};
5334
5335static inline __attribute__((always_inline)) void
5336GFX8_3DSTATE_TE_pack(__attribute__((unused)) __gen_user_data *data,
5337                     __attribute__((unused)) void * restrict dst,
5338                     __attribute__((unused)) const struct GFX8_3DSTATE_TE * restrict values)
5339{
5340   uint32_t * restrict dw = (uint32_t * restrict) dst;
5341
5342   dw[0] =
5343      __gen_uint(values->DWordLength, 0, 7) |
5344      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5345      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5346      __gen_uint(values->CommandSubType, 27, 28) |
5347      __gen_uint(values->CommandType, 29, 31);
5348
5349   dw[1] =
5350      __gen_uint(values->TEEnable, 0, 0) |
5351      __gen_uint(values->TEMode, 1, 2) |
5352      __gen_uint(values->TEDomain, 4, 5) |
5353      __gen_uint(values->OutputTopology, 8, 9) |
5354      __gen_uint(values->Partitioning, 12, 13);
5355
5356   dw[2] =
5357      __gen_float(values->MaximumTessellationFactorOdd);
5358
5359   dw[3] =
5360      __gen_float(values->MaximumTessellationFactorNotOdd);
5361}
5362
5363#define GFX8_3DSTATE_URB_DS_length             2
5364#define GFX8_3DSTATE_URB_DS_length_bias        2
5365#define GFX8_3DSTATE_URB_DS_header              \
5366   .DWordLength                         =      0,  \
5367   ._3DCommandSubOpcode                 =     50,  \
5368   ._3DCommandOpcode                    =      0,  \
5369   .CommandSubType                      =      3,  \
5370   .CommandType                         =      3
5371
5372struct GFX8_3DSTATE_URB_DS {
5373   uint32_t                             DWordLength;
5374   uint32_t                             _3DCommandSubOpcode;
5375   uint32_t                             _3DCommandOpcode;
5376   uint32_t                             CommandSubType;
5377   uint32_t                             CommandType;
5378   uint32_t                             DSNumberofURBEntries;
5379   uint32_t                             DSURBEntryAllocationSize;
5380   uint32_t                             DSURBStartingAddress;
5381};
5382
5383static inline __attribute__((always_inline)) void
5384GFX8_3DSTATE_URB_DS_pack(__attribute__((unused)) __gen_user_data *data,
5385                         __attribute__((unused)) void * restrict dst,
5386                         __attribute__((unused)) const struct GFX8_3DSTATE_URB_DS * restrict values)
5387{
5388   uint32_t * restrict dw = (uint32_t * restrict) dst;
5389
5390   dw[0] =
5391      __gen_uint(values->DWordLength, 0, 7) |
5392      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5393      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5394      __gen_uint(values->CommandSubType, 27, 28) |
5395      __gen_uint(values->CommandType, 29, 31);
5396
5397   dw[1] =
5398      __gen_uint(values->DSNumberofURBEntries, 0, 15) |
5399      __gen_uint(values->DSURBEntryAllocationSize, 16, 24) |
5400      __gen_uint(values->DSURBStartingAddress, 25, 31);
5401}
5402
5403#define GFX8_3DSTATE_URB_GS_length             2
5404#define GFX8_3DSTATE_URB_GS_length_bias        2
5405#define GFX8_3DSTATE_URB_GS_header              \
5406   .DWordLength                         =      0,  \
5407   ._3DCommandSubOpcode                 =     51,  \
5408   ._3DCommandOpcode                    =      0,  \
5409   .CommandSubType                      =      3,  \
5410   .CommandType                         =      3
5411
5412struct GFX8_3DSTATE_URB_GS {
5413   uint32_t                             DWordLength;
5414   uint32_t                             _3DCommandSubOpcode;
5415   uint32_t                             _3DCommandOpcode;
5416   uint32_t                             CommandSubType;
5417   uint32_t                             CommandType;
5418   uint32_t                             GSNumberofURBEntries;
5419   uint32_t                             GSURBEntryAllocationSize;
5420   uint32_t                             GSURBStartingAddress;
5421};
5422
5423static inline __attribute__((always_inline)) void
5424GFX8_3DSTATE_URB_GS_pack(__attribute__((unused)) __gen_user_data *data,
5425                         __attribute__((unused)) void * restrict dst,
5426                         __attribute__((unused)) const struct GFX8_3DSTATE_URB_GS * restrict values)
5427{
5428   uint32_t * restrict dw = (uint32_t * restrict) dst;
5429
5430   dw[0] =
5431      __gen_uint(values->DWordLength, 0, 7) |
5432      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5433      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5434      __gen_uint(values->CommandSubType, 27, 28) |
5435      __gen_uint(values->CommandType, 29, 31);
5436
5437   dw[1] =
5438      __gen_uint(values->GSNumberofURBEntries, 0, 15) |
5439      __gen_uint(values->GSURBEntryAllocationSize, 16, 24) |
5440      __gen_uint(values->GSURBStartingAddress, 25, 31);
5441}
5442
5443#define GFX8_3DSTATE_URB_HS_length             2
5444#define GFX8_3DSTATE_URB_HS_length_bias        2
5445#define GFX8_3DSTATE_URB_HS_header              \
5446   .DWordLength                         =      0,  \
5447   ._3DCommandSubOpcode                 =     49,  \
5448   ._3DCommandOpcode                    =      0,  \
5449   .CommandSubType                      =      3,  \
5450   .CommandType                         =      3
5451
5452struct GFX8_3DSTATE_URB_HS {
5453   uint32_t                             DWordLength;
5454   uint32_t                             _3DCommandSubOpcode;
5455   uint32_t                             _3DCommandOpcode;
5456   uint32_t                             CommandSubType;
5457   uint32_t                             CommandType;
5458   uint32_t                             HSNumberofURBEntries;
5459   uint32_t                             HSURBEntryAllocationSize;
5460   uint32_t                             HSURBStartingAddress;
5461};
5462
5463static inline __attribute__((always_inline)) void
5464GFX8_3DSTATE_URB_HS_pack(__attribute__((unused)) __gen_user_data *data,
5465                         __attribute__((unused)) void * restrict dst,
5466                         __attribute__((unused)) const struct GFX8_3DSTATE_URB_HS * restrict values)
5467{
5468   uint32_t * restrict dw = (uint32_t * restrict) dst;
5469
5470   dw[0] =
5471      __gen_uint(values->DWordLength, 0, 7) |
5472      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5473      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5474      __gen_uint(values->CommandSubType, 27, 28) |
5475      __gen_uint(values->CommandType, 29, 31);
5476
5477   dw[1] =
5478      __gen_uint(values->HSNumberofURBEntries, 0, 15) |
5479      __gen_uint(values->HSURBEntryAllocationSize, 16, 24) |
5480      __gen_uint(values->HSURBStartingAddress, 25, 31);
5481}
5482
5483#define GFX8_3DSTATE_URB_VS_length             2
5484#define GFX8_3DSTATE_URB_VS_length_bias        2
5485#define GFX8_3DSTATE_URB_VS_header              \
5486   .DWordLength                         =      0,  \
5487   ._3DCommandSubOpcode                 =     48,  \
5488   ._3DCommandOpcode                    =      0,  \
5489   .CommandSubType                      =      3,  \
5490   .CommandType                         =      3
5491
5492struct GFX8_3DSTATE_URB_VS {
5493   uint32_t                             DWordLength;
5494   uint32_t                             _3DCommandSubOpcode;
5495   uint32_t                             _3DCommandOpcode;
5496   uint32_t                             CommandSubType;
5497   uint32_t                             CommandType;
5498   uint32_t                             VSNumberofURBEntries;
5499   uint32_t                             VSURBEntryAllocationSize;
5500   uint32_t                             VSURBStartingAddress;
5501};
5502
5503static inline __attribute__((always_inline)) void
5504GFX8_3DSTATE_URB_VS_pack(__attribute__((unused)) __gen_user_data *data,
5505                         __attribute__((unused)) void * restrict dst,
5506                         __attribute__((unused)) const struct GFX8_3DSTATE_URB_VS * restrict values)
5507{
5508   uint32_t * restrict dw = (uint32_t * restrict) dst;
5509
5510   dw[0] =
5511      __gen_uint(values->DWordLength, 0, 7) |
5512      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5513      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5514      __gen_uint(values->CommandSubType, 27, 28) |
5515      __gen_uint(values->CommandType, 29, 31);
5516
5517   dw[1] =
5518      __gen_uint(values->VSNumberofURBEntries, 0, 15) |
5519      __gen_uint(values->VSURBEntryAllocationSize, 16, 24) |
5520      __gen_uint(values->VSURBStartingAddress, 25, 31);
5521}
5522
5523#define GFX8_3DSTATE_VERTEX_BUFFERS_length_bias      2
5524#define GFX8_3DSTATE_VERTEX_BUFFERS_header      \
5525   .DWordLength                         =      3,  \
5526   ._3DCommandSubOpcode                 =      8,  \
5527   ._3DCommandOpcode                    =      0,  \
5528   .CommandSubType                      =      3,  \
5529   .CommandType                         =      3
5530
5531struct GFX8_3DSTATE_VERTEX_BUFFERS {
5532   uint32_t                             DWordLength;
5533   uint32_t                             _3DCommandSubOpcode;
5534   uint32_t                             _3DCommandOpcode;
5535   uint32_t                             CommandSubType;
5536   uint32_t                             CommandType;
5537   /* variable length fields follow */
5538};
5539
5540static inline __attribute__((always_inline)) void
5541GFX8_3DSTATE_VERTEX_BUFFERS_pack(__attribute__((unused)) __gen_user_data *data,
5542                                 __attribute__((unused)) void * restrict dst,
5543                                 __attribute__((unused)) const struct GFX8_3DSTATE_VERTEX_BUFFERS * 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->_3DCommandSubOpcode, 16, 23) |
5550      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5551      __gen_uint(values->CommandSubType, 27, 28) |
5552      __gen_uint(values->CommandType, 29, 31);
5553}
5554
5555#define GFX8_3DSTATE_VERTEX_ELEMENTS_length_bias      2
5556#define GFX8_3DSTATE_VERTEX_ELEMENTS_header     \
5557   .DWordLength                         =      1,  \
5558   ._3DCommandSubOpcode                 =      9,  \
5559   ._3DCommandOpcode                    =      0,  \
5560   .CommandSubType                      =      3,  \
5561   .CommandType                         =      3
5562
5563struct GFX8_3DSTATE_VERTEX_ELEMENTS {
5564   uint32_t                             DWordLength;
5565   uint32_t                             _3DCommandSubOpcode;
5566   uint32_t                             _3DCommandOpcode;
5567   uint32_t                             CommandSubType;
5568   uint32_t                             CommandType;
5569   /* variable length fields follow */
5570};
5571
5572static inline __attribute__((always_inline)) void
5573GFX8_3DSTATE_VERTEX_ELEMENTS_pack(__attribute__((unused)) __gen_user_data *data,
5574                                  __attribute__((unused)) void * restrict dst,
5575                                  __attribute__((unused)) const struct GFX8_3DSTATE_VERTEX_ELEMENTS * restrict values)
5576{
5577   uint32_t * restrict dw = (uint32_t * restrict) dst;
5578
5579   dw[0] =
5580      __gen_uint(values->DWordLength, 0, 7) |
5581      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5582      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5583      __gen_uint(values->CommandSubType, 27, 28) |
5584      __gen_uint(values->CommandType, 29, 31);
5585}
5586
5587#define GFX8_3DSTATE_VF_length                 2
5588#define GFX8_3DSTATE_VF_length_bias            2
5589#define GFX8_3DSTATE_VF_header                  \
5590   .DWordLength                         =      0,  \
5591   ._3DCommandSubOpcode                 =     12,  \
5592   ._3DCommandOpcode                    =      0,  \
5593   .CommandSubType                      =      3,  \
5594   .CommandType                         =      3
5595
5596struct GFX8_3DSTATE_VF {
5597   uint32_t                             DWordLength;
5598   bool                                 IndexedDrawCutIndexEnable;
5599   uint32_t                             _3DCommandSubOpcode;
5600   uint32_t                             _3DCommandOpcode;
5601   uint32_t                             CommandSubType;
5602   uint32_t                             CommandType;
5603   uint32_t                             CutIndex;
5604};
5605
5606static inline __attribute__((always_inline)) void
5607GFX8_3DSTATE_VF_pack(__attribute__((unused)) __gen_user_data *data,
5608                     __attribute__((unused)) void * restrict dst,
5609                     __attribute__((unused)) const struct GFX8_3DSTATE_VF * restrict values)
5610{
5611   uint32_t * restrict dw = (uint32_t * restrict) dst;
5612
5613   dw[0] =
5614      __gen_uint(values->DWordLength, 0, 7) |
5615      __gen_uint(values->IndexedDrawCutIndexEnable, 8, 8) |
5616      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5617      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5618      __gen_uint(values->CommandSubType, 27, 28) |
5619      __gen_uint(values->CommandType, 29, 31);
5620
5621   dw[1] =
5622      __gen_uint(values->CutIndex, 0, 31);
5623}
5624
5625#define GFX8_3DSTATE_VF_INSTANCING_length      3
5626#define GFX8_3DSTATE_VF_INSTANCING_length_bias      2
5627#define GFX8_3DSTATE_VF_INSTANCING_header       \
5628   .DWordLength                         =      1,  \
5629   ._3DCommandSubOpcode                 =     73,  \
5630   ._3DCommandOpcode                    =      0,  \
5631   .CommandSubType                      =      3,  \
5632   .CommandType                         =      3
5633
5634struct GFX8_3DSTATE_VF_INSTANCING {
5635   uint32_t                             DWordLength;
5636   uint32_t                             _3DCommandSubOpcode;
5637   uint32_t                             _3DCommandOpcode;
5638   uint32_t                             CommandSubType;
5639   uint32_t                             CommandType;
5640   uint32_t                             VertexElementIndex;
5641   bool                                 InstancingEnable;
5642   uint32_t                             InstanceDataStepRate;
5643};
5644
5645static inline __attribute__((always_inline)) void
5646GFX8_3DSTATE_VF_INSTANCING_pack(__attribute__((unused)) __gen_user_data *data,
5647                                __attribute__((unused)) void * restrict dst,
5648                                __attribute__((unused)) const struct GFX8_3DSTATE_VF_INSTANCING * restrict values)
5649{
5650   uint32_t * restrict dw = (uint32_t * restrict) dst;
5651
5652   dw[0] =
5653      __gen_uint(values->DWordLength, 0, 7) |
5654      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5655      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5656      __gen_uint(values->CommandSubType, 27, 28) |
5657      __gen_uint(values->CommandType, 29, 31);
5658
5659   dw[1] =
5660      __gen_uint(values->VertexElementIndex, 0, 5) |
5661      __gen_uint(values->InstancingEnable, 8, 8);
5662
5663   dw[2] =
5664      __gen_uint(values->InstanceDataStepRate, 0, 31);
5665}
5666
5667#define GFX8_3DSTATE_VF_SGVS_length            2
5668#define GFX8_3DSTATE_VF_SGVS_length_bias       2
5669#define GFX8_3DSTATE_VF_SGVS_header             \
5670   .DWordLength                         =      0,  \
5671   ._3DCommandSubOpcode                 =     74,  \
5672   ._3DCommandOpcode                    =      0,  \
5673   .CommandSubType                      =      3,  \
5674   .CommandType                         =      3
5675
5676struct GFX8_3DSTATE_VF_SGVS {
5677   uint32_t                             DWordLength;
5678   uint32_t                             _3DCommandSubOpcode;
5679   uint32_t                             _3DCommandOpcode;
5680   uint32_t                             CommandSubType;
5681   uint32_t                             CommandType;
5682   uint32_t                             VertexIDElementOffset;
5683   uint32_t                             VertexIDComponentNumber;
5684#define COMP_0                                   0
5685#define COMP_1                                   1
5686#define COMP_2                                   2
5687#define COMP_3                                   3
5688   bool                                 VertexIDEnable;
5689   uint32_t                             InstanceIDElementOffset;
5690   uint32_t                             InstanceIDComponentNumber;
5691#define COMP_0                                   0
5692#define COMP_1                                   1
5693#define COMP_2                                   2
5694#define COMP_3                                   3
5695   bool                                 InstanceIDEnable;
5696};
5697
5698static inline __attribute__((always_inline)) void
5699GFX8_3DSTATE_VF_SGVS_pack(__attribute__((unused)) __gen_user_data *data,
5700                          __attribute__((unused)) void * restrict dst,
5701                          __attribute__((unused)) const struct GFX8_3DSTATE_VF_SGVS * restrict values)
5702{
5703   uint32_t * restrict dw = (uint32_t * restrict) dst;
5704
5705   dw[0] =
5706      __gen_uint(values->DWordLength, 0, 7) |
5707      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5708      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5709      __gen_uint(values->CommandSubType, 27, 28) |
5710      __gen_uint(values->CommandType, 29, 31);
5711
5712   dw[1] =
5713      __gen_uint(values->VertexIDElementOffset, 0, 5) |
5714      __gen_uint(values->VertexIDComponentNumber, 13, 14) |
5715      __gen_uint(values->VertexIDEnable, 15, 15) |
5716      __gen_uint(values->InstanceIDElementOffset, 16, 21) |
5717      __gen_uint(values->InstanceIDComponentNumber, 29, 30) |
5718      __gen_uint(values->InstanceIDEnable, 31, 31);
5719}
5720
5721#define GFX8_3DSTATE_VF_STATISTICS_length      1
5722#define GFX8_3DSTATE_VF_STATISTICS_length_bias      1
5723#define GFX8_3DSTATE_VF_STATISTICS_header       \
5724   ._3DCommandSubOpcode                 =     11,  \
5725   ._3DCommandOpcode                    =      0,  \
5726   .CommandSubType                      =      1,  \
5727   .CommandType                         =      3
5728
5729struct GFX8_3DSTATE_VF_STATISTICS {
5730   bool                                 StatisticsEnable;
5731   uint32_t                             _3DCommandSubOpcode;
5732   uint32_t                             _3DCommandOpcode;
5733   uint32_t                             CommandSubType;
5734   uint32_t                             CommandType;
5735};
5736
5737static inline __attribute__((always_inline)) void
5738GFX8_3DSTATE_VF_STATISTICS_pack(__attribute__((unused)) __gen_user_data *data,
5739                                __attribute__((unused)) void * restrict dst,
5740                                __attribute__((unused)) const struct GFX8_3DSTATE_VF_STATISTICS * restrict values)
5741{
5742   uint32_t * restrict dw = (uint32_t * restrict) dst;
5743
5744   dw[0] =
5745      __gen_uint(values->StatisticsEnable, 0, 0) |
5746      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5747      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5748      __gen_uint(values->CommandSubType, 27, 28) |
5749      __gen_uint(values->CommandType, 29, 31);
5750}
5751
5752#define GFX8_3DSTATE_VF_TOPOLOGY_length        2
5753#define GFX8_3DSTATE_VF_TOPOLOGY_length_bias      2
5754#define GFX8_3DSTATE_VF_TOPOLOGY_header         \
5755   .DWordLength                         =      0,  \
5756   ._3DCommandSubOpcode                 =     75,  \
5757   ._3DCommandOpcode                    =      0,  \
5758   .CommandSubType                      =      3,  \
5759   .CommandType                         =      3
5760
5761struct GFX8_3DSTATE_VF_TOPOLOGY {
5762   uint32_t                             DWordLength;
5763   uint32_t                             _3DCommandSubOpcode;
5764   uint32_t                             _3DCommandOpcode;
5765   uint32_t                             CommandSubType;
5766   uint32_t                             CommandType;
5767   enum GFX8_3D_Prim_Topo_Type          PrimitiveTopologyType;
5768};
5769
5770static inline __attribute__((always_inline)) void
5771GFX8_3DSTATE_VF_TOPOLOGY_pack(__attribute__((unused)) __gen_user_data *data,
5772                              __attribute__((unused)) void * restrict dst,
5773                              __attribute__((unused)) const struct GFX8_3DSTATE_VF_TOPOLOGY * restrict values)
5774{
5775   uint32_t * restrict dw = (uint32_t * restrict) dst;
5776
5777   dw[0] =
5778      __gen_uint(values->DWordLength, 0, 7) |
5779      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5780      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5781      __gen_uint(values->CommandSubType, 27, 28) |
5782      __gen_uint(values->CommandType, 29, 31);
5783
5784   dw[1] =
5785      __gen_uint(values->PrimitiveTopologyType, 0, 5);
5786}
5787
5788#define GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_CC_length      2
5789#define GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_CC_length_bias      2
5790#define GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_CC_header\
5791   .DWordLength                         =      0,  \
5792   ._3DCommandSubOpcode                 =     35,  \
5793   ._3DCommandOpcode                    =      0,  \
5794   .CommandSubType                      =      3,  \
5795   .CommandType                         =      3
5796
5797struct GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_CC {
5798   uint32_t                             DWordLength;
5799   uint32_t                             _3DCommandSubOpcode;
5800   uint32_t                             _3DCommandOpcode;
5801   uint32_t                             CommandSubType;
5802   uint32_t                             CommandType;
5803   uint64_t                             CCViewportPointer;
5804};
5805
5806static inline __attribute__((always_inline)) void
5807GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_CC_pack(__attribute__((unused)) __gen_user_data *data,
5808                                             __attribute__((unused)) void * restrict dst,
5809                                             __attribute__((unused)) const struct GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_CC * restrict values)
5810{
5811   uint32_t * restrict dw = (uint32_t * restrict) dst;
5812
5813   dw[0] =
5814      __gen_uint(values->DWordLength, 0, 7) |
5815      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5816      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5817      __gen_uint(values->CommandSubType, 27, 28) |
5818      __gen_uint(values->CommandType, 29, 31);
5819
5820   dw[1] =
5821      __gen_offset(values->CCViewportPointer, 5, 31);
5822}
5823
5824#define GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP_length      2
5825#define GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP_length_bias      2
5826#define GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP_header\
5827   .DWordLength                         =      0,  \
5828   ._3DCommandSubOpcode                 =     33,  \
5829   ._3DCommandOpcode                    =      0,  \
5830   .CommandSubType                      =      3,  \
5831   .CommandType                         =      3
5832
5833struct GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP {
5834   uint32_t                             DWordLength;
5835   uint32_t                             _3DCommandSubOpcode;
5836   uint32_t                             _3DCommandOpcode;
5837   uint32_t                             CommandSubType;
5838   uint32_t                             CommandType;
5839   uint64_t                             SFClipViewportPointer;
5840};
5841
5842static inline __attribute__((always_inline)) void
5843GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP_pack(__attribute__((unused)) __gen_user_data *data,
5844                                                  __attribute__((unused)) void * restrict dst,
5845                                                  __attribute__((unused)) const struct GFX8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP * restrict values)
5846{
5847   uint32_t * restrict dw = (uint32_t * restrict) dst;
5848
5849   dw[0] =
5850      __gen_uint(values->DWordLength, 0, 7) |
5851      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5852      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5853      __gen_uint(values->CommandSubType, 27, 28) |
5854      __gen_uint(values->CommandType, 29, 31);
5855
5856   dw[1] =
5857      __gen_offset(values->SFClipViewportPointer, 6, 31);
5858}
5859
5860#define GFX8_3DSTATE_VS_length                 9
5861#define GFX8_3DSTATE_VS_length_bias            2
5862#define GFX8_3DSTATE_VS_header                  \
5863   .DWordLength                         =      7,  \
5864   ._3DCommandSubOpcode                 =     16,  \
5865   ._3DCommandOpcode                    =      0,  \
5866   .CommandSubType                      =      3,  \
5867   .CommandType                         =      3
5868
5869struct GFX8_3DSTATE_VS {
5870   uint32_t                             DWordLength;
5871   uint32_t                             _3DCommandSubOpcode;
5872   uint32_t                             _3DCommandOpcode;
5873   uint32_t                             CommandSubType;
5874   uint32_t                             CommandType;
5875   uint64_t                             KernelStartPointer;
5876   bool                                 SoftwareExceptionEnable;
5877   bool                                 AccessesUAV;
5878   bool                                 IllegalOpcodeExceptionEnable;
5879   uint32_t                             FloatingPointMode;
5880#define IEEE754                                  0
5881#define Alternate                                1
5882   uint32_t                             ThreadDispatchPriority;
5883#define High                                     1
5884   uint32_t                             BindingTableEntryCount;
5885   uint32_t                             SamplerCount;
5886#define NoSamplers                               0
5887#define _14Samplers                              1
5888#define _58Samplers                              2
5889#define _912Samplers                             3
5890#define _1316Samplers                            4
5891   bool                                 VectorMaskEnable;
5892   bool                                 SingleVertexDispatch;
5893   uint32_t                             PerThreadScratchSpace;
5894   __gen_address_type                   ScratchSpaceBasePointer;
5895   uint32_t                             VertexURBEntryReadOffset;
5896   uint32_t                             VertexURBEntryReadLength;
5897   uint32_t                             DispatchGRFStartRegisterForURBData;
5898   bool                                 Enable;
5899   bool                                 VertexCacheDisable;
5900   bool                                 SIMD8DispatchEnable;
5901   bool                                 StatisticsEnable;
5902   uint32_t                             MaximumNumberofThreads;
5903   uint32_t                             UserClipDistanceCullTestEnableBitmask;
5904   uint32_t                             UserClipDistanceClipTestEnableBitmask;
5905   uint32_t                             VertexURBEntryOutputLength;
5906   uint32_t                             VertexURBEntryOutputReadOffset;
5907};
5908
5909static inline __attribute__((always_inline)) void
5910GFX8_3DSTATE_VS_pack(__attribute__((unused)) __gen_user_data *data,
5911                     __attribute__((unused)) void * restrict dst,
5912                     __attribute__((unused)) const struct GFX8_3DSTATE_VS * restrict values)
5913{
5914   uint32_t * restrict dw = (uint32_t * restrict) dst;
5915
5916   dw[0] =
5917      __gen_uint(values->DWordLength, 0, 7) |
5918      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
5919      __gen_uint(values->_3DCommandOpcode, 24, 26) |
5920      __gen_uint(values->CommandSubType, 27, 28) |
5921      __gen_uint(values->CommandType, 29, 31);
5922
5923   const uint64_t v1 =
5924      __gen_offset(values->KernelStartPointer, 6, 63);
5925   dw[1] = v1;
5926   dw[2] = v1 >> 32;
5927
5928   dw[3] =
5929      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
5930      __gen_uint(values->AccessesUAV, 12, 12) |
5931      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
5932      __gen_uint(values->FloatingPointMode, 16, 16) |
5933      __gen_uint(values->ThreadDispatchPriority, 17, 17) |
5934      __gen_uint(values->BindingTableEntryCount, 18, 25) |
5935      __gen_uint(values->SamplerCount, 27, 29) |
5936      __gen_uint(values->VectorMaskEnable, 30, 30) |
5937      __gen_uint(values->SingleVertexDispatch, 31, 31);
5938
5939   const uint64_t v4 =
5940      __gen_uint(values->PerThreadScratchSpace, 0, 3);
5941   const uint64_t v4_address =
5942      __gen_address(data, &dw[4], values->ScratchSpaceBasePointer, v4, 10, 63);
5943   dw[4] = v4_address;
5944   dw[5] = (v4_address >> 32) | (v4 >> 32);
5945
5946   dw[6] =
5947      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
5948      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
5949      __gen_uint(values->DispatchGRFStartRegisterForURBData, 20, 24);
5950
5951   dw[7] =
5952      __gen_uint(values->Enable, 0, 0) |
5953      __gen_uint(values->VertexCacheDisable, 1, 1) |
5954      __gen_uint(values->SIMD8DispatchEnable, 2, 2) |
5955      __gen_uint(values->StatisticsEnable, 10, 10) |
5956      __gen_uint(values->MaximumNumberofThreads, 23, 31);
5957
5958   dw[8] =
5959      __gen_uint(values->UserClipDistanceCullTestEnableBitmask, 0, 7) |
5960      __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 8, 15) |
5961      __gen_uint(values->VertexURBEntryOutputLength, 16, 20) |
5962      __gen_uint(values->VertexURBEntryOutputReadOffset, 21, 26);
5963}
5964
5965#define GFX8_3DSTATE_WM_length                 2
5966#define GFX8_3DSTATE_WM_length_bias            2
5967#define GFX8_3DSTATE_WM_header                  \
5968   .DWordLength                         =      0,  \
5969   ._3DCommandSubOpcode                 =     20,  \
5970   ._3DCommandOpcode                    =      0,  \
5971   .CommandSubType                      =      3,  \
5972   .CommandType                         =      3
5973
5974struct GFX8_3DSTATE_WM {
5975   uint32_t                             DWordLength;
5976   uint32_t                             _3DCommandSubOpcode;
5977   uint32_t                             _3DCommandOpcode;
5978   uint32_t                             CommandSubType;
5979   uint32_t                             CommandType;
5980   uint32_t                             ForceKillPixelEnable;
5981#define ForceOff                                 1
5982#define ForceON                                  2
5983   uint32_t                             PointRasterizationRule;
5984#define RASTRULE_UPPER_LEFT                      0
5985#define RASTRULE_UPPER_RIGHT                     1
5986   bool                                 LineStippleEnable;
5987   bool                                 PolygonStippleEnable;
5988   uint32_t                             LineAntialiasingRegionWidth;
5989#define _05pixels                                0
5990#define _10pixels                                1
5991#define _20pixels                                2
5992#define _40pixels                                3
5993   uint32_t                             LineEndCapAntialiasingRegionWidth;
5994#define _05pixels                                0
5995#define _10pixels                                1
5996#define _20pixels                                2
5997#define _40pixels                                3
5998   uint32_t                             BarycentricInterpolationMode;
5999#define BIM_PERSPECTIVE_PIXEL                    1
6000#define BIM_PERSPECTIVE_CENTROID                 2
6001#define BIM_PERSPECTIVE_SAMPLE                   4
6002#define BIM_LINEAR_PIXEL                         8
6003#define BIM_LINEAR_CENTROID                      16
6004#define BIM_LINEAR_SAMPLE                        32
6005   uint32_t                             PositionZWInterpolationMode;
6006#define INTERP_PIXEL                             0
6007#define INTERP_CENTROID                          2
6008#define INTERP_SAMPLE                            3
6009   uint32_t                             ForceThreadDispatchEnable;
6010#define ForceOff                                 1
6011#define ForceON                                  2
6012   uint32_t                             EarlyDepthStencilControl;
6013#define EDSC_NORMAL                              0
6014#define EDSC_PSEXEC                              1
6015#define EDSC_PREPS                               2
6016   bool                                 LegacyDiamondLineRasterization;
6017   bool                                 LegacyHierarchicalDepthBufferResolveEnable;
6018   bool                                 LegacyDepthBufferResolveEnable;
6019   bool                                 LegacyDepthBufferClearEnable;
6020   bool                                 StatisticsEnable;
6021};
6022
6023static inline __attribute__((always_inline)) void
6024GFX8_3DSTATE_WM_pack(__attribute__((unused)) __gen_user_data *data,
6025                     __attribute__((unused)) void * restrict dst,
6026                     __attribute__((unused)) const struct GFX8_3DSTATE_WM * restrict values)
6027{
6028   uint32_t * restrict dw = (uint32_t * restrict) dst;
6029
6030   dw[0] =
6031      __gen_uint(values->DWordLength, 0, 7) |
6032      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
6033      __gen_uint(values->_3DCommandOpcode, 24, 26) |
6034      __gen_uint(values->CommandSubType, 27, 28) |
6035      __gen_uint(values->CommandType, 29, 31);
6036
6037   dw[1] =
6038      __gen_uint(values->ForceKillPixelEnable, 0, 1) |
6039      __gen_uint(values->PointRasterizationRule, 2, 2) |
6040      __gen_uint(values->LineStippleEnable, 3, 3) |
6041      __gen_uint(values->PolygonStippleEnable, 4, 4) |
6042      __gen_uint(values->LineAntialiasingRegionWidth, 6, 7) |
6043      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 8, 9) |
6044      __gen_uint(values->BarycentricInterpolationMode, 11, 16) |
6045      __gen_uint(values->PositionZWInterpolationMode, 17, 18) |
6046      __gen_uint(values->ForceThreadDispatchEnable, 19, 20) |
6047      __gen_uint(values->EarlyDepthStencilControl, 21, 22) |
6048      __gen_uint(values->LegacyDiamondLineRasterization, 26, 26) |
6049      __gen_uint(values->LegacyHierarchicalDepthBufferResolveEnable, 27, 27) |
6050      __gen_uint(values->LegacyDepthBufferResolveEnable, 28, 28) |
6051      __gen_uint(values->LegacyDepthBufferClearEnable, 30, 30) |
6052      __gen_uint(values->StatisticsEnable, 31, 31);
6053}
6054
6055#define GFX8_3DSTATE_WM_CHROMAKEY_length       2
6056#define GFX8_3DSTATE_WM_CHROMAKEY_length_bias      2
6057#define GFX8_3DSTATE_WM_CHROMAKEY_header        \
6058   .DWordLength                         =      0,  \
6059   ._3DCommandSubOpcode                 =     76,  \
6060   ._3DCommandOpcode                    =      0,  \
6061   .CommandSubType                      =      3,  \
6062   .CommandType                         =      3
6063
6064struct GFX8_3DSTATE_WM_CHROMAKEY {
6065   uint32_t                             DWordLength;
6066   uint32_t                             _3DCommandSubOpcode;
6067   uint32_t                             _3DCommandOpcode;
6068   uint32_t                             CommandSubType;
6069   uint32_t                             CommandType;
6070   bool                                 ChromaKeyKillEnable;
6071};
6072
6073static inline __attribute__((always_inline)) void
6074GFX8_3DSTATE_WM_CHROMAKEY_pack(__attribute__((unused)) __gen_user_data *data,
6075                               __attribute__((unused)) void * restrict dst,
6076                               __attribute__((unused)) const struct GFX8_3DSTATE_WM_CHROMAKEY * restrict values)
6077{
6078   uint32_t * restrict dw = (uint32_t * restrict) dst;
6079
6080   dw[0] =
6081      __gen_uint(values->DWordLength, 0, 7) |
6082      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
6083      __gen_uint(values->_3DCommandOpcode, 24, 26) |
6084      __gen_uint(values->CommandSubType, 27, 28) |
6085      __gen_uint(values->CommandType, 29, 31);
6086
6087   dw[1] =
6088      __gen_uint(values->ChromaKeyKillEnable, 31, 31);
6089}
6090
6091#define GFX8_3DSTATE_WM_DEPTH_STENCIL_length      3
6092#define GFX8_3DSTATE_WM_DEPTH_STENCIL_length_bias      2
6093#define GFX8_3DSTATE_WM_DEPTH_STENCIL_header    \
6094   .DWordLength                         =      1,  \
6095   ._3DCommandSubOpcode                 =     78,  \
6096   ._3DCommandOpcode                    =      0,  \
6097   .CommandSubType                      =      3,  \
6098   .CommandType                         =      3
6099
6100struct GFX8_3DSTATE_WM_DEPTH_STENCIL {
6101   uint32_t                             DWordLength;
6102   uint32_t                             _3DCommandSubOpcode;
6103   uint32_t                             _3DCommandOpcode;
6104   uint32_t                             CommandSubType;
6105   uint32_t                             CommandType;
6106   bool                                 DepthBufferWriteEnable;
6107   bool                                 DepthTestEnable;
6108   bool                                 StencilBufferWriteEnable;
6109   bool                                 StencilTestEnable;
6110   bool                                 DoubleSidedStencilEnable;
6111   enum GFX8_3D_Compare_Function        DepthTestFunction;
6112   enum GFX8_3D_Compare_Function        StencilTestFunction;
6113   enum GFX8_3D_Stencil_Operation       BackfaceStencilPassDepthPassOp;
6114   enum GFX8_3D_Stencil_Operation       BackfaceStencilPassDepthFailOp;
6115   enum GFX8_3D_Stencil_Operation       BackfaceStencilFailOp;
6116   enum GFX8_3D_Compare_Function        BackfaceStencilTestFunction;
6117   enum GFX8_3D_Stencil_Operation       StencilPassDepthPassOp;
6118   enum GFX8_3D_Stencil_Operation       StencilPassDepthFailOp;
6119   enum GFX8_3D_Stencil_Operation       StencilFailOp;
6120   uint32_t                             BackfaceStencilWriteMask;
6121   uint32_t                             BackfaceStencilTestMask;
6122   uint32_t                             StencilWriteMask;
6123   uint32_t                             StencilTestMask;
6124};
6125
6126static inline __attribute__((always_inline)) void
6127GFX8_3DSTATE_WM_DEPTH_STENCIL_pack(__attribute__((unused)) __gen_user_data *data,
6128                                   __attribute__((unused)) void * restrict dst,
6129                                   __attribute__((unused)) const struct GFX8_3DSTATE_WM_DEPTH_STENCIL * restrict values)
6130{
6131   uint32_t * restrict dw = (uint32_t * restrict) dst;
6132
6133   dw[0] =
6134      __gen_uint(values->DWordLength, 0, 7) |
6135      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
6136      __gen_uint(values->_3DCommandOpcode, 24, 26) |
6137      __gen_uint(values->CommandSubType, 27, 28) |
6138      __gen_uint(values->CommandType, 29, 31);
6139
6140   dw[1] =
6141      __gen_uint(values->DepthBufferWriteEnable, 0, 0) |
6142      __gen_uint(values->DepthTestEnable, 1, 1) |
6143      __gen_uint(values->StencilBufferWriteEnable, 2, 2) |
6144      __gen_uint(values->StencilTestEnable, 3, 3) |
6145      __gen_uint(values->DoubleSidedStencilEnable, 4, 4) |
6146      __gen_uint(values->DepthTestFunction, 5, 7) |
6147      __gen_uint(values->StencilTestFunction, 8, 10) |
6148      __gen_uint(values->BackfaceStencilPassDepthPassOp, 11, 13) |
6149      __gen_uint(values->BackfaceStencilPassDepthFailOp, 14, 16) |
6150      __gen_uint(values->BackfaceStencilFailOp, 17, 19) |
6151      __gen_uint(values->BackfaceStencilTestFunction, 20, 22) |
6152      __gen_uint(values->StencilPassDepthPassOp, 23, 25) |
6153      __gen_uint(values->StencilPassDepthFailOp, 26, 28) |
6154      __gen_uint(values->StencilFailOp, 29, 31);
6155
6156   dw[2] =
6157      __gen_uint(values->BackfaceStencilWriteMask, 0, 7) |
6158      __gen_uint(values->BackfaceStencilTestMask, 8, 15) |
6159      __gen_uint(values->StencilWriteMask, 16, 23) |
6160      __gen_uint(values->StencilTestMask, 24, 31);
6161}
6162
6163#define GFX8_3DSTATE_WM_HZ_OP_length           5
6164#define GFX8_3DSTATE_WM_HZ_OP_length_bias      2
6165#define GFX8_3DSTATE_WM_HZ_OP_header            \
6166   .DWordLength                         =      3,  \
6167   ._3DCommandSubOpcode                 =     82,  \
6168   ._3DCommandOpcode                    =      0,  \
6169   .CommandSubType                      =      3,  \
6170   .CommandType                         =      3
6171
6172struct GFX8_3DSTATE_WM_HZ_OP {
6173   uint32_t                             DWordLength;
6174   uint32_t                             _3DCommandSubOpcode;
6175   uint32_t                             _3DCommandOpcode;
6176   uint32_t                             CommandSubType;
6177   uint32_t                             CommandType;
6178   uint32_t                             NumberofMultisamples;
6179   uint32_t                             StencilClearValue;
6180   bool                                 FullSurfaceDepthandStencilClear;
6181   bool                                 PixelPositionOffsetEnable;
6182   bool                                 HierarchicalDepthBufferResolveEnable;
6183   bool                                 DepthBufferResolveEnable;
6184   bool                                 ScissorRectangleEnable;
6185   bool                                 DepthBufferClearEnable;
6186   bool                                 StencilBufferClearEnable;
6187   uint32_t                             ClearRectangleXMin;
6188   uint32_t                             ClearRectangleYMin;
6189   uint32_t                             ClearRectangleXMax;
6190   uint32_t                             ClearRectangleYMax;
6191   uint32_t                             SampleMask;
6192};
6193
6194static inline __attribute__((always_inline)) void
6195GFX8_3DSTATE_WM_HZ_OP_pack(__attribute__((unused)) __gen_user_data *data,
6196                           __attribute__((unused)) void * restrict dst,
6197                           __attribute__((unused)) const struct GFX8_3DSTATE_WM_HZ_OP * restrict values)
6198{
6199   uint32_t * restrict dw = (uint32_t * restrict) dst;
6200
6201   dw[0] =
6202      __gen_uint(values->DWordLength, 0, 7) |
6203      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
6204      __gen_uint(values->_3DCommandOpcode, 24, 26) |
6205      __gen_uint(values->CommandSubType, 27, 28) |
6206      __gen_uint(values->CommandType, 29, 31);
6207
6208   dw[1] =
6209      __gen_uint(values->NumberofMultisamples, 13, 15) |
6210      __gen_uint(values->StencilClearValue, 16, 23) |
6211      __gen_uint(values->FullSurfaceDepthandStencilClear, 25, 25) |
6212      __gen_uint(values->PixelPositionOffsetEnable, 26, 26) |
6213      __gen_uint(values->HierarchicalDepthBufferResolveEnable, 27, 27) |
6214      __gen_uint(values->DepthBufferResolveEnable, 28, 28) |
6215      __gen_uint(values->ScissorRectangleEnable, 29, 29) |
6216      __gen_uint(values->DepthBufferClearEnable, 30, 30) |
6217      __gen_uint(values->StencilBufferClearEnable, 31, 31);
6218
6219   dw[2] =
6220      __gen_uint(values->ClearRectangleXMin, 0, 15) |
6221      __gen_uint(values->ClearRectangleYMin, 16, 31);
6222
6223   dw[3] =
6224      __gen_uint(values->ClearRectangleXMax, 0, 15) |
6225      __gen_uint(values->ClearRectangleYMax, 16, 31);
6226
6227   dw[4] =
6228      __gen_uint(values->SampleMask, 0, 15);
6229}
6230
6231#define GFX8_GPGPU_CSR_BASE_ADDRESS_length      3
6232#define GFX8_GPGPU_CSR_BASE_ADDRESS_length_bias      2
6233#define GFX8_GPGPU_CSR_BASE_ADDRESS_header      \
6234   .DWordLength                         =      1,  \
6235   ._3DCommandSubOpcode                 =      4,  \
6236   ._3DCommandOpcode                    =      1,  \
6237   .CommandSubType                      =      0,  \
6238   .CommandType                         =      3
6239
6240struct GFX8_GPGPU_CSR_BASE_ADDRESS {
6241   uint32_t                             DWordLength;
6242   uint32_t                             _3DCommandSubOpcode;
6243   uint32_t                             _3DCommandOpcode;
6244   uint32_t                             CommandSubType;
6245   uint32_t                             CommandType;
6246   __gen_address_type                   GPGPUCSRBaseAddress;
6247};
6248
6249static inline __attribute__((always_inline)) void
6250GFX8_GPGPU_CSR_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data,
6251                                 __attribute__((unused)) void * restrict dst,
6252                                 __attribute__((unused)) const struct GFX8_GPGPU_CSR_BASE_ADDRESS * restrict values)
6253{
6254   uint32_t * restrict dw = (uint32_t * restrict) dst;
6255
6256   dw[0] =
6257      __gen_uint(values->DWordLength, 0, 7) |
6258      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
6259      __gen_uint(values->_3DCommandOpcode, 24, 26) |
6260      __gen_uint(values->CommandSubType, 27, 28) |
6261      __gen_uint(values->CommandType, 29, 31);
6262
6263   const uint64_t v1_address =
6264      __gen_address(data, &dw[1], values->GPGPUCSRBaseAddress, 0, 12, 63);
6265   dw[1] = v1_address;
6266   dw[2] = v1_address >> 32;
6267}
6268
6269#define GFX8_GPGPU_WALKER_length              15
6270#define GFX8_GPGPU_WALKER_length_bias          2
6271#define GFX8_GPGPU_WALKER_header                \
6272   .DWordLength                         =     13,  \
6273   .SubOpcode                           =      5,  \
6274   .MediaCommandOpcode                  =      1,  \
6275   .Pipeline                            =      2,  \
6276   .CommandType                         =      3
6277
6278struct GFX8_GPGPU_WALKER {
6279   uint32_t                             DWordLength;
6280   bool                                 PredicateEnable;
6281   bool                                 IndirectParameterEnable;
6282   uint32_t                             SubOpcode;
6283   uint32_t                             MediaCommandOpcode;
6284   uint32_t                             Pipeline;
6285   uint32_t                             CommandType;
6286   uint32_t                             InterfaceDescriptorOffset;
6287   uint32_t                             IndirectDataLength;
6288   uint64_t                             IndirectDataStartAddress;
6289   uint32_t                             ThreadWidthCounterMaximum;
6290   uint32_t                             ThreadHeightCounterMaximum;
6291   uint32_t                             ThreadDepthCounterMaximum;
6292   uint32_t                             SIMDSize;
6293#define SIMD8                                    0
6294#define SIMD16                                   1
6295#define SIMD32                                   2
6296   uint32_t                             ThreadGroupIDStartingX;
6297   uint32_t                             ThreadGroupIDXDimension;
6298   uint32_t                             ThreadGroupIDStartingY;
6299   uint32_t                             ThreadGroupIDYDimension;
6300   uint32_t                             ThreadGroupIDStartingResumeZ;
6301   uint32_t                             ThreadGroupIDZDimension;
6302   uint32_t                             RightExecutionMask;
6303   uint32_t                             BottomExecutionMask;
6304};
6305
6306static inline __attribute__((always_inline)) void
6307GFX8_GPGPU_WALKER_pack(__attribute__((unused)) __gen_user_data *data,
6308                       __attribute__((unused)) void * restrict dst,
6309                       __attribute__((unused)) const struct GFX8_GPGPU_WALKER * restrict values)
6310{
6311   uint32_t * restrict dw = (uint32_t * restrict) dst;
6312
6313   dw[0] =
6314      __gen_uint(values->DWordLength, 0, 7) |
6315      __gen_uint(values->PredicateEnable, 8, 8) |
6316      __gen_uint(values->IndirectParameterEnable, 10, 10) |
6317      __gen_uint(values->SubOpcode, 16, 23) |
6318      __gen_uint(values->MediaCommandOpcode, 24, 26) |
6319      __gen_uint(values->Pipeline, 27, 28) |
6320      __gen_uint(values->CommandType, 29, 31);
6321
6322   dw[1] =
6323      __gen_uint(values->InterfaceDescriptorOffset, 0, 5);
6324
6325   dw[2] =
6326      __gen_uint(values->IndirectDataLength, 0, 16);
6327
6328   dw[3] =
6329      __gen_offset(values->IndirectDataStartAddress, 6, 31);
6330
6331   dw[4] =
6332      __gen_uint(values->ThreadWidthCounterMaximum, 0, 5) |
6333      __gen_uint(values->ThreadHeightCounterMaximum, 8, 13) |
6334      __gen_uint(values->ThreadDepthCounterMaximum, 16, 21) |
6335      __gen_uint(values->SIMDSize, 30, 31);
6336
6337   dw[5] =
6338      __gen_uint(values->ThreadGroupIDStartingX, 0, 31);
6339
6340   dw[6] = 0;
6341
6342   dw[7] =
6343      __gen_uint(values->ThreadGroupIDXDimension, 0, 31);
6344
6345   dw[8] =
6346      __gen_uint(values->ThreadGroupIDStartingY, 0, 31);
6347
6348   dw[9] = 0;
6349
6350   dw[10] =
6351      __gen_uint(values->ThreadGroupIDYDimension, 0, 31);
6352
6353   dw[11] =
6354      __gen_uint(values->ThreadGroupIDStartingResumeZ, 0, 31);
6355
6356   dw[12] =
6357      __gen_uint(values->ThreadGroupIDZDimension, 0, 31);
6358
6359   dw[13] =
6360      __gen_uint(values->RightExecutionMask, 0, 31);
6361
6362   dw[14] =
6363      __gen_uint(values->BottomExecutionMask, 0, 31);
6364}
6365
6366#define GFX8_MEDIA_CURBE_LOAD_length           4
6367#define GFX8_MEDIA_CURBE_LOAD_length_bias      2
6368#define GFX8_MEDIA_CURBE_LOAD_header            \
6369   .DWordLength                         =      2,  \
6370   .SubOpcode                           =      1,  \
6371   .MediaCommandOpcode                  =      0,  \
6372   .Pipeline                            =      2,  \
6373   .CommandType                         =      3
6374
6375struct GFX8_MEDIA_CURBE_LOAD {
6376   uint32_t                             DWordLength;
6377   uint32_t                             SubOpcode;
6378   uint32_t                             MediaCommandOpcode;
6379   uint32_t                             Pipeline;
6380   uint32_t                             CommandType;
6381   uint32_t                             CURBETotalDataLength;
6382   uint32_t                             CURBEDataStartAddress;
6383};
6384
6385static inline __attribute__((always_inline)) void
6386GFX8_MEDIA_CURBE_LOAD_pack(__attribute__((unused)) __gen_user_data *data,
6387                           __attribute__((unused)) void * restrict dst,
6388                           __attribute__((unused)) const struct GFX8_MEDIA_CURBE_LOAD * restrict values)
6389{
6390   uint32_t * restrict dw = (uint32_t * restrict) dst;
6391
6392   dw[0] =
6393      __gen_uint(values->DWordLength, 0, 15) |
6394      __gen_uint(values->SubOpcode, 16, 23) |
6395      __gen_uint(values->MediaCommandOpcode, 24, 26) |
6396      __gen_uint(values->Pipeline, 27, 28) |
6397      __gen_uint(values->CommandType, 29, 31);
6398
6399   dw[1] = 0;
6400
6401   dw[2] =
6402      __gen_uint(values->CURBETotalDataLength, 0, 16);
6403
6404   dw[3] =
6405      __gen_uint(values->CURBEDataStartAddress, 0, 31);
6406}
6407
6408#define GFX8_MEDIA_INTERFACE_DESCRIPTOR_LOAD_length      4
6409#define GFX8_MEDIA_INTERFACE_DESCRIPTOR_LOAD_length_bias      2
6410#define GFX8_MEDIA_INTERFACE_DESCRIPTOR_LOAD_header\
6411   .DWordLength                         =      2,  \
6412   .SubOpcode                           =      2,  \
6413   .MediaCommandOpcode                  =      0,  \
6414   .Pipeline                            =      2,  \
6415   .CommandType                         =      3
6416
6417struct GFX8_MEDIA_INTERFACE_DESCRIPTOR_LOAD {
6418   uint32_t                             DWordLength;
6419   uint32_t                             SubOpcode;
6420   uint32_t                             MediaCommandOpcode;
6421   uint32_t                             Pipeline;
6422   uint32_t                             CommandType;
6423   uint32_t                             InterfaceDescriptorTotalLength;
6424   uint64_t                             InterfaceDescriptorDataStartAddress;
6425};
6426
6427static inline __attribute__((always_inline)) void
6428GFX8_MEDIA_INTERFACE_DESCRIPTOR_LOAD_pack(__attribute__((unused)) __gen_user_data *data,
6429                                          __attribute__((unused)) void * restrict dst,
6430                                          __attribute__((unused)) const struct GFX8_MEDIA_INTERFACE_DESCRIPTOR_LOAD * restrict values)
6431{
6432   uint32_t * restrict dw = (uint32_t * restrict) dst;
6433
6434   dw[0] =
6435      __gen_uint(values->DWordLength, 0, 15) |
6436      __gen_uint(values->SubOpcode, 16, 23) |
6437      __gen_uint(values->MediaCommandOpcode, 24, 26) |
6438      __gen_uint(values->Pipeline, 27, 28) |
6439      __gen_uint(values->CommandType, 29, 31);
6440
6441   dw[1] = 0;
6442
6443   dw[2] =
6444      __gen_uint(values->InterfaceDescriptorTotalLength, 0, 16);
6445
6446   dw[3] =
6447      __gen_offset(values->InterfaceDescriptorDataStartAddress, 0, 31);
6448}
6449
6450#define GFX8_MEDIA_OBJECT_length_bias          2
6451#define GFX8_MEDIA_OBJECT_header                \
6452   .DWordLength                         =      4,  \
6453   .MediaCommandSubOpcode               =      0,  \
6454   .MediaCommandOpcode                  =      1,  \
6455   .MediaCommandPipeline                =      2,  \
6456   .CommandType                         =      3
6457
6458struct GFX8_MEDIA_OBJECT {
6459   uint32_t                             DWordLength;
6460   uint32_t                             MediaCommandSubOpcode;
6461   uint32_t                             MediaCommandOpcode;
6462   uint32_t                             MediaCommandPipeline;
6463   uint32_t                             CommandType;
6464   uint32_t                             InterfaceDescriptorOffset;
6465   uint32_t                             IndirectDataLength;
6466   uint32_t                             SubSliceDestinationSelect;
6467#define SubSlice2                                2
6468#define SubSlice1                                1
6469#define SubSlice0                                0
6470   uint32_t                             SliceDestinationSelect;
6471#define Slice0                                   0
6472#define Slice1                                   1
6473#define Slice2                                   2
6474   uint32_t                             UseScoreboard;
6475#define Notusingscoreboard                       0
6476#define Usingscoreboard                          1
6477   uint32_t                             ForceDestination;
6478   uint32_t                             ThreadSynchronization;
6479#define Nothreadsynchronization                  0
6480#define Threaddispatchissynchronizedbythespawnrootthreadmessage 1
6481   bool                                 ChildrenPresent;
6482   __gen_address_type                   IndirectDataStartAddress;
6483   uint32_t                             ScoreboardX;
6484   uint32_t                             ScoredboardY;
6485   uint32_t                             ScoreboardMask;
6486   uint32_t                             ScoreboardColor;
6487   /* variable length fields follow */
6488};
6489
6490static inline __attribute__((always_inline)) void
6491GFX8_MEDIA_OBJECT_pack(__attribute__((unused)) __gen_user_data *data,
6492                       __attribute__((unused)) void * restrict dst,
6493                       __attribute__((unused)) const struct GFX8_MEDIA_OBJECT * restrict values)
6494{
6495   uint32_t * restrict dw = (uint32_t * restrict) dst;
6496
6497   dw[0] =
6498      __gen_uint(values->DWordLength, 0, 15) |
6499      __gen_uint(values->MediaCommandSubOpcode, 16, 23) |
6500      __gen_uint(values->MediaCommandOpcode, 24, 26) |
6501      __gen_uint(values->MediaCommandPipeline, 27, 28) |
6502      __gen_uint(values->CommandType, 29, 31);
6503
6504   dw[1] =
6505      __gen_uint(values->InterfaceDescriptorOffset, 0, 5);
6506
6507   dw[2] =
6508      __gen_uint(values->IndirectDataLength, 0, 16) |
6509      __gen_uint(values->SubSliceDestinationSelect, 17, 18) |
6510      __gen_uint(values->SliceDestinationSelect, 19, 20) |
6511      __gen_uint(values->UseScoreboard, 21, 21) |
6512      __gen_uint(values->ForceDestination, 22, 22) |
6513      __gen_uint(values->ThreadSynchronization, 24, 24) |
6514      __gen_uint(values->ChildrenPresent, 31, 31);
6515
6516   dw[3] = __gen_address(data, &dw[3], values->IndirectDataStartAddress, 0, 0, 31);
6517
6518   dw[4] =
6519      __gen_uint(values->ScoreboardX, 0, 8) |
6520      __gen_uint(values->ScoredboardY, 16, 24);
6521
6522   dw[5] =
6523      __gen_uint(values->ScoreboardMask, 0, 7) |
6524      __gen_uint(values->ScoreboardColor, 16, 19);
6525}
6526
6527#define GFX8_MEDIA_OBJECT_GRPID_length_bias      2
6528#define GFX8_MEDIA_OBJECT_GRPID_header          \
6529   .DWordLength                         =      5,  \
6530   .MediaCommandSubOpcode               =      6,  \
6531   .MediaCommandOpcode                  =      1,  \
6532   .MediaCommandPipeline                =      2,  \
6533   .CommandType                         =      3
6534
6535struct GFX8_MEDIA_OBJECT_GRPID {
6536   uint32_t                             DWordLength;
6537   uint32_t                             MediaCommandSubOpcode;
6538   uint32_t                             MediaCommandOpcode;
6539   uint32_t                             MediaCommandPipeline;
6540   uint32_t                             CommandType;
6541   uint32_t                             InterfaceDescriptorOffset;
6542   uint32_t                             IndirectDataLength;
6543   uint32_t                             SubSliceDestinationSelect;
6544#define SubSlice2                                2
6545#define SubSlice1                                1
6546#define SubSlice0                                0
6547   uint32_t                             SliceDestinationSelect;
6548#define Slice0                                   0
6549#define Slice1                                   1
6550#define Slice2                                   2
6551   uint32_t                             UseScoreboard;
6552#define Notusingscoreboard                       0
6553#define Usingscoreboard                          1
6554   uint32_t                             ForceDestination;
6555   uint32_t                             EndofThreadGroup;
6556   __gen_address_type                   IndirectDataStartAddress;
6557   uint32_t                             ScoreboardX;
6558   uint32_t                             ScoreboardY;
6559   uint32_t                             ScoreboardMask;
6560   uint32_t                             ScoreboardColor;
6561   uint32_t                             GroupID;
6562   /* variable length fields follow */
6563};
6564
6565static inline __attribute__((always_inline)) void
6566GFX8_MEDIA_OBJECT_GRPID_pack(__attribute__((unused)) __gen_user_data *data,
6567                             __attribute__((unused)) void * restrict dst,
6568                             __attribute__((unused)) const struct GFX8_MEDIA_OBJECT_GRPID * restrict values)
6569{
6570   uint32_t * restrict dw = (uint32_t * restrict) dst;
6571
6572   dw[0] =
6573      __gen_uint(values->DWordLength, 0, 15) |
6574      __gen_uint(values->MediaCommandSubOpcode, 16, 23) |
6575      __gen_uint(values->MediaCommandOpcode, 24, 26) |
6576      __gen_uint(values->MediaCommandPipeline, 27, 28) |
6577      __gen_uint(values->CommandType, 29, 31);
6578
6579   dw[1] =
6580      __gen_uint(values->InterfaceDescriptorOffset, 0, 5);
6581
6582   dw[2] =
6583      __gen_uint(values->IndirectDataLength, 0, 16) |
6584      __gen_uint(values->SubSliceDestinationSelect, 17, 18) |
6585      __gen_uint(values->SliceDestinationSelect, 19, 20) |
6586      __gen_uint(values->UseScoreboard, 21, 21) |
6587      __gen_uint(values->ForceDestination, 22, 22) |
6588      __gen_uint(values->EndofThreadGroup, 23, 23);
6589
6590   dw[3] = __gen_address(data, &dw[3], values->IndirectDataStartAddress, 0, 0, 31);
6591
6592   dw[4] =
6593      __gen_uint(values->ScoreboardX, 0, 8) |
6594      __gen_uint(values->ScoreboardY, 16, 24);
6595
6596   dw[5] =
6597      __gen_uint(values->ScoreboardMask, 0, 7) |
6598      __gen_uint(values->ScoreboardColor, 16, 19);
6599
6600   dw[6] =
6601      __gen_uint(values->GroupID, 0, 31);
6602}
6603
6604#define GFX8_MEDIA_OBJECT_PRT_length          16
6605#define GFX8_MEDIA_OBJECT_PRT_length_bias      2
6606#define GFX8_MEDIA_OBJECT_PRT_header            \
6607   .DWordLength                         =     14,  \
6608   .SubOpcode                           =      2,  \
6609   .MediaCommandOpcode                  =      1,  \
6610   .Pipeline                            =      2,  \
6611   .CommandType                         =      3
6612
6613struct GFX8_MEDIA_OBJECT_PRT {
6614   uint32_t                             DWordLength;
6615   uint32_t                             SubOpcode;
6616   uint32_t                             MediaCommandOpcode;
6617   uint32_t                             Pipeline;
6618   uint32_t                             CommandType;
6619   uint32_t                             InterfaceDescriptorOffset;
6620   uint32_t                             PRT_FenceType;
6621#define Rootthreadqueue                          0
6622#define VFEstateflush                            1
6623   bool                                 PRT_FenceNeeded;
6624   bool                                 ChildrenPresent;
6625   uint32_t                             InlineData[12];
6626};
6627
6628static inline __attribute__((always_inline)) void
6629GFX8_MEDIA_OBJECT_PRT_pack(__attribute__((unused)) __gen_user_data *data,
6630                           __attribute__((unused)) void * restrict dst,
6631                           __attribute__((unused)) const struct GFX8_MEDIA_OBJECT_PRT * restrict values)
6632{
6633   uint32_t * restrict dw = (uint32_t * restrict) dst;
6634
6635   dw[0] =
6636      __gen_uint(values->DWordLength, 0, 15) |
6637      __gen_uint(values->SubOpcode, 16, 23) |
6638      __gen_uint(values->MediaCommandOpcode, 24, 26) |
6639      __gen_uint(values->Pipeline, 27, 28) |
6640      __gen_uint(values->CommandType, 29, 31);
6641
6642   dw[1] =
6643      __gen_uint(values->InterfaceDescriptorOffset, 0, 5);
6644
6645   dw[2] =
6646      __gen_uint(values->PRT_FenceType, 22, 22) |
6647      __gen_uint(values->PRT_FenceNeeded, 23, 23) |
6648      __gen_uint(values->ChildrenPresent, 31, 31);
6649
6650   dw[3] = 0;
6651
6652   dw[4] =
6653      __gen_uint(values->InlineData[0], 0, 31);
6654
6655   dw[5] =
6656      __gen_uint(values->InlineData[1], 0, 31);
6657
6658   dw[6] =
6659      __gen_uint(values->InlineData[2], 0, 31);
6660
6661   dw[7] =
6662      __gen_uint(values->InlineData[3], 0, 31);
6663
6664   dw[8] =
6665      __gen_uint(values->InlineData[4], 0, 31);
6666
6667   dw[9] =
6668      __gen_uint(values->InlineData[5], 0, 31);
6669
6670   dw[10] =
6671      __gen_uint(values->InlineData[6], 0, 31);
6672
6673   dw[11] =
6674      __gen_uint(values->InlineData[7], 0, 31);
6675
6676   dw[12] =
6677      __gen_uint(values->InlineData[8], 0, 31);
6678
6679   dw[13] =
6680      __gen_uint(values->InlineData[9], 0, 31);
6681
6682   dw[14] =
6683      __gen_uint(values->InlineData[10], 0, 31);
6684
6685   dw[15] =
6686      __gen_uint(values->InlineData[11], 0, 31);
6687}
6688
6689#define GFX8_MEDIA_OBJECT_WALKER_length_bias      2
6690#define GFX8_MEDIA_OBJECT_WALKER_header         \
6691   .DWordLength                         =     15,  \
6692   .SubOpcode                           =      3,  \
6693   .MediaCommandOpcode                  =      1,  \
6694   .Pipeline                            =      2,  \
6695   .CommandType                         =      3
6696
6697struct GFX8_MEDIA_OBJECT_WALKER {
6698   uint32_t                             DWordLength;
6699   uint32_t                             SubOpcode;
6700   uint32_t                             MediaCommandOpcode;
6701   uint32_t                             Pipeline;
6702   uint32_t                             CommandType;
6703   uint32_t                             InterfaceDescriptorOffset;
6704   uint32_t                             IndirectDataLength;
6705   uint32_t                             UseScoreboard;
6706#define Notusingscoreboard                       0
6707#define Usingscoreboard                          1
6708   uint32_t                             ThreadSynchronization;
6709#define Nothreadsynchronization                  0
6710#define Threaddispatchissynchronizedbythespawnrootthreadmessage 1
6711   uint32_t                             ChildrenPresent;
6712   uint64_t                             IndirectDataStartAddress;
6713   uint32_t                             ScoreboardMask;
6714   uint32_t                             GroupIDLoopSelect;
6715   int32_t                              MidLoopUnitX;
6716   int32_t                              LocalMidLoopUnitY;
6717   uint32_t                             MiddleLoopExtraSteps;
6718   uint32_t                             ColorCountMinusOne;
6719   uint32_t                             LocalLoopExecCount;
6720   uint32_t                             GlobalLoopExecCount;
6721   uint32_t                             BlockResolutionX;
6722   uint32_t                             BlockResolutionY;
6723   uint32_t                             LocalStartX;
6724   uint32_t                             LocalStartY;
6725   int32_t                              LocalOuterLoopStrideX;
6726   int32_t                              LocalOuterLoopStrideY;
6727   int32_t                              LocalInnerLoopUnitX;
6728   int32_t                              LocalInnerLoopUnitY;
6729   uint32_t                             GlobalResolutionX;
6730   uint32_t                             GlobalResolutionY;
6731   int32_t                              GlobalStartX;
6732   int32_t                              GlobalStartY;
6733   int32_t                              GlobalOuterLoopStrideX;
6734   int32_t                              GlobalOuterLoopStrideY;
6735   int32_t                              GlobalInnerLoopUnitX;
6736   int32_t                              GlobalInnerLoopUnitY;
6737   /* variable length fields follow */
6738};
6739
6740static inline __attribute__((always_inline)) void
6741GFX8_MEDIA_OBJECT_WALKER_pack(__attribute__((unused)) __gen_user_data *data,
6742                              __attribute__((unused)) void * restrict dst,
6743                              __attribute__((unused)) const struct GFX8_MEDIA_OBJECT_WALKER * restrict values)
6744{
6745   uint32_t * restrict dw = (uint32_t * restrict) dst;
6746
6747   dw[0] =
6748      __gen_uint(values->DWordLength, 0, 15) |
6749      __gen_uint(values->SubOpcode, 16, 23) |
6750      __gen_uint(values->MediaCommandOpcode, 24, 26) |
6751      __gen_uint(values->Pipeline, 27, 28) |
6752      __gen_uint(values->CommandType, 29, 31);
6753
6754   dw[1] =
6755      __gen_uint(values->InterfaceDescriptorOffset, 0, 5);
6756
6757   dw[2] =
6758      __gen_uint(values->IndirectDataLength, 0, 16) |
6759      __gen_uint(values->UseScoreboard, 21, 21) |
6760      __gen_uint(values->ThreadSynchronization, 24, 24) |
6761      __gen_uint(values->ChildrenPresent, 31, 31);
6762
6763   dw[3] =
6764      __gen_offset(values->IndirectDataStartAddress, 0, 31);
6765
6766   dw[4] = 0;
6767
6768   dw[5] =
6769      __gen_uint(values->ScoreboardMask, 0, 7) |
6770      __gen_uint(values->GroupIDLoopSelect, 8, 31);
6771
6772   dw[6] =
6773      __gen_sint(values->MidLoopUnitX, 8, 9) |
6774      __gen_sint(values->LocalMidLoopUnitY, 12, 13) |
6775      __gen_uint(values->MiddleLoopExtraSteps, 16, 20) |
6776      __gen_uint(values->ColorCountMinusOne, 24, 27);
6777
6778   dw[7] =
6779      __gen_uint(values->LocalLoopExecCount, 0, 9) |
6780      __gen_uint(values->GlobalLoopExecCount, 16, 25);
6781
6782   dw[8] =
6783      __gen_uint(values->BlockResolutionX, 0, 8) |
6784      __gen_uint(values->BlockResolutionY, 16, 24);
6785
6786   dw[9] =
6787      __gen_uint(values->LocalStartX, 0, 8) |
6788      __gen_uint(values->LocalStartY, 16, 24);
6789
6790   dw[10] = 0;
6791
6792   dw[11] =
6793      __gen_sint(values->LocalOuterLoopStrideX, 0, 9) |
6794      __gen_sint(values->LocalOuterLoopStrideY, 16, 25);
6795
6796   dw[12] =
6797      __gen_sint(values->LocalInnerLoopUnitX, 0, 9) |
6798      __gen_sint(values->LocalInnerLoopUnitY, 16, 25);
6799
6800   dw[13] =
6801      __gen_uint(values->GlobalResolutionX, 0, 8) |
6802      __gen_uint(values->GlobalResolutionY, 16, 24);
6803
6804   dw[14] =
6805      __gen_sint(values->GlobalStartX, 0, 9) |
6806      __gen_sint(values->GlobalStartY, 16, 25);
6807
6808   dw[15] =
6809      __gen_sint(values->GlobalOuterLoopStrideX, 0, 9) |
6810      __gen_sint(values->GlobalOuterLoopStrideY, 16, 25);
6811
6812   dw[16] =
6813      __gen_sint(values->GlobalInnerLoopUnitX, 0, 9) |
6814      __gen_sint(values->GlobalInnerLoopUnitY, 16, 25);
6815}
6816
6817#define GFX8_MEDIA_STATE_FLUSH_length          2
6818#define GFX8_MEDIA_STATE_FLUSH_length_bias      2
6819#define GFX8_MEDIA_STATE_FLUSH_header           \
6820   .DWordLength                         =      0,  \
6821   .SubOpcode                           =      4,  \
6822   .MediaCommandOpcode                  =      0,  \
6823   .Pipeline                            =      2,  \
6824   .CommandType                         =      3
6825
6826struct GFX8_MEDIA_STATE_FLUSH {
6827   uint32_t                             DWordLength;
6828   uint32_t                             SubOpcode;
6829   uint32_t                             MediaCommandOpcode;
6830   uint32_t                             Pipeline;
6831   uint32_t                             CommandType;
6832   uint32_t                             InterfaceDescriptorOffset;
6833   uint32_t                             WatermarkRequired;
6834   bool                                 FlushtoGO;
6835};
6836
6837static inline __attribute__((always_inline)) void
6838GFX8_MEDIA_STATE_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
6839                            __attribute__((unused)) void * restrict dst,
6840                            __attribute__((unused)) const struct GFX8_MEDIA_STATE_FLUSH * restrict values)
6841{
6842   uint32_t * restrict dw = (uint32_t * restrict) dst;
6843
6844   dw[0] =
6845      __gen_uint(values->DWordLength, 0, 15) |
6846      __gen_uint(values->SubOpcode, 16, 23) |
6847      __gen_uint(values->MediaCommandOpcode, 24, 26) |
6848      __gen_uint(values->Pipeline, 27, 28) |
6849      __gen_uint(values->CommandType, 29, 31);
6850
6851   dw[1] =
6852      __gen_uint(values->InterfaceDescriptorOffset, 0, 5) |
6853      __gen_uint(values->WatermarkRequired, 6, 6) |
6854      __gen_uint(values->FlushtoGO, 7, 7);
6855}
6856
6857#define GFX8_MEDIA_VFE_STATE_length            9
6858#define GFX8_MEDIA_VFE_STATE_length_bias       2
6859#define GFX8_MEDIA_VFE_STATE_header             \
6860   .DWordLength                         =      7,  \
6861   .SubOpcode                           =      0,  \
6862   .MediaCommandOpcode                  =      0,  \
6863   .Pipeline                            =      2,  \
6864   .CommandType                         =      3
6865
6866struct GFX8_MEDIA_VFE_STATE {
6867   uint32_t                             DWordLength;
6868   uint32_t                             SubOpcode;
6869   uint32_t                             MediaCommandOpcode;
6870   uint32_t                             Pipeline;
6871   uint32_t                             CommandType;
6872   uint32_t                             PerThreadScratchSpace;
6873   uint32_t                             StackSize;
6874   __gen_address_type                   ScratchSpaceBasePointer;
6875   uint32_t                             BypassGatewayControl;
6876#define MaintainingOpenGatewayForwardMsgCloseGatewayprotocollegacymode 0
6877#define BypassingOpenGatewayCloseGatewayprotocol 1
6878   uint32_t                             ResetGatewayTimer;
6879#define Maintainingtheexistingtimestampstate     0
6880#define Resettingrelativetimerandlatchingtheglobaltimestamp 1
6881   uint32_t                             NumberofURBEntries;
6882   uint32_t                             MaximumNumberofThreads;
6883   uint32_t                             SliceDisable;
6884#define AllSubslicesEnabled                      0
6885#define OnlySlice0Enabled                        1
6886#define OnlySlice0Subslice0Enabled               3
6887   uint32_t                             CURBEAllocationSize;
6888   uint32_t                             URBEntryAllocationSize;
6889   uint32_t                             ScoreboardMask;
6890   uint32_t                             ScoreboardType;
6891#define StallingScoreboard                       0
6892#define NonStallingScoreboard                    1
6893   bool                                 ScoreboardEnable;
6894   int32_t                              Scoreboard0DeltaX;
6895   int32_t                              Scoreboard0DeltaY;
6896   int32_t                              Scoreboard1DeltaX;
6897   int32_t                              Scoreboard1DeltaY;
6898   int32_t                              Scoreboard2DeltaX;
6899   int32_t                              Scoreboard2DeltaY;
6900   int32_t                              Scoreboard3DeltaX;
6901   int32_t                              Scoreboard3DeltaY;
6902   int32_t                              Scoreboard4DeltaX;
6903   int32_t                              Scoreboard4DeltaY;
6904   int32_t                              Scoreboard5DeltaX;
6905   int32_t                              Scoreboard5DeltaY;
6906   int32_t                              Scoreboard6DeltaX;
6907   int32_t                              Scoreboard6DeltaY;
6908   int32_t                              Scoreboard7DeltaX;
6909   int32_t                              Scoreboard7DeltaY;
6910};
6911
6912static inline __attribute__((always_inline)) void
6913GFX8_MEDIA_VFE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
6914                          __attribute__((unused)) void * restrict dst,
6915                          __attribute__((unused)) const struct GFX8_MEDIA_VFE_STATE * restrict values)
6916{
6917   uint32_t * restrict dw = (uint32_t * restrict) dst;
6918
6919   dw[0] =
6920      __gen_uint(values->DWordLength, 0, 15) |
6921      __gen_uint(values->SubOpcode, 16, 23) |
6922      __gen_uint(values->MediaCommandOpcode, 24, 26) |
6923      __gen_uint(values->Pipeline, 27, 28) |
6924      __gen_uint(values->CommandType, 29, 31);
6925
6926   const uint64_t v1 =
6927      __gen_uint(values->PerThreadScratchSpace, 0, 3) |
6928      __gen_uint(values->StackSize, 4, 7);
6929   const uint64_t v1_address =
6930      __gen_address(data, &dw[1], values->ScratchSpaceBasePointer, v1, 10, 47);
6931   dw[1] = v1_address;
6932   dw[2] = (v1_address >> 32) | (v1 >> 32);
6933
6934   dw[3] =
6935      __gen_uint(values->BypassGatewayControl, 6, 6) |
6936      __gen_uint(values->ResetGatewayTimer, 7, 7) |
6937      __gen_uint(values->NumberofURBEntries, 8, 15) |
6938      __gen_uint(values->MaximumNumberofThreads, 16, 31);
6939
6940   dw[4] =
6941      __gen_uint(values->SliceDisable, 0, 1);
6942
6943   dw[5] =
6944      __gen_uint(values->CURBEAllocationSize, 0, 15) |
6945      __gen_uint(values->URBEntryAllocationSize, 16, 31);
6946
6947   dw[6] =
6948      __gen_uint(values->ScoreboardMask, 0, 7) |
6949      __gen_uint(values->ScoreboardType, 30, 30) |
6950      __gen_uint(values->ScoreboardEnable, 31, 31);
6951
6952   dw[7] =
6953      __gen_sint(values->Scoreboard0DeltaX, 0, 3) |
6954      __gen_sint(values->Scoreboard0DeltaY, 4, 7) |
6955      __gen_sint(values->Scoreboard1DeltaX, 8, 11) |
6956      __gen_sint(values->Scoreboard1DeltaY, 12, 15) |
6957      __gen_sint(values->Scoreboard2DeltaX, 16, 19) |
6958      __gen_sint(values->Scoreboard2DeltaY, 20, 23) |
6959      __gen_sint(values->Scoreboard3DeltaX, 24, 27) |
6960      __gen_sint(values->Scoreboard3DeltaY, 28, 31);
6961
6962   dw[8] =
6963      __gen_sint(values->Scoreboard4DeltaX, 0, 3) |
6964      __gen_sint(values->Scoreboard4DeltaY, 4, 7) |
6965      __gen_sint(values->Scoreboard5DeltaX, 8, 11) |
6966      __gen_sint(values->Scoreboard5DeltaY, 12, 15) |
6967      __gen_sint(values->Scoreboard6DeltaX, 16, 19) |
6968      __gen_sint(values->Scoreboard6DeltaY, 20, 23) |
6969      __gen_sint(values->Scoreboard7DeltaX, 24, 27) |
6970      __gen_sint(values->Scoreboard7DeltaY, 28, 31);
6971}
6972
6973#define GFX8_MI_ARB_CHECK_length               1
6974#define GFX8_MI_ARB_CHECK_length_bias          1
6975#define GFX8_MI_ARB_CHECK_header                \
6976   .MICommandOpcode                     =      5,  \
6977   .CommandType                         =      0
6978
6979struct GFX8_MI_ARB_CHECK {
6980   uint32_t                             MICommandOpcode;
6981   uint32_t                             CommandType;
6982};
6983
6984static inline __attribute__((always_inline)) void
6985GFX8_MI_ARB_CHECK_pack(__attribute__((unused)) __gen_user_data *data,
6986                       __attribute__((unused)) void * restrict dst,
6987                       __attribute__((unused)) const struct GFX8_MI_ARB_CHECK * restrict values)
6988{
6989   uint32_t * restrict dw = (uint32_t * restrict) dst;
6990
6991   dw[0] =
6992      __gen_uint(values->MICommandOpcode, 23, 28) |
6993      __gen_uint(values->CommandType, 29, 31);
6994}
6995
6996#define GFX8_MI_ARB_ON_OFF_length              1
6997#define GFX8_MI_ARB_ON_OFF_length_bias         1
6998#define GFX8_MI_ARB_ON_OFF_header               \
6999   .ArbitrationEnable                   =      1,  \
7000   .MICommandOpcode                     =      8,  \
7001   .CommandType                         =      0
7002
7003struct GFX8_MI_ARB_ON_OFF {
7004   bool                                 ArbitrationEnable;
7005   uint32_t                             MICommandOpcode;
7006   uint32_t                             CommandType;
7007};
7008
7009static inline __attribute__((always_inline)) void
7010GFX8_MI_ARB_ON_OFF_pack(__attribute__((unused)) __gen_user_data *data,
7011                        __attribute__((unused)) void * restrict dst,
7012                        __attribute__((unused)) const struct GFX8_MI_ARB_ON_OFF * restrict values)
7013{
7014   uint32_t * restrict dw = (uint32_t * restrict) dst;
7015
7016   dw[0] =
7017      __gen_uint(values->ArbitrationEnable, 0, 0) |
7018      __gen_uint(values->MICommandOpcode, 23, 28) |
7019      __gen_uint(values->CommandType, 29, 31);
7020}
7021
7022#define GFX8_MI_ATOMIC_length                  3
7023#define GFX8_MI_ATOMIC_length_bias             2
7024#define GFX8_MI_ATOMIC_header                   \
7025   .DWordLength                         =      1,  \
7026   .MICommandOpcode                     =     47,  \
7027   .CommandType                         =      0
7028
7029struct GFX8_MI_ATOMIC {
7030   uint32_t                             DWordLength;
7031   uint32_t                             ATOMICOPCODE;
7032   uint32_t                             ReturnDataControl;
7033   uint32_t                             CSSTALL;
7034   uint32_t                             InlineData;
7035   uint32_t                             DataSize;
7036#define DWORD                                    0
7037#define QWORD                                    1
7038#define OCTWORD                                  2
7039#define RESERVED                                 3
7040   bool                                 PostSyncOperation;
7041   uint32_t                             MemoryType;
7042#define PerProcessGraphicsAddress                0
7043#define GlobalGraphicsAddress                    1
7044   uint32_t                             MICommandOpcode;
7045   uint32_t                             CommandType;
7046   __gen_address_type                   MemoryAddress;
7047   uint32_t                             Operand1DataDword0;
7048   uint32_t                             Operand2DataDword0;
7049   uint32_t                             Operand1DataDword1;
7050   uint32_t                             Operand2DataDword1;
7051   uint32_t                             Operand1DataDword2;
7052   uint32_t                             Operand2DataDword2;
7053   uint32_t                             Operand1DataDword3;
7054   uint32_t                             Operand2DataDword3;
7055};
7056
7057static inline __attribute__((always_inline)) void
7058GFX8_MI_ATOMIC_pack(__attribute__((unused)) __gen_user_data *data,
7059                    __attribute__((unused)) void * restrict dst,
7060                    __attribute__((unused)) const struct GFX8_MI_ATOMIC * restrict values)
7061{
7062   uint32_t * restrict dw = (uint32_t * restrict) dst;
7063
7064   dw[0] =
7065      __gen_uint(values->DWordLength, 0, 7) |
7066      __gen_uint(values->ATOMICOPCODE, 8, 15) |
7067      __gen_uint(values->ReturnDataControl, 16, 16) |
7068      __gen_uint(values->CSSTALL, 17, 17) |
7069      __gen_uint(values->InlineData, 18, 18) |
7070      __gen_uint(values->DataSize, 19, 20) |
7071      __gen_uint(values->PostSyncOperation, 21, 21) |
7072      __gen_uint(values->MemoryType, 22, 22) |
7073      __gen_uint(values->MICommandOpcode, 23, 28) |
7074      __gen_uint(values->CommandType, 29, 31);
7075
7076   const uint64_t v1_address =
7077      __gen_address(data, &dw[1], values->MemoryAddress, 0, 2, 47);
7078   dw[1] = v1_address;
7079   dw[2] = v1_address >> 32;
7080}
7081
7082#define GFX8_MI_BATCH_BUFFER_END_length        1
7083#define GFX8_MI_BATCH_BUFFER_END_length_bias      1
7084#define GFX8_MI_BATCH_BUFFER_END_header         \
7085   .MICommandOpcode                     =     10,  \
7086   .CommandType                         =      0
7087
7088struct GFX8_MI_BATCH_BUFFER_END {
7089   uint32_t                             MICommandOpcode;
7090   uint32_t                             CommandType;
7091};
7092
7093static inline __attribute__((always_inline)) void
7094GFX8_MI_BATCH_BUFFER_END_pack(__attribute__((unused)) __gen_user_data *data,
7095                              __attribute__((unused)) void * restrict dst,
7096                              __attribute__((unused)) const struct GFX8_MI_BATCH_BUFFER_END * restrict values)
7097{
7098   uint32_t * restrict dw = (uint32_t * restrict) dst;
7099
7100   dw[0] =
7101      __gen_uint(values->MICommandOpcode, 23, 28) |
7102      __gen_uint(values->CommandType, 29, 31);
7103}
7104
7105#define GFX8_MI_BATCH_BUFFER_START_length      3
7106#define GFX8_MI_BATCH_BUFFER_START_length_bias      2
7107#define GFX8_MI_BATCH_BUFFER_START_header       \
7108   .DWordLength                         =      1,  \
7109   .MICommandOpcode                     =     49,  \
7110   .CommandType                         =      0
7111
7112struct GFX8_MI_BATCH_BUFFER_START {
7113   uint32_t                             DWordLength;
7114   uint32_t                             AddressSpaceIndicator;
7115#define ASI_GGTT                                 0
7116#define ASI_PPGTT                                1
7117   bool                                 ResourceStreamerEnable;
7118   bool                                 PredicationEnable;
7119   bool                                 AddOffsetEnable;
7120   uint32_t                             SecondLevelBatchBuffer;
7121#define Firstlevelbatch                          0
7122#define Secondlevelbatch                         1
7123   uint32_t                             MICommandOpcode;
7124   uint32_t                             CommandType;
7125   __gen_address_type                   BatchBufferStartAddress;
7126};
7127
7128static inline __attribute__((always_inline)) void
7129GFX8_MI_BATCH_BUFFER_START_pack(__attribute__((unused)) __gen_user_data *data,
7130                                __attribute__((unused)) void * restrict dst,
7131                                __attribute__((unused)) const struct GFX8_MI_BATCH_BUFFER_START * restrict values)
7132{
7133   uint32_t * restrict dw = (uint32_t * restrict) dst;
7134
7135   dw[0] =
7136      __gen_uint(values->DWordLength, 0, 7) |
7137      __gen_uint(values->AddressSpaceIndicator, 8, 8) |
7138      __gen_uint(values->ResourceStreamerEnable, 10, 10) |
7139      __gen_uint(values->PredicationEnable, 15, 15) |
7140      __gen_uint(values->AddOffsetEnable, 16, 16) |
7141      __gen_uint(values->SecondLevelBatchBuffer, 22, 22) |
7142      __gen_uint(values->MICommandOpcode, 23, 28) |
7143      __gen_uint(values->CommandType, 29, 31);
7144
7145   const uint64_t v1_address =
7146      __gen_address(data, &dw[1], values->BatchBufferStartAddress, 0, 2, 47);
7147   dw[1] = v1_address;
7148   dw[2] = v1_address >> 32;
7149}
7150
7151#define GFX8_MI_CLFLUSH_length_bias            2
7152#define GFX8_MI_CLFLUSH_header                  \
7153   .DWordLength                         =      1,  \
7154   .MICommandOpcode                     =     39,  \
7155   .CommandType                         =      0
7156
7157struct GFX8_MI_CLFLUSH {
7158   uint32_t                             DWordLength;
7159   bool                                 UseGlobalGTT;
7160   uint32_t                             MICommandOpcode;
7161   uint32_t                             CommandType;
7162   uint32_t                             StartingCachelineOffset;
7163   __gen_address_type                   PageBaseAddress;
7164   /* variable length fields follow */
7165};
7166
7167static inline __attribute__((always_inline)) void
7168GFX8_MI_CLFLUSH_pack(__attribute__((unused)) __gen_user_data *data,
7169                     __attribute__((unused)) void * restrict dst,
7170                     __attribute__((unused)) const struct GFX8_MI_CLFLUSH * restrict values)
7171{
7172   uint32_t * restrict dw = (uint32_t * restrict) dst;
7173
7174   dw[0] =
7175      __gen_uint(values->DWordLength, 0, 9) |
7176      __gen_uint(values->UseGlobalGTT, 22, 22) |
7177      __gen_uint(values->MICommandOpcode, 23, 28) |
7178      __gen_uint(values->CommandType, 29, 31);
7179
7180   const uint64_t v1 =
7181      __gen_uint(values->StartingCachelineOffset, 6, 11);
7182   const uint64_t v1_address =
7183      __gen_address(data, &dw[1], values->PageBaseAddress, v1, 12, 47);
7184   dw[1] = v1_address;
7185   dw[2] = (v1_address >> 32) | (v1 >> 32);
7186}
7187
7188#define GFX8_MI_CONDITIONAL_BATCH_BUFFER_END_length      3
7189#define GFX8_MI_CONDITIONAL_BATCH_BUFFER_END_length_bias      2
7190#define GFX8_MI_CONDITIONAL_BATCH_BUFFER_END_header\
7191   .DWordLength                         =      1,  \
7192   .CompareSemaphore                    =      0,  \
7193   .MICommandOpcode                     =     54,  \
7194   .CommandType                         =      0
7195
7196struct GFX8_MI_CONDITIONAL_BATCH_BUFFER_END {
7197   uint32_t                             DWordLength;
7198   uint32_t                             CompareSemaphore;
7199   bool                                 UseGlobalGTT;
7200   uint32_t                             MICommandOpcode;
7201   uint32_t                             CommandType;
7202   uint32_t                             CompareDataDword;
7203   __gen_address_type                   CompareAddress;
7204};
7205
7206static inline __attribute__((always_inline)) void
7207GFX8_MI_CONDITIONAL_BATCH_BUFFER_END_pack(__attribute__((unused)) __gen_user_data *data,
7208                                          __attribute__((unused)) void * restrict dst,
7209                                          __attribute__((unused)) const struct GFX8_MI_CONDITIONAL_BATCH_BUFFER_END * restrict values)
7210{
7211   uint32_t * restrict dw = (uint32_t * restrict) dst;
7212
7213   dw[0] =
7214      __gen_uint(values->DWordLength, 0, 7) |
7215      __gen_uint(values->CompareSemaphore, 21, 21) |
7216      __gen_uint(values->UseGlobalGTT, 22, 22) |
7217      __gen_uint(values->MICommandOpcode, 23, 28) |
7218      __gen_uint(values->CommandType, 29, 31);
7219
7220   dw[1] =
7221      __gen_uint(values->CompareDataDword, 0, 31);
7222
7223   const uint64_t v2_address =
7224      __gen_address(data, &dw[2], values->CompareAddress, 0, 3, 47);
7225   dw[2] = v2_address;
7226   dw[3] = v2_address >> 32;
7227}
7228
7229#define GFX8_MI_COPY_MEM_MEM_length            5
7230#define GFX8_MI_COPY_MEM_MEM_length_bias       2
7231#define GFX8_MI_COPY_MEM_MEM_header             \
7232   .DWordLength                         =      3,  \
7233   .MICommandOpcode                     =     46,  \
7234   .CommandType                         =      0
7235
7236struct GFX8_MI_COPY_MEM_MEM {
7237   uint32_t                             DWordLength;
7238   bool                                 UseGlobalGTTDestination;
7239   bool                                 UseGlobalGTTSource;
7240   uint32_t                             MICommandOpcode;
7241   uint32_t                             CommandType;
7242   __gen_address_type                   DestinationMemoryAddress;
7243   __gen_address_type                   SourceMemoryAddress;
7244};
7245
7246static inline __attribute__((always_inline)) void
7247GFX8_MI_COPY_MEM_MEM_pack(__attribute__((unused)) __gen_user_data *data,
7248                          __attribute__((unused)) void * restrict dst,
7249                          __attribute__((unused)) const struct GFX8_MI_COPY_MEM_MEM * restrict values)
7250{
7251   uint32_t * restrict dw = (uint32_t * restrict) dst;
7252
7253   dw[0] =
7254      __gen_uint(values->DWordLength, 0, 7) |
7255      __gen_uint(values->UseGlobalGTTDestination, 21, 21) |
7256      __gen_uint(values->UseGlobalGTTSource, 22, 22) |
7257      __gen_uint(values->MICommandOpcode, 23, 28) |
7258      __gen_uint(values->CommandType, 29, 31);
7259
7260   const uint64_t v1_address =
7261      __gen_address(data, &dw[1], values->DestinationMemoryAddress, 0, 2, 63);
7262   dw[1] = v1_address;
7263   dw[2] = v1_address >> 32;
7264
7265   const uint64_t v3_address =
7266      __gen_address(data, &dw[3], values->SourceMemoryAddress, 0, 2, 63);
7267   dw[3] = v3_address;
7268   dw[4] = v3_address >> 32;
7269}
7270
7271#define GFX8_MI_LOAD_REGISTER_IMM_length       3
7272#define GFX8_MI_LOAD_REGISTER_IMM_length_bias      2
7273#define GFX8_MI_LOAD_REGISTER_IMM_header        \
7274   .DWordLength                         =      1,  \
7275   .MICommandOpcode                     =     34,  \
7276   .CommandType                         =      0
7277
7278struct GFX8_MI_LOAD_REGISTER_IMM {
7279   uint32_t                             DWordLength;
7280   uint32_t                             ByteWriteDisables;
7281   uint32_t                             MICommandOpcode;
7282   uint32_t                             CommandType;
7283   uint64_t                             RegisterOffset;
7284   uint32_t                             DataDWord;
7285   /* variable length fields follow */
7286};
7287
7288static inline __attribute__((always_inline)) void
7289GFX8_MI_LOAD_REGISTER_IMM_pack(__attribute__((unused)) __gen_user_data *data,
7290                               __attribute__((unused)) void * restrict dst,
7291                               __attribute__((unused)) const struct GFX8_MI_LOAD_REGISTER_IMM * restrict values)
7292{
7293   uint32_t * restrict dw = (uint32_t * restrict) dst;
7294
7295   dw[0] =
7296      __gen_uint(values->DWordLength, 0, 7) |
7297      __gen_uint(values->ByteWriteDisables, 8, 11) |
7298      __gen_uint(values->MICommandOpcode, 23, 28) |
7299      __gen_uint(values->CommandType, 29, 31);
7300
7301   dw[1] =
7302      __gen_offset(values->RegisterOffset, 2, 22);
7303
7304   dw[2] =
7305      __gen_uint(values->DataDWord, 0, 31);
7306}
7307
7308#define GFX8_MI_LOAD_REGISTER_MEM_length       4
7309#define GFX8_MI_LOAD_REGISTER_MEM_length_bias      2
7310#define GFX8_MI_LOAD_REGISTER_MEM_header        \
7311   .DWordLength                         =      2,  \
7312   .MICommandOpcode                     =     41,  \
7313   .CommandType                         =      0
7314
7315struct GFX8_MI_LOAD_REGISTER_MEM {
7316   uint32_t                             DWordLength;
7317   bool                                 AsyncModeEnable;
7318   bool                                 UseGlobalGTT;
7319   uint32_t                             MICommandOpcode;
7320   uint32_t                             CommandType;
7321   uint64_t                             RegisterAddress;
7322   __gen_address_type                   MemoryAddress;
7323};
7324
7325static inline __attribute__((always_inline)) void
7326GFX8_MI_LOAD_REGISTER_MEM_pack(__attribute__((unused)) __gen_user_data *data,
7327                               __attribute__((unused)) void * restrict dst,
7328                               __attribute__((unused)) const struct GFX8_MI_LOAD_REGISTER_MEM * restrict values)
7329{
7330   uint32_t * restrict dw = (uint32_t * restrict) dst;
7331
7332   dw[0] =
7333      __gen_uint(values->DWordLength, 0, 7) |
7334      __gen_uint(values->AsyncModeEnable, 21, 21) |
7335      __gen_uint(values->UseGlobalGTT, 22, 22) |
7336      __gen_uint(values->MICommandOpcode, 23, 28) |
7337      __gen_uint(values->CommandType, 29, 31);
7338
7339   dw[1] =
7340      __gen_offset(values->RegisterAddress, 2, 22);
7341
7342   const uint64_t v2_address =
7343      __gen_address(data, &dw[2], values->MemoryAddress, 0, 2, 63);
7344   dw[2] = v2_address;
7345   dw[3] = v2_address >> 32;
7346}
7347
7348#define GFX8_MI_LOAD_REGISTER_REG_length       3
7349#define GFX8_MI_LOAD_REGISTER_REG_length_bias      2
7350#define GFX8_MI_LOAD_REGISTER_REG_header        \
7351   .DWordLength                         =      1,  \
7352   .MICommandOpcode                     =     42,  \
7353   .CommandType                         =      0
7354
7355struct GFX8_MI_LOAD_REGISTER_REG {
7356   uint32_t                             DWordLength;
7357   uint32_t                             MICommandOpcode;
7358   uint32_t                             CommandType;
7359   uint64_t                             SourceRegisterAddress;
7360   uint64_t                             DestinationRegisterAddress;
7361};
7362
7363static inline __attribute__((always_inline)) void
7364GFX8_MI_LOAD_REGISTER_REG_pack(__attribute__((unused)) __gen_user_data *data,
7365                               __attribute__((unused)) void * restrict dst,
7366                               __attribute__((unused)) const struct GFX8_MI_LOAD_REGISTER_REG * restrict values)
7367{
7368   uint32_t * restrict dw = (uint32_t * restrict) dst;
7369
7370   dw[0] =
7371      __gen_uint(values->DWordLength, 0, 7) |
7372      __gen_uint(values->MICommandOpcode, 23, 28) |
7373      __gen_uint(values->CommandType, 29, 31);
7374
7375   dw[1] =
7376      __gen_offset(values->SourceRegisterAddress, 2, 22);
7377
7378   dw[2] =
7379      __gen_offset(values->DestinationRegisterAddress, 2, 22);
7380}
7381
7382#define GFX8_MI_LOAD_SCAN_LINES_EXCL_length      2
7383#define GFX8_MI_LOAD_SCAN_LINES_EXCL_length_bias      2
7384#define GFX8_MI_LOAD_SCAN_LINES_EXCL_header     \
7385   .DWordLength                         =      0,  \
7386   .MICommandOpcode                     =     19,  \
7387   .CommandType                         =      0
7388
7389struct GFX8_MI_LOAD_SCAN_LINES_EXCL {
7390   uint32_t                             DWordLength;
7391   uint32_t                             DisplayPlaneSelect;
7392#define DisplayPlaneA                            0
7393#define DisplayPlaneB                            1
7394#define DisplayPlaneC                            4
7395   uint32_t                             MICommandOpcode;
7396   uint32_t                             CommandType;
7397   uint32_t                             EndScanLineNumber;
7398   uint32_t                             StartScanLineNumber;
7399};
7400
7401static inline __attribute__((always_inline)) void
7402GFX8_MI_LOAD_SCAN_LINES_EXCL_pack(__attribute__((unused)) __gen_user_data *data,
7403                                  __attribute__((unused)) void * restrict dst,
7404                                  __attribute__((unused)) const struct GFX8_MI_LOAD_SCAN_LINES_EXCL * restrict values)
7405{
7406   uint32_t * restrict dw = (uint32_t * restrict) dst;
7407
7408   dw[0] =
7409      __gen_uint(values->DWordLength, 0, 5) |
7410      __gen_uint(values->DisplayPlaneSelect, 19, 21) |
7411      __gen_uint(values->MICommandOpcode, 23, 28) |
7412      __gen_uint(values->CommandType, 29, 31);
7413
7414   dw[1] =
7415      __gen_uint(values->EndScanLineNumber, 0, 12) |
7416      __gen_uint(values->StartScanLineNumber, 16, 28);
7417}
7418
7419#define GFX8_MI_LOAD_SCAN_LINES_INCL_length      2
7420#define GFX8_MI_LOAD_SCAN_LINES_INCL_length_bias      2
7421#define GFX8_MI_LOAD_SCAN_LINES_INCL_header     \
7422   .DWordLength                         =      0,  \
7423   .MICommandOpcode                     =     18,  \
7424   .CommandType                         =      0
7425
7426struct GFX8_MI_LOAD_SCAN_LINES_INCL {
7427   uint32_t                             DWordLength;
7428   uint32_t                             ScanLineEventDoneForward;
7429   uint32_t                             DisplayPlaneSelect;
7430#define DisplayPlaneA                            0
7431#define DisplayPlaneB                            1
7432#define DisplayPlaneC                            4
7433   uint32_t                             MICommandOpcode;
7434   uint32_t                             CommandType;
7435   uint32_t                             EndScanLineNumber;
7436   uint32_t                             StartScanLineNumber;
7437};
7438
7439static inline __attribute__((always_inline)) void
7440GFX8_MI_LOAD_SCAN_LINES_INCL_pack(__attribute__((unused)) __gen_user_data *data,
7441                                  __attribute__((unused)) void * restrict dst,
7442                                  __attribute__((unused)) const struct GFX8_MI_LOAD_SCAN_LINES_INCL * restrict values)
7443{
7444   uint32_t * restrict dw = (uint32_t * restrict) dst;
7445
7446   dw[0] =
7447      __gen_uint(values->DWordLength, 0, 5) |
7448      __gen_uint(values->ScanLineEventDoneForward, 17, 18) |
7449      __gen_uint(values->DisplayPlaneSelect, 19, 21) |
7450      __gen_uint(values->MICommandOpcode, 23, 28) |
7451      __gen_uint(values->CommandType, 29, 31);
7452
7453   dw[1] =
7454      __gen_uint(values->EndScanLineNumber, 0, 12) |
7455      __gen_uint(values->StartScanLineNumber, 16, 28);
7456}
7457
7458#define GFX8_MI_LOAD_URB_MEM_length            4
7459#define GFX8_MI_LOAD_URB_MEM_length_bias       2
7460#define GFX8_MI_LOAD_URB_MEM_header             \
7461   .DWordLength                         =      2,  \
7462   .MICommandOpcode                     =     44,  \
7463   .CommandType                         =      0
7464
7465struct GFX8_MI_LOAD_URB_MEM {
7466   uint32_t                             DWordLength;
7467   uint32_t                             MICommandOpcode;
7468   uint32_t                             CommandType;
7469   uint32_t                             URBAddress;
7470   __gen_address_type                   MemoryAddress;
7471};
7472
7473static inline __attribute__((always_inline)) void
7474GFX8_MI_LOAD_URB_MEM_pack(__attribute__((unused)) __gen_user_data *data,
7475                          __attribute__((unused)) void * restrict dst,
7476                          __attribute__((unused)) const struct GFX8_MI_LOAD_URB_MEM * restrict values)
7477{
7478   uint32_t * restrict dw = (uint32_t * restrict) dst;
7479
7480   dw[0] =
7481      __gen_uint(values->DWordLength, 0, 7) |
7482      __gen_uint(values->MICommandOpcode, 23, 28) |
7483      __gen_uint(values->CommandType, 29, 31);
7484
7485   dw[1] =
7486      __gen_uint(values->URBAddress, 2, 14);
7487
7488   const uint64_t v2_address =
7489      __gen_address(data, &dw[2], values->MemoryAddress, 0, 6, 63);
7490   dw[2] = v2_address;
7491   dw[3] = v2_address >> 32;
7492}
7493
7494#define GFX8_MI_MATH_length_bias               2
7495#define GFX8_MI_MATH_header                     \
7496   .DWordLength                         =      0,  \
7497   .MICommandOpcode                     =     26,  \
7498   .CommandType                         =      0
7499
7500struct GFX8_MI_MATH {
7501   uint32_t                             DWordLength;
7502   uint32_t                             MICommandOpcode;
7503   uint32_t                             CommandType;
7504   /* variable length fields follow */
7505};
7506
7507static inline __attribute__((always_inline)) void
7508GFX8_MI_MATH_pack(__attribute__((unused)) __gen_user_data *data,
7509                  __attribute__((unused)) void * restrict dst,
7510                  __attribute__((unused)) const struct GFX8_MI_MATH * restrict values)
7511{
7512   uint32_t * restrict dw = (uint32_t * restrict) dst;
7513
7514   dw[0] =
7515      __gen_uint(values->DWordLength, 0, 5) |
7516      __gen_uint(values->MICommandOpcode, 23, 28) |
7517      __gen_uint(values->CommandType, 29, 31);
7518}
7519
7520#define GFX8_MI_NOOP_length                    1
7521#define GFX8_MI_NOOP_length_bias               1
7522#define GFX8_MI_NOOP_header                     \
7523   .MICommandOpcode                     =      0,  \
7524   .CommandType                         =      0
7525
7526struct GFX8_MI_NOOP {
7527   uint32_t                             IdentificationNumber;
7528   bool                                 IdentificationNumberRegisterWriteEnable;
7529   uint32_t                             MICommandOpcode;
7530   uint32_t                             CommandType;
7531};
7532
7533static inline __attribute__((always_inline)) void
7534GFX8_MI_NOOP_pack(__attribute__((unused)) __gen_user_data *data,
7535                  __attribute__((unused)) void * restrict dst,
7536                  __attribute__((unused)) const struct GFX8_MI_NOOP * restrict values)
7537{
7538   uint32_t * restrict dw = (uint32_t * restrict) dst;
7539
7540   dw[0] =
7541      __gen_uint(values->IdentificationNumber, 0, 21) |
7542      __gen_uint(values->IdentificationNumberRegisterWriteEnable, 22, 22) |
7543      __gen_uint(values->MICommandOpcode, 23, 28) |
7544      __gen_uint(values->CommandType, 29, 31);
7545}
7546
7547#define GFX8_MI_PREDICATE_length               1
7548#define GFX8_MI_PREDICATE_length_bias          1
7549#define GFX8_MI_PREDICATE_header                \
7550   .MICommandOpcode                     =     12,  \
7551   .CommandType                         =      0
7552
7553struct GFX8_MI_PREDICATE {
7554   uint32_t                             CompareOperation;
7555#define COMPARE_TRUE                             0
7556#define COMPARE_FALSE                            1
7557#define COMPARE_SRCS_EQUAL                       2
7558#define COMPARE_DELTAS_EQUAL                     3
7559   uint32_t                             CombineOperation;
7560#define COMBINE_SET                              0
7561#define COMBINE_AND                              1
7562#define COMBINE_OR                               2
7563#define COMBINE_XOR                              3
7564   uint32_t                             LoadOperation;
7565#define LOAD_KEEP                                0
7566#define LOAD_LOAD                                2
7567#define LOAD_LOADINV                             3
7568   uint32_t                             MICommandOpcode;
7569   uint32_t                             CommandType;
7570};
7571
7572static inline __attribute__((always_inline)) void
7573GFX8_MI_PREDICATE_pack(__attribute__((unused)) __gen_user_data *data,
7574                       __attribute__((unused)) void * restrict dst,
7575                       __attribute__((unused)) const struct GFX8_MI_PREDICATE * restrict values)
7576{
7577   uint32_t * restrict dw = (uint32_t * restrict) dst;
7578
7579   dw[0] =
7580      __gen_uint(values->CompareOperation, 0, 1) |
7581      __gen_uint(values->CombineOperation, 3, 4) |
7582      __gen_uint(values->LoadOperation, 6, 7) |
7583      __gen_uint(values->MICommandOpcode, 23, 28) |
7584      __gen_uint(values->CommandType, 29, 31);
7585}
7586
7587#define GFX8_MI_REPORT_HEAD_length             1
7588#define GFX8_MI_REPORT_HEAD_length_bias        1
7589#define GFX8_MI_REPORT_HEAD_header              \
7590   .MICommandOpcode                     =      7,  \
7591   .CommandType                         =      0
7592
7593struct GFX8_MI_REPORT_HEAD {
7594   uint32_t                             MICommandOpcode;
7595   uint32_t                             CommandType;
7596};
7597
7598static inline __attribute__((always_inline)) void
7599GFX8_MI_REPORT_HEAD_pack(__attribute__((unused)) __gen_user_data *data,
7600                         __attribute__((unused)) void * restrict dst,
7601                         __attribute__((unused)) const struct GFX8_MI_REPORT_HEAD * restrict values)
7602{
7603   uint32_t * restrict dw = (uint32_t * restrict) dst;
7604
7605   dw[0] =
7606      __gen_uint(values->MICommandOpcode, 23, 28) |
7607      __gen_uint(values->CommandType, 29, 31);
7608}
7609
7610#define GFX8_MI_REPORT_PERF_COUNT_length       4
7611#define GFX8_MI_REPORT_PERF_COUNT_length_bias      2
7612#define GFX8_MI_REPORT_PERF_COUNT_header        \
7613   .DWordLength                         =      2,  \
7614   .MICommandOpcode                     =     40,  \
7615   .CommandType                         =      0
7616
7617struct GFX8_MI_REPORT_PERF_COUNT {
7618   uint32_t                             DWordLength;
7619   uint32_t                             MICommandOpcode;
7620   uint32_t                             CommandType;
7621   bool                                 UseGlobalGTT;
7622   uint32_t                             CoreModeEnable;
7623   __gen_address_type                   MemoryAddress;
7624   uint32_t                             ReportID;
7625};
7626
7627static inline __attribute__((always_inline)) void
7628GFX8_MI_REPORT_PERF_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
7629                               __attribute__((unused)) void * restrict dst,
7630                               __attribute__((unused)) const struct GFX8_MI_REPORT_PERF_COUNT * restrict values)
7631{
7632   uint32_t * restrict dw = (uint32_t * restrict) dst;
7633
7634   dw[0] =
7635      __gen_uint(values->DWordLength, 0, 5) |
7636      __gen_uint(values->MICommandOpcode, 23, 28) |
7637      __gen_uint(values->CommandType, 29, 31);
7638
7639   const uint64_t v1 =
7640      __gen_uint(values->UseGlobalGTT, 0, 0) |
7641      __gen_uint(values->CoreModeEnable, 4, 4);
7642   const uint64_t v1_address =
7643      __gen_address(data, &dw[1], values->MemoryAddress, v1, 6, 63);
7644   dw[1] = v1_address;
7645   dw[2] = (v1_address >> 32) | (v1 >> 32);
7646
7647   dw[3] =
7648      __gen_uint(values->ReportID, 0, 31);
7649}
7650
7651#define GFX8_MI_RS_CONTEXT_length              1
7652#define GFX8_MI_RS_CONTEXT_length_bias         1
7653#define GFX8_MI_RS_CONTEXT_header               \
7654   .MICommandOpcode                     =     15,  \
7655   .CommandType                         =      0
7656
7657struct GFX8_MI_RS_CONTEXT {
7658   uint32_t                             ResourceStreamerSave;
7659#define RS_Restore                               0
7660#define RS_Save                                  1
7661   uint32_t                             MICommandOpcode;
7662   uint32_t                             CommandType;
7663};
7664
7665static inline __attribute__((always_inline)) void
7666GFX8_MI_RS_CONTEXT_pack(__attribute__((unused)) __gen_user_data *data,
7667                        __attribute__((unused)) void * restrict dst,
7668                        __attribute__((unused)) const struct GFX8_MI_RS_CONTEXT * restrict values)
7669{
7670   uint32_t * restrict dw = (uint32_t * restrict) dst;
7671
7672   dw[0] =
7673      __gen_uint(values->ResourceStreamerSave, 0, 0) |
7674      __gen_uint(values->MICommandOpcode, 23, 28) |
7675      __gen_uint(values->CommandType, 29, 31);
7676}
7677
7678#define GFX8_MI_RS_CONTROL_length              1
7679#define GFX8_MI_RS_CONTROL_length_bias         1
7680#define GFX8_MI_RS_CONTROL_header               \
7681   .MICommandOpcode                     =      6,  \
7682   .CommandType                         =      0
7683
7684struct GFX8_MI_RS_CONTROL {
7685   uint32_t                             ResourceStreamerControl;
7686#define RS_Stop                                  0
7687#define RS_Start                                 1
7688   uint32_t                             MICommandOpcode;
7689   uint32_t                             CommandType;
7690};
7691
7692static inline __attribute__((always_inline)) void
7693GFX8_MI_RS_CONTROL_pack(__attribute__((unused)) __gen_user_data *data,
7694                        __attribute__((unused)) void * restrict dst,
7695                        __attribute__((unused)) const struct GFX8_MI_RS_CONTROL * restrict values)
7696{
7697   uint32_t * restrict dw = (uint32_t * restrict) dst;
7698
7699   dw[0] =
7700      __gen_uint(values->ResourceStreamerControl, 0, 0) |
7701      __gen_uint(values->MICommandOpcode, 23, 28) |
7702      __gen_uint(values->CommandType, 29, 31);
7703}
7704
7705#define GFX8_MI_RS_STORE_DATA_IMM_length       4
7706#define GFX8_MI_RS_STORE_DATA_IMM_length_bias      2
7707#define GFX8_MI_RS_STORE_DATA_IMM_header        \
7708   .DWordLength                         =      2,  \
7709   .MICommandOpcode                     =     43,  \
7710   .CommandType                         =      0
7711
7712struct GFX8_MI_RS_STORE_DATA_IMM {
7713   uint32_t                             DWordLength;
7714   uint32_t                             MICommandOpcode;
7715   uint32_t                             CommandType;
7716   uint32_t                             CoreModeEnable;
7717   __gen_address_type                   DestinationAddress;
7718   uint32_t                             DataDWord0;
7719};
7720
7721static inline __attribute__((always_inline)) void
7722GFX8_MI_RS_STORE_DATA_IMM_pack(__attribute__((unused)) __gen_user_data *data,
7723                               __attribute__((unused)) void * restrict dst,
7724                               __attribute__((unused)) const struct GFX8_MI_RS_STORE_DATA_IMM * restrict values)
7725{
7726   uint32_t * restrict dw = (uint32_t * restrict) dst;
7727
7728   dw[0] =
7729      __gen_uint(values->DWordLength, 0, 7) |
7730      __gen_uint(values->MICommandOpcode, 23, 28) |
7731      __gen_uint(values->CommandType, 29, 31);
7732
7733   const uint64_t v1 =
7734      __gen_uint(values->CoreModeEnable, 0, 0);
7735   const uint64_t v1_address =
7736      __gen_address(data, &dw[1], values->DestinationAddress, v1, 2, 63);
7737   dw[1] = v1_address;
7738   dw[2] = (v1_address >> 32) | (v1 >> 32);
7739
7740   dw[3] =
7741      __gen_uint(values->DataDWord0, 0, 31);
7742}
7743
7744#define GFX8_MI_SEMAPHORE_SIGNAL_length        2
7745#define GFX8_MI_SEMAPHORE_SIGNAL_length_bias      2
7746#define GFX8_MI_SEMAPHORE_SIGNAL_header         \
7747   .DWordLength                         =      0,  \
7748   .MICommandOpcode                     =     27,  \
7749   .CommandType                         =      0
7750
7751struct GFX8_MI_SEMAPHORE_SIGNAL {
7752   uint32_t                             DWordLength;
7753   uint32_t                             TargetEngineSelect;
7754#define RCS                                      0
7755#define VCS0                                     1
7756#define BCS                                      2
7757#define VECS                                     3
7758#define VCS1                                     4
7759   bool                                 PostSyncOperation;
7760   uint32_t                             MICommandOpcode;
7761   uint32_t                             CommandType;
7762   uint32_t                             TargetContextID;
7763};
7764
7765static inline __attribute__((always_inline)) void
7766GFX8_MI_SEMAPHORE_SIGNAL_pack(__attribute__((unused)) __gen_user_data *data,
7767                              __attribute__((unused)) void * restrict dst,
7768                              __attribute__((unused)) const struct GFX8_MI_SEMAPHORE_SIGNAL * restrict values)
7769{
7770   uint32_t * restrict dw = (uint32_t * restrict) dst;
7771
7772   dw[0] =
7773      __gen_uint(values->DWordLength, 0, 7) |
7774      __gen_uint(values->TargetEngineSelect, 15, 17) |
7775      __gen_uint(values->PostSyncOperation, 21, 21) |
7776      __gen_uint(values->MICommandOpcode, 23, 28) |
7777      __gen_uint(values->CommandType, 29, 31);
7778
7779   dw[1] =
7780      __gen_uint(values->TargetContextID, 0, 31);
7781}
7782
7783#define GFX8_MI_SEMAPHORE_WAIT_length          4
7784#define GFX8_MI_SEMAPHORE_WAIT_length_bias      2
7785#define GFX8_MI_SEMAPHORE_WAIT_header           \
7786   .DWordLength                         =      2,  \
7787   .MICommandOpcode                     =     28,  \
7788   .CommandType                         =      0
7789
7790struct GFX8_MI_SEMAPHORE_WAIT {
7791   uint32_t                             DWordLength;
7792   uint32_t                             CompareOperation;
7793#define COMPARE_SAD_GREATER_THAN_SDD             0
7794#define COMPARE_SAD_GREATER_THAN_OR_EQUAL_SDD    1
7795#define COMPARE_SAD_LESS_THAN_SDD                2
7796#define COMPARE_SAD_LESS_THAN_OR_EQUAL_SDD       3
7797#define COMPARE_SAD_EQUAL_SDD                    4
7798#define COMPARE_SAD_NOT_EQUAL_SDD                5
7799   uint32_t                             WaitMode;
7800#define PollingMode                              1
7801#define SignalMode                               0
7802   uint32_t                             MemoryType;
7803#define PerProcessGraphicsAddress                0
7804#define GlobalGraphicsAddress                    1
7805   uint32_t                             MICommandOpcode;
7806   uint32_t                             CommandType;
7807   uint32_t                             SemaphoreDataDword;
7808   __gen_address_type                   SemaphoreAddress;
7809   __gen_address_type                   SemaphoreAddressHigh;
7810};
7811
7812static inline __attribute__((always_inline)) void
7813GFX8_MI_SEMAPHORE_WAIT_pack(__attribute__((unused)) __gen_user_data *data,
7814                            __attribute__((unused)) void * restrict dst,
7815                            __attribute__((unused)) const struct GFX8_MI_SEMAPHORE_WAIT * restrict values)
7816{
7817   uint32_t * restrict dw = (uint32_t * restrict) dst;
7818
7819   dw[0] =
7820      __gen_uint(values->DWordLength, 0, 7) |
7821      __gen_uint(values->CompareOperation, 12, 14) |
7822      __gen_uint(values->WaitMode, 15, 15) |
7823      __gen_uint(values->MemoryType, 22, 22) |
7824      __gen_uint(values->MICommandOpcode, 23, 28) |
7825      __gen_uint(values->CommandType, 29, 31);
7826
7827   dw[1] =
7828      __gen_uint(values->SemaphoreDataDword, 0, 31);
7829
7830   dw[2] = __gen_address(data, &dw[2], values->SemaphoreAddress, 0, 2, 31);
7831
7832   dw[3] = __gen_address(data, &dw[3], values->SemaphoreAddressHigh, 0, 0, 15);
7833}
7834
7835#define GFX8_MI_SET_CONTEXT_length             2
7836#define GFX8_MI_SET_CONTEXT_length_bias        2
7837#define GFX8_MI_SET_CONTEXT_header              \
7838   .DWordLength                         =      0,  \
7839   .MICommandOpcode                     =     24,  \
7840   .CommandType                         =      0
7841
7842struct GFX8_MI_SET_CONTEXT {
7843   uint32_t                             DWordLength;
7844   uint32_t                             MICommandOpcode;
7845   uint32_t                             CommandType;
7846   uint32_t                             RestoreInhibit;
7847   uint32_t                             ForceRestore;
7848   bool                                 ResourceStreamerStateRestoreEnable;
7849   bool                                 ResourceStreamerStateSaveEnable;
7850   bool                                 CoreModeEnable;
7851   uint32_t                             ReservedMustbe1;
7852   __gen_address_type                   LogicalContextAddress;
7853};
7854
7855static inline __attribute__((always_inline)) void
7856GFX8_MI_SET_CONTEXT_pack(__attribute__((unused)) __gen_user_data *data,
7857                         __attribute__((unused)) void * restrict dst,
7858                         __attribute__((unused)) const struct GFX8_MI_SET_CONTEXT * restrict values)
7859{
7860   uint32_t * restrict dw = (uint32_t * restrict) dst;
7861
7862   dw[0] =
7863      __gen_uint(values->DWordLength, 0, 7) |
7864      __gen_uint(values->MICommandOpcode, 23, 28) |
7865      __gen_uint(values->CommandType, 29, 31);
7866
7867   const uint32_t v1 =
7868      __gen_uint(values->RestoreInhibit, 0, 0) |
7869      __gen_uint(values->ForceRestore, 1, 1) |
7870      __gen_uint(values->ResourceStreamerStateRestoreEnable, 2, 2) |
7871      __gen_uint(values->ResourceStreamerStateSaveEnable, 3, 3) |
7872      __gen_uint(values->CoreModeEnable, 4, 4) |
7873      __gen_uint(values->ReservedMustbe1, 8, 8);
7874   dw[1] = __gen_address(data, &dw[1], values->LogicalContextAddress, v1, 12, 31);
7875}
7876
7877#define GFX8_MI_SET_PREDICATE_length           1
7878#define GFX8_MI_SET_PREDICATE_length_bias      1
7879#define GFX8_MI_SET_PREDICATE_header            \
7880   .MICommandOpcode                     =      1,  \
7881   .CommandType                         =      0
7882
7883struct GFX8_MI_SET_PREDICATE {
7884   uint32_t                             PREDICATEENABLE;
7885#define NOOPNever                                0
7886#define NOOPonResult2clear                       1
7887#define NOOPonResult2set                         2
7888#define NOOPonResultclear                        3
7889#define NOOPonResultset                          4
7890#define Executewhenonesliceenabled               5
7891#define Executewhentwoslicesareenabled           6
7892#define Executewhenthreeslicesareenabled         7
7893#define NOOPAlways                               15
7894   uint32_t                             MICommandOpcode;
7895   uint32_t                             CommandType;
7896};
7897
7898static inline __attribute__((always_inline)) void
7899GFX8_MI_SET_PREDICATE_pack(__attribute__((unused)) __gen_user_data *data,
7900                           __attribute__((unused)) void * restrict dst,
7901                           __attribute__((unused)) const struct GFX8_MI_SET_PREDICATE * restrict values)
7902{
7903   uint32_t * restrict dw = (uint32_t * restrict) dst;
7904
7905   dw[0] =
7906      __gen_uint(values->PREDICATEENABLE, 0, 3) |
7907      __gen_uint(values->MICommandOpcode, 23, 28) |
7908      __gen_uint(values->CommandType, 29, 31);
7909}
7910
7911#define GFX8_MI_STORE_DATA_IMM_length          4
7912#define GFX8_MI_STORE_DATA_IMM_length_bias      2
7913#define GFX8_MI_STORE_DATA_IMM_header           \
7914   .DWordLength                         =      2,  \
7915   .MICommandOpcode                     =     32,  \
7916   .CommandType                         =      0
7917
7918struct GFX8_MI_STORE_DATA_IMM {
7919   uint32_t                             DWordLength;
7920   uint32_t                             StoreQword;
7921   bool                                 UseGlobalGTT;
7922   uint32_t                             MICommandOpcode;
7923   uint32_t                             CommandType;
7924   uint32_t                             CoreModeEnable;
7925   __gen_address_type                   Address;
7926   uint64_t                             ImmediateData;
7927};
7928
7929static inline __attribute__((always_inline)) void
7930GFX8_MI_STORE_DATA_IMM_pack(__attribute__((unused)) __gen_user_data *data,
7931                            __attribute__((unused)) void * restrict dst,
7932                            __attribute__((unused)) const struct GFX8_MI_STORE_DATA_IMM * restrict values)
7933{
7934   uint32_t * restrict dw = (uint32_t * restrict) dst;
7935
7936   dw[0] =
7937      __gen_uint(values->DWordLength, 0, 9) |
7938      __gen_uint(values->StoreQword, 21, 21) |
7939      __gen_uint(values->UseGlobalGTT, 22, 22) |
7940      __gen_uint(values->MICommandOpcode, 23, 28) |
7941      __gen_uint(values->CommandType, 29, 31);
7942
7943   const uint64_t v1 =
7944      __gen_uint(values->CoreModeEnable, 0, 0);
7945   const uint64_t v1_address =
7946      __gen_address(data, &dw[1], values->Address, v1, 2, 47);
7947   dw[1] = v1_address;
7948   dw[2] = (v1_address >> 32) | (v1 >> 32);
7949
7950   const uint64_t v3 =
7951      __gen_uint(values->ImmediateData, 0, 63);
7952   dw[3] = v3;
7953   dw[4] = v3 >> 32;
7954}
7955
7956#define GFX8_MI_STORE_DATA_INDEX_length        3
7957#define GFX8_MI_STORE_DATA_INDEX_length_bias      2
7958#define GFX8_MI_STORE_DATA_INDEX_header         \
7959   .DWordLength                         =      1,  \
7960   .MICommandOpcode                     =     33,  \
7961   .CommandType                         =      0
7962
7963struct GFX8_MI_STORE_DATA_INDEX {
7964   uint32_t                             DWordLength;
7965   uint32_t                             UsePerProcessHardwareStatusPage;
7966   uint32_t                             MICommandOpcode;
7967   uint32_t                             CommandType;
7968   uint32_t                             Offset;
7969   uint32_t                             DataDWord0;
7970   uint32_t                             DataDWord1;
7971};
7972
7973static inline __attribute__((always_inline)) void
7974GFX8_MI_STORE_DATA_INDEX_pack(__attribute__((unused)) __gen_user_data *data,
7975                              __attribute__((unused)) void * restrict dst,
7976                              __attribute__((unused)) const struct GFX8_MI_STORE_DATA_INDEX * restrict values)
7977{
7978   uint32_t * restrict dw = (uint32_t * restrict) dst;
7979
7980   dw[0] =
7981      __gen_uint(values->DWordLength, 0, 7) |
7982      __gen_uint(values->UsePerProcessHardwareStatusPage, 21, 21) |
7983      __gen_uint(values->MICommandOpcode, 23, 28) |
7984      __gen_uint(values->CommandType, 29, 31);
7985
7986   dw[1] =
7987      __gen_uint(values->Offset, 2, 11);
7988
7989   dw[2] =
7990      __gen_uint(values->DataDWord0, 0, 31);
7991}
7992
7993#define GFX8_MI_STORE_REGISTER_MEM_length      4
7994#define GFX8_MI_STORE_REGISTER_MEM_length_bias      2
7995#define GFX8_MI_STORE_REGISTER_MEM_header       \
7996   .DWordLength                         =      2,  \
7997   .MICommandOpcode                     =     36,  \
7998   .CommandType                         =      0
7999
8000struct GFX8_MI_STORE_REGISTER_MEM {
8001   uint32_t                             DWordLength;
8002   bool                                 PredicateEnable;
8003   bool                                 UseGlobalGTT;
8004   uint32_t                             MICommandOpcode;
8005   uint32_t                             CommandType;
8006   uint64_t                             RegisterAddress;
8007   __gen_address_type                   MemoryAddress;
8008};
8009
8010static inline __attribute__((always_inline)) void
8011GFX8_MI_STORE_REGISTER_MEM_pack(__attribute__((unused)) __gen_user_data *data,
8012                                __attribute__((unused)) void * restrict dst,
8013                                __attribute__((unused)) const struct GFX8_MI_STORE_REGISTER_MEM * restrict values)
8014{
8015   uint32_t * restrict dw = (uint32_t * restrict) dst;
8016
8017   dw[0] =
8018      __gen_uint(values->DWordLength, 0, 7) |
8019      __gen_uint(values->PredicateEnable, 21, 21) |
8020      __gen_uint(values->UseGlobalGTT, 22, 22) |
8021      __gen_uint(values->MICommandOpcode, 23, 28) |
8022      __gen_uint(values->CommandType, 29, 31);
8023
8024   dw[1] =
8025      __gen_offset(values->RegisterAddress, 2, 22);
8026
8027   const uint64_t v2_address =
8028      __gen_address(data, &dw[2], values->MemoryAddress, 0, 2, 63);
8029   dw[2] = v2_address;
8030   dw[3] = v2_address >> 32;
8031}
8032
8033#define GFX8_MI_STORE_URB_MEM_length           4
8034#define GFX8_MI_STORE_URB_MEM_length_bias      2
8035#define GFX8_MI_STORE_URB_MEM_header            \
8036   .DWordLength                         =      2,  \
8037   .MICommandOpcode                     =     45,  \
8038   .CommandType                         =      0
8039
8040struct GFX8_MI_STORE_URB_MEM {
8041   uint32_t                             DWordLength;
8042   uint32_t                             MICommandOpcode;
8043   uint32_t                             CommandType;
8044   uint32_t                             URBAddress;
8045   __gen_address_type                   MemoryAddress;
8046};
8047
8048static inline __attribute__((always_inline)) void
8049GFX8_MI_STORE_URB_MEM_pack(__attribute__((unused)) __gen_user_data *data,
8050                           __attribute__((unused)) void * restrict dst,
8051                           __attribute__((unused)) const struct GFX8_MI_STORE_URB_MEM * restrict values)
8052{
8053   uint32_t * restrict dw = (uint32_t * restrict) dst;
8054
8055   dw[0] =
8056      __gen_uint(values->DWordLength, 0, 7) |
8057      __gen_uint(values->MICommandOpcode, 23, 28) |
8058      __gen_uint(values->CommandType, 29, 31);
8059
8060   dw[1] =
8061      __gen_uint(values->URBAddress, 2, 14);
8062
8063   const uint64_t v2_address =
8064      __gen_address(data, &dw[2], values->MemoryAddress, 0, 6, 63);
8065   dw[2] = v2_address;
8066   dw[3] = v2_address >> 32;
8067}
8068
8069#define GFX8_MI_SUSPEND_FLUSH_length           1
8070#define GFX8_MI_SUSPEND_FLUSH_length_bias      1
8071#define GFX8_MI_SUSPEND_FLUSH_header            \
8072   .MICommandOpcode                     =     11,  \
8073   .CommandType                         =      0
8074
8075struct GFX8_MI_SUSPEND_FLUSH {
8076   bool                                 SuspendFlush;
8077   uint32_t                             MICommandOpcode;
8078   uint32_t                             CommandType;
8079};
8080
8081static inline __attribute__((always_inline)) void
8082GFX8_MI_SUSPEND_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
8083                           __attribute__((unused)) void * restrict dst,
8084                           __attribute__((unused)) const struct GFX8_MI_SUSPEND_FLUSH * restrict values)
8085{
8086   uint32_t * restrict dw = (uint32_t * restrict) dst;
8087
8088   dw[0] =
8089      __gen_uint(values->SuspendFlush, 0, 0) |
8090      __gen_uint(values->MICommandOpcode, 23, 28) |
8091      __gen_uint(values->CommandType, 29, 31);
8092}
8093
8094#define GFX8_MI_TOPOLOGY_FILTER_length         1
8095#define GFX8_MI_TOPOLOGY_FILTER_length_bias      1
8096#define GFX8_MI_TOPOLOGY_FILTER_header          \
8097   .MICommandOpcode                     =     13,  \
8098   .CommandType                         =      0
8099
8100struct GFX8_MI_TOPOLOGY_FILTER {
8101   enum GFX8_3D_Prim_Topo_Type          TopologyFilterValue;
8102   uint32_t                             MICommandOpcode;
8103   uint32_t                             CommandType;
8104};
8105
8106static inline __attribute__((always_inline)) void
8107GFX8_MI_TOPOLOGY_FILTER_pack(__attribute__((unused)) __gen_user_data *data,
8108                             __attribute__((unused)) void * restrict dst,
8109                             __attribute__((unused)) const struct GFX8_MI_TOPOLOGY_FILTER * restrict values)
8110{
8111   uint32_t * restrict dw = (uint32_t * restrict) dst;
8112
8113   dw[0] =
8114      __gen_uint(values->TopologyFilterValue, 0, 5) |
8115      __gen_uint(values->MICommandOpcode, 23, 28) |
8116      __gen_uint(values->CommandType, 29, 31);
8117}
8118
8119#define GFX8_MI_URB_ATOMIC_ALLOC_length        1
8120#define GFX8_MI_URB_ATOMIC_ALLOC_length_bias      1
8121#define GFX8_MI_URB_ATOMIC_ALLOC_header         \
8122   .MICommandOpcode                     =      9,  \
8123   .CommandType                         =      0
8124
8125struct GFX8_MI_URB_ATOMIC_ALLOC {
8126   uint32_t                             URBAtomicStorageSize;
8127   uint32_t                             URBAtomicStorageOffset;
8128   uint32_t                             MICommandOpcode;
8129   uint32_t                             CommandType;
8130};
8131
8132static inline __attribute__((always_inline)) void
8133GFX8_MI_URB_ATOMIC_ALLOC_pack(__attribute__((unused)) __gen_user_data *data,
8134                              __attribute__((unused)) void * restrict dst,
8135                              __attribute__((unused)) const struct GFX8_MI_URB_ATOMIC_ALLOC * restrict values)
8136{
8137   uint32_t * restrict dw = (uint32_t * restrict) dst;
8138
8139   dw[0] =
8140      __gen_uint(values->URBAtomicStorageSize, 0, 8) |
8141      __gen_uint(values->URBAtomicStorageOffset, 12, 19) |
8142      __gen_uint(values->MICommandOpcode, 23, 28) |
8143      __gen_uint(values->CommandType, 29, 31);
8144}
8145
8146#define GFX8_MI_URB_CLEAR_length               2
8147#define GFX8_MI_URB_CLEAR_length_bias          2
8148#define GFX8_MI_URB_CLEAR_header                \
8149   .DWordLength                         =      0,  \
8150   .MICommandOpcode                     =     25,  \
8151   .CommandType                         =      0
8152
8153struct GFX8_MI_URB_CLEAR {
8154   uint32_t                             DWordLength;
8155   uint32_t                             MICommandOpcode;
8156   uint32_t                             CommandType;
8157   uint64_t                             URBAddress;
8158   uint32_t                             URBClearLength;
8159};
8160
8161static inline __attribute__((always_inline)) void
8162GFX8_MI_URB_CLEAR_pack(__attribute__((unused)) __gen_user_data *data,
8163                       __attribute__((unused)) void * restrict dst,
8164                       __attribute__((unused)) const struct GFX8_MI_URB_CLEAR * restrict values)
8165{
8166   uint32_t * restrict dw = (uint32_t * restrict) dst;
8167
8168   dw[0] =
8169      __gen_uint(values->DWordLength, 0, 7) |
8170      __gen_uint(values->MICommandOpcode, 23, 28) |
8171      __gen_uint(values->CommandType, 29, 31);
8172
8173   dw[1] =
8174      __gen_offset(values->URBAddress, 0, 14) |
8175      __gen_uint(values->URBClearLength, 16, 29);
8176}
8177
8178#define GFX8_MI_USER_INTERRUPT_length          1
8179#define GFX8_MI_USER_INTERRUPT_length_bias      1
8180#define GFX8_MI_USER_INTERRUPT_header           \
8181   .MICommandOpcode                     =      2,  \
8182   .CommandType                         =      0
8183
8184struct GFX8_MI_USER_INTERRUPT {
8185   uint32_t                             MICommandOpcode;
8186   uint32_t                             CommandType;
8187};
8188
8189static inline __attribute__((always_inline)) void
8190GFX8_MI_USER_INTERRUPT_pack(__attribute__((unused)) __gen_user_data *data,
8191                            __attribute__((unused)) void * restrict dst,
8192                            __attribute__((unused)) const struct GFX8_MI_USER_INTERRUPT * restrict values)
8193{
8194   uint32_t * restrict dw = (uint32_t * restrict) dst;
8195
8196   dw[0] =
8197      __gen_uint(values->MICommandOpcode, 23, 28) |
8198      __gen_uint(values->CommandType, 29, 31);
8199}
8200
8201#define GFX8_MI_WAIT_FOR_EVENT_length          1
8202#define GFX8_MI_WAIT_FOR_EVENT_length_bias      1
8203#define GFX8_MI_WAIT_FOR_EVENT_header           \
8204   .MICommandOpcode                     =      3,  \
8205   .CommandType                         =      0
8206
8207struct GFX8_MI_WAIT_FOR_EVENT {
8208   bool                                 DisplayPipeAScanLineWaitEnable;
8209   bool                                 DisplayPlaneAFlipPendingWaitEnable;
8210   bool                                 DisplaySpriteAFlipPendingWaitEnable;
8211   bool                                 DisplayPipeAVerticalBlankWaitEnable;
8212   bool                                 DisplayPipeBScanLineWaitEnable;
8213   bool                                 DisplayPlaneBFlipPendingWaitEnable;
8214   bool                                 DisplaySpriteBFlipPendingWaitEnable;
8215   bool                                 DisplayPipeBVerticalBlankWaitEnable;
8216   bool                                 DisplayPipeCScanLineWaitEnable;
8217   bool                                 DisplayPlaneCFlipPendingWaitEnable;
8218   bool                                 DisplaySpriteCFlipPendingWaitEnable;
8219   bool                                 DisplayPipeCVerticalBlankWaitEnable;
8220   uint32_t                             MICommandOpcode;
8221   uint32_t                             CommandType;
8222};
8223
8224static inline __attribute__((always_inline)) void
8225GFX8_MI_WAIT_FOR_EVENT_pack(__attribute__((unused)) __gen_user_data *data,
8226                            __attribute__((unused)) void * restrict dst,
8227                            __attribute__((unused)) const struct GFX8_MI_WAIT_FOR_EVENT * restrict values)
8228{
8229   uint32_t * restrict dw = (uint32_t * restrict) dst;
8230
8231   dw[0] =
8232      __gen_uint(values->DisplayPipeAScanLineWaitEnable, 0, 0) |
8233      __gen_uint(values->DisplayPlaneAFlipPendingWaitEnable, 1, 1) |
8234      __gen_uint(values->DisplaySpriteAFlipPendingWaitEnable, 2, 2) |
8235      __gen_uint(values->DisplayPipeAVerticalBlankWaitEnable, 3, 3) |
8236      __gen_uint(values->DisplayPipeBScanLineWaitEnable, 8, 8) |
8237      __gen_uint(values->DisplayPlaneBFlipPendingWaitEnable, 9, 9) |
8238      __gen_uint(values->DisplaySpriteBFlipPendingWaitEnable, 10, 10) |
8239      __gen_uint(values->DisplayPipeBVerticalBlankWaitEnable, 11, 11) |
8240      __gen_uint(values->DisplayPipeCScanLineWaitEnable, 14, 14) |
8241      __gen_uint(values->DisplayPlaneCFlipPendingWaitEnable, 15, 15) |
8242      __gen_uint(values->DisplaySpriteCFlipPendingWaitEnable, 20, 20) |
8243      __gen_uint(values->DisplayPipeCVerticalBlankWaitEnable, 21, 21) |
8244      __gen_uint(values->MICommandOpcode, 23, 28) |
8245      __gen_uint(values->CommandType, 29, 31);
8246}
8247
8248#define GFX8_PIPELINE_SELECT_length            1
8249#define GFX8_PIPELINE_SELECT_length_bias       1
8250#define GFX8_PIPELINE_SELECT_header             \
8251   ._3DCommandSubOpcode                 =      4,  \
8252   ._3DCommandOpcode                    =      1,  \
8253   .CommandSubType                      =      1,  \
8254   .CommandType                         =      3
8255
8256struct GFX8_PIPELINE_SELECT {
8257   uint32_t                             PipelineSelection;
8258#define _3D                                      0
8259#define Media                                    1
8260#define GPGPU                                    2
8261   uint32_t                             _3DCommandSubOpcode;
8262   uint32_t                             _3DCommandOpcode;
8263   uint32_t                             CommandSubType;
8264   uint32_t                             CommandType;
8265};
8266
8267static inline __attribute__((always_inline)) void
8268GFX8_PIPELINE_SELECT_pack(__attribute__((unused)) __gen_user_data *data,
8269                          __attribute__((unused)) void * restrict dst,
8270                          __attribute__((unused)) const struct GFX8_PIPELINE_SELECT * restrict values)
8271{
8272   uint32_t * restrict dw = (uint32_t * restrict) dst;
8273
8274   dw[0] =
8275      __gen_uint(values->PipelineSelection, 0, 1) |
8276      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
8277      __gen_uint(values->_3DCommandOpcode, 24, 26) |
8278      __gen_uint(values->CommandSubType, 27, 28) |
8279      __gen_uint(values->CommandType, 29, 31);
8280}
8281
8282#define GFX8_PIPE_CONTROL_length               6
8283#define GFX8_PIPE_CONTROL_length_bias          2
8284#define GFX8_PIPE_CONTROL_header                \
8285   .DWordLength                         =      4,  \
8286   ._3DCommandSubOpcode                 =      0,  \
8287   ._3DCommandOpcode                    =      2,  \
8288   .CommandSubType                      =      3,  \
8289   .CommandType                         =      3
8290
8291struct GFX8_PIPE_CONTROL {
8292   uint32_t                             DWordLength;
8293   uint32_t                             _3DCommandSubOpcode;
8294   uint32_t                             _3DCommandOpcode;
8295   uint32_t                             CommandSubType;
8296   uint32_t                             CommandType;
8297   bool                                 DepthCacheFlushEnable;
8298   bool                                 StallAtPixelScoreboard;
8299   bool                                 StateCacheInvalidationEnable;
8300   bool                                 ConstantCacheInvalidationEnable;
8301   bool                                 VFCacheInvalidationEnable;
8302   bool                                 DCFlushEnable;
8303   bool                                 PipeControlFlushEnable;
8304   bool                                 NotifyEnable;
8305   bool                                 IndirectStatePointersDisable;
8306   bool                                 TextureCacheInvalidationEnable;
8307   bool                                 InstructionCacheInvalidateEnable;
8308   bool                                 RenderTargetCacheFlushEnable;
8309   bool                                 DepthStallEnable;
8310   uint32_t                             PostSyncOperation;
8311#define NoWrite                                  0
8312#define WriteImmediateData                       1
8313#define WritePSDepthCount                        2
8314#define WriteTimestamp                           3
8315   bool                                 GenericMediaStateClear;
8316   bool                                 TLBInvalidate;
8317   bool                                 GlobalSnapshotCountReset;
8318   bool                                 CommandStreamerStallEnable;
8319   uint32_t                             StoreDataIndex;
8320   uint32_t                             LRIPostSyncOperation;
8321#define NoLRIOperation                           0
8322#define MMIOWriteImmediateData                   1
8323   uint32_t                             DestinationAddressType;
8324#define DAT_PPGTT                                0
8325#define DAT_GGTT                                 1
8326   __gen_address_type                   Address;
8327   uint64_t                             ImmediateData;
8328};
8329
8330static inline __attribute__((always_inline)) void
8331GFX8_PIPE_CONTROL_pack(__attribute__((unused)) __gen_user_data *data,
8332                       __attribute__((unused)) void * restrict dst,
8333                       __attribute__((unused)) const struct GFX8_PIPE_CONTROL * restrict values)
8334{
8335   uint32_t * restrict dw = (uint32_t * restrict) dst;
8336
8337   dw[0] =
8338      __gen_uint(values->DWordLength, 0, 7) |
8339      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
8340      __gen_uint(values->_3DCommandOpcode, 24, 26) |
8341      __gen_uint(values->CommandSubType, 27, 28) |
8342      __gen_uint(values->CommandType, 29, 31);
8343
8344   dw[1] =
8345      __gen_uint(values->DepthCacheFlushEnable, 0, 0) |
8346      __gen_uint(values->StallAtPixelScoreboard, 1, 1) |
8347      __gen_uint(values->StateCacheInvalidationEnable, 2, 2) |
8348      __gen_uint(values->ConstantCacheInvalidationEnable, 3, 3) |
8349      __gen_uint(values->VFCacheInvalidationEnable, 4, 4) |
8350      __gen_uint(values->DCFlushEnable, 5, 5) |
8351      __gen_uint(values->PipeControlFlushEnable, 7, 7) |
8352      __gen_uint(values->NotifyEnable, 8, 8) |
8353      __gen_uint(values->IndirectStatePointersDisable, 9, 9) |
8354      __gen_uint(values->TextureCacheInvalidationEnable, 10, 10) |
8355      __gen_uint(values->InstructionCacheInvalidateEnable, 11, 11) |
8356      __gen_uint(values->RenderTargetCacheFlushEnable, 12, 12) |
8357      __gen_uint(values->DepthStallEnable, 13, 13) |
8358      __gen_uint(values->PostSyncOperation, 14, 15) |
8359      __gen_uint(values->GenericMediaStateClear, 16, 16) |
8360      __gen_uint(values->TLBInvalidate, 18, 18) |
8361      __gen_uint(values->GlobalSnapshotCountReset, 19, 19) |
8362      __gen_uint(values->CommandStreamerStallEnable, 20, 20) |
8363      __gen_uint(values->StoreDataIndex, 21, 21) |
8364      __gen_uint(values->LRIPostSyncOperation, 23, 23) |
8365      __gen_uint(values->DestinationAddressType, 24, 24);
8366
8367   const uint64_t v2_address =
8368      __gen_address(data, &dw[2], values->Address, 0, 2, 47);
8369   dw[2] = v2_address;
8370   dw[3] = v2_address >> 32;
8371
8372   const uint64_t v4 =
8373      __gen_uint(values->ImmediateData, 0, 63);
8374   dw[4] = v4;
8375   dw[5] = v4 >> 32;
8376}
8377
8378#define GFX8_STATE_BASE_ADDRESS_length        16
8379#define GFX8_STATE_BASE_ADDRESS_length_bias      2
8380#define GFX8_STATE_BASE_ADDRESS_header          \
8381   .DWordLength                         =     14,  \
8382   ._3DCommandSubOpcode                 =      1,  \
8383   ._3DCommandOpcode                    =      1,  \
8384   .CommandSubType                      =      0,  \
8385   .CommandType                         =      3
8386
8387struct GFX8_STATE_BASE_ADDRESS {
8388   uint32_t                             DWordLength;
8389   uint32_t                             _3DCommandSubOpcode;
8390   uint32_t                             _3DCommandOpcode;
8391   uint32_t                             CommandSubType;
8392   uint32_t                             CommandType;
8393   bool                                 GeneralStateBaseAddressModifyEnable;
8394   uint32_t                             GeneralStateMOCS;
8395   __gen_address_type                   GeneralStateBaseAddress;
8396   uint32_t                             StatelessDataPortAccessMOCS;
8397   bool                                 SurfaceStateBaseAddressModifyEnable;
8398   uint32_t                             SurfaceStateMOCS;
8399   __gen_address_type                   SurfaceStateBaseAddress;
8400   bool                                 DynamicStateBaseAddressModifyEnable;
8401   uint32_t                             DynamicStateMOCS;
8402   __gen_address_type                   DynamicStateBaseAddress;
8403   bool                                 IndirectObjectBaseAddressModifyEnable;
8404   uint32_t                             IndirectObjectMOCS;
8405   __gen_address_type                   IndirectObjectBaseAddress;
8406   bool                                 InstructionBaseAddressModifyEnable;
8407   uint32_t                             InstructionMOCS;
8408   __gen_address_type                   InstructionBaseAddress;
8409   bool                                 GeneralStateBufferSizeModifyEnable;
8410   uint32_t                             GeneralStateBufferSize;
8411   bool                                 DynamicStateBufferSizeModifyEnable;
8412   uint32_t                             DynamicStateBufferSize;
8413   bool                                 IndirectObjectBufferSizeModifyEnable;
8414   uint32_t                             IndirectObjectBufferSize;
8415   bool                                 InstructionBuffersizeModifyEnable;
8416   uint32_t                             InstructionBufferSize;
8417};
8418
8419static inline __attribute__((always_inline)) void
8420GFX8_STATE_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data,
8421                             __attribute__((unused)) void * restrict dst,
8422                             __attribute__((unused)) const struct GFX8_STATE_BASE_ADDRESS * restrict values)
8423{
8424   uint32_t * restrict dw = (uint32_t * restrict) dst;
8425
8426   dw[0] =
8427      __gen_uint(values->DWordLength, 0, 7) |
8428      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
8429      __gen_uint(values->_3DCommandOpcode, 24, 26) |
8430      __gen_uint(values->CommandSubType, 27, 28) |
8431      __gen_uint(values->CommandType, 29, 31);
8432
8433   const uint64_t v1 =
8434      __gen_uint(values->GeneralStateBaseAddressModifyEnable, 0, 0) |
8435      __gen_uint(values->GeneralStateMOCS, 4, 10);
8436   const uint64_t v1_address =
8437      __gen_address(data, &dw[1], values->GeneralStateBaseAddress, v1, 12, 63);
8438   dw[1] = v1_address;
8439   dw[2] = (v1_address >> 32) | (v1 >> 32);
8440
8441   dw[3] =
8442      __gen_uint(values->StatelessDataPortAccessMOCS, 16, 22);
8443
8444   const uint64_t v4 =
8445      __gen_uint(values->SurfaceStateBaseAddressModifyEnable, 0, 0) |
8446      __gen_uint(values->SurfaceStateMOCS, 4, 10);
8447   const uint64_t v4_address =
8448      __gen_address(data, &dw[4], values->SurfaceStateBaseAddress, v4, 12, 63);
8449   dw[4] = v4_address;
8450   dw[5] = (v4_address >> 32) | (v4 >> 32);
8451
8452   const uint64_t v6 =
8453      __gen_uint(values->DynamicStateBaseAddressModifyEnable, 0, 0) |
8454      __gen_uint(values->DynamicStateMOCS, 4, 10);
8455   const uint64_t v6_address =
8456      __gen_address(data, &dw[6], values->DynamicStateBaseAddress, v6, 12, 63);
8457   dw[6] = v6_address;
8458   dw[7] = (v6_address >> 32) | (v6 >> 32);
8459
8460   const uint64_t v8 =
8461      __gen_uint(values->IndirectObjectBaseAddressModifyEnable, 0, 0) |
8462      __gen_uint(values->IndirectObjectMOCS, 4, 10);
8463   const uint64_t v8_address =
8464      __gen_address(data, &dw[8], values->IndirectObjectBaseAddress, v8, 12, 63);
8465   dw[8] = v8_address;
8466   dw[9] = (v8_address >> 32) | (v8 >> 32);
8467
8468   const uint64_t v10 =
8469      __gen_uint(values->InstructionBaseAddressModifyEnable, 0, 0) |
8470      __gen_uint(values->InstructionMOCS, 4, 10);
8471   const uint64_t v10_address =
8472      __gen_address(data, &dw[10], values->InstructionBaseAddress, v10, 12, 63);
8473   dw[10] = v10_address;
8474   dw[11] = (v10_address >> 32) | (v10 >> 32);
8475
8476   dw[12] =
8477      __gen_uint(values->GeneralStateBufferSizeModifyEnable, 0, 0) |
8478      __gen_uint(values->GeneralStateBufferSize, 12, 31);
8479
8480   dw[13] =
8481      __gen_uint(values->DynamicStateBufferSizeModifyEnable, 0, 0) |
8482      __gen_uint(values->DynamicStateBufferSize, 12, 31);
8483
8484   dw[14] =
8485      __gen_uint(values->IndirectObjectBufferSizeModifyEnable, 0, 0) |
8486      __gen_uint(values->IndirectObjectBufferSize, 12, 31);
8487
8488   dw[15] =
8489      __gen_uint(values->InstructionBuffersizeModifyEnable, 0, 0) |
8490      __gen_uint(values->InstructionBufferSize, 12, 31);
8491}
8492
8493#define GFX8_STATE_PREFETCH_length             2
8494#define GFX8_STATE_PREFETCH_length_bias        2
8495#define GFX8_STATE_PREFETCH_header              \
8496   .DWordLength                         =      0,  \
8497   ._3DCommandSubOpcode                 =      3,  \
8498   ._3DCommandOpcode                    =      0,  \
8499   .CommandSubType                      =      0,  \
8500   .CommandType                         =      3
8501
8502struct GFX8_STATE_PREFETCH {
8503   uint32_t                             DWordLength;
8504   uint32_t                             _3DCommandSubOpcode;
8505   uint32_t                             _3DCommandOpcode;
8506   uint32_t                             CommandSubType;
8507   uint32_t                             CommandType;
8508   uint32_t                             PrefetchCount;
8509   __gen_address_type                   PrefetchPointer;
8510};
8511
8512static inline __attribute__((always_inline)) void
8513GFX8_STATE_PREFETCH_pack(__attribute__((unused)) __gen_user_data *data,
8514                         __attribute__((unused)) void * restrict dst,
8515                         __attribute__((unused)) const struct GFX8_STATE_PREFETCH * restrict values)
8516{
8517   uint32_t * restrict dw = (uint32_t * restrict) dst;
8518
8519   dw[0] =
8520      __gen_uint(values->DWordLength, 0, 7) |
8521      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
8522      __gen_uint(values->_3DCommandOpcode, 24, 26) |
8523      __gen_uint(values->CommandSubType, 27, 28) |
8524      __gen_uint(values->CommandType, 29, 31);
8525
8526   const uint32_t v1 =
8527      __gen_uint(values->PrefetchCount, 0, 2);
8528   dw[1] = __gen_address(data, &dw[1], values->PrefetchPointer, v1, 6, 31);
8529}
8530
8531#define GFX8_STATE_SIP_length                  3
8532#define GFX8_STATE_SIP_length_bias             2
8533#define GFX8_STATE_SIP_header                   \
8534   .DWordLength                         =      1,  \
8535   ._3DCommandSubOpcode                 =      2,  \
8536   ._3DCommandOpcode                    =      1,  \
8537   .CommandSubType                      =      0,  \
8538   .CommandType                         =      3
8539
8540struct GFX8_STATE_SIP {
8541   uint32_t                             DWordLength;
8542   uint32_t                             _3DCommandSubOpcode;
8543   uint32_t                             _3DCommandOpcode;
8544   uint32_t                             CommandSubType;
8545   uint32_t                             CommandType;
8546   uint64_t                             SystemInstructionPointer;
8547};
8548
8549static inline __attribute__((always_inline)) void
8550GFX8_STATE_SIP_pack(__attribute__((unused)) __gen_user_data *data,
8551                    __attribute__((unused)) void * restrict dst,
8552                    __attribute__((unused)) const struct GFX8_STATE_SIP * restrict values)
8553{
8554   uint32_t * restrict dw = (uint32_t * restrict) dst;
8555
8556   dw[0] =
8557      __gen_uint(values->DWordLength, 0, 7) |
8558      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
8559      __gen_uint(values->_3DCommandOpcode, 24, 26) |
8560      __gen_uint(values->CommandSubType, 27, 28) |
8561      __gen_uint(values->CommandType, 29, 31);
8562
8563   const uint64_t v1 =
8564      __gen_offset(values->SystemInstructionPointer, 4, 63);
8565   dw[1] = v1;
8566   dw[2] = v1 >> 32;
8567}
8568
8569#define GFX8_SWTESS_BASE_ADDRESS_length        2
8570#define GFX8_SWTESS_BASE_ADDRESS_length_bias      2
8571#define GFX8_SWTESS_BASE_ADDRESS_header         \
8572   .DWordLength                         =      0,  \
8573   ._3DCommandSubOpcode                 =      3,  \
8574   ._3DCommandOpcode                    =      1,  \
8575   .CommandSubType                      =      0,  \
8576   .CommandType                         =      3
8577
8578struct GFX8_SWTESS_BASE_ADDRESS {
8579   uint32_t                             DWordLength;
8580   uint32_t                             _3DCommandSubOpcode;
8581   uint32_t                             _3DCommandOpcode;
8582   uint32_t                             CommandSubType;
8583   uint32_t                             CommandType;
8584   uint32_t                             SWTessellationMOCS;
8585   __gen_address_type                   SWTessellationBaseAddress;
8586};
8587
8588static inline __attribute__((always_inline)) void
8589GFX8_SWTESS_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data,
8590                              __attribute__((unused)) void * restrict dst,
8591                              __attribute__((unused)) const struct GFX8_SWTESS_BASE_ADDRESS * restrict values)
8592{
8593   uint32_t * restrict dw = (uint32_t * restrict) dst;
8594
8595   dw[0] =
8596      __gen_uint(values->DWordLength, 0, 7) |
8597      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
8598      __gen_uint(values->_3DCommandOpcode, 24, 26) |
8599      __gen_uint(values->CommandSubType, 27, 28) |
8600      __gen_uint(values->CommandType, 29, 31);
8601
8602   const uint64_t v1 =
8603      __gen_uint(values->SWTessellationMOCS, 8, 11);
8604   const uint64_t v1_address =
8605      __gen_address(data, &dw[1], values->SWTessellationBaseAddress, v1, 12, 47);
8606   dw[1] = v1_address;
8607   dw[2] = (v1_address >> 32) | (v1 >> 32);
8608}
8609
8610#define GFX8_ACTHD_UDW_num                0x205c
8611#define GFX8_ACTHD_UDW_length                  1
8612struct GFX8_ACTHD_UDW {
8613   uint32_t                             HeadPointerUpperDWORD;
8614};
8615
8616static inline __attribute__((always_inline)) void
8617GFX8_ACTHD_UDW_pack(__attribute__((unused)) __gen_user_data *data,
8618                    __attribute__((unused)) void * restrict dst,
8619                    __attribute__((unused)) const struct GFX8_ACTHD_UDW * restrict values)
8620{
8621   uint32_t * restrict dw = (uint32_t * restrict) dst;
8622
8623   dw[0] =
8624      __gen_uint(values->HeadPointerUpperDWORD, 0, 15);
8625}
8626
8627#define GFX8_BCS_ACTHD_UDW_num            0x2205c
8628#define GFX8_BCS_ACTHD_UDW_length              1
8629struct GFX8_BCS_ACTHD_UDW {
8630   uint32_t                             HeadPointerUpperDWORD;
8631};
8632
8633static inline __attribute__((always_inline)) void
8634GFX8_BCS_ACTHD_UDW_pack(__attribute__((unused)) __gen_user_data *data,
8635                        __attribute__((unused)) void * restrict dst,
8636                        __attribute__((unused)) const struct GFX8_BCS_ACTHD_UDW * restrict values)
8637{
8638   uint32_t * restrict dw = (uint32_t * restrict) dst;
8639
8640   dw[0] =
8641      __gen_uint(values->HeadPointerUpperDWORD, 0, 15);
8642}
8643
8644#define GFX8_BCS_INSTDONE_num             0x2206c
8645#define GFX8_BCS_INSTDONE_length               1
8646struct GFX8_BCS_INSTDONE {
8647   bool                                 RingEnable;
8648   bool                                 BlitterIDLE;
8649   bool                                 GABIDLE;
8650   bool                                 BCSDone;
8651};
8652
8653static inline __attribute__((always_inline)) void
8654GFX8_BCS_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
8655                       __attribute__((unused)) void * restrict dst,
8656                       __attribute__((unused)) const struct GFX8_BCS_INSTDONE * restrict values)
8657{
8658   uint32_t * restrict dw = (uint32_t * restrict) dst;
8659
8660   dw[0] =
8661      __gen_uint(values->RingEnable, 0, 0) |
8662      __gen_uint(values->BlitterIDLE, 1, 1) |
8663      __gen_uint(values->GABIDLE, 2, 2) |
8664      __gen_uint(values->BCSDone, 3, 3);
8665}
8666
8667#define GFX8_BCS_RING_BUFFER_CTL_num      0x2203c
8668#define GFX8_BCS_RING_BUFFER_CTL_length        1
8669struct GFX8_BCS_RING_BUFFER_CTL {
8670   bool                                 RingBufferEnable;
8671   uint32_t                             AutomaticReportHeadPointer;
8672#define MI_AUTOREPORT_OFF                        0
8673#define MI_AUTOREPORT_64KB                       1
8674#define MI_AUTOREPORT_4KB                        2
8675#define MI_AUTOREPORT_128KB                      3
8676   bool                                 DisableRegisterAccesses;
8677   bool                                 SemaphoreWait;
8678   bool                                 RBWait;
8679   uint32_t                             BufferLengthinpages1;
8680};
8681
8682static inline __attribute__((always_inline)) void
8683GFX8_BCS_RING_BUFFER_CTL_pack(__attribute__((unused)) __gen_user_data *data,
8684                              __attribute__((unused)) void * restrict dst,
8685                              __attribute__((unused)) const struct GFX8_BCS_RING_BUFFER_CTL * restrict values)
8686{
8687   uint32_t * restrict dw = (uint32_t * restrict) dst;
8688
8689   dw[0] =
8690      __gen_uint(values->RingBufferEnable, 0, 0) |
8691      __gen_uint(values->AutomaticReportHeadPointer, 1, 2) |
8692      __gen_uint(values->DisableRegisterAccesses, 8, 8) |
8693      __gen_uint(values->SemaphoreWait, 10, 10) |
8694      __gen_uint(values->RBWait, 11, 11) |
8695      __gen_uint(values->BufferLengthinpages1, 12, 20);
8696}
8697
8698#define GFX8_CACHE_MODE_1_num             0x7004
8699#define GFX8_CACHE_MODE_1_length               1
8700struct GFX8_CACHE_MODE_1 {
8701   bool                                 RCZReadafterexpansioncontrolfix2;
8702   bool                                 DepthReadHitWriteOnlyOptimizationDisable;
8703   bool                                 MCSCacheDisable;
8704   bool                                 _4X4RCPFESTCOptimizationDisable;
8705   uint32_t                             SamplerCacheSetXORselection;
8706   uint32_t                             NPPMAFixEnable;
8707   uint32_t                             HIZEvictionPolicy;
8708   uint32_t                             NPEarlyZFailsDisable;
8709   uint32_t                             MSCResolveOptimizationDisable;
8710   bool                                 RCZReadafterexpansioncontrolfix2Mask;
8711   bool                                 DepthReadHitWriteOnlyOptimizationDisableMask;
8712   bool                                 MCSCacheDisableMask;
8713   bool                                 _4X4RCPFESTCOptimizationDisableMask;
8714   uint32_t                             SamplerCacheSetXORselectionMask;
8715   uint32_t                             NPPMAFixEnableMask;
8716   uint32_t                             HIZEvictionPolicyMask;
8717   uint32_t                             NPEarlyZFailsDisableMask;
8718   uint32_t                             MSCResolveOptimizationDisableMask;
8719};
8720
8721static inline __attribute__((always_inline)) void
8722GFX8_CACHE_MODE_1_pack(__attribute__((unused)) __gen_user_data *data,
8723                       __attribute__((unused)) void * restrict dst,
8724                       __attribute__((unused)) const struct GFX8_CACHE_MODE_1 * restrict values)
8725{
8726   uint32_t * restrict dw = (uint32_t * restrict) dst;
8727
8728   dw[0] =
8729      __gen_uint(values->RCZReadafterexpansioncontrolfix2, 2, 2) |
8730      __gen_uint(values->DepthReadHitWriteOnlyOptimizationDisable, 3, 3) |
8731      __gen_uint(values->MCSCacheDisable, 5, 5) |
8732      __gen_uint(values->_4X4RCPFESTCOptimizationDisable, 6, 6) |
8733      __gen_uint(values->SamplerCacheSetXORselection, 7, 8) |
8734      __gen_uint(values->NPPMAFixEnable, 11, 11) |
8735      __gen_uint(values->HIZEvictionPolicy, 12, 12) |
8736      __gen_uint(values->NPEarlyZFailsDisable, 13, 13) |
8737      __gen_uint(values->MSCResolveOptimizationDisable, 14, 14) |
8738      __gen_uint(values->RCZReadafterexpansioncontrolfix2Mask, 18, 18) |
8739      __gen_uint(values->DepthReadHitWriteOnlyOptimizationDisableMask, 19, 19) |
8740      __gen_uint(values->MCSCacheDisableMask, 21, 21) |
8741      __gen_uint(values->_4X4RCPFESTCOptimizationDisableMask, 22, 22) |
8742      __gen_uint(values->SamplerCacheSetXORselectionMask, 23, 24) |
8743      __gen_uint(values->NPPMAFixEnableMask, 27, 27) |
8744      __gen_uint(values->HIZEvictionPolicyMask, 28, 28) |
8745      __gen_uint(values->NPEarlyZFailsDisableMask, 29, 29) |
8746      __gen_uint(values->MSCResolveOptimizationDisableMask, 30, 30);
8747}
8748
8749#define GFX8_CL_INVOCATION_COUNT_num      0x2338
8750#define GFX8_CL_INVOCATION_COUNT_length        2
8751struct GFX8_CL_INVOCATION_COUNT {
8752   uint64_t                             CLInvocationCountReport;
8753};
8754
8755static inline __attribute__((always_inline)) void
8756GFX8_CL_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
8757                              __attribute__((unused)) void * restrict dst,
8758                              __attribute__((unused)) const struct GFX8_CL_INVOCATION_COUNT * restrict values)
8759{
8760   uint32_t * restrict dw = (uint32_t * restrict) dst;
8761
8762   const uint64_t v0 =
8763      __gen_uint(values->CLInvocationCountReport, 0, 63);
8764   dw[0] = v0;
8765   dw[1] = v0 >> 32;
8766}
8767
8768#define GFX8_CL_PRIMITIVES_COUNT_num      0x2340
8769#define GFX8_CL_PRIMITIVES_COUNT_length        2
8770struct GFX8_CL_PRIMITIVES_COUNT {
8771   uint64_t                             CLPrimitivesCountReport;
8772};
8773
8774static inline __attribute__((always_inline)) void
8775GFX8_CL_PRIMITIVES_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
8776                              __attribute__((unused)) void * restrict dst,
8777                              __attribute__((unused)) const struct GFX8_CL_PRIMITIVES_COUNT * restrict values)
8778{
8779   uint32_t * restrict dw = (uint32_t * restrict) dst;
8780
8781   const uint64_t v0 =
8782      __gen_uint(values->CLPrimitivesCountReport, 0, 63);
8783   dw[0] = v0;
8784   dw[1] = v0 >> 32;
8785}
8786
8787#define GFX8_CS_INVOCATION_COUNT_num      0x2290
8788#define GFX8_CS_INVOCATION_COUNT_length        2
8789struct GFX8_CS_INVOCATION_COUNT {
8790   uint64_t                             CSInvocationCountReport;
8791};
8792
8793static inline __attribute__((always_inline)) void
8794GFX8_CS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
8795                              __attribute__((unused)) void * restrict dst,
8796                              __attribute__((unused)) const struct GFX8_CS_INVOCATION_COUNT * restrict values)
8797{
8798   uint32_t * restrict dw = (uint32_t * restrict) dst;
8799
8800   const uint64_t v0 =
8801      __gen_uint(values->CSInvocationCountReport, 0, 63);
8802   dw[0] = v0;
8803   dw[1] = v0 >> 32;
8804}
8805
8806#define GFX8_DS_INVOCATION_COUNT_num      0x2308
8807#define GFX8_DS_INVOCATION_COUNT_length        2
8808struct GFX8_DS_INVOCATION_COUNT {
8809   uint64_t                             DSInvocationCountReport;
8810};
8811
8812static inline __attribute__((always_inline)) void
8813GFX8_DS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
8814                              __attribute__((unused)) void * restrict dst,
8815                              __attribute__((unused)) const struct GFX8_DS_INVOCATION_COUNT * restrict values)
8816{
8817   uint32_t * restrict dw = (uint32_t * restrict) dst;
8818
8819   const uint64_t v0 =
8820      __gen_uint(values->DSInvocationCountReport, 0, 63);
8821   dw[0] = v0;
8822   dw[1] = v0 >> 32;
8823}
8824
8825#define GFX8_FAULT_REG_num                0x4094
8826#define GFX8_FAULT_REG_length                  1
8827struct GFX8_FAULT_REG {
8828   bool                                 ValidBit;
8829   uint32_t                             FaultType;
8830#define InvalidPTEFault                          0
8831#define InvalidPDEFault                          1
8832#define InvalidPDPEFault                         2
8833#define InvalidPML4EFault                        3
8834   uint32_t                             SRCIDofFault;
8835   uint32_t                             GTTSEL;
8836#define PPGTT                                    0
8837#define GGTT                                     1
8838   uint32_t                             EngineID;
8839#define GFX                                      0
8840#define MFX0                                     1
8841#define MFX1                                     2
8842#define VEBX                                     3
8843#define BLT                                      4
8844#define GUC                                      5
8845};
8846
8847static inline __attribute__((always_inline)) void
8848GFX8_FAULT_REG_pack(__attribute__((unused)) __gen_user_data *data,
8849                    __attribute__((unused)) void * restrict dst,
8850                    __attribute__((unused)) const struct GFX8_FAULT_REG * restrict values)
8851{
8852   uint32_t * restrict dw = (uint32_t * restrict) dst;
8853
8854   dw[0] =
8855      __gen_uint(values->ValidBit, 0, 0) |
8856      __gen_uint(values->FaultType, 1, 2) |
8857      __gen_uint(values->SRCIDofFault, 3, 10) |
8858      __gen_uint(values->GTTSEL, 11, 11) |
8859      __gen_uint(values->EngineID, 12, 14);
8860}
8861
8862#define GFX8_GFX_ARB_ERROR_RPT_num        0x40a0
8863#define GFX8_GFX_ARB_ERROR_RPT_length          1
8864struct GFX8_GFX_ARB_ERROR_RPT {
8865   bool                                 TLBPageFaultError;
8866   bool                                 RSTRMPAVPReadInvalid;
8867   bool                                 InvalidPageDirectoryEntryError;
8868   bool                                 ROSTRMPAVPInvalidPhysicalAddress;
8869   bool                                 TLBPageVTDTranslationError;
8870   bool                                 WRDPPAVPInvalid;
8871   bool                                 PageDirectoryEntryVTDTranslationError;
8872   bool                                 UnloadedPDError;
8873   bool                                 GuCVTdtranslationPageFault2ndlevelUndefineddoorbell;
8874   bool                                 NonWBmemorytypeforAdvancedContext;
8875   bool                                 PASIDNotEnabled;
8876   bool                                 PASIDBoundaryViolation;
8877   bool                                 PASIDNotValid;
8878   bool                                 PASIDWasZeroForUntranslatedRequest;
8879   bool                                 ContextWasNotMarkedAsPresentWhenDoingDMA;
8880};
8881
8882static inline __attribute__((always_inline)) void
8883GFX8_GFX_ARB_ERROR_RPT_pack(__attribute__((unused)) __gen_user_data *data,
8884                            __attribute__((unused)) void * restrict dst,
8885                            __attribute__((unused)) const struct GFX8_GFX_ARB_ERROR_RPT * restrict values)
8886{
8887   uint32_t * restrict dw = (uint32_t * restrict) dst;
8888
8889   dw[0] =
8890      __gen_uint(values->TLBPageFaultError, 0, 0) |
8891      __gen_uint(values->RSTRMPAVPReadInvalid, 1, 1) |
8892      __gen_uint(values->InvalidPageDirectoryEntryError, 2, 2) |
8893      __gen_uint(values->ROSTRMPAVPInvalidPhysicalAddress, 3, 3) |
8894      __gen_uint(values->TLBPageVTDTranslationError, 4, 4) |
8895      __gen_uint(values->WRDPPAVPInvalid, 5, 5) |
8896      __gen_uint(values->PageDirectoryEntryVTDTranslationError, 6, 6) |
8897      __gen_uint(values->UnloadedPDError, 8, 8) |
8898      __gen_uint(values->GuCVTdtranslationPageFault2ndlevelUndefineddoorbell, 9, 9) |
8899      __gen_uint(values->NonWBmemorytypeforAdvancedContext, 10, 10) |
8900      __gen_uint(values->PASIDNotEnabled, 11, 11) |
8901      __gen_uint(values->PASIDBoundaryViolation, 12, 12) |
8902      __gen_uint(values->PASIDNotValid, 13, 13) |
8903      __gen_uint(values->PASIDWasZeroForUntranslatedRequest, 14, 14) |
8904      __gen_uint(values->ContextWasNotMarkedAsPresentWhenDoingDMA, 15, 15);
8905}
8906
8907#define GFX8_GS_INVOCATION_COUNT_num      0x2328
8908#define GFX8_GS_INVOCATION_COUNT_length        2
8909struct GFX8_GS_INVOCATION_COUNT {
8910   uint64_t                             GSInvocationCountReport;
8911};
8912
8913static inline __attribute__((always_inline)) void
8914GFX8_GS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
8915                              __attribute__((unused)) void * restrict dst,
8916                              __attribute__((unused)) const struct GFX8_GS_INVOCATION_COUNT * restrict values)
8917{
8918   uint32_t * restrict dw = (uint32_t * restrict) dst;
8919
8920   const uint64_t v0 =
8921      __gen_uint(values->GSInvocationCountReport, 0, 63);
8922   dw[0] = v0;
8923   dw[1] = v0 >> 32;
8924}
8925
8926#define GFX8_GS_PRIMITIVES_COUNT_num      0x2330
8927#define GFX8_GS_PRIMITIVES_COUNT_length        2
8928struct GFX8_GS_PRIMITIVES_COUNT {
8929   uint64_t                             GSPrimitivesCountReport;
8930};
8931
8932static inline __attribute__((always_inline)) void
8933GFX8_GS_PRIMITIVES_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
8934                              __attribute__((unused)) void * restrict dst,
8935                              __attribute__((unused)) const struct GFX8_GS_PRIMITIVES_COUNT * restrict values)
8936{
8937   uint32_t * restrict dw = (uint32_t * restrict) dst;
8938
8939   const uint64_t v0 =
8940      __gen_uint(values->GSPrimitivesCountReport, 0, 63);
8941   dw[0] = v0;
8942   dw[1] = v0 >> 32;
8943}
8944
8945#define GFX8_HS_INVOCATION_COUNT_num      0x2300
8946#define GFX8_HS_INVOCATION_COUNT_length        2
8947struct GFX8_HS_INVOCATION_COUNT {
8948   uint64_t                             HSInvocationCountReport;
8949};
8950
8951static inline __attribute__((always_inline)) void
8952GFX8_HS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
8953                              __attribute__((unused)) void * restrict dst,
8954                              __attribute__((unused)) const struct GFX8_HS_INVOCATION_COUNT * restrict values)
8955{
8956   uint32_t * restrict dw = (uint32_t * restrict) dst;
8957
8958   const uint64_t v0 =
8959      __gen_uint(values->HSInvocationCountReport, 0, 63);
8960   dw[0] = v0;
8961   dw[1] = v0 >> 32;
8962}
8963
8964#define GFX8_IA_PRIMITIVES_COUNT_num      0x2318
8965#define GFX8_IA_PRIMITIVES_COUNT_length        2
8966struct GFX8_IA_PRIMITIVES_COUNT {
8967   uint64_t                             IAPrimitivesCountReport;
8968};
8969
8970static inline __attribute__((always_inline)) void
8971GFX8_IA_PRIMITIVES_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
8972                              __attribute__((unused)) void * restrict dst,
8973                              __attribute__((unused)) const struct GFX8_IA_PRIMITIVES_COUNT * restrict values)
8974{
8975   uint32_t * restrict dw = (uint32_t * restrict) dst;
8976
8977   const uint64_t v0 =
8978      __gen_uint(values->IAPrimitivesCountReport, 0, 63);
8979   dw[0] = v0;
8980   dw[1] = v0 >> 32;
8981}
8982
8983#define GFX8_IA_VERTICES_COUNT_num        0x2310
8984#define GFX8_IA_VERTICES_COUNT_length          2
8985struct GFX8_IA_VERTICES_COUNT {
8986   uint64_t                             IAVerticesCountReport;
8987};
8988
8989static inline __attribute__((always_inline)) void
8990GFX8_IA_VERTICES_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
8991                            __attribute__((unused)) void * restrict dst,
8992                            __attribute__((unused)) const struct GFX8_IA_VERTICES_COUNT * restrict values)
8993{
8994   uint32_t * restrict dw = (uint32_t * restrict) dst;
8995
8996   const uint64_t v0 =
8997      __gen_uint(values->IAVerticesCountReport, 0, 63);
8998   dw[0] = v0;
8999   dw[1] = v0 >> 32;
9000}
9001
9002#define GFX8_INSTDONE_1_num               0x206c
9003#define GFX8_INSTDONE_1_length                 1
9004struct GFX8_INSTDONE_1 {
9005   bool                                 PRB0RingEnable;
9006   bool                                 VFGDone;
9007   bool                                 VSDone;
9008   bool                                 HSDone;
9009   bool                                 TEDone;
9010   bool                                 DSDone;
9011   bool                                 GSDone;
9012   bool                                 SOLDone;
9013   bool                                 CLDone;
9014   bool                                 SFDone;
9015   bool                                 TDGDone;
9016   bool                                 URBMDone;
9017   bool                                 SVGDone;
9018   bool                                 GAFSDone;
9019   bool                                 VFEDone;
9020   bool                                 TSGDone;
9021   bool                                 GAFMDone;
9022   bool                                 GAMDone;
9023   bool                                 RSDone;
9024   bool                                 CSDone;
9025   bool                                 SDEDone;
9026   bool                                 RCCFBCCSDone;
9027};
9028
9029static inline __attribute__((always_inline)) void
9030GFX8_INSTDONE_1_pack(__attribute__((unused)) __gen_user_data *data,
9031                     __attribute__((unused)) void * restrict dst,
9032                     __attribute__((unused)) const struct GFX8_INSTDONE_1 * restrict values)
9033{
9034   uint32_t * restrict dw = (uint32_t * restrict) dst;
9035
9036   dw[0] =
9037      __gen_uint(values->PRB0RingEnable, 0, 0) |
9038      __gen_uint(values->VFGDone, 1, 1) |
9039      __gen_uint(values->VSDone, 2, 2) |
9040      __gen_uint(values->HSDone, 3, 3) |
9041      __gen_uint(values->TEDone, 4, 4) |
9042      __gen_uint(values->DSDone, 5, 5) |
9043      __gen_uint(values->GSDone, 6, 6) |
9044      __gen_uint(values->SOLDone, 7, 7) |
9045      __gen_uint(values->CLDone, 8, 8) |
9046      __gen_uint(values->SFDone, 9, 9) |
9047      __gen_uint(values->TDGDone, 12, 12) |
9048      __gen_uint(values->URBMDone, 13, 13) |
9049      __gen_uint(values->SVGDone, 14, 14) |
9050      __gen_uint(values->GAFSDone, 15, 15) |
9051      __gen_uint(values->VFEDone, 16, 16) |
9052      __gen_uint(values->TSGDone, 17, 17) |
9053      __gen_uint(values->GAFMDone, 18, 18) |
9054      __gen_uint(values->GAMDone, 19, 19) |
9055      __gen_uint(values->RSDone, 20, 20) |
9056      __gen_uint(values->CSDone, 21, 21) |
9057      __gen_uint(values->SDEDone, 22, 22) |
9058      __gen_uint(values->RCCFBCCSDone, 23, 23);
9059}
9060
9061#define GFX8_INSTPM_num                   0x20c0
9062#define GFX8_INSTPM_length                     1
9063struct GFX8_INSTPM {
9064   bool                                 _3DStateInstructionDisable;
9065   bool                                 _3DRenderingInstructionDisable;
9066   bool                                 MediaInstructionDisable;
9067   bool                                 CONSTANT_BUFFERAddressOffsetDisable;
9068   bool                                 _3DStateInstructionDisableMask;
9069   bool                                 _3DRenderingInstructionDisableMask;
9070   bool                                 MediaInstructionDisableMask;
9071   bool                                 CONSTANT_BUFFERAddressOffsetDisableMask;
9072};
9073
9074static inline __attribute__((always_inline)) void
9075GFX8_INSTPM_pack(__attribute__((unused)) __gen_user_data *data,
9076                 __attribute__((unused)) void * restrict dst,
9077                 __attribute__((unused)) const struct GFX8_INSTPM * restrict values)
9078{
9079   uint32_t * restrict dw = (uint32_t * restrict) dst;
9080
9081   dw[0] =
9082      __gen_uint(values->_3DStateInstructionDisable, 1, 1) |
9083      __gen_uint(values->_3DRenderingInstructionDisable, 2, 2) |
9084      __gen_uint(values->MediaInstructionDisable, 3, 3) |
9085      __gen_uint(values->CONSTANT_BUFFERAddressOffsetDisable, 6, 6) |
9086      __gen_uint(values->_3DStateInstructionDisableMask, 17, 17) |
9087      __gen_uint(values->_3DRenderingInstructionDisableMask, 18, 18) |
9088      __gen_uint(values->MediaInstructionDisableMask, 19, 19) |
9089      __gen_uint(values->CONSTANT_BUFFERAddressOffsetDisableMask, 22, 22);
9090}
9091
9092#define GFX8_L3CNTLREG_num                0x7034
9093#define GFX8_L3CNTLREG_length                  1
9094struct GFX8_L3CNTLREG {
9095   bool                                 SLMEnable;
9096   uint32_t                             URBAllocation;
9097   uint32_t                             ROAllocation;
9098   uint32_t                             DCAllocation;
9099   uint32_t                             AllAllocation;
9100};
9101
9102static inline __attribute__((always_inline)) void
9103GFX8_L3CNTLREG_pack(__attribute__((unused)) __gen_user_data *data,
9104                    __attribute__((unused)) void * restrict dst,
9105                    __attribute__((unused)) const struct GFX8_L3CNTLREG * restrict values)
9106{
9107   uint32_t * restrict dw = (uint32_t * restrict) dst;
9108
9109   dw[0] =
9110      __gen_uint(values->SLMEnable, 0, 0) |
9111      __gen_uint(values->URBAllocation, 1, 7) |
9112      __gen_uint(values->ROAllocation, 11, 17) |
9113      __gen_uint(values->DCAllocation, 18, 24) |
9114      __gen_uint(values->AllAllocation, 25, 31);
9115}
9116
9117#define GFX8_PERFCNT1_num                 0x91b8
9118#define GFX8_PERFCNT1_length                   2
9119struct GFX8_PERFCNT1 {
9120   uint64_t                             Value;
9121   uint32_t                             EventSelection;
9122   bool                                 CounterClear;
9123   bool                                 EdgeDetect;
9124   bool                                 OverflowEnable;
9125   bool                                 CounterEnable;
9126};
9127
9128static inline __attribute__((always_inline)) void
9129GFX8_PERFCNT1_pack(__attribute__((unused)) __gen_user_data *data,
9130                   __attribute__((unused)) void * restrict dst,
9131                   __attribute__((unused)) const struct GFX8_PERFCNT1 * restrict values)
9132{
9133   uint32_t * restrict dw = (uint32_t * restrict) dst;
9134
9135   const uint64_t v0 =
9136      __gen_uint(values->Value, 0, 43) |
9137      __gen_uint(values->EventSelection, 52, 59) |
9138      __gen_uint(values->CounterClear, 60, 60) |
9139      __gen_uint(values->EdgeDetect, 61, 61) |
9140      __gen_uint(values->OverflowEnable, 62, 62) |
9141      __gen_uint(values->CounterEnable, 63, 63);
9142   dw[0] = v0;
9143   dw[1] = v0 >> 32;
9144}
9145
9146#define GFX8_PERFCNT2_num                 0x91c0
9147#define GFX8_PERFCNT2_length                   2
9148struct GFX8_PERFCNT2 {
9149   uint64_t                             Value;
9150   uint32_t                             EventSelection;
9151   bool                                 CounterClear;
9152   bool                                 EdgeDetect;
9153   bool                                 OverflowEnable;
9154   bool                                 CounterEnable;
9155};
9156
9157static inline __attribute__((always_inline)) void
9158GFX8_PERFCNT2_pack(__attribute__((unused)) __gen_user_data *data,
9159                   __attribute__((unused)) void * restrict dst,
9160                   __attribute__((unused)) const struct GFX8_PERFCNT2 * restrict values)
9161{
9162   uint32_t * restrict dw = (uint32_t * restrict) dst;
9163
9164   const uint64_t v0 =
9165      __gen_uint(values->Value, 0, 43) |
9166      __gen_uint(values->EventSelection, 52, 59) |
9167      __gen_uint(values->CounterClear, 60, 60) |
9168      __gen_uint(values->EdgeDetect, 61, 61) |
9169      __gen_uint(values->OverflowEnable, 62, 62) |
9170      __gen_uint(values->CounterEnable, 63, 63);
9171   dw[0] = v0;
9172   dw[1] = v0 >> 32;
9173}
9174
9175#define GFX8_PS_INVOCATION_COUNT_num      0x2348
9176#define GFX8_PS_INVOCATION_COUNT_length        2
9177struct GFX8_PS_INVOCATION_COUNT {
9178   uint64_t                             PSInvocationCountReport;
9179};
9180
9181static inline __attribute__((always_inline)) void
9182GFX8_PS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
9183                              __attribute__((unused)) void * restrict dst,
9184                              __attribute__((unused)) const struct GFX8_PS_INVOCATION_COUNT * restrict values)
9185{
9186   uint32_t * restrict dw = (uint32_t * restrict) dst;
9187
9188   const uint64_t v0 =
9189      __gen_uint(values->PSInvocationCountReport, 0, 63);
9190   dw[0] = v0;
9191   dw[1] = v0 >> 32;
9192}
9193
9194#define GFX8_RCS_RING_BUFFER_CTL_num      0x203c
9195#define GFX8_RCS_RING_BUFFER_CTL_length        1
9196struct GFX8_RCS_RING_BUFFER_CTL {
9197   bool                                 RingBufferEnable;
9198   uint32_t                             AutomaticReportHeadPointer;
9199#define MI_AUTOREPORT_OFF                        0
9200#define MI_AUTOREPORT_64KB                       1
9201#define MI_AUTOREPORT_4KB                        2
9202#define MI_AUTOREPORT_128KB                      3
9203   bool                                 SemaphoreWait;
9204   bool                                 RBWait;
9205   uint32_t                             BufferLengthinpages1;
9206};
9207
9208static inline __attribute__((always_inline)) void
9209GFX8_RCS_RING_BUFFER_CTL_pack(__attribute__((unused)) __gen_user_data *data,
9210                              __attribute__((unused)) void * restrict dst,
9211                              __attribute__((unused)) const struct GFX8_RCS_RING_BUFFER_CTL * restrict values)
9212{
9213   uint32_t * restrict dw = (uint32_t * restrict) dst;
9214
9215   dw[0] =
9216      __gen_uint(values->RingBufferEnable, 0, 0) |
9217      __gen_uint(values->AutomaticReportHeadPointer, 1, 2) |
9218      __gen_uint(values->SemaphoreWait, 10, 10) |
9219      __gen_uint(values->RBWait, 11, 11) |
9220      __gen_uint(values->BufferLengthinpages1, 12, 20);
9221}
9222
9223#define GFX8_ROW_INSTDONE_num             0xe164
9224#define GFX8_ROW_INSTDONE_length               1
9225struct GFX8_ROW_INSTDONE {
9226   bool                                 BCDone;
9227   bool                                 PSDDone;
9228   bool                                 DAPRDone;
9229   bool                                 TDLDone;
9230   bool                                 ICDone;
9231   bool                                 MA0Done;
9232   bool                                 EU00DoneSS0;
9233   bool                                 EU01DoneSS0;
9234   bool                                 EU02DoneSS0;
9235   bool                                 EU03DoneSS0;
9236   bool                                 EU10DoneSS0;
9237   bool                                 EU11DoneSS0;
9238   bool                                 EU12DoneSS0;
9239   bool                                 EU13DoneSS0;
9240   bool                                 MA1DoneSS0;
9241};
9242
9243static inline __attribute__((always_inline)) void
9244GFX8_ROW_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
9245                       __attribute__((unused)) void * restrict dst,
9246                       __attribute__((unused)) const struct GFX8_ROW_INSTDONE * restrict values)
9247{
9248   uint32_t * restrict dw = (uint32_t * restrict) dst;
9249
9250   dw[0] =
9251      __gen_uint(values->BCDone, 0, 0) |
9252      __gen_uint(values->PSDDone, 1, 1) |
9253      __gen_uint(values->DAPRDone, 3, 3) |
9254      __gen_uint(values->TDLDone, 6, 6) |
9255      __gen_uint(values->ICDone, 12, 12) |
9256      __gen_uint(values->MA0Done, 15, 15) |
9257      __gen_uint(values->EU00DoneSS0, 16, 16) |
9258      __gen_uint(values->EU01DoneSS0, 17, 17) |
9259      __gen_uint(values->EU02DoneSS0, 18, 18) |
9260      __gen_uint(values->EU03DoneSS0, 19, 19) |
9261      __gen_uint(values->EU10DoneSS0, 21, 21) |
9262      __gen_uint(values->EU11DoneSS0, 22, 22) |
9263      __gen_uint(values->EU12DoneSS0, 23, 23) |
9264      __gen_uint(values->EU13DoneSS0, 24, 24) |
9265      __gen_uint(values->MA1DoneSS0, 26, 26);
9266}
9267
9268#define GFX8_RPSTAT1_num                  0xa01c
9269#define GFX8_RPSTAT1_length                    1
9270struct GFX8_RPSTAT1 {
9271   uint32_t                             PreviousGTFrequency;
9272   uint32_t                             CurrentGTFrequency;
9273};
9274
9275static inline __attribute__((always_inline)) void
9276GFX8_RPSTAT1_pack(__attribute__((unused)) __gen_user_data *data,
9277                  __attribute__((unused)) void * restrict dst,
9278                  __attribute__((unused)) const struct GFX8_RPSTAT1 * restrict values)
9279{
9280   uint32_t * restrict dw = (uint32_t * restrict) dst;
9281
9282   dw[0] =
9283      __gen_uint(values->PreviousGTFrequency, 0, 6) |
9284      __gen_uint(values->CurrentGTFrequency, 7, 14);
9285}
9286
9287#define GFX8_SAMPLER_INSTDONE_num         0xe160
9288#define GFX8_SAMPLER_INSTDONE_length           1
9289struct GFX8_SAMPLER_INSTDONE {
9290   bool                                 IMEDone;
9291   bool                                 PL0Done;
9292   bool                                 SO0Done;
9293   bool                                 DG0Done;
9294   bool                                 FT0Done;
9295   bool                                 DM0Done;
9296   bool                                 SCDone;
9297   bool                                 FL0Done;
9298   bool                                 QCDone;
9299   bool                                 SVSMDone;
9300   bool                                 SI0Done;
9301   bool                                 MT0Done;
9302   bool                                 AVSDone;
9303   bool                                 IEFDone;
9304   bool                                 CREDone;
9305   bool                                 SVSMARB3;
9306   bool                                 SVSMARB2;
9307   bool                                 SVSMARB1;
9308   bool                                 SVSMAdapter;
9309   bool                                 BDMDone;
9310};
9311
9312static inline __attribute__((always_inline)) void
9313GFX8_SAMPLER_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
9314                           __attribute__((unused)) void * restrict dst,
9315                           __attribute__((unused)) const struct GFX8_SAMPLER_INSTDONE * restrict values)
9316{
9317   uint32_t * restrict dw = (uint32_t * restrict) dst;
9318
9319   dw[0] =
9320      __gen_uint(values->IMEDone, 0, 0) |
9321      __gen_uint(values->PL0Done, 1, 1) |
9322      __gen_uint(values->SO0Done, 2, 2) |
9323      __gen_uint(values->DG0Done, 3, 3) |
9324      __gen_uint(values->FT0Done, 4, 4) |
9325      __gen_uint(values->DM0Done, 5, 5) |
9326      __gen_uint(values->SCDone, 6, 6) |
9327      __gen_uint(values->FL0Done, 7, 7) |
9328      __gen_uint(values->QCDone, 8, 8) |
9329      __gen_uint(values->SVSMDone, 9, 9) |
9330      __gen_uint(values->SI0Done, 10, 10) |
9331      __gen_uint(values->MT0Done, 11, 11) |
9332      __gen_uint(values->AVSDone, 12, 12) |
9333      __gen_uint(values->IEFDone, 13, 13) |
9334      __gen_uint(values->CREDone, 14, 14) |
9335      __gen_uint(values->SVSMARB3, 15, 15) |
9336      __gen_uint(values->SVSMARB2, 16, 16) |
9337      __gen_uint(values->SVSMARB1, 17, 17) |
9338      __gen_uint(values->SVSMAdapter, 18, 18) |
9339      __gen_uint(values->BDMDone, 19, 19);
9340}
9341
9342#define GFX8_SC_INSTDONE_num              0x7100
9343#define GFX8_SC_INSTDONE_length                1
9344struct GFX8_SC_INSTDONE {
9345   bool                                 SVLDone;
9346   bool                                 WMFEDone;
9347   bool                                 WMBEDone;
9348   bool                                 HIZDone;
9349   bool                                 STCDone;
9350   bool                                 IZDone;
9351   bool                                 SBEDone;
9352   bool                                 RCZDone;
9353   bool                                 RCCDone;
9354   bool                                 RCPBEDone;
9355   bool                                 RCPFEDone;
9356   bool                                 DAPBDone;
9357   bool                                 DAPRBEDone;
9358   bool                                 SARBDone;
9359   bool                                 DC0Done;
9360   bool                                 DC1Done;
9361   bool                                 DC2Done;
9362   bool                                 GW0Done;
9363   bool                                 GW1Done;
9364   bool                                 GW2Done;
9365   bool                                 TDCDone;
9366};
9367
9368static inline __attribute__((always_inline)) void
9369GFX8_SC_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
9370                      __attribute__((unused)) void * restrict dst,
9371                      __attribute__((unused)) const struct GFX8_SC_INSTDONE * restrict values)
9372{
9373   uint32_t * restrict dw = (uint32_t * restrict) dst;
9374
9375   dw[0] =
9376      __gen_uint(values->SVLDone, 0, 0) |
9377      __gen_uint(values->WMFEDone, 1, 1) |
9378      __gen_uint(values->WMBEDone, 2, 2) |
9379      __gen_uint(values->HIZDone, 3, 3) |
9380      __gen_uint(values->STCDone, 4, 4) |
9381      __gen_uint(values->IZDone, 5, 5) |
9382      __gen_uint(values->SBEDone, 6, 6) |
9383      __gen_uint(values->RCZDone, 8, 8) |
9384      __gen_uint(values->RCCDone, 9, 9) |
9385      __gen_uint(values->RCPBEDone, 10, 10) |
9386      __gen_uint(values->RCPFEDone, 11, 11) |
9387      __gen_uint(values->DAPBDone, 12, 12) |
9388      __gen_uint(values->DAPRBEDone, 13, 13) |
9389      __gen_uint(values->SARBDone, 15, 15) |
9390      __gen_uint(values->DC0Done, 16, 16) |
9391      __gen_uint(values->DC1Done, 17, 17) |
9392      __gen_uint(values->DC2Done, 18, 18) |
9393      __gen_uint(values->GW0Done, 20, 20) |
9394      __gen_uint(values->GW1Done, 21, 21) |
9395      __gen_uint(values->GW2Done, 22, 22) |
9396      __gen_uint(values->TDCDone, 24, 24);
9397}
9398
9399#define GFX8_SO_NUM_PRIMS_WRITTEN0_num    0x5200
9400#define GFX8_SO_NUM_PRIMS_WRITTEN0_length      2
9401struct GFX8_SO_NUM_PRIMS_WRITTEN0 {
9402   uint64_t                             NumPrimsWrittenCount;
9403};
9404
9405static inline __attribute__((always_inline)) void
9406GFX8_SO_NUM_PRIMS_WRITTEN0_pack(__attribute__((unused)) __gen_user_data *data,
9407                                __attribute__((unused)) void * restrict dst,
9408                                __attribute__((unused)) const struct GFX8_SO_NUM_PRIMS_WRITTEN0 * restrict values)
9409{
9410   uint32_t * restrict dw = (uint32_t * restrict) dst;
9411
9412   const uint64_t v0 =
9413      __gen_uint(values->NumPrimsWrittenCount, 0, 63);
9414   dw[0] = v0;
9415   dw[1] = v0 >> 32;
9416}
9417
9418#define GFX8_SO_NUM_PRIMS_WRITTEN1_num    0x5208
9419#define GFX8_SO_NUM_PRIMS_WRITTEN1_length      2
9420struct GFX8_SO_NUM_PRIMS_WRITTEN1 {
9421   uint64_t                             NumPrimsWrittenCount;
9422};
9423
9424static inline __attribute__((always_inline)) void
9425GFX8_SO_NUM_PRIMS_WRITTEN1_pack(__attribute__((unused)) __gen_user_data *data,
9426                                __attribute__((unused)) void * restrict dst,
9427                                __attribute__((unused)) const struct GFX8_SO_NUM_PRIMS_WRITTEN1 * restrict values)
9428{
9429   uint32_t * restrict dw = (uint32_t * restrict) dst;
9430
9431   const uint64_t v0 =
9432      __gen_uint(values->NumPrimsWrittenCount, 0, 63);
9433   dw[0] = v0;
9434   dw[1] = v0 >> 32;
9435}
9436
9437#define GFX8_SO_NUM_PRIMS_WRITTEN2_num    0x5210
9438#define GFX8_SO_NUM_PRIMS_WRITTEN2_length      2
9439struct GFX8_SO_NUM_PRIMS_WRITTEN2 {
9440   uint64_t                             NumPrimsWrittenCount;
9441};
9442
9443static inline __attribute__((always_inline)) void
9444GFX8_SO_NUM_PRIMS_WRITTEN2_pack(__attribute__((unused)) __gen_user_data *data,
9445                                __attribute__((unused)) void * restrict dst,
9446                                __attribute__((unused)) const struct GFX8_SO_NUM_PRIMS_WRITTEN2 * restrict values)
9447{
9448   uint32_t * restrict dw = (uint32_t * restrict) dst;
9449
9450   const uint64_t v0 =
9451      __gen_uint(values->NumPrimsWrittenCount, 0, 63);
9452   dw[0] = v0;
9453   dw[1] = v0 >> 32;
9454}
9455
9456#define GFX8_SO_NUM_PRIMS_WRITTEN3_num    0x5218
9457#define GFX8_SO_NUM_PRIMS_WRITTEN3_length      2
9458struct GFX8_SO_NUM_PRIMS_WRITTEN3 {
9459   uint64_t                             NumPrimsWrittenCount;
9460};
9461
9462static inline __attribute__((always_inline)) void
9463GFX8_SO_NUM_PRIMS_WRITTEN3_pack(__attribute__((unused)) __gen_user_data *data,
9464                                __attribute__((unused)) void * restrict dst,
9465                                __attribute__((unused)) const struct GFX8_SO_NUM_PRIMS_WRITTEN3 * restrict values)
9466{
9467   uint32_t * restrict dw = (uint32_t * restrict) dst;
9468
9469   const uint64_t v0 =
9470      __gen_uint(values->NumPrimsWrittenCount, 0, 63);
9471   dw[0] = v0;
9472   dw[1] = v0 >> 32;
9473}
9474
9475#define GFX8_SO_PRIM_STORAGE_NEEDED0_num  0x5240
9476#define GFX8_SO_PRIM_STORAGE_NEEDED0_length      2
9477struct GFX8_SO_PRIM_STORAGE_NEEDED0 {
9478   uint64_t                             PrimStorageNeededCount;
9479};
9480
9481static inline __attribute__((always_inline)) void
9482GFX8_SO_PRIM_STORAGE_NEEDED0_pack(__attribute__((unused)) __gen_user_data *data,
9483                                  __attribute__((unused)) void * restrict dst,
9484                                  __attribute__((unused)) const struct GFX8_SO_PRIM_STORAGE_NEEDED0 * restrict values)
9485{
9486   uint32_t * restrict dw = (uint32_t * restrict) dst;
9487
9488   const uint64_t v0 =
9489      __gen_uint(values->PrimStorageNeededCount, 0, 63);
9490   dw[0] = v0;
9491   dw[1] = v0 >> 32;
9492}
9493
9494#define GFX8_SO_PRIM_STORAGE_NEEDED1_num  0x5248
9495#define GFX8_SO_PRIM_STORAGE_NEEDED1_length      2
9496struct GFX8_SO_PRIM_STORAGE_NEEDED1 {
9497   uint64_t                             PrimStorageNeededCount;
9498};
9499
9500static inline __attribute__((always_inline)) void
9501GFX8_SO_PRIM_STORAGE_NEEDED1_pack(__attribute__((unused)) __gen_user_data *data,
9502                                  __attribute__((unused)) void * restrict dst,
9503                                  __attribute__((unused)) const struct GFX8_SO_PRIM_STORAGE_NEEDED1 * restrict values)
9504{
9505   uint32_t * restrict dw = (uint32_t * restrict) dst;
9506
9507   const uint64_t v0 =
9508      __gen_uint(values->PrimStorageNeededCount, 0, 63);
9509   dw[0] = v0;
9510   dw[1] = v0 >> 32;
9511}
9512
9513#define GFX8_SO_PRIM_STORAGE_NEEDED2_num  0x5250
9514#define GFX8_SO_PRIM_STORAGE_NEEDED2_length      2
9515struct GFX8_SO_PRIM_STORAGE_NEEDED2 {
9516   uint64_t                             PrimStorageNeededCount;
9517};
9518
9519static inline __attribute__((always_inline)) void
9520GFX8_SO_PRIM_STORAGE_NEEDED2_pack(__attribute__((unused)) __gen_user_data *data,
9521                                  __attribute__((unused)) void * restrict dst,
9522                                  __attribute__((unused)) const struct GFX8_SO_PRIM_STORAGE_NEEDED2 * restrict values)
9523{
9524   uint32_t * restrict dw = (uint32_t * restrict) dst;
9525
9526   const uint64_t v0 =
9527      __gen_uint(values->PrimStorageNeededCount, 0, 63);
9528   dw[0] = v0;
9529   dw[1] = v0 >> 32;
9530}
9531
9532#define GFX8_SO_PRIM_STORAGE_NEEDED3_num  0x5258
9533#define GFX8_SO_PRIM_STORAGE_NEEDED3_length      2
9534struct GFX8_SO_PRIM_STORAGE_NEEDED3 {
9535   uint64_t                             PrimStorageNeededCount;
9536};
9537
9538static inline __attribute__((always_inline)) void
9539GFX8_SO_PRIM_STORAGE_NEEDED3_pack(__attribute__((unused)) __gen_user_data *data,
9540                                  __attribute__((unused)) void * restrict dst,
9541                                  __attribute__((unused)) const struct GFX8_SO_PRIM_STORAGE_NEEDED3 * restrict values)
9542{
9543   uint32_t * restrict dw = (uint32_t * restrict) dst;
9544
9545   const uint64_t v0 =
9546      __gen_uint(values->PrimStorageNeededCount, 0, 63);
9547   dw[0] = v0;
9548   dw[1] = v0 >> 32;
9549}
9550
9551#define GFX8_SO_WRITE_OFFSET0_num         0x5280
9552#define GFX8_SO_WRITE_OFFSET0_length           1
9553struct GFX8_SO_WRITE_OFFSET0 {
9554   uint64_t                             WriteOffset;
9555};
9556
9557static inline __attribute__((always_inline)) void
9558GFX8_SO_WRITE_OFFSET0_pack(__attribute__((unused)) __gen_user_data *data,
9559                           __attribute__((unused)) void * restrict dst,
9560                           __attribute__((unused)) const struct GFX8_SO_WRITE_OFFSET0 * restrict values)
9561{
9562   uint32_t * restrict dw = (uint32_t * restrict) dst;
9563
9564   dw[0] =
9565      __gen_offset(values->WriteOffset, 2, 31);
9566}
9567
9568#define GFX8_SO_WRITE_OFFSET1_num         0x5284
9569#define GFX8_SO_WRITE_OFFSET1_length           1
9570struct GFX8_SO_WRITE_OFFSET1 {
9571   uint64_t                             WriteOffset;
9572};
9573
9574static inline __attribute__((always_inline)) void
9575GFX8_SO_WRITE_OFFSET1_pack(__attribute__((unused)) __gen_user_data *data,
9576                           __attribute__((unused)) void * restrict dst,
9577                           __attribute__((unused)) const struct GFX8_SO_WRITE_OFFSET1 * restrict values)
9578{
9579   uint32_t * restrict dw = (uint32_t * restrict) dst;
9580
9581   dw[0] =
9582      __gen_offset(values->WriteOffset, 2, 31);
9583}
9584
9585#define GFX8_SO_WRITE_OFFSET2_num         0x5288
9586#define GFX8_SO_WRITE_OFFSET2_length           1
9587struct GFX8_SO_WRITE_OFFSET2 {
9588   uint64_t                             WriteOffset;
9589};
9590
9591static inline __attribute__((always_inline)) void
9592GFX8_SO_WRITE_OFFSET2_pack(__attribute__((unused)) __gen_user_data *data,
9593                           __attribute__((unused)) void * restrict dst,
9594                           __attribute__((unused)) const struct GFX8_SO_WRITE_OFFSET2 * restrict values)
9595{
9596   uint32_t * restrict dw = (uint32_t * restrict) dst;
9597
9598   dw[0] =
9599      __gen_offset(values->WriteOffset, 2, 31);
9600}
9601
9602#define GFX8_SO_WRITE_OFFSET3_num         0x528c
9603#define GFX8_SO_WRITE_OFFSET3_length           1
9604struct GFX8_SO_WRITE_OFFSET3 {
9605   uint64_t                             WriteOffset;
9606};
9607
9608static inline __attribute__((always_inline)) void
9609GFX8_SO_WRITE_OFFSET3_pack(__attribute__((unused)) __gen_user_data *data,
9610                           __attribute__((unused)) void * restrict dst,
9611                           __attribute__((unused)) const struct GFX8_SO_WRITE_OFFSET3 * restrict values)
9612{
9613   uint32_t * restrict dw = (uint32_t * restrict) dst;
9614
9615   dw[0] =
9616      __gen_offset(values->WriteOffset, 2, 31);
9617}
9618
9619#define GFX8_VCS2_RING_BUFFER_CTL_num     0x1203c
9620#define GFX8_VCS2_RING_BUFFER_CTL_length       1
9621struct GFX8_VCS2_RING_BUFFER_CTL {
9622   bool                                 RingBufferEnable;
9623   uint32_t                             AutomaticReportHeadPointer;
9624#define MI_AUTOREPORT_OFF                        0
9625#define MI_AUTOREPORT_64KB                       1
9626#define MI_AUTOREPORT_4KB                        2
9627#define MI_AUTOREPORT_128KB                      3
9628   bool                                 DisableRegisterAccesses;
9629   bool                                 SemaphoreWait;
9630   bool                                 RBWait;
9631   uint32_t                             BufferLengthinpages1;
9632};
9633
9634static inline __attribute__((always_inline)) void
9635GFX8_VCS2_RING_BUFFER_CTL_pack(__attribute__((unused)) __gen_user_data *data,
9636                               __attribute__((unused)) void * restrict dst,
9637                               __attribute__((unused)) const struct GFX8_VCS2_RING_BUFFER_CTL * restrict values)
9638{
9639   uint32_t * restrict dw = (uint32_t * restrict) dst;
9640
9641   dw[0] =
9642      __gen_uint(values->RingBufferEnable, 0, 0) |
9643      __gen_uint(values->AutomaticReportHeadPointer, 1, 2) |
9644      __gen_uint(values->DisableRegisterAccesses, 8, 8) |
9645      __gen_uint(values->SemaphoreWait, 10, 10) |
9646      __gen_uint(values->RBWait, 11, 11) |
9647      __gen_uint(values->BufferLengthinpages1, 12, 20);
9648}
9649
9650#define GFX8_VCS_ACTHD_UDW_num            0x1205c
9651#define GFX8_VCS_ACTHD_UDW_length              1
9652struct GFX8_VCS_ACTHD_UDW {
9653   uint32_t                             HeadPointerUpperDWORD;
9654};
9655
9656static inline __attribute__((always_inline)) void
9657GFX8_VCS_ACTHD_UDW_pack(__attribute__((unused)) __gen_user_data *data,
9658                        __attribute__((unused)) void * restrict dst,
9659                        __attribute__((unused)) const struct GFX8_VCS_ACTHD_UDW * restrict values)
9660{
9661   uint32_t * restrict dw = (uint32_t * restrict) dst;
9662
9663   dw[0] =
9664      __gen_uint(values->HeadPointerUpperDWORD, 0, 15);
9665}
9666
9667#define GFX8_VCS_INSTDONE_num             0x1206c
9668#define GFX8_VCS_INSTDONE_length               1
9669struct GFX8_VCS_INSTDONE {
9670   bool                                 RingEnable;
9671   bool                                 USBDone;
9672   bool                                 QRCDone;
9673   bool                                 SECDone;
9674   bool                                 MPCDone;
9675   bool                                 VFTDone;
9676   bool                                 BSPDone;
9677   bool                                 VLFDone;
9678   bool                                 VOPDone;
9679   bool                                 VMCDone;
9680   bool                                 VIPDone;
9681   bool                                 VITDone;
9682   bool                                 VDSDone;
9683   bool                                 VMXDone;
9684   bool                                 VCPDone;
9685   bool                                 VCDDone;
9686   bool                                 VADDone;
9687   bool                                 VMDDone;
9688   bool                                 VISDone;
9689   bool                                 VACDone;
9690   bool                                 VAMDone;
9691   bool                                 JPGDone;
9692   bool                                 VBPDone;
9693   bool                                 VHRDone;
9694   bool                                 VCIDone;
9695   bool                                 VCRDone;
9696   bool                                 VINDone;
9697   bool                                 VPRDone;
9698   bool                                 VTQDone;
9699   bool                                 Reserved;
9700   bool                                 VCSDone;
9701   bool                                 GACDone;
9702};
9703
9704static inline __attribute__((always_inline)) void
9705GFX8_VCS_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
9706                       __attribute__((unused)) void * restrict dst,
9707                       __attribute__((unused)) const struct GFX8_VCS_INSTDONE * restrict values)
9708{
9709   uint32_t * restrict dw = (uint32_t * restrict) dst;
9710
9711   dw[0] =
9712      __gen_uint(values->RingEnable, 0, 0) |
9713      __gen_uint(values->USBDone, 1, 1) |
9714      __gen_uint(values->QRCDone, 2, 2) |
9715      __gen_uint(values->SECDone, 3, 3) |
9716      __gen_uint(values->MPCDone, 4, 4) |
9717      __gen_uint(values->VFTDone, 5, 5) |
9718      __gen_uint(values->BSPDone, 6, 6) |
9719      __gen_uint(values->VLFDone, 7, 7) |
9720      __gen_uint(values->VOPDone, 8, 8) |
9721      __gen_uint(values->VMCDone, 9, 9) |
9722      __gen_uint(values->VIPDone, 10, 10) |
9723      __gen_uint(values->VITDone, 11, 11) |
9724      __gen_uint(values->VDSDone, 12, 12) |
9725      __gen_uint(values->VMXDone, 13, 13) |
9726      __gen_uint(values->VCPDone, 14, 14) |
9727      __gen_uint(values->VCDDone, 15, 15) |
9728      __gen_uint(values->VADDone, 16, 16) |
9729      __gen_uint(values->VMDDone, 17, 17) |
9730      __gen_uint(values->VISDone, 18, 18) |
9731      __gen_uint(values->VACDone, 19, 19) |
9732      __gen_uint(values->VAMDone, 20, 20) |
9733      __gen_uint(values->JPGDone, 21, 21) |
9734      __gen_uint(values->VBPDone, 22, 22) |
9735      __gen_uint(values->VHRDone, 23, 23) |
9736      __gen_uint(values->VCIDone, 24, 24) |
9737      __gen_uint(values->VCRDone, 25, 25) |
9738      __gen_uint(values->VINDone, 26, 26) |
9739      __gen_uint(values->VPRDone, 27, 27) |
9740      __gen_uint(values->VTQDone, 28, 28) |
9741      __gen_uint(values->Reserved, 29, 29) |
9742      __gen_uint(values->VCSDone, 30, 30) |
9743      __gen_uint(values->GACDone, 31, 31);
9744}
9745
9746#define GFX8_VCS_RING_BUFFER_CTL_num      0x1203c
9747#define GFX8_VCS_RING_BUFFER_CTL_length        1
9748struct GFX8_VCS_RING_BUFFER_CTL {
9749   bool                                 RingBufferEnable;
9750   uint32_t                             AutomaticReportHeadPointer;
9751#define MI_AUTOREPORT_OFF                        0
9752#define MI_AUTOREPORT_64KB                       1
9753#define MI_AUTOREPORT_4KB                        2
9754#define MI_AUTOREPORT_128KB                      3
9755   bool                                 DisableRegisterAccesses;
9756   bool                                 SemaphoreWait;
9757   bool                                 RBWait;
9758   uint32_t                             BufferLengthinpages1;
9759};
9760
9761static inline __attribute__((always_inline)) void
9762GFX8_VCS_RING_BUFFER_CTL_pack(__attribute__((unused)) __gen_user_data *data,
9763                              __attribute__((unused)) void * restrict dst,
9764                              __attribute__((unused)) const struct GFX8_VCS_RING_BUFFER_CTL * restrict values)
9765{
9766   uint32_t * restrict dw = (uint32_t * restrict) dst;
9767
9768   dw[0] =
9769      __gen_uint(values->RingBufferEnable, 0, 0) |
9770      __gen_uint(values->AutomaticReportHeadPointer, 1, 2) |
9771      __gen_uint(values->DisableRegisterAccesses, 8, 8) |
9772      __gen_uint(values->SemaphoreWait, 10, 10) |
9773      __gen_uint(values->RBWait, 11, 11) |
9774      __gen_uint(values->BufferLengthinpages1, 12, 20);
9775}
9776
9777#define GFX8_VECS_ACTHD_UDW_num           0x1a05c
9778#define GFX8_VECS_ACTHD_UDW_length             1
9779struct GFX8_VECS_ACTHD_UDW {
9780   uint32_t                             HeadPointerUpperDWORD;
9781};
9782
9783static inline __attribute__((always_inline)) void
9784GFX8_VECS_ACTHD_UDW_pack(__attribute__((unused)) __gen_user_data *data,
9785                         __attribute__((unused)) void * restrict dst,
9786                         __attribute__((unused)) const struct GFX8_VECS_ACTHD_UDW * restrict values)
9787{
9788   uint32_t * restrict dw = (uint32_t * restrict) dst;
9789
9790   dw[0] =
9791      __gen_uint(values->HeadPointerUpperDWORD, 0, 15);
9792}
9793
9794#define GFX8_VECS_INSTDONE_num            0x1a06c
9795#define GFX8_VECS_INSTDONE_length              1
9796struct GFX8_VECS_INSTDONE {
9797   bool                                 RingEnable;
9798   bool                                 VECSDone;
9799   bool                                 GAMDone;
9800};
9801
9802static inline __attribute__((always_inline)) void
9803GFX8_VECS_INSTDONE_pack(__attribute__((unused)) __gen_user_data *data,
9804                        __attribute__((unused)) void * restrict dst,
9805                        __attribute__((unused)) const struct GFX8_VECS_INSTDONE * restrict values)
9806{
9807   uint32_t * restrict dw = (uint32_t * restrict) dst;
9808
9809   dw[0] =
9810      __gen_uint(values->RingEnable, 0, 0) |
9811      __gen_uint(values->VECSDone, 30, 30) |
9812      __gen_uint(values->GAMDone, 31, 31);
9813}
9814
9815#define GFX8_VECS_RING_BUFFER_CTL_num     0x1a03c
9816#define GFX8_VECS_RING_BUFFER_CTL_length       1
9817struct GFX8_VECS_RING_BUFFER_CTL {
9818   bool                                 RingBufferEnable;
9819   uint32_t                             AutomaticReportHeadPointer;
9820#define MI_AUTOREPORT_OFF                        0
9821#define MI_AUTOREPORT_64KB                       1
9822#define MI_AUTOREPORT_4KB                        2
9823#define MI_AUTOREPORT_128KB                      3
9824   bool                                 DisableRegisterAccesses;
9825   bool                                 SemaphoreWait;
9826   bool                                 RBWait;
9827   uint32_t                             BufferLengthinpages1;
9828};
9829
9830static inline __attribute__((always_inline)) void
9831GFX8_VECS_RING_BUFFER_CTL_pack(__attribute__((unused)) __gen_user_data *data,
9832                               __attribute__((unused)) void * restrict dst,
9833                               __attribute__((unused)) const struct GFX8_VECS_RING_BUFFER_CTL * restrict values)
9834{
9835   uint32_t * restrict dw = (uint32_t * restrict) dst;
9836
9837   dw[0] =
9838      __gen_uint(values->RingBufferEnable, 0, 0) |
9839      __gen_uint(values->AutomaticReportHeadPointer, 1, 2) |
9840      __gen_uint(values->DisableRegisterAccesses, 8, 8) |
9841      __gen_uint(values->SemaphoreWait, 10, 10) |
9842      __gen_uint(values->RBWait, 11, 11) |
9843      __gen_uint(values->BufferLengthinpages1, 12, 20);
9844}
9845
9846#define GFX8_VS_INVOCATION_COUNT_num      0x2320
9847#define GFX8_VS_INVOCATION_COUNT_length        2
9848struct GFX8_VS_INVOCATION_COUNT {
9849   uint64_t                             VSInvocationCountReport;
9850};
9851
9852static inline __attribute__((always_inline)) void
9853GFX8_VS_INVOCATION_COUNT_pack(__attribute__((unused)) __gen_user_data *data,
9854                              __attribute__((unused)) void * restrict dst,
9855                              __attribute__((unused)) const struct GFX8_VS_INVOCATION_COUNT * restrict values)
9856{
9857   uint32_t * restrict dw = (uint32_t * restrict) dst;
9858
9859   const uint64_t v0 =
9860      __gen_uint(values->VSInvocationCountReport, 0, 63);
9861   dw[0] = v0;
9862   dw[1] = v0 >> 32;
9863}
9864
9865#endif /* GFX8_PACK_H */
9866