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 ILK.
26 *
27 * This file has been generated, do not hand edit.
28 */
29
30#ifndef GFX5_PACK_H
31#define GFX5_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 GFX5_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 GFX5_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 GFX5_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 GFX5_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 GFX5_3D_Prim_Topo_Type {
246   _3DPRIM_POINTLIST                    =      1,
247   _3DPRIM_LINELIST                     =      2,
248   _3DPRIM_LINESTRIP                    =      3,
249   _3DPRIM_TRILIST                      =      4,
250   _3DPRIM_TRISTRIP                     =      5,
251   _3DPRIM_TRIFAN                       =      6,
252   _3DPRIM_QUADLIST                     =      7,
253   _3DPRIM_QUADSTRIP                    =      8,
254   _3DPRIM_LINELIST_ADJ                 =      9,
255   _3DPRIM_LINESTRIP_ADJ                =     10,
256   _3DPRIM_TRILIST_ADJ                  =     11,
257   _3DPRIM_TRISTRIP_ADJ                 =     12,
258   _3DPRIM_TRISTRIP_REVERSE             =     13,
259   _3DPRIM_POLYGON                      =     14,
260   _3DPRIM_RECTLIST                     =     15,
261   _3DPRIM_LINELOOP                     =     16,
262   _3DPRIM_POINTLIST_BF                 =     17,
263   _3DPRIM_LINESTRIP_CONT               =     18,
264   _3DPRIM_LINESTRIP_BF                 =     19,
265   _3DPRIM_LINESTRIP_CONT_BF            =     20,
266   _3DPRIM_TRIFAN_NOSTIPPLE             =     22,
267};
268
269enum GFX5_3D_Stencil_Operation {
270   STENCILOP_KEEP                       =      0,
271   STENCILOP_ZERO                       =      1,
272   STENCILOP_REPLACE                    =      2,
273   STENCILOP_INCRSAT                    =      3,
274   STENCILOP_DECRSAT                    =      4,
275   STENCILOP_INCR                       =      5,
276   STENCILOP_DECR                       =      6,
277   STENCILOP_INVERT                     =      7,
278};
279
280enum GFX5_3D_Vertex_Component_Control {
281   VFCOMP_NOSTORE                       =      0,
282   VFCOMP_STORE_SRC                     =      1,
283   VFCOMP_STORE_0                       =      2,
284   VFCOMP_STORE_1_FP                    =      3,
285   VFCOMP_STORE_1_INT                   =      4,
286   VFCOMP_STORE_VID                     =      5,
287   VFCOMP_STORE_IID                     =      6,
288   VFCOMP_STORE_PID                     =      7,
289};
290
291enum GFX5_Texture_Coordinate_Mode {
292   TCM_WRAP                             =      0,
293   TCM_MIRROR                           =      1,
294   TCM_CLAMP                            =      2,
295   TCM_CUBE                             =      3,
296   TCM_CLAMP_BORDER                     =      4,
297   TCM_MIRROR_ONCE                      =      5,
298};
299
300#define GFX5_CC_VIEWPORT_length                2
301struct GFX5_CC_VIEWPORT {
302   float                                MinimumDepth;
303   float                                MaximumDepth;
304};
305
306static inline __attribute__((always_inline)) void
307GFX5_CC_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
308                      __attribute__((unused)) void * restrict dst,
309                      __attribute__((unused)) const struct GFX5_CC_VIEWPORT * restrict values)
310{
311   uint32_t * restrict dw = (uint32_t * restrict) dst;
312
313   dw[0] =
314      __gen_float(values->MinimumDepth);
315
316   dw[1] =
317      __gen_float(values->MaximumDepth);
318}
319
320#define GFX5_CLIP_STATE_length                11
321struct GFX5_CLIP_STATE {
322   uint32_t                             GRFRegisterCount;
323   uint64_t                             KernelStartPointer;
324   bool                                 SoftwareExceptionEnable;
325   bool                                 MaskStackExceptionEnable;
326   bool                                 IllegalOpcodeExceptionEnable;
327   uint32_t                             FloatingPointMode;
328#define FLOATING_POINT_MODE_IEEE754              0
329#define FLOATING_POINT_MODE_Alternate            1
330   uint32_t                             ThreadPriority;
331#define NormalPriority                           0
332#define HighPriority                             1
333   uint32_t                             BindingTableEntryCount;
334   bool                                 SingleProgramFlow;
335   uint32_t                             PerThreadScratchSpace;
336   __gen_address_type                   ScratchSpaceBasePointer;
337   uint32_t                             DispatchGRFStartRegisterForURBData;
338   uint32_t                             VertexURBEntryReadOffset;
339   uint32_t                             VertexURBEntryReadLength;
340   uint32_t                             ConstantURBEntryReadOffset;
341   uint32_t                             ConstantURBEntryReadLength;
342   uint32_t                             NumberofURBEntries;
343   uint32_t                             URBEntryAllocationSize;
344   uint32_t                             MaximumNumberofThreads;
345   uint32_t                             ClipMode;
346#define CLIPMODE_NORMAL                          0
347#define CLIPMODE_ALL                             1
348#define CLIPMODE_CLIP_NON_REJECTED               2
349#define CLIPMODE_REJECT_ALL                      3
350#define CLIPMODE_ACCEPT_ALL                      4
351   uint32_t                             UserClipDistanceClipTestEnableBitmask;
352   bool                                 UserClipFlagsMustClipEnable;
353   bool                                 NegativeWClipTestEnable;
354   bool                                 GuardbandClipTestEnable;
355   bool                                 ViewportZClipTestEnable;
356   bool                                 ViewportXYClipTestEnable;
357   uint32_t                             VertexPositionSpace;
358#define VPOS_NDCSPACE                            0
359#define VPOS_SCREENSPACE                         1
360   uint32_t                             APIMode;
361#define APIMODE_OGL                              0
362#define APIMODE_D3D                              1
363   __gen_address_type                   ClipperViewportStatePointer;
364   float                                ScreenSpaceViewportXMin;
365   float                                ScreenSpaceViewportXMax;
366   float                                ScreenSpaceViewportYMin;
367   float                                ScreenSpaceViewportYMax;
368};
369
370static inline __attribute__((always_inline)) void
371GFX5_CLIP_STATE_pack(__attribute__((unused)) __gen_user_data *data,
372                     __attribute__((unused)) void * restrict dst,
373                     __attribute__((unused)) const struct GFX5_CLIP_STATE * restrict values)
374{
375   uint32_t * restrict dw = (uint32_t * restrict) dst;
376
377   dw[0] =
378      __gen_uint(values->GRFRegisterCount, 1, 3) |
379      __gen_offset(values->KernelStartPointer, 6, 31);
380
381   dw[1] =
382      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
383      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
384      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
385      __gen_uint(values->FloatingPointMode, 16, 16) |
386      __gen_uint(values->ThreadPriority, 17, 17) |
387      __gen_uint(values->BindingTableEntryCount, 18, 25) |
388      __gen_uint(values->SingleProgramFlow, 31, 31);
389
390   const uint32_t v2 =
391      __gen_uint(values->PerThreadScratchSpace, 0, 3);
392   dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31);
393
394   dw[3] =
395      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
396      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
397      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
398      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
399      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
400
401   dw[4] =
402      __gen_uint(values->NumberofURBEntries, 11, 18) |
403      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
404      __gen_uint(values->MaximumNumberofThreads, 25, 30);
405
406   dw[5] =
407      __gen_uint(values->ClipMode, 13, 15) |
408      __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 16, 23) |
409      __gen_uint(values->UserClipFlagsMustClipEnable, 24, 24) |
410      __gen_uint(values->NegativeWClipTestEnable, 25, 25) |
411      __gen_uint(values->GuardbandClipTestEnable, 26, 26) |
412      __gen_uint(values->ViewportZClipTestEnable, 27, 27) |
413      __gen_uint(values->ViewportXYClipTestEnable, 28, 28) |
414      __gen_uint(values->VertexPositionSpace, 29, 29) |
415      __gen_uint(values->APIMode, 30, 30);
416
417   dw[6] = __gen_address(data, &dw[6], values->ClipperViewportStatePointer, 0, 5, 31);
418
419   dw[7] =
420      __gen_float(values->ScreenSpaceViewportXMin);
421
422   dw[8] =
423      __gen_float(values->ScreenSpaceViewportXMax);
424
425   dw[9] =
426      __gen_float(values->ScreenSpaceViewportYMin);
427
428   dw[10] =
429      __gen_float(values->ScreenSpaceViewportYMax);
430}
431
432#define GFX5_CLIP_VIEWPORT_length              4
433struct GFX5_CLIP_VIEWPORT {
434   float                                XMinClipGuardband;
435   float                                XMaxClipGuardband;
436   float                                YMinClipGuardband;
437   float                                YMaxClipGuardband;
438};
439
440static inline __attribute__((always_inline)) void
441GFX5_CLIP_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
442                        __attribute__((unused)) void * restrict dst,
443                        __attribute__((unused)) const struct GFX5_CLIP_VIEWPORT * restrict values)
444{
445   uint32_t * restrict dw = (uint32_t * restrict) dst;
446
447   dw[0] =
448      __gen_float(values->XMinClipGuardband);
449
450   dw[1] =
451      __gen_float(values->XMaxClipGuardband);
452
453   dw[2] =
454      __gen_float(values->YMinClipGuardband);
455
456   dw[3] =
457      __gen_float(values->YMaxClipGuardband);
458}
459
460#define GFX5_COLOR_CALC_STATE_length           8
461struct GFX5_COLOR_CALC_STATE {
462   enum GFX5_3D_Stencil_Operation       BackfaceStencilPassDepthPassOp;
463   enum GFX5_3D_Stencil_Operation       BackfaceStencilPassDepthFailOp;
464   enum GFX5_3D_Stencil_Operation       BackfaceStencilFailOp;
465   enum GFX5_3D_Compare_Function        BackfaceStencilTestFunction;
466   bool                                 DoubleSidedStencilEnable;
467   bool                                 StencilBufferWriteEnable;
468   enum GFX5_3D_Stencil_Operation       StencilPassDepthPassOp;
469   enum GFX5_3D_Stencil_Operation       StencilPassDepthFailOp;
470   enum GFX5_3D_Stencil_Operation       StencilFailOp;
471   enum GFX5_3D_Compare_Function        StencilTestFunction;
472   bool                                 StencilTestEnable;
473   uint32_t                             BackfaceStencilReferenceValue;
474   uint32_t                             StencilWriteMask;
475   uint32_t                             StencilTestMask;
476   uint32_t                             StencilReferenceValue;
477   bool                                 LogicOpEnable;
478   bool                                 DepthBufferWriteEnable;
479   enum GFX5_3D_Compare_Function        DepthTestFunction;
480   bool                                 DepthTestEnable;
481   uint32_t                             BackfaceStencilWriteMask;
482   uint32_t                             BackfaceStencilTestMask;
483   enum GFX5_3D_Compare_Function        AlphaTestFunction;
484   bool                                 AlphaTestEnable;
485   bool                                 ColorBufferBlendEnable;
486   bool                                 IndependentAlphaBlendEnable;
487   uint32_t                             AlphaTestFormat;
488#define ALPHATEST_UNORM8                         0
489#define ALPHATEST_FLOAT32                        1
490   __gen_address_type                   CCViewportStatePointer;
491   enum GFX5_3D_Color_Buffer_Blend_Factor DestinationAlphaBlendFactor;
492   enum GFX5_3D_Color_Buffer_Blend_Factor SourceAlphaBlendFactor;
493   enum GFX5_3D_Color_Buffer_Blend_Function AlphaBlendFunction;
494   bool                                 StatisticsEnable;
495   enum GFX5_3D_Logic_Op_Function       LogicOpFunction;
496   bool                                 RoundDisableFunctionDisable;
497   bool                                 ColorDitherEnable;
498   bool                                 PostBlendColorClampEnable;
499   bool                                 PreBlendColorClampEnable;
500   uint32_t                             ColorClampRange;
501#define COLORCLAMP_UNORM                         0
502#define COLORCLAMP_SNORM                         1
503#define COLORCLAMP_RTFORMAT                      2
504   uint32_t                             YDitherOffset;
505   uint32_t                             XDitherOffset;
506   enum GFX5_3D_Color_Buffer_Blend_Factor DestinationBlendFactor;
507   enum GFX5_3D_Color_Buffer_Blend_Factor SourceBlendFactor;
508   enum GFX5_3D_Color_Buffer_Blend_Function ColorBlendFunction;
509   uint32_t                             AlphaReferenceValueAsUNORM8;
510   float                                AlphaReferenceValueAsFLOAT32;
511};
512
513static inline __attribute__((always_inline)) void
514GFX5_COLOR_CALC_STATE_pack(__attribute__((unused)) __gen_user_data *data,
515                           __attribute__((unused)) void * restrict dst,
516                           __attribute__((unused)) const struct GFX5_COLOR_CALC_STATE * restrict values)
517{
518   uint32_t * restrict dw = (uint32_t * restrict) dst;
519
520   dw[0] =
521      __gen_uint(values->BackfaceStencilPassDepthPassOp, 3, 5) |
522      __gen_uint(values->BackfaceStencilPassDepthFailOp, 6, 8) |
523      __gen_uint(values->BackfaceStencilFailOp, 9, 11) |
524      __gen_uint(values->BackfaceStencilTestFunction, 12, 14) |
525      __gen_uint(values->DoubleSidedStencilEnable, 15, 15) |
526      __gen_uint(values->StencilBufferWriteEnable, 18, 18) |
527      __gen_uint(values->StencilPassDepthPassOp, 19, 21) |
528      __gen_uint(values->StencilPassDepthFailOp, 22, 24) |
529      __gen_uint(values->StencilFailOp, 25, 27) |
530      __gen_uint(values->StencilTestFunction, 28, 30) |
531      __gen_uint(values->StencilTestEnable, 31, 31);
532
533   dw[1] =
534      __gen_uint(values->BackfaceStencilReferenceValue, 0, 7) |
535      __gen_uint(values->StencilWriteMask, 8, 15) |
536      __gen_uint(values->StencilTestMask, 16, 23) |
537      __gen_uint(values->StencilReferenceValue, 24, 31);
538
539   dw[2] =
540      __gen_uint(values->LogicOpEnable, 0, 0) |
541      __gen_uint(values->DepthBufferWriteEnable, 11, 11) |
542      __gen_uint(values->DepthTestFunction, 12, 14) |
543      __gen_uint(values->DepthTestEnable, 15, 15) |
544      __gen_uint(values->BackfaceStencilWriteMask, 16, 23) |
545      __gen_uint(values->BackfaceStencilTestMask, 24, 31);
546
547   dw[3] =
548      __gen_uint(values->AlphaTestFunction, 8, 10) |
549      __gen_uint(values->AlphaTestEnable, 11, 11) |
550      __gen_uint(values->ColorBufferBlendEnable, 12, 12) |
551      __gen_uint(values->IndependentAlphaBlendEnable, 13, 13) |
552      __gen_uint(values->AlphaTestFormat, 15, 15);
553
554   dw[4] = __gen_address(data, &dw[4], values->CCViewportStatePointer, 0, 5, 31);
555
556   dw[5] =
557      __gen_uint(values->DestinationAlphaBlendFactor, 2, 6) |
558      __gen_uint(values->SourceAlphaBlendFactor, 7, 11) |
559      __gen_uint(values->AlphaBlendFunction, 12, 14) |
560      __gen_uint(values->StatisticsEnable, 15, 15) |
561      __gen_uint(values->LogicOpFunction, 16, 19) |
562      __gen_uint(values->RoundDisableFunctionDisable, 30, 30) |
563      __gen_uint(values->ColorDitherEnable, 31, 31);
564
565   dw[6] =
566      __gen_uint(values->PostBlendColorClampEnable, 0, 0) |
567      __gen_uint(values->PreBlendColorClampEnable, 1, 1) |
568      __gen_uint(values->ColorClampRange, 2, 3) |
569      __gen_uint(values->YDitherOffset, 15, 16) |
570      __gen_uint(values->XDitherOffset, 17, 18) |
571      __gen_uint(values->DestinationBlendFactor, 19, 23) |
572      __gen_uint(values->SourceBlendFactor, 24, 28) |
573      __gen_uint(values->ColorBlendFunction, 29, 31);
574
575   dw[7] =
576      __gen_uint(values->AlphaReferenceValueAsUNORM8, 0, 31) |
577      __gen_float(values->AlphaReferenceValueAsFLOAT32);
578}
579
580#define GFX5_GS_STATE_length                   7
581struct GFX5_GS_STATE {
582   uint32_t                             GRFRegisterCount;
583   uint64_t                             KernelStartPointer;
584   bool                                 SoftwareExceptionEnable;
585   bool                                 MaskStackExceptionEnable;
586   bool                                 IllegalOpcodeExceptionEnable;
587   uint32_t                             FloatingPointMode;
588#define FLOATING_POINT_MODE_IEEE754              0
589#define FLOATING_POINT_MODE_Alternate            1
590   uint32_t                             BindingTableEntryCount;
591   bool                                 SingleProgramFlow;
592   uint32_t                             PerThreadScratchSpace;
593   __gen_address_type                   ScratchSpaceBasePointer;
594   uint32_t                             DispatchGRFStartRegisterForURBData;
595   uint32_t                             VertexURBEntryReadOffset;
596   uint32_t                             VertexURBEntryReadLength;
597   uint32_t                             ConstantURBEntryReadOffset;
598   uint32_t                             ConstantURBEntryReadLength;
599   bool                                 RenderingEnabled;
600   bool                                 SOStatisticsEnable;
601   bool                                 GSStatisticsEnable;
602   uint32_t                             NumberofURBEntries;
603   uint32_t                             URBEntryAllocationSize;
604   uint32_t                             MaximumNumberofThreads;
605   uint32_t                             SamplerCount;
606   __gen_address_type                   SamplerStatePointer;
607   uint32_t                             MaximumVPIndex;
608   bool                                 ReorderEnable;
609};
610
611static inline __attribute__((always_inline)) void
612GFX5_GS_STATE_pack(__attribute__((unused)) __gen_user_data *data,
613                   __attribute__((unused)) void * restrict dst,
614                   __attribute__((unused)) const struct GFX5_GS_STATE * restrict values)
615{
616   uint32_t * restrict dw = (uint32_t * restrict) dst;
617
618   dw[0] =
619      __gen_uint(values->GRFRegisterCount, 1, 3) |
620      __gen_offset(values->KernelStartPointer, 6, 31);
621
622   dw[1] =
623      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
624      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
625      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
626      __gen_uint(values->FloatingPointMode, 16, 16) |
627      __gen_uint(values->BindingTableEntryCount, 18, 25) |
628      __gen_uint(values->SingleProgramFlow, 31, 31);
629
630   const uint32_t v2 =
631      __gen_uint(values->PerThreadScratchSpace, 0, 3);
632   dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31);
633
634   dw[3] =
635      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
636      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
637      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
638      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
639      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
640
641   dw[4] =
642      __gen_uint(values->RenderingEnabled, 8, 8) |
643      __gen_uint(values->SOStatisticsEnable, 9, 9) |
644      __gen_uint(values->GSStatisticsEnable, 10, 10) |
645      __gen_uint(values->NumberofURBEntries, 11, 18) |
646      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
647      __gen_uint(values->MaximumNumberofThreads, 25, 30);
648
649   const uint32_t v5 =
650      __gen_uint(values->SamplerCount, 0, 2);
651   dw[5] = __gen_address(data, &dw[5], values->SamplerStatePointer, v5, 5, 31);
652
653   dw[6] =
654      __gen_uint(values->MaximumVPIndex, 0, 3) |
655      __gen_uint(values->ReorderEnable, 30, 30);
656}
657
658#define GFX5_MEMORY_OBJECT_CONTROL_STATE_length      1
659struct GFX5_MEMORY_OBJECT_CONTROL_STATE {
660   uint32_t                             CacheabilityControl;
661   uint32_t                             GraphicsDataTypeGFDT;
662   bool                                 EncryptedData;
663};
664
665static inline __attribute__((always_inline)) void
666GFX5_MEMORY_OBJECT_CONTROL_STATE_pack(__attribute__((unused)) __gen_user_data *data,
667                                      __attribute__((unused)) void * restrict dst,
668                                      __attribute__((unused)) const struct GFX5_MEMORY_OBJECT_CONTROL_STATE * restrict values)
669{
670   uint32_t * restrict dw = (uint32_t * restrict) dst;
671
672   dw[0] =
673      __gen_uint(values->CacheabilityControl, 0, 1) |
674      __gen_uint(values->GraphicsDataTypeGFDT, 2, 2) |
675      __gen_uint(values->EncryptedData, 3, 3);
676}
677
678#define GFX5_RENDER_SURFACE_STATE_length       6
679struct GFX5_RENDER_SURFACE_STATE {
680   bool                                 CubeFaceEnablePositiveZ;
681   bool                                 CubeFaceEnableNegativeZ;
682   bool                                 CubeFaceEnablePositiveY;
683   bool                                 CubeFaceEnableNegativeY;
684   bool                                 CubeFaceEnablePositiveX;
685   bool                                 CubeFaceEnableNegativeX;
686   uint32_t                             MediaBoundaryPixelMode;
687#define NORMAL_MODE                              0
688   uint32_t                             RenderCacheReadWriteMode;
689#define WRITE_ONLY                               0
690#define READ_WRITE                               1
691   uint32_t                             CubeMapCornerMode;
692#define CUBE_REPLICATE                           0
693#define CUBE_AVERAGE                             1
694   uint32_t                             MIPMapLayoutMode;
695#define MIPLAYOUT_BELOW                          0
696#define MIPLAYOUT_RIGHT                          1
697   uint32_t                             VerticalLineStrideOffset;
698   uint32_t                             VerticalLineStride;
699   bool                                 ColorBlendEnable;
700   uint32_t                             ColorBufferComponentWriteDisables;
701#define WRITEDISABLE_ALPHA                       8
702#define WRITEDISABLE_RED                         4
703#define WRITEDISABLE_GREEN                       2
704#define WRITEDISABLE_BLUE                        1
705   uint32_t                             SurfaceFormat;
706   uint32_t                             DataReturnFormat;
707#define DATA_RETURN_FLOAT32                      0
708#define DATA_RETURN_S114                         1
709   uint32_t                             SurfaceType;
710#define SURFTYPE_1D                              0
711#define SURFTYPE_2D                              1
712#define SURFTYPE_3D                              2
713#define SURFTYPE_CUBE                            3
714#define SURFTYPE_BUFFER                          4
715#define SURFTYPE_NULL                            7
716   __gen_address_type                   SurfaceBaseAddress;
717   uint32_t                             RenderTargetRotation;
718#define RTROTATE_0DEG                            0
719#define RTROTATE_90DEG                           1
720#define RTROTATE_270DEG                          3
721   uint32_t                             MIPCountLOD;
722   uint32_t                             Width;
723   uint32_t                             Height;
724   uint32_t                             TileWalk;
725#define TILEWALK_XMAJOR                          0
726#define TILEWALK_YMAJOR                          1
727   uint32_t                             TiledSurface;
728   uint32_t                             SurfacePitch;
729   uint32_t                             Depth;
730   uint32_t                             RenderTargetViewExtent;
731   uint32_t                             MinimumArrayElement;
732   uint32_t                             SurfaceMinLOD;
733   uint32_t                             YOffset;
734   uint32_t                             XOffset;
735};
736
737static inline __attribute__((always_inline)) void
738GFX5_RENDER_SURFACE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
739                               __attribute__((unused)) void * restrict dst,
740                               __attribute__((unused)) const struct GFX5_RENDER_SURFACE_STATE * restrict values)
741{
742   uint32_t * restrict dw = (uint32_t * restrict) dst;
743
744   dw[0] =
745      __gen_uint(values->CubeFaceEnablePositiveZ, 0, 0) |
746      __gen_uint(values->CubeFaceEnableNegativeZ, 1, 1) |
747      __gen_uint(values->CubeFaceEnablePositiveY, 2, 2) |
748      __gen_uint(values->CubeFaceEnableNegativeY, 3, 3) |
749      __gen_uint(values->CubeFaceEnablePositiveX, 4, 4) |
750      __gen_uint(values->CubeFaceEnableNegativeX, 5, 5) |
751      __gen_uint(values->MediaBoundaryPixelMode, 6, 7) |
752      __gen_uint(values->RenderCacheReadWriteMode, 8, 8) |
753      __gen_uint(values->CubeMapCornerMode, 9, 9) |
754      __gen_uint(values->MIPMapLayoutMode, 10, 10) |
755      __gen_uint(values->VerticalLineStrideOffset, 11, 11) |
756      __gen_uint(values->VerticalLineStride, 12, 12) |
757      __gen_uint(values->ColorBlendEnable, 13, 13) |
758      __gen_uint(values->ColorBufferComponentWriteDisables, 14, 17) |
759      __gen_uint(values->SurfaceFormat, 18, 26) |
760      __gen_uint(values->DataReturnFormat, 27, 27) |
761      __gen_uint(values->SurfaceType, 29, 31);
762
763   dw[1] = __gen_address(data, &dw[1], values->SurfaceBaseAddress, 0, 0, 31);
764
765   dw[2] =
766      __gen_uint(values->RenderTargetRotation, 0, 1) |
767      __gen_uint(values->MIPCountLOD, 2, 5) |
768      __gen_uint(values->Width, 6, 18) |
769      __gen_uint(values->Height, 19, 31);
770
771   dw[3] =
772      __gen_uint(values->TileWalk, 0, 0) |
773      __gen_uint(values->TiledSurface, 1, 1) |
774      __gen_uint(values->SurfacePitch, 3, 19) |
775      __gen_uint(values->Depth, 21, 31);
776
777   dw[4] =
778      __gen_uint(values->RenderTargetViewExtent, 8, 16) |
779      __gen_uint(values->MinimumArrayElement, 17, 27) |
780      __gen_uint(values->SurfaceMinLOD, 28, 31);
781
782   dw[5] =
783      __gen_uint(values->YOffset, 20, 23) |
784      __gen_uint(values->XOffset, 25, 31);
785}
786
787#define GFX5_SAMPLER_BORDER_COLOR_STATE_length     12
788struct GFX5_SAMPLER_BORDER_COLOR_STATE {
789   uint32_t                             BorderColorUnormRed;
790   uint32_t                             BorderColorUnormGreen;
791   uint32_t                             BorderColorUnormBlue;
792   uint32_t                             BorderColorUnormAlpha;
793   float                                BorderColorFloatRed;
794   float                                BorderColorFloatGreen;
795   float                                BorderColorFloatBlue;
796   float                                BorderColorFloatAlpha;
797   uint32_t                             BorderColorFloat16Red;
798   uint32_t                             BorderColorFloat16Green;
799   uint32_t                             BorderColorFloat16Blue;
800   uint32_t                             BorderColorFloat16Alpha;
801   uint32_t                             BorderColorUnorm16Red;
802   uint32_t                             BorderColorUnorm16Green;
803   uint32_t                             BorderColorUnorm16Blue;
804   uint32_t                             BorderColorUnorm16Alpha;
805   int32_t                              BorderColorSnorm16Red;
806   int32_t                              BorderColorSnorm16Green;
807   int32_t                              BorderColorSnorm16Blue;
808   int32_t                              BorderColorSnorm16Alpha;
809   int32_t                              BorderColorSnorm8Red;
810   int32_t                              BorderColorSnorm8Green;
811   int32_t                              BorderColorSnorm8Blue;
812   int32_t                              BorderColorSnorm8Alpha;
813};
814
815static inline __attribute__((always_inline)) void
816GFX5_SAMPLER_BORDER_COLOR_STATE_pack(__attribute__((unused)) __gen_user_data *data,
817                                     __attribute__((unused)) void * restrict dst,
818                                     __attribute__((unused)) const struct GFX5_SAMPLER_BORDER_COLOR_STATE * restrict values)
819{
820   uint32_t * restrict dw = (uint32_t * restrict) dst;
821
822   dw[0] =
823      __gen_uint(values->BorderColorUnormRed, 0, 7) |
824      __gen_uint(values->BorderColorUnormGreen, 8, 15) |
825      __gen_uint(values->BorderColorUnormBlue, 16, 23) |
826      __gen_uint(values->BorderColorUnormAlpha, 24, 31);
827
828   dw[1] =
829      __gen_float(values->BorderColorFloatRed);
830
831   dw[2] =
832      __gen_float(values->BorderColorFloatGreen);
833
834   dw[3] =
835      __gen_float(values->BorderColorFloatBlue);
836
837   dw[4] =
838      __gen_float(values->BorderColorFloatAlpha);
839
840   dw[5] =
841      __gen_uint(values->BorderColorFloat16Red, 0, 15) |
842      __gen_uint(values->BorderColorFloat16Green, 16, 31);
843
844   dw[6] =
845      __gen_uint(values->BorderColorFloat16Blue, 0, 15) |
846      __gen_uint(values->BorderColorFloat16Alpha, 16, 31);
847
848   dw[7] =
849      __gen_uint(values->BorderColorUnorm16Red, 0, 15) |
850      __gen_uint(values->BorderColorUnorm16Green, 16, 31);
851
852   dw[8] =
853      __gen_uint(values->BorderColorUnorm16Blue, 0, 15) |
854      __gen_uint(values->BorderColorUnorm16Alpha, 16, 31);
855
856   dw[9] =
857      __gen_sint(values->BorderColorSnorm16Red, 0, 15) |
858      __gen_sint(values->BorderColorSnorm16Green, 16, 31);
859
860   dw[10] =
861      __gen_sint(values->BorderColorSnorm16Blue, 0, 15) |
862      __gen_sint(values->BorderColorSnorm16Alpha, 16, 31);
863
864   dw[11] =
865      __gen_sint(values->BorderColorSnorm8Red, 0, 7) |
866      __gen_sint(values->BorderColorSnorm8Green, 8, 15) |
867      __gen_sint(values->BorderColorSnorm8Blue, 16, 23) |
868      __gen_sint(values->BorderColorSnorm8Alpha, 24, 31);
869}
870
871#define GFX5_SAMPLER_STATE_length              4
872struct GFX5_SAMPLER_STATE {
873   uint32_t                             ShadowFunction;
874#define PREFILTEROP_ALWAYS                       0
875#define PREFILTEROP_NEVER                        1
876#define PREFILTEROP_LESS                         2
877#define PREFILTEROP_EQUAL                        3
878#define PREFILTEROP_LEQUAL                       4
879#define PREFILTEROP_GREATER                      5
880#define PREFILTEROP_NOTEQUAL                     6
881#define PREFILTEROP_GEQUAL                       7
882   float                                TextureLODBias;
883   uint32_t                             MinModeFilter;
884   uint32_t                             MagModeFilter;
885#define MAPFILTER_NEAREST                        0
886#define MAPFILTER_LINEAR                         1
887#define MAPFILTER_ANISOTROPIC                    2
888#define MAPFILTER_MONO                           6
889   uint32_t                             MipModeFilter;
890#define MIPFILTER_NONE                           0
891#define MIPFILTER_NEAREST                        1
892#define MIPFILTER_LINEAR                         3
893   float                                BaseMipLevel;
894   bool                                 LODPreClampEnable;
895   bool                                 SamplerDisable;
896   enum GFX5_Texture_Coordinate_Mode    TCZAddressControlMode;
897   enum GFX5_Texture_Coordinate_Mode    TCYAddressControlMode;
898   enum GFX5_Texture_Coordinate_Mode    TCXAddressControlMode;
899   uint32_t                             CubeSurfaceControlMode;
900#define CUBECTRLMODE_PROGRAMMED                  0
901#define CUBECTRLMODE_OVERRIDE                    1
902   float                                MaxLOD;
903   float                                MinLOD;
904   __gen_address_type                   BorderColorPointer;
905   bool                                 RAddressMinFilterRoundingEnable;
906   bool                                 RAddressMagFilterRoundingEnable;
907   bool                                 VAddressMinFilterRoundingEnable;
908   bool                                 VAddressMagFilterRoundingEnable;
909   bool                                 UAddressMinFilterRoundingEnable;
910   bool                                 UAddressMagFilterRoundingEnable;
911   uint32_t                             MaximumAnisotropy;
912#define RATIO21                                  0
913#define RATIO41                                  1
914#define RATIO61                                  2
915#define RATIO81                                  3
916#define RATIO101                                 4
917#define RATIO121                                 5
918#define RATIO141                                 6
919#define RATIO161                                 7
920   uint32_t                             ChromaKeyMode;
921#define KEYFILTER_KILL_ON_ANY_MATCH              0
922#define KEYFILTER_REPLACE_BLACK                  1
923   uint32_t                             ChromaKeyIndex;
924   bool                                 ChromaKeyEnable;
925   uint32_t                             MonochromeFilterWidth;
926   uint32_t                             MonochromeFilterHeight;
927};
928
929static inline __attribute__((always_inline)) void
930GFX5_SAMPLER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
931                        __attribute__((unused)) void * restrict dst,
932                        __attribute__((unused)) const struct GFX5_SAMPLER_STATE * restrict values)
933{
934   uint32_t * restrict dw = (uint32_t * restrict) dst;
935
936   dw[0] =
937      __gen_uint(values->ShadowFunction, 0, 2) |
938      __gen_sfixed(values->TextureLODBias, 3, 13, 6) |
939      __gen_uint(values->MinModeFilter, 14, 16) |
940      __gen_uint(values->MagModeFilter, 17, 19) |
941      __gen_uint(values->MipModeFilter, 20, 21) |
942      __gen_ufixed(values->BaseMipLevel, 22, 26, 1) |
943      __gen_uint(values->LODPreClampEnable, 28, 28) |
944      __gen_uint(values->SamplerDisable, 31, 31);
945
946   dw[1] =
947      __gen_uint(values->TCZAddressControlMode, 0, 2) |
948      __gen_uint(values->TCYAddressControlMode, 3, 5) |
949      __gen_uint(values->TCXAddressControlMode, 6, 8) |
950      __gen_uint(values->CubeSurfaceControlMode, 9, 9) |
951      __gen_ufixed(values->MaxLOD, 12, 21, 6) |
952      __gen_ufixed(values->MinLOD, 22, 31, 6);
953
954   dw[2] = __gen_address(data, &dw[2], values->BorderColorPointer, 0, 5, 31);
955
956   dw[3] =
957      __gen_uint(values->RAddressMinFilterRoundingEnable, 13, 13) |
958      __gen_uint(values->RAddressMagFilterRoundingEnable, 14, 14) |
959      __gen_uint(values->VAddressMinFilterRoundingEnable, 15, 15) |
960      __gen_uint(values->VAddressMagFilterRoundingEnable, 16, 16) |
961      __gen_uint(values->UAddressMinFilterRoundingEnable, 17, 17) |
962      __gen_uint(values->UAddressMagFilterRoundingEnable, 18, 18) |
963      __gen_uint(values->MaximumAnisotropy, 19, 21) |
964      __gen_uint(values->ChromaKeyMode, 22, 22) |
965      __gen_uint(values->ChromaKeyIndex, 23, 24) |
966      __gen_uint(values->ChromaKeyEnable, 25, 25) |
967      __gen_uint(values->MonochromeFilterWidth, 26, 28) |
968      __gen_uint(values->MonochromeFilterHeight, 29, 31);
969}
970
971#define GFX5_SCISSOR_RECT_length               2
972struct GFX5_SCISSOR_RECT {
973   uint32_t                             ScissorRectangleXMin;
974   uint32_t                             ScissorRectangleYMin;
975   uint32_t                             ScissorRectangleXMax;
976   uint32_t                             ScissorRectangleYMax;
977};
978
979static inline __attribute__((always_inline)) void
980GFX5_SCISSOR_RECT_pack(__attribute__((unused)) __gen_user_data *data,
981                       __attribute__((unused)) void * restrict dst,
982                       __attribute__((unused)) const struct GFX5_SCISSOR_RECT * restrict values)
983{
984   uint32_t * restrict dw = (uint32_t * restrict) dst;
985
986   dw[0] =
987      __gen_uint(values->ScissorRectangleXMin, 0, 15) |
988      __gen_uint(values->ScissorRectangleYMin, 16, 31);
989
990   dw[1] =
991      __gen_uint(values->ScissorRectangleXMax, 0, 15) |
992      __gen_uint(values->ScissorRectangleYMax, 16, 31);
993}
994
995#define GFX5_SF_STATE_length                   8
996struct GFX5_SF_STATE {
997   uint32_t                             GRFRegisterCount;
998   uint64_t                             KernelStartPointer;
999   bool                                 SoftwareExceptionEnable;
1000   bool                                 MaskStackExceptionEnable;
1001   bool                                 IllegalOpcodeExceptionEnable;
1002   uint32_t                             FloatingPointMode;
1003#define FLOATING_POINT_MODE_IEEE754              0
1004#define FLOATING_POINT_MODE_Alternate            1
1005   uint32_t                             ThreadPriority;
1006#define NormalPriority                           0
1007#define HighPriority                             1
1008   uint32_t                             BindingTableEntryCount;
1009   bool                                 SingleProgramFlow;
1010   uint32_t                             PerThreadScratchSpace;
1011   __gen_address_type                   ScratchSpaceBasePointer;
1012   uint32_t                             DispatchGRFStartRegisterForURBData;
1013   uint32_t                             VertexURBEntryReadOffset;
1014   uint32_t                             VertexURBEntryReadLength;
1015   uint32_t                             ConstantURBEntryReadOffset;
1016   uint32_t                             ConstantURBEntryReadLength;
1017   uint32_t                             NumberofURBEntries;
1018   uint32_t                             URBEntryAllocationSize;
1019   uint32_t                             MaximumNumberofThreads;
1020   uint32_t                             FrontWinding;
1021#define FRONTWINDING_CW                          0
1022#define FRONTWINDING_CCW                         1
1023   bool                                 ViewportTransformEnable;
1024   __gen_address_type                   SetupViewportStateOffset;
1025   float                                DestinationOriginVerticalBias;
1026   float                                DestinationOriginHorizontalBias;
1027   bool                                 ScissorRectangleEnable;
1028   bool                                 _2x2PixelTriangleFilterDisable;
1029   bool                                 ZeroPixelTriangleFilterDisable;
1030   uint32_t                             PointRasterizationRule;
1031#define RASTRULE_UPPER_LEFT                      0
1032#define RASTRULE_UPPER_RIGHT                     1
1033   uint32_t                             LineEndCapAntialiasingRegionWidth;
1034#define _05pixels                                0
1035#define _10pixels                                1
1036#define _20pixels                                2
1037#define _40pixels                                3
1038   float                                LineWidth;
1039   bool                                 FastScissorClipDisable;
1040   uint32_t                             CullMode;
1041#define CULLMODE_BOTH                            0
1042#define CULLMODE_NONE                            1
1043#define CULLMODE_FRONT                           2
1044#define CULLMODE_BACK                            3
1045   bool                                 AntialiasingEnable;
1046   float                                PointWidth;
1047   uint32_t                             PointWidthSource;
1048#define Vertex                                   0
1049#define State                                    1
1050   uint32_t                             VertexSubPixelPrecisionSelect;
1051#define _8SubPixelPrecisionBits                  0
1052#define _4SubPixelPrecisionBits                  1
1053   bool                                 SpritePointEnable;
1054   uint32_t                             AALineDistanceMode;
1055#define AALINEDISTANCE_MANHATTAN                 0
1056#define AALINEDISTANCE_TRUE                      1
1057   uint32_t                             TriangleFanProvokingVertexSelect;
1058#define Vertex0                                  0
1059#define Vertex1                                  1
1060#define Vertex2                                  2
1061   uint32_t                             LineStripListProvokingVertexSelect;
1062#define Vertex0                                  0
1063#define Vertex1                                  1
1064   uint32_t                             TriangleStripListProvokingVertexSelect;
1065#define Vertex0                                  0
1066#define Vertex1                                  1
1067#define Vertex2                                  2
1068   bool                                 LastPixelEnable;
1069};
1070
1071static inline __attribute__((always_inline)) void
1072GFX5_SF_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1073                   __attribute__((unused)) void * restrict dst,
1074                   __attribute__((unused)) const struct GFX5_SF_STATE * restrict values)
1075{
1076   uint32_t * restrict dw = (uint32_t * restrict) dst;
1077
1078   dw[0] =
1079      __gen_uint(values->GRFRegisterCount, 1, 3) |
1080      __gen_offset(values->KernelStartPointer, 6, 31);
1081
1082   dw[1] =
1083      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
1084      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
1085      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
1086      __gen_uint(values->FloatingPointMode, 16, 16) |
1087      __gen_uint(values->ThreadPriority, 17, 17) |
1088      __gen_uint(values->BindingTableEntryCount, 18, 25) |
1089      __gen_uint(values->SingleProgramFlow, 31, 31);
1090
1091   const uint32_t v2 =
1092      __gen_uint(values->PerThreadScratchSpace, 0, 3);
1093   dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31);
1094
1095   dw[3] =
1096      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
1097      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
1098      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
1099      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
1100      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
1101
1102   dw[4] =
1103      __gen_uint(values->NumberofURBEntries, 11, 18) |
1104      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
1105      __gen_uint(values->MaximumNumberofThreads, 25, 30);
1106
1107   const uint32_t v5 =
1108      __gen_uint(values->FrontWinding, 0, 0) |
1109      __gen_uint(values->ViewportTransformEnable, 1, 1);
1110   dw[5] = __gen_address(data, &dw[5], values->SetupViewportStateOffset, v5, 5, 31);
1111
1112   dw[6] =
1113      __gen_ufixed(values->DestinationOriginVerticalBias, 9, 12, 4) |
1114      __gen_ufixed(values->DestinationOriginHorizontalBias, 13, 16, 4) |
1115      __gen_uint(values->ScissorRectangleEnable, 17, 17) |
1116      __gen_uint(values->_2x2PixelTriangleFilterDisable, 18, 18) |
1117      __gen_uint(values->ZeroPixelTriangleFilterDisable, 19, 19) |
1118      __gen_uint(values->PointRasterizationRule, 20, 21) |
1119      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 22, 23) |
1120      __gen_ufixed(values->LineWidth, 24, 27, 1) |
1121      __gen_uint(values->FastScissorClipDisable, 28, 28) |
1122      __gen_uint(values->CullMode, 29, 30) |
1123      __gen_uint(values->AntialiasingEnable, 31, 31);
1124
1125   dw[7] =
1126      __gen_ufixed(values->PointWidth, 0, 10, 3) |
1127      __gen_uint(values->PointWidthSource, 11, 11) |
1128      __gen_uint(values->VertexSubPixelPrecisionSelect, 12, 12) |
1129      __gen_uint(values->SpritePointEnable, 13, 13) |
1130      __gen_uint(values->AALineDistanceMode, 14, 14) |
1131      __gen_uint(values->TriangleFanProvokingVertexSelect, 25, 26) |
1132      __gen_uint(values->LineStripListProvokingVertexSelect, 27, 28) |
1133      __gen_uint(values->TriangleStripListProvokingVertexSelect, 29, 30) |
1134      __gen_uint(values->LastPixelEnable, 31, 31);
1135}
1136
1137#define GFX5_SF_VIEWPORT_length                8
1138struct GFX5_SF_VIEWPORT {
1139   float                                ViewportMatrixElementm00;
1140   float                                ViewportMatrixElementm11;
1141   float                                ViewportMatrixElementm22;
1142   float                                ViewportMatrixElementm30;
1143   float                                ViewportMatrixElementm31;
1144   float                                ViewportMatrixElementm32;
1145   struct GFX5_SCISSOR_RECT             ScissorRectangle;
1146};
1147
1148static inline __attribute__((always_inline)) void
1149GFX5_SF_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
1150                      __attribute__((unused)) void * restrict dst,
1151                      __attribute__((unused)) const struct GFX5_SF_VIEWPORT * restrict values)
1152{
1153   uint32_t * restrict dw = (uint32_t * restrict) dst;
1154
1155   dw[0] =
1156      __gen_float(values->ViewportMatrixElementm00);
1157
1158   dw[1] =
1159      __gen_float(values->ViewportMatrixElementm11);
1160
1161   dw[2] =
1162      __gen_float(values->ViewportMatrixElementm22);
1163
1164   dw[3] =
1165      __gen_float(values->ViewportMatrixElementm30);
1166
1167   dw[4] =
1168      __gen_float(values->ViewportMatrixElementm31);
1169
1170   dw[5] =
1171      __gen_float(values->ViewportMatrixElementm32);
1172
1173   GFX5_SCISSOR_RECT_pack(data, &dw[6], &values->ScissorRectangle);
1174}
1175
1176#define GFX5_VERTEX_BUFFER_STATE_length        4
1177struct GFX5_VERTEX_BUFFER_STATE {
1178   uint32_t                             BufferPitch;
1179   bool                                 NullVertexBuffer;
1180   uint32_t                             BufferAccessType;
1181#define VERTEXDATA                               0
1182#define INSTANCEDATA                             1
1183   uint32_t                             VertexBufferIndex;
1184   __gen_address_type                   BufferStartingAddress;
1185   __gen_address_type                   EndAddress;
1186   uint32_t                             InstanceDataStepRate;
1187};
1188
1189static inline __attribute__((always_inline)) void
1190GFX5_VERTEX_BUFFER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1191                              __attribute__((unused)) void * restrict dst,
1192                              __attribute__((unused)) const struct GFX5_VERTEX_BUFFER_STATE * restrict values)
1193{
1194   uint32_t * restrict dw = (uint32_t * restrict) dst;
1195
1196   dw[0] =
1197      __gen_uint(values->BufferPitch, 0, 11) |
1198      __gen_uint(values->NullVertexBuffer, 13, 13) |
1199      __gen_uint(values->BufferAccessType, 26, 26) |
1200      __gen_uint(values->VertexBufferIndex, 27, 31);
1201
1202   dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, 0, 0, 31);
1203
1204   dw[2] = __gen_address(data, &dw[2], values->EndAddress, 0, 0, 31);
1205
1206   dw[3] =
1207      __gen_uint(values->InstanceDataStepRate, 0, 31);
1208}
1209
1210#define GFX5_VERTEX_ELEMENT_STATE_length       2
1211struct GFX5_VERTEX_ELEMENT_STATE {
1212   uint32_t                             SourceElementOffset;
1213   uint32_t                             SourceElementFormat;
1214   bool                                 Valid;
1215   uint32_t                             VertexBufferIndex;
1216   uint32_t                             DestinationElementOffset;
1217   enum GFX5_3D_Vertex_Component_Control Component3Control;
1218   enum GFX5_3D_Vertex_Component_Control Component2Control;
1219   enum GFX5_3D_Vertex_Component_Control Component1Control;
1220   enum GFX5_3D_Vertex_Component_Control Component0Control;
1221};
1222
1223static inline __attribute__((always_inline)) void
1224GFX5_VERTEX_ELEMENT_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1225                               __attribute__((unused)) void * restrict dst,
1226                               __attribute__((unused)) const struct GFX5_VERTEX_ELEMENT_STATE * restrict values)
1227{
1228   uint32_t * restrict dw = (uint32_t * restrict) dst;
1229
1230   dw[0] =
1231      __gen_uint(values->SourceElementOffset, 0, 10) |
1232      __gen_uint(values->SourceElementFormat, 16, 24) |
1233      __gen_uint(values->Valid, 26, 26) |
1234      __gen_uint(values->VertexBufferIndex, 27, 31);
1235
1236   dw[1] =
1237      __gen_uint(values->DestinationElementOffset, 0, 7) |
1238      __gen_uint(values->Component3Control, 16, 18) |
1239      __gen_uint(values->Component2Control, 20, 22) |
1240      __gen_uint(values->Component1Control, 24, 26) |
1241      __gen_uint(values->Component0Control, 28, 30);
1242}
1243
1244#define GFX5_VS_STATE_length                   7
1245struct GFX5_VS_STATE {
1246   uint32_t                             GRFRegisterCount;
1247   uint64_t                             KernelStartPointer;
1248   bool                                 SoftwareExceptionEnable;
1249   bool                                 MaskStackExceptionEnable;
1250   bool                                 IllegalOpcodeExceptionEnable;
1251   uint32_t                             FloatingPointMode;
1252#define FLOATING_POINT_MODE_IEEE754              0
1253#define FLOATING_POINT_MODE_Alternate            1
1254   uint32_t                             ThreadPriority;
1255#define NormalPriority                           0
1256#define HighPriority                             1
1257   uint32_t                             BindingTableEntryCount;
1258   bool                                 SingleProgramFlow;
1259   uint32_t                             PerThreadScratchSpace;
1260   __gen_address_type                   ScratchSpaceBasePointer;
1261   uint32_t                             DispatchGRFStartRegisterForURBData;
1262   uint32_t                             VertexURBEntryReadOffset;
1263   uint32_t                             VertexURBEntryReadLength;
1264   uint32_t                             ConstantURBEntryReadOffset;
1265   uint32_t                             ConstantURBEntryReadLength;
1266   bool                                 StatisticsEnable;
1267   uint32_t                             NumberofURBEntries;
1268   uint32_t                             URBEntryAllocationSize;
1269   uint32_t                             MaximumNumberofThreads;
1270   uint32_t                             SamplerCount;
1271   __gen_address_type                   SamplerStatePointer;
1272   bool                                 Enable;
1273   bool                                 VertexCacheDisable;
1274};
1275
1276static inline __attribute__((always_inline)) void
1277GFX5_VS_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1278                   __attribute__((unused)) void * restrict dst,
1279                   __attribute__((unused)) const struct GFX5_VS_STATE * restrict values)
1280{
1281   uint32_t * restrict dw = (uint32_t * restrict) dst;
1282
1283   dw[0] =
1284      __gen_uint(values->GRFRegisterCount, 1, 3) |
1285      __gen_offset(values->KernelStartPointer, 6, 31);
1286
1287   dw[1] =
1288      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
1289      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
1290      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
1291      __gen_uint(values->FloatingPointMode, 16, 16) |
1292      __gen_uint(values->ThreadPriority, 17, 17) |
1293      __gen_uint(values->BindingTableEntryCount, 18, 25) |
1294      __gen_uint(values->SingleProgramFlow, 31, 31);
1295
1296   const uint32_t v2 =
1297      __gen_uint(values->PerThreadScratchSpace, 0, 3);
1298   dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31);
1299
1300   dw[3] =
1301      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
1302      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
1303      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
1304      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
1305      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
1306
1307   dw[4] =
1308      __gen_uint(values->StatisticsEnable, 10, 10) |
1309      __gen_uint(values->NumberofURBEntries, 11, 18) |
1310      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
1311      __gen_uint(values->MaximumNumberofThreads, 25, 30);
1312
1313   const uint32_t v5 =
1314      __gen_uint(values->SamplerCount, 0, 2);
1315   dw[5] = __gen_address(data, &dw[5], values->SamplerStatePointer, v5, 5, 31);
1316
1317   dw[6] =
1318      __gen_uint(values->Enable, 0, 0) |
1319      __gen_uint(values->VertexCacheDisable, 1, 1);
1320}
1321
1322#define GFX5_WM_STATE_length                  11
1323struct GFX5_WM_STATE {
1324   uint32_t                             GRFRegisterCount0;
1325   uint64_t                             KernelStartPointer0;
1326   bool                                 SoftwareExceptionEnable;
1327   bool                                 MaskStackExceptionEnable;
1328   bool                                 IllegalOpcodeExceptionEnable;
1329   uint32_t                             DepthCoefficientURBReadOffset;
1330   uint32_t                             FloatingPointMode;
1331#define FLOATING_POINT_MODE_IEEE754              0
1332#define FLOATING_POINT_MODE_Alternate            1
1333   uint32_t                             ThreadPriority;
1334#define High                                     1
1335   uint32_t                             BindingTableEntryCount;
1336   bool                                 SingleProgramFlow;
1337   uint32_t                             PerThreadScratchSpace;
1338   __gen_address_type                   ScratchSpaceBasePointer;
1339   uint32_t                             DispatchGRFStartRegisterForConstantSetupData0;
1340   uint32_t                             SetupURBEntryReadOffset;
1341   uint32_t                             SetupURBEntryReadLength;
1342   uint32_t                             ConstantURBEntryReadOffset;
1343   uint32_t                             ConstantURBEntryReadLength;
1344   bool                                 StatisticsEnable;
1345   uint32_t                             SamplerCount;
1346   __gen_address_type                   SamplerStatePointer;
1347   bool                                 _8PixelDispatchEnable;
1348   bool                                 _16PixelDispatchEnable;
1349   bool                                 _32PixelDispatchEnable;
1350   bool                                 Contiguous32PixelDispatchEnable;
1351   bool                                 Contiguous64PixelDispatchEnable;
1352   bool                                 FastSpanCoverageEnable;
1353   bool                                 DepthBufferClear;
1354   bool                                 DepthBufferResolveEnable;
1355   bool                                 HierarchicalDepthBufferResolveEnable;
1356   bool                                 LegacyGlobalDepthBiasEnable;
1357   bool                                 LineStippleEnable;
1358   bool                                 GlobalDepthOffsetEnable;
1359   bool                                 PolygonStippleEnable;
1360   uint32_t                             LineAntialiasingRegionWidth;
1361#define _05pixels                                0
1362#define _10pixels                                1
1363#define _20pixels                                2
1364#define _40pixels                                3
1365   uint32_t                             LineEndCapAntialiasingRegionWidth;
1366#define _05pixels                                0
1367#define _10pixels                                1
1368#define _20pixels                                2
1369#define _40pixels                                3
1370   bool                                 EarlyDepthTestEnable;
1371   bool                                 ThreadDispatchEnable;
1372   bool                                 PixelShaderUsesSourceDepth;
1373   bool                                 PixelShaderComputedDepth;
1374   bool                                 PixelShaderKillsPixel;
1375   bool                                 LegacyDiamondLineRasterization;
1376   uint32_t                             MaximumNumberofThreads;
1377   float                                GlobalDepthOffsetConstant;
1378   float                                GlobalDepthOffsetScale;
1379   uint32_t                             GRFRegisterCount1;
1380   uint64_t                             KernelStartPointer1;
1381   uint32_t                             GRFRegisterCount2;
1382   uint64_t                             KernelStartPointer2;
1383   uint32_t                             GRFRegisterCount3;
1384   uint64_t                             KernelStartPointer3;
1385};
1386
1387static inline __attribute__((always_inline)) void
1388GFX5_WM_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1389                   __attribute__((unused)) void * restrict dst,
1390                   __attribute__((unused)) const struct GFX5_WM_STATE * restrict values)
1391{
1392   uint32_t * restrict dw = (uint32_t * restrict) dst;
1393
1394   dw[0] =
1395      __gen_uint(values->GRFRegisterCount0, 1, 3) |
1396      __gen_offset(values->KernelStartPointer0, 6, 31);
1397
1398   dw[1] =
1399      __gen_uint(values->SoftwareExceptionEnable, 1, 1) |
1400      __gen_uint(values->MaskStackExceptionEnable, 2, 2) |
1401      __gen_uint(values->IllegalOpcodeExceptionEnable, 4, 4) |
1402      __gen_uint(values->DepthCoefficientURBReadOffset, 8, 13) |
1403      __gen_uint(values->FloatingPointMode, 16, 16) |
1404      __gen_uint(values->ThreadPriority, 17, 17) |
1405      __gen_uint(values->BindingTableEntryCount, 18, 25) |
1406      __gen_uint(values->SingleProgramFlow, 31, 31);
1407
1408   const uint32_t v2 =
1409      __gen_uint(values->PerThreadScratchSpace, 0, 3);
1410   dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31);
1411
1412   dw[3] =
1413      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData0, 0, 3) |
1414      __gen_uint(values->SetupURBEntryReadOffset, 4, 9) |
1415      __gen_uint(values->SetupURBEntryReadLength, 11, 16) |
1416      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
1417      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
1418
1419   const uint32_t v4 =
1420      __gen_uint(values->StatisticsEnable, 0, 0) |
1421      __gen_uint(values->SamplerCount, 2, 4);
1422   dw[4] = __gen_address(data, &dw[4], values->SamplerStatePointer, v4, 5, 31);
1423
1424   dw[5] =
1425      __gen_uint(values->_8PixelDispatchEnable, 0, 0) |
1426      __gen_uint(values->_16PixelDispatchEnable, 1, 1) |
1427      __gen_uint(values->_32PixelDispatchEnable, 2, 2) |
1428      __gen_uint(values->Contiguous32PixelDispatchEnable, 3, 3) |
1429      __gen_uint(values->Contiguous64PixelDispatchEnable, 4, 4) |
1430      __gen_uint(values->FastSpanCoverageEnable, 6, 6) |
1431      __gen_uint(values->DepthBufferClear, 7, 7) |
1432      __gen_uint(values->DepthBufferResolveEnable, 8, 8) |
1433      __gen_uint(values->HierarchicalDepthBufferResolveEnable, 9, 9) |
1434      __gen_uint(values->LegacyGlobalDepthBiasEnable, 10, 10) |
1435      __gen_uint(values->LineStippleEnable, 11, 11) |
1436      __gen_uint(values->GlobalDepthOffsetEnable, 12, 12) |
1437      __gen_uint(values->PolygonStippleEnable, 13, 13) |
1438      __gen_uint(values->LineAntialiasingRegionWidth, 14, 15) |
1439      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 16, 17) |
1440      __gen_uint(values->EarlyDepthTestEnable, 18, 18) |
1441      __gen_uint(values->ThreadDispatchEnable, 19, 19) |
1442      __gen_uint(values->PixelShaderUsesSourceDepth, 20, 20) |
1443      __gen_uint(values->PixelShaderComputedDepth, 21, 21) |
1444      __gen_uint(values->PixelShaderKillsPixel, 22, 22) |
1445      __gen_uint(values->LegacyDiamondLineRasterization, 23, 23) |
1446      __gen_uint(values->MaximumNumberofThreads, 25, 31);
1447
1448   dw[6] =
1449      __gen_float(values->GlobalDepthOffsetConstant);
1450
1451   dw[7] =
1452      __gen_float(values->GlobalDepthOffsetScale);
1453
1454   dw[8] =
1455      __gen_uint(values->GRFRegisterCount1, 1, 3) |
1456      __gen_offset(values->KernelStartPointer1, 6, 31);
1457
1458   dw[9] =
1459      __gen_uint(values->GRFRegisterCount2, 1, 3) |
1460      __gen_offset(values->KernelStartPointer2, 6, 31);
1461
1462   dw[10] =
1463      __gen_uint(values->GRFRegisterCount3, 1, 3) |
1464      __gen_offset(values->KernelStartPointer3, 6, 31);
1465}
1466
1467#define GFX5_3DPRIMITIVE_length                6
1468#define GFX5_3DPRIMITIVE_length_bias           2
1469#define GFX5_3DPRIMITIVE_header                 \
1470   .DWordLength                         =      4,  \
1471   ._3DCommandSubOpcode                 =      0,  \
1472   ._3DCommandOpcode                    =      3,  \
1473   .CommandSubType                      =      3,  \
1474   .CommandType                         =      3
1475
1476struct GFX5_3DPRIMITIVE {
1477   uint32_t                             DWordLength;
1478   uint32_t                             IndirectVertexCount;
1479   enum GFX5_3D_Prim_Topo_Type          PrimitiveTopologyType;
1480   uint32_t                             VertexAccessType;
1481#define SEQUENTIAL                               0
1482#define RANDOM                                   1
1483   uint32_t                             _3DCommandSubOpcode;
1484   uint32_t                             _3DCommandOpcode;
1485   uint32_t                             CommandSubType;
1486   uint32_t                             CommandType;
1487   uint32_t                             VertexCountPerInstance;
1488   uint32_t                             StartVertexLocation;
1489   uint32_t                             InstanceCount;
1490   uint32_t                             StartInstanceLocation;
1491   int32_t                              BaseVertexLocation;
1492};
1493
1494static inline __attribute__((always_inline)) void
1495GFX5_3DPRIMITIVE_pack(__attribute__((unused)) __gen_user_data *data,
1496                      __attribute__((unused)) void * restrict dst,
1497                      __attribute__((unused)) const struct GFX5_3DPRIMITIVE * restrict values)
1498{
1499   uint32_t * restrict dw = (uint32_t * restrict) dst;
1500
1501   dw[0] =
1502      __gen_uint(values->DWordLength, 0, 7) |
1503      __gen_uint(values->IndirectVertexCount, 9, 9) |
1504      __gen_uint(values->PrimitiveTopologyType, 10, 14) |
1505      __gen_uint(values->VertexAccessType, 15, 15) |
1506      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1507      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1508      __gen_uint(values->CommandSubType, 27, 28) |
1509      __gen_uint(values->CommandType, 29, 31);
1510
1511   dw[1] =
1512      __gen_uint(values->VertexCountPerInstance, 0, 31);
1513
1514   dw[2] =
1515      __gen_uint(values->StartVertexLocation, 0, 31);
1516
1517   dw[3] =
1518      __gen_uint(values->InstanceCount, 0, 31);
1519
1520   dw[4] =
1521      __gen_uint(values->StartInstanceLocation, 0, 31);
1522
1523   dw[5] =
1524      __gen_sint(values->BaseVertexLocation, 0, 31);
1525}
1526
1527#define GFX5_3DSTATE_AA_LINE_PARAMETERS_length      3
1528#define GFX5_3DSTATE_AA_LINE_PARAMETERS_length_bias      2
1529#define GFX5_3DSTATE_AA_LINE_PARAMETERS_header  \
1530   .DWordLength                         =      1,  \
1531   ._3DCommandSubOpcode                 =     10,  \
1532   ._3DCommandOpcode                    =      1,  \
1533   .CommandSubType                      =      3,  \
1534   .CommandType                         =      3
1535
1536struct GFX5_3DSTATE_AA_LINE_PARAMETERS {
1537   uint32_t                             DWordLength;
1538   uint32_t                             _3DCommandSubOpcode;
1539   uint32_t                             _3DCommandOpcode;
1540   uint32_t                             CommandSubType;
1541   uint32_t                             CommandType;
1542   float                                AACoverageSlope;
1543   float                                AACoverageBias;
1544   float                                AACoverageEndCapSlope;
1545   float                                AACoverageEndCapBias;
1546};
1547
1548static inline __attribute__((always_inline)) void
1549GFX5_3DSTATE_AA_LINE_PARAMETERS_pack(__attribute__((unused)) __gen_user_data *data,
1550                                     __attribute__((unused)) void * restrict dst,
1551                                     __attribute__((unused)) const struct GFX5_3DSTATE_AA_LINE_PARAMETERS * restrict values)
1552{
1553   uint32_t * restrict dw = (uint32_t * restrict) dst;
1554
1555   dw[0] =
1556      __gen_uint(values->DWordLength, 0, 7) |
1557      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1558      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1559      __gen_uint(values->CommandSubType, 27, 28) |
1560      __gen_uint(values->CommandType, 29, 31);
1561
1562   dw[1] =
1563      __gen_ufixed(values->AACoverageSlope, 0, 7, 8) |
1564      __gen_ufixed(values->AACoverageBias, 16, 23, 8);
1565
1566   dw[2] =
1567      __gen_ufixed(values->AACoverageEndCapSlope, 0, 7, 8) |
1568      __gen_ufixed(values->AACoverageEndCapBias, 16, 23, 8);
1569}
1570
1571#define GFX5_3DSTATE_BINDING_TABLE_POINTERS_length      6
1572#define GFX5_3DSTATE_BINDING_TABLE_POINTERS_length_bias      2
1573#define GFX5_3DSTATE_BINDING_TABLE_POINTERS_header\
1574   .DWordLength                         =      4,  \
1575   ._3DCommandSubOpcode                 =      1,  \
1576   ._3DCommandOpcode                    =      0,  \
1577   .CommandSubType                      =      3,  \
1578   .CommandType                         =      3
1579
1580struct GFX5_3DSTATE_BINDING_TABLE_POINTERS {
1581   uint32_t                             DWordLength;
1582   uint32_t                             _3DCommandSubOpcode;
1583   uint32_t                             _3DCommandOpcode;
1584   uint32_t                             CommandSubType;
1585   uint32_t                             CommandType;
1586   uint64_t                             PointertoVSBindingTable;
1587   uint64_t                             PointertoGSBindingTable;
1588   uint64_t                             PointertoCLIPBindingTable;
1589   uint64_t                             PointertoSFBindingTable;
1590   uint64_t                             PointertoPSBindingTable;
1591};
1592
1593static inline __attribute__((always_inline)) void
1594GFX5_3DSTATE_BINDING_TABLE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
1595                                         __attribute__((unused)) void * restrict dst,
1596                                         __attribute__((unused)) const struct GFX5_3DSTATE_BINDING_TABLE_POINTERS * restrict values)
1597{
1598   uint32_t * restrict dw = (uint32_t * restrict) dst;
1599
1600   dw[0] =
1601      __gen_uint(values->DWordLength, 0, 7) |
1602      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1603      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1604      __gen_uint(values->CommandSubType, 27, 28) |
1605      __gen_uint(values->CommandType, 29, 31);
1606
1607   dw[1] =
1608      __gen_offset(values->PointertoVSBindingTable, 5, 31);
1609
1610   dw[2] =
1611      __gen_offset(values->PointertoGSBindingTable, 5, 31);
1612
1613   dw[3] =
1614      __gen_offset(values->PointertoCLIPBindingTable, 5, 31);
1615
1616   dw[4] =
1617      __gen_offset(values->PointertoSFBindingTable, 5, 31);
1618
1619   dw[5] =
1620      __gen_offset(values->PointertoPSBindingTable, 5, 31);
1621}
1622
1623#define GFX5_3DSTATE_CLEAR_PARAMS_length       2
1624#define GFX5_3DSTATE_CLEAR_PARAMS_length_bias      2
1625#define GFX5_3DSTATE_CLEAR_PARAMS_header        \
1626   .DWordLength                         =      0,  \
1627   ._3DCommandSubOpcode                 =     16,  \
1628   ._3DCommandOpcode                    =      1,  \
1629   .CommandSubType                      =      3,  \
1630   .CommandType                         =      3
1631
1632struct GFX5_3DSTATE_CLEAR_PARAMS {
1633   uint32_t                             DWordLength;
1634   bool                                 DepthClearValueValid;
1635   uint32_t                             _3DCommandSubOpcode;
1636   uint32_t                             _3DCommandOpcode;
1637   uint32_t                             CommandSubType;
1638   uint32_t                             CommandType;
1639   uint32_t                             DepthClearValue;
1640};
1641
1642static inline __attribute__((always_inline)) void
1643GFX5_3DSTATE_CLEAR_PARAMS_pack(__attribute__((unused)) __gen_user_data *data,
1644                               __attribute__((unused)) void * restrict dst,
1645                               __attribute__((unused)) const struct GFX5_3DSTATE_CLEAR_PARAMS * restrict values)
1646{
1647   uint32_t * restrict dw = (uint32_t * restrict) dst;
1648
1649   dw[0] =
1650      __gen_uint(values->DWordLength, 0, 7) |
1651      __gen_uint(values->DepthClearValueValid, 15, 15) |
1652      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1653      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1654      __gen_uint(values->CommandSubType, 27, 28) |
1655      __gen_uint(values->CommandType, 29, 31);
1656
1657   dw[1] =
1658      __gen_uint(values->DepthClearValue, 0, 31);
1659}
1660
1661#define GFX5_3DSTATE_CONSTANT_COLOR_length      5
1662#define GFX5_3DSTATE_CONSTANT_COLOR_length_bias      2
1663#define GFX5_3DSTATE_CONSTANT_COLOR_header      \
1664   .DWordLength                         =      3,  \
1665   ._3DCommandSubOpcode                 =      1,  \
1666   ._3DCommandOpcode                    =      1,  \
1667   .CommandSubType                      =      3,  \
1668   .CommandType                         =      3
1669
1670struct GFX5_3DSTATE_CONSTANT_COLOR {
1671   uint32_t                             DWordLength;
1672   uint32_t                             _3DCommandSubOpcode;
1673   uint32_t                             _3DCommandOpcode;
1674   uint32_t                             CommandSubType;
1675   uint32_t                             CommandType;
1676   float                                BlendConstantColorRed;
1677   float                                BlendConstantColorGreen;
1678   float                                BlendConstantColorBlue;
1679   float                                BlendConstantColorAlpha;
1680};
1681
1682static inline __attribute__((always_inline)) void
1683GFX5_3DSTATE_CONSTANT_COLOR_pack(__attribute__((unused)) __gen_user_data *data,
1684                                 __attribute__((unused)) void * restrict dst,
1685                                 __attribute__((unused)) const struct GFX5_3DSTATE_CONSTANT_COLOR * restrict values)
1686{
1687   uint32_t * restrict dw = (uint32_t * restrict) dst;
1688
1689   dw[0] =
1690      __gen_uint(values->DWordLength, 0, 7) |
1691      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1692      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1693      __gen_uint(values->CommandSubType, 27, 28) |
1694      __gen_uint(values->CommandType, 29, 31);
1695
1696   dw[1] =
1697      __gen_float(values->BlendConstantColorRed);
1698
1699   dw[2] =
1700      __gen_float(values->BlendConstantColorGreen);
1701
1702   dw[3] =
1703      __gen_float(values->BlendConstantColorBlue);
1704
1705   dw[4] =
1706      __gen_float(values->BlendConstantColorAlpha);
1707}
1708
1709#define GFX5_3DSTATE_DEPTH_BUFFER_length       6
1710#define GFX5_3DSTATE_DEPTH_BUFFER_length_bias      2
1711#define GFX5_3DSTATE_DEPTH_BUFFER_header        \
1712   .DWordLength                         =      4,  \
1713   ._3DCommandSubOpcode                 =      5,  \
1714   ._3DCommandOpcode                    =      1,  \
1715   .CommandSubType                      =      3,  \
1716   .CommandType                         =      3
1717
1718struct GFX5_3DSTATE_DEPTH_BUFFER {
1719   uint32_t                             DWordLength;
1720   uint32_t                             _3DCommandSubOpcode;
1721   uint32_t                             _3DCommandOpcode;
1722   uint32_t                             CommandSubType;
1723   uint32_t                             CommandType;
1724   uint32_t                             SurfacePitch;
1725   uint32_t                             SurfaceFormat;
1726#define D32_FLOAT_S8X24_UINT                     0
1727#define D32_FLOAT                                1
1728#define D24_UNORM_S8_UINT                        2
1729#define D24_UNORM_X8_UINT                        3
1730#define D16_UNORM                                5
1731   bool                                 SeparateStencilBufferEnable;
1732   bool                                 HierarchicalDepthBufferEnable;
1733   uint32_t                             SoftwareTiledRenderingMode;
1734#define NORMAL                                   0
1735#define STR1                                     1
1736#define STR2                                     3
1737   uint32_t                             TileWalk;
1738#define TILEWALK_YMAJOR                          1
1739   bool                                 TiledSurface;
1740   uint32_t                             SurfaceType;
1741#define SURFTYPE_1D                              0
1742#define SURFTYPE_2D                              1
1743#define SURFTYPE_3D                              2
1744#define SURFTYPE_CUBE                            3
1745#define SURFTYPE_NULL                            7
1746   __gen_address_type                   SurfaceBaseAddress;
1747   uint32_t                             MIPMapLayoutMode;
1748#define MIPLAYOUT_BELOW                          0
1749#define MIPLAYOUT_RIGHT                          1
1750   uint32_t                             LOD;
1751   uint32_t                             Width;
1752   uint32_t                             Height;
1753   uint32_t                             RenderTargetViewExtent;
1754   uint32_t                             MinimumArrayElement;
1755   uint32_t                             Depth;
1756   int32_t                              DepthCoordinateOffsetX;
1757   int32_t                              DepthCoordinateOffsetY;
1758};
1759
1760static inline __attribute__((always_inline)) void
1761GFX5_3DSTATE_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
1762                               __attribute__((unused)) void * restrict dst,
1763                               __attribute__((unused)) const struct GFX5_3DSTATE_DEPTH_BUFFER * restrict values)
1764{
1765   uint32_t * restrict dw = (uint32_t * restrict) dst;
1766
1767   dw[0] =
1768      __gen_uint(values->DWordLength, 0, 7) |
1769      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1770      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1771      __gen_uint(values->CommandSubType, 27, 28) |
1772      __gen_uint(values->CommandType, 29, 31);
1773
1774   dw[1] =
1775      __gen_uint(values->SurfacePitch, 0, 16) |
1776      __gen_uint(values->SurfaceFormat, 18, 20) |
1777      __gen_uint(values->SeparateStencilBufferEnable, 21, 21) |
1778      __gen_uint(values->HierarchicalDepthBufferEnable, 22, 22) |
1779      __gen_uint(values->SoftwareTiledRenderingMode, 23, 24) |
1780      __gen_uint(values->TileWalk, 26, 26) |
1781      __gen_uint(values->TiledSurface, 27, 27) |
1782      __gen_uint(values->SurfaceType, 29, 31);
1783
1784   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
1785
1786   dw[3] =
1787      __gen_uint(values->MIPMapLayoutMode, 1, 1) |
1788      __gen_uint(values->LOD, 2, 5) |
1789      __gen_uint(values->Width, 6, 18) |
1790      __gen_uint(values->Height, 19, 31);
1791
1792   dw[4] =
1793      __gen_uint(values->RenderTargetViewExtent, 1, 9) |
1794      __gen_uint(values->MinimumArrayElement, 10, 20) |
1795      __gen_uint(values->Depth, 21, 31);
1796
1797   dw[5] =
1798      __gen_sint(values->DepthCoordinateOffsetX, 0, 15) |
1799      __gen_sint(values->DepthCoordinateOffsetY, 16, 31);
1800}
1801
1802#define GFX5_3DSTATE_DRAWING_RECTANGLE_length      4
1803#define GFX5_3DSTATE_DRAWING_RECTANGLE_length_bias      2
1804#define GFX5_3DSTATE_DRAWING_RECTANGLE_header   \
1805   .DWordLength                         =      2,  \
1806   ._3DCommandSubOpcode                 =      0,  \
1807   ._3DCommandOpcode                    =      1,  \
1808   .CommandSubType                      =      3,  \
1809   .CommandType                         =      3
1810
1811struct GFX5_3DSTATE_DRAWING_RECTANGLE {
1812   uint32_t                             DWordLength;
1813   uint32_t                             _3DCommandSubOpcode;
1814   uint32_t                             _3DCommandOpcode;
1815   uint32_t                             CommandSubType;
1816   uint32_t                             CommandType;
1817   uint32_t                             ClippedDrawingRectangleXMin;
1818   uint32_t                             ClippedDrawingRectangleYMin;
1819   uint32_t                             ClippedDrawingRectangleXMax;
1820   uint32_t                             ClippedDrawingRectangleYMax;
1821   int32_t                              DrawingRectangleOriginX;
1822   int32_t                              DrawingRectangleOriginY;
1823};
1824
1825static inline __attribute__((always_inline)) void
1826GFX5_3DSTATE_DRAWING_RECTANGLE_pack(__attribute__((unused)) __gen_user_data *data,
1827                                    __attribute__((unused)) void * restrict dst,
1828                                    __attribute__((unused)) const struct GFX5_3DSTATE_DRAWING_RECTANGLE * restrict values)
1829{
1830   uint32_t * restrict dw = (uint32_t * restrict) dst;
1831
1832   dw[0] =
1833      __gen_uint(values->DWordLength, 0, 7) |
1834      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1835      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1836      __gen_uint(values->CommandSubType, 27, 28) |
1837      __gen_uint(values->CommandType, 29, 31);
1838
1839   dw[1] =
1840      __gen_uint(values->ClippedDrawingRectangleXMin, 0, 15) |
1841      __gen_uint(values->ClippedDrawingRectangleYMin, 16, 31);
1842
1843   dw[2] =
1844      __gen_uint(values->ClippedDrawingRectangleXMax, 0, 15) |
1845      __gen_uint(values->ClippedDrawingRectangleYMax, 16, 31);
1846
1847   dw[3] =
1848      __gen_sint(values->DrawingRectangleOriginX, 0, 15) |
1849      __gen_sint(values->DrawingRectangleOriginY, 16, 31);
1850}
1851
1852#define GFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length      2
1853#define GFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length_bias      2
1854#define GFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_header\
1855   .DWordLength                         =      0,  \
1856   ._3DCommandSubOpcode                 =      9,  \
1857   ._3DCommandOpcode                    =      1,  \
1858   .CommandSubType                      =      3,  \
1859   .CommandType                         =      3
1860
1861struct GFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP {
1862   uint32_t                             DWordLength;
1863   uint32_t                             _3DCommandSubOpcode;
1864   uint32_t                             _3DCommandOpcode;
1865   uint32_t                             CommandSubType;
1866   uint32_t                             CommandType;
1867   float                                GlobalDepthOffsetClamp;
1868};
1869
1870static inline __attribute__((always_inline)) void
1871GFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_pack(__attribute__((unused)) __gen_user_data *data,
1872                                            __attribute__((unused)) void * restrict dst,
1873                                            __attribute__((unused)) const struct GFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP * restrict values)
1874{
1875   uint32_t * restrict dw = (uint32_t * restrict) dst;
1876
1877   dw[0] =
1878      __gen_uint(values->DWordLength, 0, 7) |
1879      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1880      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1881      __gen_uint(values->CommandSubType, 27, 28) |
1882      __gen_uint(values->CommandType, 29, 31);
1883
1884   dw[1] =
1885      __gen_float(values->GlobalDepthOffsetClamp);
1886}
1887
1888#define GFX5_3DSTATE_HIER_DEPTH_BUFFER_length      3
1889#define GFX5_3DSTATE_HIER_DEPTH_BUFFER_length_bias      2
1890#define GFX5_3DSTATE_HIER_DEPTH_BUFFER_header   \
1891   .DWordLength                         =      1,  \
1892   ._3DCommandSubOpcode                 =     15,  \
1893   ._3DCommandOpcode                    =      1,  \
1894   .CommandSubType                      =      3,  \
1895   .CommandType                         =      3
1896
1897struct GFX5_3DSTATE_HIER_DEPTH_BUFFER {
1898   uint32_t                             DWordLength;
1899   uint32_t                             _3DCommandSubOpcode;
1900   uint32_t                             _3DCommandOpcode;
1901   uint32_t                             CommandSubType;
1902   uint32_t                             CommandType;
1903   uint32_t                             SurfacePitch;
1904   __gen_address_type                   SurfaceBaseAddress;
1905};
1906
1907static inline __attribute__((always_inline)) void
1908GFX5_3DSTATE_HIER_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
1909                                    __attribute__((unused)) void * restrict dst,
1910                                    __attribute__((unused)) const struct GFX5_3DSTATE_HIER_DEPTH_BUFFER * restrict values)
1911{
1912   uint32_t * restrict dw = (uint32_t * restrict) dst;
1913
1914   dw[0] =
1915      __gen_uint(values->DWordLength, 0, 7) |
1916      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1917      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1918      __gen_uint(values->CommandSubType, 27, 28) |
1919      __gen_uint(values->CommandType, 29, 31);
1920
1921   dw[1] =
1922      __gen_uint(values->SurfacePitch, 0, 16);
1923
1924   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
1925}
1926
1927#define GFX5_3DSTATE_INDEX_BUFFER_length       3
1928#define GFX5_3DSTATE_INDEX_BUFFER_length_bias      2
1929#define GFX5_3DSTATE_INDEX_BUFFER_header        \
1930   .DWordLength                         =      1,  \
1931   ._3DCommandSubOpcode                 =     10,  \
1932   ._3DCommandOpcode                    =      0,  \
1933   .CommandSubType                      =      3,  \
1934   .CommandType                         =      3
1935
1936struct GFX5_3DSTATE_INDEX_BUFFER {
1937   uint32_t                             DWordLength;
1938   uint32_t                             IndexFormat;
1939#define INDEX_BYTE                               0
1940#define INDEX_WORD                               1
1941#define INDEX_DWORD                              2
1942   bool                                 CutIndexEnable;
1943   uint32_t                             _3DCommandSubOpcode;
1944   uint32_t                             _3DCommandOpcode;
1945   uint32_t                             CommandSubType;
1946   uint32_t                             CommandType;
1947   __gen_address_type                   BufferStartingAddress;
1948   __gen_address_type                   BufferEndingAddress;
1949};
1950
1951static inline __attribute__((always_inline)) void
1952GFX5_3DSTATE_INDEX_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
1953                               __attribute__((unused)) void * restrict dst,
1954                               __attribute__((unused)) const struct GFX5_3DSTATE_INDEX_BUFFER * restrict values)
1955{
1956   uint32_t * restrict dw = (uint32_t * restrict) dst;
1957
1958   dw[0] =
1959      __gen_uint(values->DWordLength, 0, 7) |
1960      __gen_uint(values->IndexFormat, 8, 9) |
1961      __gen_uint(values->CutIndexEnable, 10, 10) |
1962      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1963      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1964      __gen_uint(values->CommandSubType, 27, 28) |
1965      __gen_uint(values->CommandType, 29, 31);
1966
1967   dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, 0, 0, 31);
1968
1969   dw[2] = __gen_address(data, &dw[2], values->BufferEndingAddress, 0, 0, 31);
1970}
1971
1972#define GFX5_3DSTATE_LINE_STIPPLE_length       3
1973#define GFX5_3DSTATE_LINE_STIPPLE_length_bias      2
1974#define GFX5_3DSTATE_LINE_STIPPLE_header        \
1975   .DWordLength                         =      1,  \
1976   ._3DCommandSubOpcode                 =      8,  \
1977   ._3DCommandOpcode                    =      1,  \
1978   .CommandSubType                      =      3,  \
1979   .CommandType                         =      3
1980
1981struct GFX5_3DSTATE_LINE_STIPPLE {
1982   uint32_t                             DWordLength;
1983   uint32_t                             _3DCommandSubOpcode;
1984   uint32_t                             _3DCommandOpcode;
1985   uint32_t                             CommandSubType;
1986   uint32_t                             CommandType;
1987   uint32_t                             LineStipplePattern;
1988   uint32_t                             CurrentStippleIndex;
1989   uint32_t                             CurrentRepeatCounter;
1990   bool                                 ModifyEnable;
1991   uint32_t                             LineStippleRepeatCount;
1992   float                                LineStippleInverseRepeatCount;
1993};
1994
1995static inline __attribute__((always_inline)) void
1996GFX5_3DSTATE_LINE_STIPPLE_pack(__attribute__((unused)) __gen_user_data *data,
1997                               __attribute__((unused)) void * restrict dst,
1998                               __attribute__((unused)) const struct GFX5_3DSTATE_LINE_STIPPLE * restrict values)
1999{
2000   uint32_t * restrict dw = (uint32_t * restrict) dst;
2001
2002   dw[0] =
2003      __gen_uint(values->DWordLength, 0, 7) |
2004      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2005      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2006      __gen_uint(values->CommandSubType, 27, 28) |
2007      __gen_uint(values->CommandType, 29, 31);
2008
2009   dw[1] =
2010      __gen_uint(values->LineStipplePattern, 0, 15) |
2011      __gen_uint(values->CurrentStippleIndex, 16, 19) |
2012      __gen_uint(values->CurrentRepeatCounter, 21, 29) |
2013      __gen_uint(values->ModifyEnable, 31, 31);
2014
2015   dw[2] =
2016      __gen_uint(values->LineStippleRepeatCount, 0, 8) |
2017      __gen_ufixed(values->LineStippleInverseRepeatCount, 16, 31, 13);
2018}
2019
2020#define GFX5_3DSTATE_PIPELINED_POINTERS_length      7
2021#define GFX5_3DSTATE_PIPELINED_POINTERS_length_bias      2
2022#define GFX5_3DSTATE_PIPELINED_POINTERS_header  \
2023   .DWordLength                         =      5,  \
2024   ._3DCommandSubOpcode                 =      0,  \
2025   ._3DCommandOpcode                    =      0,  \
2026   .CommandSubType                      =      3,  \
2027   .CommandType                         =      3
2028
2029struct GFX5_3DSTATE_PIPELINED_POINTERS {
2030   uint32_t                             DWordLength;
2031   uint32_t                             _3DCommandSubOpcode;
2032   uint32_t                             _3DCommandOpcode;
2033   uint32_t                             CommandSubType;
2034   uint32_t                             CommandType;
2035   __gen_address_type                   PointertoVSState;
2036   bool                                 GSEnable;
2037   __gen_address_type                   PointertoGSState;
2038   bool                                 ClipEnable;
2039   __gen_address_type                   PointertoCLIPState;
2040   __gen_address_type                   PointertoSFState;
2041   __gen_address_type                   PointertoWMState;
2042   __gen_address_type                   PointertoColorCalcState;
2043};
2044
2045static inline __attribute__((always_inline)) void
2046GFX5_3DSTATE_PIPELINED_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
2047                                     __attribute__((unused)) void * restrict dst,
2048                                     __attribute__((unused)) const struct GFX5_3DSTATE_PIPELINED_POINTERS * restrict values)
2049{
2050   uint32_t * restrict dw = (uint32_t * restrict) dst;
2051
2052   dw[0] =
2053      __gen_uint(values->DWordLength, 0, 7) |
2054      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2055      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2056      __gen_uint(values->CommandSubType, 27, 28) |
2057      __gen_uint(values->CommandType, 29, 31);
2058
2059   dw[1] = __gen_address(data, &dw[1], values->PointertoVSState, 0, 5, 31);
2060
2061   const uint32_t v2 =
2062      __gen_uint(values->GSEnable, 0, 0);
2063   dw[2] = __gen_address(data, &dw[2], values->PointertoGSState, v2, 5, 31);
2064
2065   const uint32_t v3 =
2066      __gen_uint(values->ClipEnable, 0, 0);
2067   dw[3] = __gen_address(data, &dw[3], values->PointertoCLIPState, v3, 5, 31);
2068
2069   dw[4] = __gen_address(data, &dw[4], values->PointertoSFState, 0, 5, 31);
2070
2071   dw[5] = __gen_address(data, &dw[5], values->PointertoWMState, 0, 5, 31);
2072
2073   dw[6] = __gen_address(data, &dw[6], values->PointertoColorCalcState, 0, 5, 31);
2074}
2075
2076#define GFX5_3DSTATE_POLY_STIPPLE_OFFSET_length      2
2077#define GFX5_3DSTATE_POLY_STIPPLE_OFFSET_length_bias      2
2078#define GFX5_3DSTATE_POLY_STIPPLE_OFFSET_header \
2079   .DWordLength                         =      0,  \
2080   ._3DCommandSubOpcode                 =      6,  \
2081   ._3DCommandOpcode                    =      1,  \
2082   .CommandSubType                      =      3,  \
2083   .CommandType                         =      3
2084
2085struct GFX5_3DSTATE_POLY_STIPPLE_OFFSET {
2086   uint32_t                             DWordLength;
2087   uint32_t                             _3DCommandSubOpcode;
2088   uint32_t                             _3DCommandOpcode;
2089   uint32_t                             CommandSubType;
2090   uint32_t                             CommandType;
2091   uint32_t                             PolygonStippleYOffset;
2092   uint32_t                             PolygonStippleXOffset;
2093};
2094
2095static inline __attribute__((always_inline)) void
2096GFX5_3DSTATE_POLY_STIPPLE_OFFSET_pack(__attribute__((unused)) __gen_user_data *data,
2097                                      __attribute__((unused)) void * restrict dst,
2098                                      __attribute__((unused)) const struct GFX5_3DSTATE_POLY_STIPPLE_OFFSET * restrict values)
2099{
2100   uint32_t * restrict dw = (uint32_t * restrict) dst;
2101
2102   dw[0] =
2103      __gen_uint(values->DWordLength, 0, 7) |
2104      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2105      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2106      __gen_uint(values->CommandSubType, 27, 28) |
2107      __gen_uint(values->CommandType, 29, 31);
2108
2109   dw[1] =
2110      __gen_uint(values->PolygonStippleYOffset, 0, 4) |
2111      __gen_uint(values->PolygonStippleXOffset, 8, 12);
2112}
2113
2114#define GFX5_3DSTATE_POLY_STIPPLE_PATTERN_length     33
2115#define GFX5_3DSTATE_POLY_STIPPLE_PATTERN_length_bias      2
2116#define GFX5_3DSTATE_POLY_STIPPLE_PATTERN_header\
2117   .DWordLength                         =     31,  \
2118   ._3DCommandSubOpcode                 =      7,  \
2119   ._3DCommandOpcode                    =      1,  \
2120   .CommandSubType                      =      3,  \
2121   .CommandType                         =      3
2122
2123struct GFX5_3DSTATE_POLY_STIPPLE_PATTERN {
2124   uint32_t                             DWordLength;
2125   uint32_t                             _3DCommandSubOpcode;
2126   uint32_t                             _3DCommandOpcode;
2127   uint32_t                             CommandSubType;
2128   uint32_t                             CommandType;
2129   uint32_t                             PatternRow[32];
2130};
2131
2132static inline __attribute__((always_inline)) void
2133GFX5_3DSTATE_POLY_STIPPLE_PATTERN_pack(__attribute__((unused)) __gen_user_data *data,
2134                                       __attribute__((unused)) void * restrict dst,
2135                                       __attribute__((unused)) const struct GFX5_3DSTATE_POLY_STIPPLE_PATTERN * restrict values)
2136{
2137   uint32_t * restrict dw = (uint32_t * restrict) dst;
2138
2139   dw[0] =
2140      __gen_uint(values->DWordLength, 0, 7) |
2141      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2142      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2143      __gen_uint(values->CommandSubType, 27, 28) |
2144      __gen_uint(values->CommandType, 29, 31);
2145
2146   dw[1] =
2147      __gen_uint(values->PatternRow[0], 0, 31);
2148
2149   dw[2] =
2150      __gen_uint(values->PatternRow[1], 0, 31);
2151
2152   dw[3] =
2153      __gen_uint(values->PatternRow[2], 0, 31);
2154
2155   dw[4] =
2156      __gen_uint(values->PatternRow[3], 0, 31);
2157
2158   dw[5] =
2159      __gen_uint(values->PatternRow[4], 0, 31);
2160
2161   dw[6] =
2162      __gen_uint(values->PatternRow[5], 0, 31);
2163
2164   dw[7] =
2165      __gen_uint(values->PatternRow[6], 0, 31);
2166
2167   dw[8] =
2168      __gen_uint(values->PatternRow[7], 0, 31);
2169
2170   dw[9] =
2171      __gen_uint(values->PatternRow[8], 0, 31);
2172
2173   dw[10] =
2174      __gen_uint(values->PatternRow[9], 0, 31);
2175
2176   dw[11] =
2177      __gen_uint(values->PatternRow[10], 0, 31);
2178
2179   dw[12] =
2180      __gen_uint(values->PatternRow[11], 0, 31);
2181
2182   dw[13] =
2183      __gen_uint(values->PatternRow[12], 0, 31);
2184
2185   dw[14] =
2186      __gen_uint(values->PatternRow[13], 0, 31);
2187
2188   dw[15] =
2189      __gen_uint(values->PatternRow[14], 0, 31);
2190
2191   dw[16] =
2192      __gen_uint(values->PatternRow[15], 0, 31);
2193
2194   dw[17] =
2195      __gen_uint(values->PatternRow[16], 0, 31);
2196
2197   dw[18] =
2198      __gen_uint(values->PatternRow[17], 0, 31);
2199
2200   dw[19] =
2201      __gen_uint(values->PatternRow[18], 0, 31);
2202
2203   dw[20] =
2204      __gen_uint(values->PatternRow[19], 0, 31);
2205
2206   dw[21] =
2207      __gen_uint(values->PatternRow[20], 0, 31);
2208
2209   dw[22] =
2210      __gen_uint(values->PatternRow[21], 0, 31);
2211
2212   dw[23] =
2213      __gen_uint(values->PatternRow[22], 0, 31);
2214
2215   dw[24] =
2216      __gen_uint(values->PatternRow[23], 0, 31);
2217
2218   dw[25] =
2219      __gen_uint(values->PatternRow[24], 0, 31);
2220
2221   dw[26] =
2222      __gen_uint(values->PatternRow[25], 0, 31);
2223
2224   dw[27] =
2225      __gen_uint(values->PatternRow[26], 0, 31);
2226
2227   dw[28] =
2228      __gen_uint(values->PatternRow[27], 0, 31);
2229
2230   dw[29] =
2231      __gen_uint(values->PatternRow[28], 0, 31);
2232
2233   dw[30] =
2234      __gen_uint(values->PatternRow[29], 0, 31);
2235
2236   dw[31] =
2237      __gen_uint(values->PatternRow[30], 0, 31);
2238
2239   dw[32] =
2240      __gen_uint(values->PatternRow[31], 0, 31);
2241}
2242
2243#define GFX5_3DSTATE_STENCIL_BUFFER_length      3
2244#define GFX5_3DSTATE_STENCIL_BUFFER_length_bias      2
2245#define GFX5_3DSTATE_STENCIL_BUFFER_header      \
2246   .DWordLength                         =      1,  \
2247   ._3DCommandSubOpcode                 =     14,  \
2248   ._3DCommandOpcode                    =      1,  \
2249   .CommandSubType                      =      3,  \
2250   .CommandType                         =      3
2251
2252struct GFX5_3DSTATE_STENCIL_BUFFER {
2253   uint32_t                             DWordLength;
2254   uint32_t                             _3DCommandSubOpcode;
2255   uint32_t                             _3DCommandOpcode;
2256   uint32_t                             CommandSubType;
2257   uint32_t                             CommandType;
2258   uint32_t                             SurfacePitch;
2259   __gen_address_type                   SurfaceBaseAddress;
2260};
2261
2262static inline __attribute__((always_inline)) void
2263GFX5_3DSTATE_STENCIL_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2264                                 __attribute__((unused)) void * restrict dst,
2265                                 __attribute__((unused)) const struct GFX5_3DSTATE_STENCIL_BUFFER * restrict values)
2266{
2267   uint32_t * restrict dw = (uint32_t * restrict) dst;
2268
2269   dw[0] =
2270      __gen_uint(values->DWordLength, 0, 7) |
2271      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2272      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2273      __gen_uint(values->CommandSubType, 27, 28) |
2274      __gen_uint(values->CommandType, 29, 31);
2275
2276   dw[1] =
2277      __gen_uint(values->SurfacePitch, 0, 16);
2278
2279   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
2280}
2281
2282#define GFX5_3DSTATE_VERTEX_BUFFERS_length_bias      2
2283#define GFX5_3DSTATE_VERTEX_BUFFERS_header      \
2284   .DWordLength                         =      3,  \
2285   ._3DCommandSubOpcode                 =      8,  \
2286   ._3DCommandOpcode                    =      0,  \
2287   .CommandSubType                      =      3,  \
2288   .CommandType                         =      3
2289
2290struct GFX5_3DSTATE_VERTEX_BUFFERS {
2291   uint32_t                             DWordLength;
2292   uint32_t                             _3DCommandSubOpcode;
2293   uint32_t                             _3DCommandOpcode;
2294   uint32_t                             CommandSubType;
2295   uint32_t                             CommandType;
2296   /* variable length fields follow */
2297};
2298
2299static inline __attribute__((always_inline)) void
2300GFX5_3DSTATE_VERTEX_BUFFERS_pack(__attribute__((unused)) __gen_user_data *data,
2301                                 __attribute__((unused)) void * restrict dst,
2302                                 __attribute__((unused)) const struct GFX5_3DSTATE_VERTEX_BUFFERS * restrict values)
2303{
2304   uint32_t * restrict dw = (uint32_t * restrict) dst;
2305
2306   dw[0] =
2307      __gen_uint(values->DWordLength, 0, 7) |
2308      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2309      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2310      __gen_uint(values->CommandSubType, 27, 28) |
2311      __gen_uint(values->CommandType, 29, 31);
2312}
2313
2314#define GFX5_3DSTATE_VERTEX_ELEMENTS_length_bias      2
2315#define GFX5_3DSTATE_VERTEX_ELEMENTS_header     \
2316   .DWordLength                         =      1,  \
2317   ._3DCommandSubOpcode                 =      9,  \
2318   ._3DCommandOpcode                    =      0,  \
2319   .CommandSubType                      =      3,  \
2320   .CommandType                         =      3
2321
2322struct GFX5_3DSTATE_VERTEX_ELEMENTS {
2323   uint32_t                             DWordLength;
2324   uint32_t                             _3DCommandSubOpcode;
2325   uint32_t                             _3DCommandOpcode;
2326   uint32_t                             CommandSubType;
2327   uint32_t                             CommandType;
2328   /* variable length fields follow */
2329};
2330
2331static inline __attribute__((always_inline)) void
2332GFX5_3DSTATE_VERTEX_ELEMENTS_pack(__attribute__((unused)) __gen_user_data *data,
2333                                  __attribute__((unused)) void * restrict dst,
2334                                  __attribute__((unused)) const struct GFX5_3DSTATE_VERTEX_ELEMENTS * restrict values)
2335{
2336   uint32_t * restrict dw = (uint32_t * restrict) dst;
2337
2338   dw[0] =
2339      __gen_uint(values->DWordLength, 0, 7) |
2340      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2341      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2342      __gen_uint(values->CommandSubType, 27, 28) |
2343      __gen_uint(values->CommandType, 29, 31);
2344}
2345
2346#define GFX5_3DSTATE_VF_STATISTICS_length      1
2347#define GFX5_3DSTATE_VF_STATISTICS_length_bias      1
2348#define GFX5_3DSTATE_VF_STATISTICS_header       \
2349   ._3DCommandSubOpcode                 =     11,  \
2350   ._3DCommandOpcode                    =      0,  \
2351   .CommandSubType                      =      1,  \
2352   .CommandType                         =      3
2353
2354struct GFX5_3DSTATE_VF_STATISTICS {
2355   bool                                 StatisticsEnable;
2356   uint32_t                             _3DCommandSubOpcode;
2357   uint32_t                             _3DCommandOpcode;
2358   uint32_t                             CommandSubType;
2359   uint32_t                             CommandType;
2360};
2361
2362static inline __attribute__((always_inline)) void
2363GFX5_3DSTATE_VF_STATISTICS_pack(__attribute__((unused)) __gen_user_data *data,
2364                                __attribute__((unused)) void * restrict dst,
2365                                __attribute__((unused)) const struct GFX5_3DSTATE_VF_STATISTICS * restrict values)
2366{
2367   uint32_t * restrict dw = (uint32_t * restrict) dst;
2368
2369   dw[0] =
2370      __gen_uint(values->StatisticsEnable, 0, 0) |
2371      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2372      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2373      __gen_uint(values->CommandSubType, 27, 28) |
2374      __gen_uint(values->CommandType, 29, 31);
2375}
2376
2377#define GFX5_CONSTANT_BUFFER_length            2
2378#define GFX5_CONSTANT_BUFFER_length_bias       2
2379#define GFX5_CONSTANT_BUFFER_header             \
2380   .DWordLength                         =      0,  \
2381   ._3DCommandSubOpcode                 =      2,  \
2382   ._3DCommandOpcode                    =      0,  \
2383   .CommandSubType                      =      0,  \
2384   .CommandType                         =      3
2385
2386struct GFX5_CONSTANT_BUFFER {
2387   uint32_t                             DWordLength;
2388   bool                                 Valid;
2389   uint32_t                             _3DCommandSubOpcode;
2390   uint32_t                             _3DCommandOpcode;
2391   uint32_t                             CommandSubType;
2392   uint32_t                             CommandType;
2393   uint32_t                             BufferLength;
2394   __gen_address_type                   BufferStartingAddress;
2395};
2396
2397static inline __attribute__((always_inline)) void
2398GFX5_CONSTANT_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2399                          __attribute__((unused)) void * restrict dst,
2400                          __attribute__((unused)) const struct GFX5_CONSTANT_BUFFER * restrict values)
2401{
2402   uint32_t * restrict dw = (uint32_t * restrict) dst;
2403
2404   dw[0] =
2405      __gen_uint(values->DWordLength, 0, 7) |
2406      __gen_uint(values->Valid, 8, 8) |
2407      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2408      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2409      __gen_uint(values->CommandSubType, 27, 28) |
2410      __gen_uint(values->CommandType, 29, 31);
2411
2412   const uint32_t v1 =
2413      __gen_uint(values->BufferLength, 0, 5);
2414   dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, v1, 6, 31);
2415}
2416
2417#define GFX5_CS_URB_STATE_length               2
2418#define GFX5_CS_URB_STATE_length_bias          2
2419#define GFX5_CS_URB_STATE_header                \
2420   .DWordLength                         =      0,  \
2421   ._3DCommandSubOpcode                 =      1,  \
2422   ._3DCommandOpcode                    =      0,  \
2423   .CommandSubType                      =      0,  \
2424   .CommandType                         =      3
2425
2426struct GFX5_CS_URB_STATE {
2427   uint32_t                             DWordLength;
2428   uint32_t                             _3DCommandSubOpcode;
2429   uint32_t                             _3DCommandOpcode;
2430   uint32_t                             CommandSubType;
2431   uint32_t                             CommandType;
2432   uint32_t                             NumberofURBEntries;
2433   uint32_t                             URBEntryAllocationSize;
2434};
2435
2436static inline __attribute__((always_inline)) void
2437GFX5_CS_URB_STATE_pack(__attribute__((unused)) __gen_user_data *data,
2438                       __attribute__((unused)) void * restrict dst,
2439                       __attribute__((unused)) const struct GFX5_CS_URB_STATE * restrict values)
2440{
2441   uint32_t * restrict dw = (uint32_t * restrict) dst;
2442
2443   dw[0] =
2444      __gen_uint(values->DWordLength, 0, 7) |
2445      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2446      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2447      __gen_uint(values->CommandSubType, 27, 28) |
2448      __gen_uint(values->CommandType, 29, 31);
2449
2450   dw[1] =
2451      __gen_uint(values->NumberofURBEntries, 0, 2) |
2452      __gen_uint(values->URBEntryAllocationSize, 4, 8);
2453}
2454
2455#define GFX5_MI_FLUSH_length                   1
2456#define GFX5_MI_FLUSH_length_bias              1
2457#define GFX5_MI_FLUSH_header                    \
2458   .MICommandOpcode                     =      4,  \
2459   .CommandType                         =      0
2460
2461struct GFX5_MI_FLUSH {
2462   uint32_t                             StateInstructionCacheInvalidate;
2463#define DontInvalidate                           0
2464#define Invalidate                               1
2465   uint32_t                             RenderCacheFlushInhibit;
2466#define Flush                                    0
2467#define DontFlush                                1
2468   uint32_t                             GlobalSnapshotCountReset;
2469#define DontReset                                0
2470#define Reset                                    1
2471   bool                                 GenericMediaStateClear;
2472   bool                                 IndirectStatePointersDisable;
2473   bool                                 ProtectedMemoryEnable;
2474   uint32_t                             MICommandOpcode;
2475   uint32_t                             CommandType;
2476};
2477
2478static inline __attribute__((always_inline)) void
2479GFX5_MI_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
2480                   __attribute__((unused)) void * restrict dst,
2481                   __attribute__((unused)) const struct GFX5_MI_FLUSH * restrict values)
2482{
2483   uint32_t * restrict dw = (uint32_t * restrict) dst;
2484
2485   dw[0] =
2486      __gen_uint(values->StateInstructionCacheInvalidate, 1, 1) |
2487      __gen_uint(values->RenderCacheFlushInhibit, 2, 2) |
2488      __gen_uint(values->GlobalSnapshotCountReset, 3, 3) |
2489      __gen_uint(values->GenericMediaStateClear, 4, 4) |
2490      __gen_uint(values->IndirectStatePointersDisable, 5, 5) |
2491      __gen_uint(values->ProtectedMemoryEnable, 6, 6) |
2492      __gen_uint(values->MICommandOpcode, 23, 28) |
2493      __gen_uint(values->CommandType, 29, 31);
2494}
2495
2496#define GFX5_MI_LOAD_REGISTER_IMM_length       3
2497#define GFX5_MI_LOAD_REGISTER_IMM_length_bias      2
2498#define GFX5_MI_LOAD_REGISTER_IMM_header        \
2499   .DWordLength                         =      1,  \
2500   .MICommandOpcode                     =     34,  \
2501   .CommandType                         =      0
2502
2503struct GFX5_MI_LOAD_REGISTER_IMM {
2504   uint32_t                             DWordLength;
2505   uint32_t                             ByteWriteDisables;
2506   uint32_t                             MICommandOpcode;
2507   uint32_t                             CommandType;
2508   uint64_t                             RegisterOffset;
2509   uint32_t                             DataDWord;
2510   /* variable length fields follow */
2511};
2512
2513static inline __attribute__((always_inline)) void
2514GFX5_MI_LOAD_REGISTER_IMM_pack(__attribute__((unused)) __gen_user_data *data,
2515                               __attribute__((unused)) void * restrict dst,
2516                               __attribute__((unused)) const struct GFX5_MI_LOAD_REGISTER_IMM * restrict values)
2517{
2518   uint32_t * restrict dw = (uint32_t * restrict) dst;
2519
2520   dw[0] =
2521      __gen_uint(values->DWordLength, 0, 5) |
2522      __gen_uint(values->ByteWriteDisables, 8, 11) |
2523      __gen_uint(values->MICommandOpcode, 23, 28) |
2524      __gen_uint(values->CommandType, 29, 31);
2525
2526   dw[1] =
2527      __gen_offset(values->RegisterOffset, 2, 31);
2528
2529   dw[2] =
2530      __gen_uint(values->DataDWord, 0, 31);
2531}
2532
2533#define GFX5_MI_STORE_DATA_IMM_length          5
2534#define GFX5_MI_STORE_DATA_IMM_length_bias      2
2535#define GFX5_MI_STORE_DATA_IMM_header           \
2536   .DWordLength                         =      2,  \
2537   .MICommandOpcode                     =     32,  \
2538   .CommandType                         =      0
2539
2540struct GFX5_MI_STORE_DATA_IMM {
2541   uint32_t                             DWordLength;
2542   bool                                 MemoryAddressType;
2543   uint32_t                             MICommandOpcode;
2544   uint32_t                             CommandType;
2545   __gen_address_type                   PhysicalStartAddressExtension;
2546   __gen_address_type                   Address;
2547   uint64_t                             ImmediateData;
2548};
2549
2550static inline __attribute__((always_inline)) void
2551GFX5_MI_STORE_DATA_IMM_pack(__attribute__((unused)) __gen_user_data *data,
2552                            __attribute__((unused)) void * restrict dst,
2553                            __attribute__((unused)) const struct GFX5_MI_STORE_DATA_IMM * restrict values)
2554{
2555   uint32_t * restrict dw = (uint32_t * restrict) dst;
2556
2557   dw[0] =
2558      __gen_uint(values->DWordLength, 0, 5) |
2559      __gen_uint(values->MemoryAddressType, 22, 22) |
2560      __gen_uint(values->MICommandOpcode, 23, 28) |
2561      __gen_uint(values->CommandType, 29, 31);
2562
2563   dw[1] = __gen_address(data, &dw[1], values->PhysicalStartAddressExtension, 0, 0, 3);
2564
2565   dw[2] = __gen_address(data, &dw[2], values->Address, 0, 2, 31);
2566
2567   const uint64_t v3 =
2568      __gen_uint(values->ImmediateData, 0, 63);
2569   dw[3] = v3;
2570   dw[4] = v3 >> 32;
2571}
2572
2573#define GFX5_MI_STORE_REGISTER_MEM_length      3
2574#define GFX5_MI_STORE_REGISTER_MEM_length_bias      2
2575#define GFX5_MI_STORE_REGISTER_MEM_header       \
2576   .DWordLength                         =      1,  \
2577   .MICommandOpcode                     =     36,  \
2578   .CommandType                         =      0
2579
2580struct GFX5_MI_STORE_REGISTER_MEM {
2581   uint32_t                             DWordLength;
2582   bool                                 UseGlobalGTT;
2583   uint32_t                             MICommandOpcode;
2584   uint32_t                             CommandType;
2585   uint64_t                             RegisterAddress;
2586   __gen_address_type                   MemoryAddress;
2587};
2588
2589static inline __attribute__((always_inline)) void
2590GFX5_MI_STORE_REGISTER_MEM_pack(__attribute__((unused)) __gen_user_data *data,
2591                                __attribute__((unused)) void * restrict dst,
2592                                __attribute__((unused)) const struct GFX5_MI_STORE_REGISTER_MEM * restrict values)
2593{
2594   uint32_t * restrict dw = (uint32_t * restrict) dst;
2595
2596   dw[0] =
2597      __gen_uint(values->DWordLength, 0, 7) |
2598      __gen_uint(values->UseGlobalGTT, 22, 22) |
2599      __gen_uint(values->MICommandOpcode, 23, 28) |
2600      __gen_uint(values->CommandType, 29, 31);
2601
2602   dw[1] =
2603      __gen_offset(values->RegisterAddress, 2, 25);
2604
2605   dw[2] = __gen_address(data, &dw[2], values->MemoryAddress, 0, 2, 31);
2606}
2607
2608#define GFX5_PIPELINE_SELECT_length            1
2609#define GFX5_PIPELINE_SELECT_length_bias       1
2610#define GFX5_PIPELINE_SELECT_header             \
2611   ._3DCommandSubOpcode                 =      4,  \
2612   ._3DCommandOpcode                    =      1,  \
2613   .CommandSubType                      =      1,  \
2614   .CommandType                         =      3
2615
2616struct GFX5_PIPELINE_SELECT {
2617   uint32_t                             PipelineSelection;
2618#define _3D                                      0
2619#define Media                                    1
2620#define GPGPU                                    2
2621   uint32_t                             _3DCommandSubOpcode;
2622   uint32_t                             _3DCommandOpcode;
2623   uint32_t                             CommandSubType;
2624   uint32_t                             CommandType;
2625};
2626
2627static inline __attribute__((always_inline)) void
2628GFX5_PIPELINE_SELECT_pack(__attribute__((unused)) __gen_user_data *data,
2629                          __attribute__((unused)) void * restrict dst,
2630                          __attribute__((unused)) const struct GFX5_PIPELINE_SELECT * restrict values)
2631{
2632   uint32_t * restrict dw = (uint32_t * restrict) dst;
2633
2634   dw[0] =
2635      __gen_uint(values->PipelineSelection, 0, 1) |
2636      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2637      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2638      __gen_uint(values->CommandSubType, 27, 28) |
2639      __gen_uint(values->CommandType, 29, 31);
2640}
2641
2642#define GFX5_PIPE_CONTROL_length               4
2643#define GFX5_PIPE_CONTROL_length_bias          2
2644#define GFX5_PIPE_CONTROL_header                \
2645   .DWordLength                         =      2,  \
2646   ._3DCommandSubOpcode                 =      0,  \
2647   ._3DCommandOpcode                    =      2,  \
2648   .CommandSubType                      =      3,  \
2649   .CommandType                         =      3
2650
2651struct GFX5_PIPE_CONTROL {
2652   uint32_t                             DWordLength;
2653   bool                                 NotifyEnable;
2654   bool                                 IndirectStatePointersDisable;
2655   bool                                 TextureCacheFlushEnable;
2656   bool                                 InstructionCacheInvalidateEnable;
2657   bool                                 WriteCacheFlush;
2658   bool                                 DepthStallEnable;
2659   uint32_t                             PostSyncOperation;
2660#define NoWrite                                  0
2661#define WriteImmediateData                       1
2662#define WritePSDepthCount                        2
2663#define WriteTimestamp                           3
2664   uint32_t                             _3DCommandSubOpcode;
2665   uint32_t                             _3DCommandOpcode;
2666   uint32_t                             CommandSubType;
2667   uint32_t                             CommandType;
2668   uint32_t                             DepthCacheFlushInhibit;
2669#define Flushed                                  0
2670#define NotFlushed                               1
2671   bool                                 StallAtPixelScoreboard;
2672   uint32_t                             DestinationAddressType;
2673#define DAT_PGTT                                 0
2674#define DAT_GGTT                                 1
2675   __gen_address_type                   Address;
2676   uint64_t                             ImmediateData;
2677};
2678
2679static inline __attribute__((always_inline)) void
2680GFX5_PIPE_CONTROL_pack(__attribute__((unused)) __gen_user_data *data,
2681                       __attribute__((unused)) void * restrict dst,
2682                       __attribute__((unused)) const struct GFX5_PIPE_CONTROL * restrict values)
2683{
2684   uint32_t * restrict dw = (uint32_t * restrict) dst;
2685
2686   dw[0] =
2687      __gen_uint(values->DWordLength, 0, 7) |
2688      __gen_uint(values->NotifyEnable, 8, 8) |
2689      __gen_uint(values->IndirectStatePointersDisable, 9, 9) |
2690      __gen_uint(values->TextureCacheFlushEnable, 10, 10) |
2691      __gen_uint(values->InstructionCacheInvalidateEnable, 11, 11) |
2692      __gen_uint(values->WriteCacheFlush, 12, 12) |
2693      __gen_uint(values->DepthStallEnable, 13, 13) |
2694      __gen_uint(values->PostSyncOperation, 14, 15) |
2695      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2696      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2697      __gen_uint(values->CommandSubType, 27, 28) |
2698      __gen_uint(values->CommandType, 29, 31);
2699
2700   const uint32_t v1 =
2701      __gen_uint(values->DepthCacheFlushInhibit, 0, 0) |
2702      __gen_uint(values->StallAtPixelScoreboard, 1, 1) |
2703      __gen_uint(values->DestinationAddressType, 2, 2);
2704   dw[1] = __gen_address(data, &dw[1], values->Address, v1, 3, 31);
2705
2706   const uint64_t v2 =
2707      __gen_uint(values->ImmediateData, 0, 63);
2708   dw[2] = v2;
2709   dw[3] = v2 >> 32;
2710}
2711
2712#define GFX5_STATE_BASE_ADDRESS_length         8
2713#define GFX5_STATE_BASE_ADDRESS_length_bias      2
2714#define GFX5_STATE_BASE_ADDRESS_header          \
2715   .DWordLength                         =      6,  \
2716   ._3DCommandSubOpcode                 =      1,  \
2717   ._3DCommandOpcode                    =      1,  \
2718   .CommandSubType                      =      0,  \
2719   .CommandType                         =      3
2720
2721struct GFX5_STATE_BASE_ADDRESS {
2722   uint32_t                             DWordLength;
2723   uint32_t                             _3DCommandSubOpcode;
2724   uint32_t                             _3DCommandOpcode;
2725   uint32_t                             CommandSubType;
2726   uint32_t                             CommandType;
2727   bool                                 GeneralStateBaseAddressModifyEnable;
2728   __gen_address_type                   GeneralStateBaseAddress;
2729   bool                                 SurfaceStateBaseAddressModifyEnable;
2730   __gen_address_type                   SurfaceStateBaseAddress;
2731   bool                                 IndirectObjectBaseAddressModifyEnable;
2732   __gen_address_type                   IndirectObjectBaseAddress;
2733   bool                                 InstructionBaseAddressModifyEnable;
2734   __gen_address_type                   InstructionBaseAddress;
2735   bool                                 GeneralStateAccessUpperBoundModifyEnable;
2736   __gen_address_type                   GeneralStateAccessUpperBound;
2737   bool                                 IndirectObjectAccessUpperBoundModifyEnable;
2738   __gen_address_type                   IndirectObjectAccessUpperBound;
2739   bool                                 InstructionAccessUpperBoundModifyEnable;
2740   __gen_address_type                   InstructionAccessUpperBound;
2741};
2742
2743static inline __attribute__((always_inline)) void
2744GFX5_STATE_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data,
2745                             __attribute__((unused)) void * restrict dst,
2746                             __attribute__((unused)) const struct GFX5_STATE_BASE_ADDRESS * restrict values)
2747{
2748   uint32_t * restrict dw = (uint32_t * restrict) dst;
2749
2750   dw[0] =
2751      __gen_uint(values->DWordLength, 0, 7) |
2752      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2753      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2754      __gen_uint(values->CommandSubType, 27, 28) |
2755      __gen_uint(values->CommandType, 29, 31);
2756
2757   const uint32_t v1 =
2758      __gen_uint(values->GeneralStateBaseAddressModifyEnable, 0, 0);
2759   dw[1] = __gen_address(data, &dw[1], values->GeneralStateBaseAddress, v1, 12, 31);
2760
2761   const uint32_t v2 =
2762      __gen_uint(values->SurfaceStateBaseAddressModifyEnable, 0, 0);
2763   dw[2] = __gen_address(data, &dw[2], values->SurfaceStateBaseAddress, v2, 12, 31);
2764
2765   const uint32_t v3 =
2766      __gen_uint(values->IndirectObjectBaseAddressModifyEnable, 0, 0);
2767   dw[3] = __gen_address(data, &dw[3], values->IndirectObjectBaseAddress, v3, 12, 31);
2768
2769   const uint32_t v4 =
2770      __gen_uint(values->InstructionBaseAddressModifyEnable, 0, 0);
2771   dw[4] = __gen_address(data, &dw[4], values->InstructionBaseAddress, v4, 12, 31);
2772
2773   const uint32_t v5 =
2774      __gen_uint(values->GeneralStateAccessUpperBoundModifyEnable, 0, 0);
2775   dw[5] = __gen_address(data, &dw[5], values->GeneralStateAccessUpperBound, v5, 12, 31);
2776
2777   const uint32_t v6 =
2778      __gen_uint(values->IndirectObjectAccessUpperBoundModifyEnable, 0, 0);
2779   dw[6] = __gen_address(data, &dw[6], values->IndirectObjectAccessUpperBound, v6, 12, 31);
2780
2781   const uint32_t v7 =
2782      __gen_uint(values->InstructionAccessUpperBoundModifyEnable, 0, 0);
2783   dw[7] = __gen_address(data, &dw[7], values->InstructionAccessUpperBound, v7, 12, 31);
2784}
2785
2786#define GFX5_STATE_SIP_length                  2
2787#define GFX5_STATE_SIP_length_bias             2
2788#define GFX5_STATE_SIP_header                   \
2789   .DWordLength                         =      0,  \
2790   ._3DCommandSubOpcode                 =      2,  \
2791   ._3DCommandOpcode                    =      1,  \
2792   .CommandSubType                      =      0,  \
2793   .CommandType                         =      3
2794
2795struct GFX5_STATE_SIP {
2796   uint32_t                             DWordLength;
2797   uint32_t                             _3DCommandSubOpcode;
2798   uint32_t                             _3DCommandOpcode;
2799   uint32_t                             CommandSubType;
2800   uint32_t                             CommandType;
2801   uint64_t                             SystemInstructionPointer;
2802};
2803
2804static inline __attribute__((always_inline)) void
2805GFX5_STATE_SIP_pack(__attribute__((unused)) __gen_user_data *data,
2806                    __attribute__((unused)) void * restrict dst,
2807                    __attribute__((unused)) const struct GFX5_STATE_SIP * restrict values)
2808{
2809   uint32_t * restrict dw = (uint32_t * restrict) dst;
2810
2811   dw[0] =
2812      __gen_uint(values->DWordLength, 0, 7) |
2813      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2814      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2815      __gen_uint(values->CommandSubType, 27, 28) |
2816      __gen_uint(values->CommandType, 29, 31);
2817
2818   dw[1] =
2819      __gen_offset(values->SystemInstructionPointer, 4, 31);
2820}
2821
2822#define GFX5_URB_FENCE_length                  3
2823#define GFX5_URB_FENCE_length_bias             2
2824#define GFX5_URB_FENCE_header                   \
2825   .DWordLength                         =      1,  \
2826   ._3DCommandSubOpcode                 =      0,  \
2827   ._3DCommandOpcode                    =      0,  \
2828   .CommandSubType                      =      0,  \
2829   .CommandType                         =      3
2830
2831struct GFX5_URB_FENCE {
2832   uint32_t                             DWordLength;
2833   bool                                 VSUnitURBReallocationRequest;
2834   bool                                 GSUnitURBReallocationRequest;
2835   bool                                 CLIPUnitURBReallocationRequest;
2836   bool                                 SFUnitURBReallocationRequest;
2837   bool                                 VFEUnitURBReallocationRequest;
2838   bool                                 CSUnitURBReallocationRequest;
2839   uint32_t                             _3DCommandSubOpcode;
2840   uint32_t                             _3DCommandOpcode;
2841   uint32_t                             CommandSubType;
2842   uint32_t                             CommandType;
2843   uint32_t                             VSFence;
2844   uint32_t                             GSFence;
2845   uint32_t                             CLIPFence;
2846   uint32_t                             SFFence;
2847   uint32_t                             VFEFence;
2848   uint32_t                             CSFence;
2849};
2850
2851static inline __attribute__((always_inline)) void
2852GFX5_URB_FENCE_pack(__attribute__((unused)) __gen_user_data *data,
2853                    __attribute__((unused)) void * restrict dst,
2854                    __attribute__((unused)) const struct GFX5_URB_FENCE * restrict values)
2855{
2856   uint32_t * restrict dw = (uint32_t * restrict) dst;
2857
2858   dw[0] =
2859      __gen_uint(values->DWordLength, 0, 7) |
2860      __gen_uint(values->VSUnitURBReallocationRequest, 8, 8) |
2861      __gen_uint(values->GSUnitURBReallocationRequest, 9, 9) |
2862      __gen_uint(values->CLIPUnitURBReallocationRequest, 10, 10) |
2863      __gen_uint(values->SFUnitURBReallocationRequest, 11, 11) |
2864      __gen_uint(values->VFEUnitURBReallocationRequest, 12, 12) |
2865      __gen_uint(values->CSUnitURBReallocationRequest, 13, 13) |
2866      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2867      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2868      __gen_uint(values->CommandSubType, 27, 28) |
2869      __gen_uint(values->CommandType, 29, 31);
2870
2871   dw[1] =
2872      __gen_uint(values->VSFence, 0, 9) |
2873      __gen_uint(values->GSFence, 10, 19) |
2874      __gen_uint(values->CLIPFence, 20, 29);
2875
2876   dw[2] =
2877      __gen_uint(values->SFFence, 0, 9) |
2878      __gen_uint(values->VFEFence, 10, 19) |
2879      __gen_uint(values->CSFence, 20, 30);
2880}
2881
2882#define GFX5_XY_COLOR_BLT_length               6
2883#define GFX5_XY_COLOR_BLT_length_bias          2
2884#define GFX5_XY_COLOR_BLT_header                \
2885   .DWordLength                         =      4,  \
2886   ._2DCommandOpcode                    =     80,  \
2887   .CommandType                         =      2
2888
2889struct GFX5_XY_COLOR_BLT {
2890   uint32_t                             DWordLength;
2891   bool                                 TilingEnable;
2892   uint32_t                             _32bppByteMask;
2893   uint32_t                             _2DCommandOpcode;
2894   uint32_t                             CommandType;
2895   int32_t                              DestinationPitch;
2896   uint32_t                             RasterOperation;
2897   uint32_t                             ColorDepth;
2898#define COLOR_DEPTH__8bit                        0
2899#define COLOR_DEPTH__565                         1
2900#define COLOR_DEPTH__1555                        2
2901#define COLOR_DEPTH__32bit                       3
2902   bool                                 ClippingEnabled;
2903   int32_t                              DestinationX1Coordinate;
2904   int32_t                              DestinationY1Coordinate;
2905   int32_t                              DestinationX2Coordinate;
2906   int32_t                              DestinationY2Coordinate;
2907   __gen_address_type                   DestinationBaseAddress;
2908   int32_t                              SolidPatternColor;
2909};
2910
2911static inline __attribute__((always_inline)) void
2912GFX5_XY_COLOR_BLT_pack(__attribute__((unused)) __gen_user_data *data,
2913                       __attribute__((unused)) void * restrict dst,
2914                       __attribute__((unused)) const struct GFX5_XY_COLOR_BLT * restrict values)
2915{
2916   uint32_t * restrict dw = (uint32_t * restrict) dst;
2917
2918   dw[0] =
2919      __gen_uint(values->DWordLength, 0, 7) |
2920      __gen_uint(values->TilingEnable, 11, 11) |
2921      __gen_uint(values->_32bppByteMask, 20, 21) |
2922      __gen_uint(values->_2DCommandOpcode, 22, 28) |
2923      __gen_uint(values->CommandType, 29, 31);
2924
2925   dw[1] =
2926      __gen_sint(values->DestinationPitch, 0, 15) |
2927      __gen_uint(values->RasterOperation, 16, 23) |
2928      __gen_uint(values->ColorDepth, 24, 26) |
2929      __gen_uint(values->ClippingEnabled, 30, 30);
2930
2931   dw[2] =
2932      __gen_sint(values->DestinationX1Coordinate, 0, 15) |
2933      __gen_sint(values->DestinationY1Coordinate, 16, 31);
2934
2935   dw[3] =
2936      __gen_sint(values->DestinationX2Coordinate, 0, 15) |
2937      __gen_sint(values->DestinationY2Coordinate, 16, 31);
2938
2939   dw[4] = __gen_address(data, &dw[4], values->DestinationBaseAddress, 0, 0, 31);
2940
2941   dw[5] =
2942      __gen_sint(values->SolidPatternColor, 0, 31);
2943}
2944
2945#define GFX5_XY_SRC_COPY_BLT_length            8
2946#define GFX5_XY_SRC_COPY_BLT_length_bias       2
2947#define GFX5_XY_SRC_COPY_BLT_header             \
2948   .DWordLength                         =      6,  \
2949   ._2DCommandOpcode                    =     83,  \
2950   .CommandType                         =      2
2951
2952struct GFX5_XY_SRC_COPY_BLT {
2953   uint32_t                             DWordLength;
2954   bool                                 DestinationTilingEnable;
2955   bool                                 SourceTilingEnable;
2956   uint32_t                             _32bppByteMask;
2957   uint32_t                             _2DCommandOpcode;
2958   uint32_t                             CommandType;
2959   int32_t                              DestinationPitch;
2960   uint32_t                             RasterOperation;
2961   uint32_t                             ColorDepth;
2962#define COLOR_DEPTH__8bit                        0
2963#define COLOR_DEPTH__565                         1
2964#define COLOR_DEPTH__1555                        2
2965#define COLOR_DEPTH__32bit                       3
2966   bool                                 ClippingEnabled;
2967   int32_t                              DestinationX1Coordinate;
2968   int32_t                              DestinationY1Coordinate;
2969   int32_t                              DestinationX2Coordinate;
2970   int32_t                              DestinationY2Coordinate;
2971   __gen_address_type                   DestinationBaseAddress;
2972   int32_t                              SourceX1Coordinate;
2973   int32_t                              SourceY1Coordinate;
2974   int32_t                              SourcePitch;
2975   __gen_address_type                   SourceBaseAddress;
2976};
2977
2978static inline __attribute__((always_inline)) void
2979GFX5_XY_SRC_COPY_BLT_pack(__attribute__((unused)) __gen_user_data *data,
2980                          __attribute__((unused)) void * restrict dst,
2981                          __attribute__((unused)) const struct GFX5_XY_SRC_COPY_BLT * restrict values)
2982{
2983   uint32_t * restrict dw = (uint32_t * restrict) dst;
2984
2985   dw[0] =
2986      __gen_uint(values->DWordLength, 0, 7) |
2987      __gen_uint(values->DestinationTilingEnable, 11, 11) |
2988      __gen_uint(values->SourceTilingEnable, 15, 15) |
2989      __gen_uint(values->_32bppByteMask, 20, 21) |
2990      __gen_uint(values->_2DCommandOpcode, 22, 28) |
2991      __gen_uint(values->CommandType, 29, 31);
2992
2993   dw[1] =
2994      __gen_sint(values->DestinationPitch, 0, 15) |
2995      __gen_uint(values->RasterOperation, 16, 23) |
2996      __gen_uint(values->ColorDepth, 24, 26) |
2997      __gen_uint(values->ClippingEnabled, 30, 30);
2998
2999   dw[2] =
3000      __gen_sint(values->DestinationX1Coordinate, 0, 15) |
3001      __gen_sint(values->DestinationY1Coordinate, 16, 31);
3002
3003   dw[3] =
3004      __gen_sint(values->DestinationX2Coordinate, 0, 15) |
3005      __gen_sint(values->DestinationY2Coordinate, 16, 31);
3006
3007   dw[4] = __gen_address(data, &dw[4], values->DestinationBaseAddress, 0, 0, 31);
3008
3009   dw[5] =
3010      __gen_sint(values->SourceX1Coordinate, 0, 15) |
3011      __gen_sint(values->SourceY1Coordinate, 16, 31);
3012
3013   dw[6] =
3014      __gen_sint(values->SourcePitch, 0, 15);
3015
3016   dw[7] = __gen_address(data, &dw[7], values->SourceBaseAddress, 0, 0, 31);
3017}
3018
3019#define GFX5_XY_TEXT_IMMEDIATE_BLT_length      3
3020#define GFX5_XY_TEXT_IMMEDIATE_BLT_length_bias      2
3021#define GFX5_XY_TEXT_IMMEDIATE_BLT_header       \
3022   .DWordLength                         =      1,  \
3023   ._2DCommandOpcode                    =     49,  \
3024   .CommandType                         =      2
3025
3026struct GFX5_XY_TEXT_IMMEDIATE_BLT {
3027   uint32_t                             DWordLength;
3028   bool                                 TilingEnable;
3029   uint32_t                             Packing;
3030#define BitPacked                                0
3031#define BytePacked                               1
3032   uint32_t                             _32bppByteMask;
3033   uint32_t                             _2DCommandOpcode;
3034   uint32_t                             CommandType;
3035   int32_t                              DestinationPitch;
3036   int32_t                              DestinationX1Coordinate;
3037   int32_t                              DestinationY1Coordinate;
3038   int32_t                              DestinationX2Coordinate;
3039   int32_t                              DestinationY2Coordinate;
3040};
3041
3042static inline __attribute__((always_inline)) void
3043GFX5_XY_TEXT_IMMEDIATE_BLT_pack(__attribute__((unused)) __gen_user_data *data,
3044                                __attribute__((unused)) void * restrict dst,
3045                                __attribute__((unused)) const struct GFX5_XY_TEXT_IMMEDIATE_BLT * restrict values)
3046{
3047   uint32_t * restrict dw = (uint32_t * restrict) dst;
3048
3049   dw[0] =
3050      __gen_uint(values->DWordLength, 0, 7) |
3051      __gen_uint(values->TilingEnable, 11, 11) |
3052      __gen_uint(values->Packing, 16, 16) |
3053      __gen_uint(values->_32bppByteMask, 20, 21) |
3054      __gen_uint(values->_2DCommandOpcode, 22, 28) |
3055      __gen_uint(values->CommandType, 29, 31);
3056
3057   dw[1] =
3058      __gen_sint(values->DestinationPitch, 0, 15) |
3059      __gen_sint(values->DestinationX1Coordinate, 0, 15) |
3060      __gen_sint(values->DestinationY1Coordinate, 16, 31);
3061
3062   dw[2] =
3063      __gen_sint(values->DestinationX2Coordinate, 0, 15) |
3064      __gen_sint(values->DestinationY2Coordinate, 16, 31);
3065}
3066
3067#endif /* GFX5_PACK_H */
3068