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 GEN5_PACK_H
31#define GEN5_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 __gen_field_functions
44#define __gen_field_functions
45
46#ifdef NDEBUG
47#define NDEBUG_UNUSED __attribute__((unused))
48#else
49#define NDEBUG_UNUSED
50#endif
51
52union __gen_value {
53   float f;
54   uint32_t dw;
55};
56
57static 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 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 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 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 uint32_t
113__gen_float(float v)
114{
115   __gen_validate_value(v);
116   return ((union __gen_value) { .f = (v) }).dw;
117}
118
119static inline uint64_t
120__gen_sfixed(float v, uint32_t start, uint32_t end, uint32_t fract_bits)
121{
122   __gen_validate_value(v);
123
124   const float factor = (1 << fract_bits);
125
126#ifndef NDEBUG
127   const float max = ((1 << (end - start)) - 1) / factor;
128   const float min = -(1 << (end - start)) / factor;
129   assert(min <= v && v <= max);
130#endif
131
132   const int64_t int_val = llroundf(v * factor);
133   const uint64_t mask = ~0ull >> (64 - (end - start + 1));
134
135   return (int_val & mask) << start;
136}
137
138static inline uint64_t
139__gen_ufixed(float v, uint32_t start, NDEBUG_UNUSED uint32_t end, uint32_t fract_bits)
140{
141   __gen_validate_value(v);
142
143   const float factor = (1 << fract_bits);
144
145#ifndef NDEBUG
146   const float max = ((1 << (end - start + 1)) - 1) / factor;
147   const float min = 0.0f;
148   assert(min <= v && v <= max);
149#endif
150
151   const uint64_t uint_val = llroundf(v * factor);
152
153   return uint_val << start;
154}
155
156#ifndef __gen_address_type
157#error #define __gen_address_type before including this file
158#endif
159
160#ifndef __gen_user_data
161#error #define __gen_combine_address before including this file
162#endif
163
164#undef NDEBUG_UNUSED
165
166#endif
167
168
169enum GEN5_3D_Color_Buffer_Blend_Factor {
170   BLENDFACTOR_ONE                      =      1,
171   BLENDFACTOR_SRC_COLOR                =      2,
172   BLENDFACTOR_SRC_ALPHA                =      3,
173   BLENDFACTOR_DST_ALPHA                =      4,
174   BLENDFACTOR_DST_COLOR                =      5,
175   BLENDFACTOR_SRC_ALPHA_SATURATE       =      6,
176   BLENDFACTOR_CONST_COLOR              =      7,
177   BLENDFACTOR_CONST_ALPHA              =      8,
178   BLENDFACTOR_SRC1_COLOR               =      9,
179   BLENDFACTOR_SRC1_ALPHA               =     10,
180   BLENDFACTOR_ZERO                     =     17,
181   BLENDFACTOR_INV_SRC_COLOR            =     18,
182   BLENDFACTOR_INV_SRC_ALPHA            =     19,
183   BLENDFACTOR_INV_DST_ALPHA            =     20,
184   BLENDFACTOR_INV_DST_COLOR            =     21,
185   BLENDFACTOR_INV_CONST_COLOR          =     23,
186   BLENDFACTOR_INV_CONST_ALPHA          =     24,
187   BLENDFACTOR_INV_SRC1_COLOR           =     25,
188   BLENDFACTOR_INV_SRC1_ALPHA           =     26,
189};
190
191enum GEN5_3D_Color_Buffer_Blend_Function {
192   BLENDFUNCTION_ADD                    =      0,
193   BLENDFUNCTION_SUBTRACT               =      1,
194   BLENDFUNCTION_REVERSE_SUBTRACT       =      2,
195   BLENDFUNCTION_MIN                    =      3,
196   BLENDFUNCTION_MAX                    =      4,
197};
198
199enum GEN5_3D_Compare_Function {
200   COMPAREFUNCTION_ALWAYS               =      0,
201   COMPAREFUNCTION_NEVER                =      1,
202   COMPAREFUNCTION_LESS                 =      2,
203   COMPAREFUNCTION_EQUAL                =      3,
204   COMPAREFUNCTION_LEQUAL               =      4,
205   COMPAREFUNCTION_GREATER              =      5,
206   COMPAREFUNCTION_NOTEQUAL             =      6,
207   COMPAREFUNCTION_GEQUAL               =      7,
208};
209
210enum GEN5_3D_Logic_Op_Function {
211   LOGICOP_CLEAR                        =      0,
212   LOGICOP_NOR                          =      1,
213   LOGICOP_AND_INVERTED                 =      2,
214   LOGICOP_COPY_INVERTED                =      3,
215   LOGICOP_AND_REVERSE                  =      4,
216   LOGICOP_INVERT                       =      5,
217   LOGICOP_XOR                          =      6,
218   LOGICOP_NAND                         =      7,
219   LOGICOP_AND                          =      8,
220   LOGICOP_EQUIV                        =      9,
221   LOGICOP_NOOP                         =     10,
222   LOGICOP_OR_INVERTED                  =     11,
223   LOGICOP_COPY                         =     12,
224   LOGICOP_OR_REVERSE                   =     13,
225   LOGICOP_OR                           =     14,
226   LOGICOP_SET                          =     15,
227};
228
229enum GEN5_3D_Prim_Topo_Type {
230   _3DPRIM_POINTLIST                    =      1,
231   _3DPRIM_LINELIST                     =      2,
232   _3DPRIM_LINESTRIP                    =      3,
233   _3DPRIM_TRILIST                      =      4,
234   _3DPRIM_TRISTRIP                     =      5,
235   _3DPRIM_TRIFAN                       =      6,
236   _3DPRIM_QUADLIST                     =      7,
237   _3DPRIM_QUADSTRIP                    =      8,
238   _3DPRIM_LINELIST_ADJ                 =      9,
239   _3DPRIM_LINESTRIP_ADJ                =     10,
240   _3DPRIM_TRILIST_ADJ                  =     11,
241   _3DPRIM_TRISTRIP_ADJ                 =     12,
242   _3DPRIM_TRISTRIP_REVERSE             =     13,
243   _3DPRIM_POLYGON                      =     14,
244   _3DPRIM_RECTLIST                     =     15,
245   _3DPRIM_LINELOOP                     =     16,
246   _3DPRIM_POINTLIST_BF                 =     17,
247   _3DPRIM_LINESTRIP_CONT               =     18,
248   _3DPRIM_LINESTRIP_BF                 =     19,
249   _3DPRIM_LINESTRIP_CONT_BF            =     20,
250   _3DPRIM_TRIFAN_NOSTIPPLE             =     22,
251};
252
253enum GEN5_3D_Stencil_Operation {
254   STENCILOP_KEEP                       =      0,
255   STENCILOP_ZERO                       =      1,
256   STENCILOP_REPLACE                    =      2,
257   STENCILOP_INCRSAT                    =      3,
258   STENCILOP_DECRSAT                    =      4,
259   STENCILOP_INCR                       =      5,
260   STENCILOP_DECR                       =      6,
261   STENCILOP_INVERT                     =      7,
262};
263
264enum GEN5_3D_Vertex_Component_Control {
265   VFCOMP_NOSTORE                       =      0,
266   VFCOMP_STORE_SRC                     =      1,
267   VFCOMP_STORE_0                       =      2,
268   VFCOMP_STORE_1_FP                    =      3,
269   VFCOMP_STORE_1_INT                   =      4,
270   VFCOMP_STORE_VID                     =      5,
271   VFCOMP_STORE_IID                     =      6,
272   VFCOMP_STORE_PID                     =      7,
273};
274
275enum GEN5_Texture_Coordinate_Mode {
276   TCM_WRAP                             =      0,
277   TCM_MIRROR                           =      1,
278   TCM_CLAMP                            =      2,
279   TCM_CUBE                             =      3,
280   TCM_CLAMP_BORDER                     =      4,
281   TCM_MIRROR_ONCE                      =      5,
282};
283
284#define GEN5_CC_VIEWPORT_length                2
285struct GEN5_CC_VIEWPORT {
286   float                                MinimumDepth;
287   float                                MaximumDepth;
288};
289
290static inline void
291GEN5_CC_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
292                      __attribute__((unused)) void * restrict dst,
293                      __attribute__((unused)) const struct GEN5_CC_VIEWPORT * restrict values)
294{
295   uint32_t * restrict dw = (uint32_t * restrict) dst;
296
297   dw[0] =
298      __gen_float(values->MinimumDepth);
299
300   dw[1] =
301      __gen_float(values->MaximumDepth);
302}
303
304#define GEN5_CLIP_STATE_length                11
305struct GEN5_CLIP_STATE {
306   uint32_t                             GRFRegisterCount;
307   uint64_t                             KernelStartPointer;
308   bool                                 SoftwareExceptionEnable;
309   bool                                 MaskStackExceptionEnable;
310   bool                                 IllegalOpcodeExceptionEnable;
311   uint32_t                             FloatingPointMode;
312#define FLOATING_POINT_MODE_IEEE754              0
313#define FLOATING_POINT_MODE_Alternate            1
314   uint32_t                             ThreadPriority;
315#define NormalPriority                           0
316#define HighPriority                             1
317   uint32_t                             BindingTableEntryCount;
318   bool                                 SingleProgramFlow;
319   uint32_t                             PerThreadScratchSpace;
320   __gen_address_type                   ScratchSpaceBasePointer;
321   uint32_t                             DispatchGRFStartRegisterForURBData;
322   uint32_t                             VertexURBEntryReadOffset;
323   uint32_t                             VertexURBEntryReadLength;
324   uint32_t                             ConstantURBEntryReadOffset;
325   uint32_t                             ConstantURBEntryReadLength;
326   uint32_t                             NumberofURBEntries;
327   uint32_t                             URBEntryAllocationSize;
328   uint32_t                             MaximumNumberofThreads;
329   uint32_t                             ClipMode;
330#define CLIPMODE_NORMAL                          0
331#define CLIPMODE_ALL                             1
332#define CLIPMODE_CLIP_NON_REJECTED               2
333#define CLIPMODE_REJECT_ALL                      3
334#define CLIPMODE_ACCEPT_ALL                      4
335   uint32_t                             UserClipDistanceClipTestEnableBitmask;
336   bool                                 UserClipFlagsMustClipEnable;
337   bool                                 NegativeWClipTestEnable;
338   bool                                 GuardbandClipTestEnable;
339   bool                                 ViewportZClipTestEnable;
340   bool                                 ViewportXYClipTestEnable;
341   uint32_t                             VertexPositionSpace;
342#define VPOS_NDCSPACE                            0
343#define VPOS_SCREENSPACE                         1
344   uint32_t                             APIMode;
345#define APIMODE_OGL                              0
346#define APIMODE_D3D                              1
347   __gen_address_type                   ClipperViewportStatePointer;
348   float                                ScreenSpaceViewportXMin;
349   float                                ScreenSpaceViewportXMax;
350   float                                ScreenSpaceViewportYMin;
351   float                                ScreenSpaceViewportYMax;
352};
353
354static inline void
355GEN5_CLIP_STATE_pack(__attribute__((unused)) __gen_user_data *data,
356                     __attribute__((unused)) void * restrict dst,
357                     __attribute__((unused)) const struct GEN5_CLIP_STATE * restrict values)
358{
359   uint32_t * restrict dw = (uint32_t * restrict) dst;
360
361   dw[0] =
362      __gen_uint(values->GRFRegisterCount, 1, 3) |
363      __gen_offset(values->KernelStartPointer, 6, 31);
364
365   dw[1] =
366      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
367      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
368      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
369      __gen_uint(values->FloatingPointMode, 16, 16) |
370      __gen_uint(values->ThreadPriority, 17, 17) |
371      __gen_uint(values->BindingTableEntryCount, 18, 25) |
372      __gen_uint(values->SingleProgramFlow, 31, 31);
373
374   const uint32_t v2 =
375      __gen_uint(values->PerThreadScratchSpace, 0, 3);
376   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
377
378   dw[3] =
379      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
380      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
381      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
382      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
383      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
384
385   dw[4] =
386      __gen_uint(values->NumberofURBEntries, 11, 18) |
387      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
388      __gen_uint(values->MaximumNumberofThreads, 25, 30);
389
390   dw[5] =
391      __gen_uint(values->ClipMode, 13, 15) |
392      __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 16, 23) |
393      __gen_uint(values->UserClipFlagsMustClipEnable, 24, 24) |
394      __gen_uint(values->NegativeWClipTestEnable, 25, 25) |
395      __gen_uint(values->GuardbandClipTestEnable, 26, 26) |
396      __gen_uint(values->ViewportZClipTestEnable, 27, 27) |
397      __gen_uint(values->ViewportXYClipTestEnable, 28, 28) |
398      __gen_uint(values->VertexPositionSpace, 29, 29) |
399      __gen_uint(values->APIMode, 30, 30);
400
401   dw[6] = __gen_combine_address(data, &dw[6], values->ClipperViewportStatePointer, 0);
402
403   dw[7] =
404      __gen_float(values->ScreenSpaceViewportXMin);
405
406   dw[8] =
407      __gen_float(values->ScreenSpaceViewportXMax);
408
409   dw[9] =
410      __gen_float(values->ScreenSpaceViewportYMin);
411
412   dw[10] =
413      __gen_float(values->ScreenSpaceViewportYMax);
414}
415
416#define GEN5_CLIP_VIEWPORT_length              4
417struct GEN5_CLIP_VIEWPORT {
418   float                                XMinClipGuardband;
419   float                                XMaxClipGuardband;
420   float                                YMinClipGuardband;
421   float                                YMaxClipGuardband;
422};
423
424static inline void
425GEN5_CLIP_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
426                        __attribute__((unused)) void * restrict dst,
427                        __attribute__((unused)) const struct GEN5_CLIP_VIEWPORT * restrict values)
428{
429   uint32_t * restrict dw = (uint32_t * restrict) dst;
430
431   dw[0] =
432      __gen_float(values->XMinClipGuardband);
433
434   dw[1] =
435      __gen_float(values->XMaxClipGuardband);
436
437   dw[2] =
438      __gen_float(values->YMinClipGuardband);
439
440   dw[3] =
441      __gen_float(values->YMaxClipGuardband);
442}
443
444#define GEN5_COLOR_CALC_STATE_length           8
445struct GEN5_COLOR_CALC_STATE {
446   enum GEN5_3D_Stencil_Operation       BackfaceStencilPassDepthPassOp;
447   enum GEN5_3D_Stencil_Operation       BackfaceStencilPassDepthFailOp;
448   enum GEN5_3D_Stencil_Operation       BackfaceStencilFailOp;
449   enum GEN5_3D_Compare_Function        BackfaceStencilTestFunction;
450   bool                                 DoubleSidedStencilEnable;
451   bool                                 StencilBufferWriteEnable;
452   enum GEN5_3D_Stencil_Operation       StencilPassDepthPassOp;
453   enum GEN5_3D_Stencil_Operation       StencilPassDepthFailOp;
454   enum GEN5_3D_Stencil_Operation       StencilFailOp;
455   enum GEN5_3D_Compare_Function        StencilTestFunction;
456   bool                                 StencilTestEnable;
457   uint32_t                             BackfaceStencilReferenceValue;
458   uint32_t                             StencilWriteMask;
459   uint32_t                             StencilTestMask;
460   uint32_t                             StencilReferenceValue;
461   bool                                 LogicOpEnable;
462   bool                                 DepthBufferWriteEnable;
463   enum GEN5_3D_Compare_Function        DepthTestFunction;
464   bool                                 DepthTestEnable;
465   uint32_t                             BackfaceStencilWriteMask;
466   uint32_t                             BackfaceStencilTestMask;
467   enum GEN5_3D_Compare_Function        AlphaTestFunction;
468   bool                                 AlphaTestEnable;
469   bool                                 ColorBufferBlendEnable;
470   bool                                 IndependentAlphaBlendEnable;
471   uint32_t                             AlphaTestFormat;
472#define ALPHATEST_UNORM8                         0
473#define ALPHATEST_FLOAT32                        1
474   __gen_address_type                   CCViewportStatePointer;
475   enum GEN5_3D_Color_Buffer_Blend_Factor DestinationAlphaBlendFactor;
476   enum GEN5_3D_Color_Buffer_Blend_Factor SourceAlphaBlendFactor;
477   enum GEN5_3D_Color_Buffer_Blend_Function AlphaBlendFunction;
478   bool                                 StatisticsEnable;
479   enum GEN5_3D_Logic_Op_Function       LogicOpFunction;
480   bool                                 RoundDisableFunctionDisable;
481   bool                                 ColorDitherEnable;
482   bool                                 PostBlendColorClampEnable;
483   bool                                 PreBlendColorClampEnable;
484   uint32_t                             ColorClampRange;
485#define COLORCLAMP_UNORM                         0
486#define COLORCLAMP_SNORM                         1
487#define COLORCLAMP_RTFORMAT                      2
488   uint32_t                             YDitherOffset;
489   uint32_t                             XDitherOffset;
490   enum GEN5_3D_Color_Buffer_Blend_Factor DestinationBlendFactor;
491   enum GEN5_3D_Color_Buffer_Blend_Factor SourceBlendFactor;
492   enum GEN5_3D_Color_Buffer_Blend_Function ColorBlendFunction;
493   uint32_t                             AlphaReferenceValueAsUNORM8;
494   float                                AlphaReferenceValueAsFLOAT32;
495};
496
497static inline void
498GEN5_COLOR_CALC_STATE_pack(__attribute__((unused)) __gen_user_data *data,
499                           __attribute__((unused)) void * restrict dst,
500                           __attribute__((unused)) const struct GEN5_COLOR_CALC_STATE * restrict values)
501{
502   uint32_t * restrict dw = (uint32_t * restrict) dst;
503
504   dw[0] =
505      __gen_uint(values->BackfaceStencilPassDepthPassOp, 3, 5) |
506      __gen_uint(values->BackfaceStencilPassDepthFailOp, 6, 8) |
507      __gen_uint(values->BackfaceStencilFailOp, 9, 11) |
508      __gen_uint(values->BackfaceStencilTestFunction, 12, 14) |
509      __gen_uint(values->DoubleSidedStencilEnable, 15, 15) |
510      __gen_uint(values->StencilBufferWriteEnable, 18, 18) |
511      __gen_uint(values->StencilPassDepthPassOp, 19, 21) |
512      __gen_uint(values->StencilPassDepthFailOp, 22, 24) |
513      __gen_uint(values->StencilFailOp, 25, 27) |
514      __gen_uint(values->StencilTestFunction, 28, 30) |
515      __gen_uint(values->StencilTestEnable, 31, 31);
516
517   dw[1] =
518      __gen_uint(values->BackfaceStencilReferenceValue, 0, 7) |
519      __gen_uint(values->StencilWriteMask, 8, 15) |
520      __gen_uint(values->StencilTestMask, 16, 23) |
521      __gen_uint(values->StencilReferenceValue, 24, 31);
522
523   dw[2] =
524      __gen_uint(values->LogicOpEnable, 0, 0) |
525      __gen_uint(values->DepthBufferWriteEnable, 11, 11) |
526      __gen_uint(values->DepthTestFunction, 12, 14) |
527      __gen_uint(values->DepthTestEnable, 15, 15) |
528      __gen_uint(values->BackfaceStencilWriteMask, 16, 23) |
529      __gen_uint(values->BackfaceStencilTestMask, 24, 31);
530
531   dw[3] =
532      __gen_uint(values->AlphaTestFunction, 8, 10) |
533      __gen_uint(values->AlphaTestEnable, 11, 11) |
534      __gen_uint(values->ColorBufferBlendEnable, 12, 12) |
535      __gen_uint(values->IndependentAlphaBlendEnable, 13, 13) |
536      __gen_uint(values->AlphaTestFormat, 15, 15);
537
538   dw[4] = __gen_combine_address(data, &dw[4], values->CCViewportStatePointer, 0);
539
540   dw[5] =
541      __gen_uint(values->DestinationAlphaBlendFactor, 2, 6) |
542      __gen_uint(values->SourceAlphaBlendFactor, 7, 11) |
543      __gen_uint(values->AlphaBlendFunction, 12, 14) |
544      __gen_uint(values->StatisticsEnable, 15, 15) |
545      __gen_uint(values->LogicOpFunction, 16, 19) |
546      __gen_uint(values->RoundDisableFunctionDisable, 30, 30) |
547      __gen_uint(values->ColorDitherEnable, 31, 31);
548
549   dw[6] =
550      __gen_uint(values->PostBlendColorClampEnable, 0, 0) |
551      __gen_uint(values->PreBlendColorClampEnable, 1, 1) |
552      __gen_uint(values->ColorClampRange, 2, 3) |
553      __gen_uint(values->YDitherOffset, 15, 16) |
554      __gen_uint(values->XDitherOffset, 17, 18) |
555      __gen_uint(values->DestinationBlendFactor, 19, 23) |
556      __gen_uint(values->SourceBlendFactor, 24, 28) |
557      __gen_uint(values->ColorBlendFunction, 29, 31);
558
559   dw[7] =
560      __gen_uint(values->AlphaReferenceValueAsUNORM8, 0, 31) |
561      __gen_float(values->AlphaReferenceValueAsFLOAT32);
562}
563
564#define GEN5_GS_STATE_length                   7
565struct GEN5_GS_STATE {
566   uint32_t                             GRFRegisterCount;
567   uint64_t                             KernelStartPointer;
568   bool                                 SoftwareExceptionEnable;
569   bool                                 MaskStackExceptionEnable;
570   bool                                 IllegalOpcodeExceptionEnable;
571   uint32_t                             FloatingPointMode;
572#define FLOATING_POINT_MODE_IEEE754              0
573#define FLOATING_POINT_MODE_Alternate            1
574   uint32_t                             BindingTableEntryCount;
575   bool                                 SingleProgramFlow;
576   uint32_t                             PerThreadScratchSpace;
577   __gen_address_type                   ScratchSpaceBasePointer;
578   uint32_t                             DispatchGRFStartRegisterForURBData;
579   uint32_t                             VertexURBEntryReadOffset;
580   uint32_t                             VertexURBEntryReadLength;
581   uint32_t                             ConstantURBEntryReadOffset;
582   uint32_t                             ConstantURBEntryReadLength;
583   bool                                 RenderingEnabled;
584   bool                                 SOStatisticsEnable;
585   bool                                 GSStatisticsEnable;
586   uint32_t                             NumberofURBEntries;
587   uint32_t                             URBEntryAllocationSize;
588   uint32_t                             MaximumNumberofThreads;
589   uint32_t                             SamplerCount;
590   __gen_address_type                   SamplerStatePointer;
591   uint32_t                             MaximumVPIndex;
592   bool                                 ReorderEnable;
593};
594
595static inline void
596GEN5_GS_STATE_pack(__attribute__((unused)) __gen_user_data *data,
597                   __attribute__((unused)) void * restrict dst,
598                   __attribute__((unused)) const struct GEN5_GS_STATE * restrict values)
599{
600   uint32_t * restrict dw = (uint32_t * restrict) dst;
601
602   dw[0] =
603      __gen_uint(values->GRFRegisterCount, 1, 3) |
604      __gen_offset(values->KernelStartPointer, 6, 31);
605
606   dw[1] =
607      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
608      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
609      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
610      __gen_uint(values->FloatingPointMode, 16, 16) |
611      __gen_uint(values->BindingTableEntryCount, 18, 25) |
612      __gen_uint(values->SingleProgramFlow, 31, 31);
613
614   const uint32_t v2 =
615      __gen_uint(values->PerThreadScratchSpace, 0, 3);
616   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
617
618   dw[3] =
619      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
620      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
621      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
622      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
623      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
624
625   dw[4] =
626      __gen_uint(values->RenderingEnabled, 8, 8) |
627      __gen_uint(values->SOStatisticsEnable, 9, 9) |
628      __gen_uint(values->GSStatisticsEnable, 10, 10) |
629      __gen_uint(values->NumberofURBEntries, 11, 18) |
630      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
631      __gen_uint(values->MaximumNumberofThreads, 25, 30);
632
633   const uint32_t v5 =
634      __gen_uint(values->SamplerCount, 0, 2);
635   dw[5] = __gen_combine_address(data, &dw[5], values->SamplerStatePointer, v5);
636
637   dw[6] =
638      __gen_uint(values->MaximumVPIndex, 0, 3) |
639      __gen_uint(values->ReorderEnable, 30, 30);
640}
641
642#define GEN5_MEMORY_OBJECT_CONTROL_STATE_length      1
643struct GEN5_MEMORY_OBJECT_CONTROL_STATE {
644   uint32_t                             CacheabilityControl;
645   uint32_t                             GraphicsDataTypeGFDT;
646   bool                                 EncryptedData;
647};
648
649static inline void
650GEN5_MEMORY_OBJECT_CONTROL_STATE_pack(__attribute__((unused)) __gen_user_data *data,
651                                      __attribute__((unused)) void * restrict dst,
652                                      __attribute__((unused)) const struct GEN5_MEMORY_OBJECT_CONTROL_STATE * restrict values)
653{
654   uint32_t * restrict dw = (uint32_t * restrict) dst;
655
656   dw[0] =
657      __gen_uint(values->CacheabilityControl, 0, 1) |
658      __gen_uint(values->GraphicsDataTypeGFDT, 2, 2) |
659      __gen_uint(values->EncryptedData, 3, 3);
660}
661
662#define GEN5_RENDER_SURFACE_STATE_length       6
663struct GEN5_RENDER_SURFACE_STATE {
664   bool                                 CubeFaceEnablePositiveZ;
665   bool                                 CubeFaceEnableNegativeZ;
666   bool                                 CubeFaceEnablePositiveY;
667   bool                                 CubeFaceEnableNegativeY;
668   bool                                 CubeFaceEnablePositiveX;
669   bool                                 CubeFaceEnableNegativeX;
670   uint32_t                             MediaBoundaryPixelMode;
671#define NORMAL_MODE                              0
672   uint32_t                             RenderCacheReadWriteMode;
673#define WRITE_ONLY                               0
674#define READ_WRITE                               1
675   uint32_t                             CubeMapCornerMode;
676#define CUBE_REPLICATE                           0
677#define CUBE_AVERAGE                             1
678   uint32_t                             MIPMapLayoutMode;
679#define MIPLAYOUT_BELOW                          0
680#define MIPLAYOUT_RIGHT                          1
681   uint32_t                             VerticalLineStrideOffset;
682   uint32_t                             VerticalLineStride;
683   bool                                 ColorBlendEnable;
684   uint32_t                             ColorBufferComponentWriteDisables;
685#define WRITEDISABLE_ALPHA                       8
686#define WRITEDISABLE_RED                         4
687#define WRITEDISABLE_GREEN                       2
688#define WRITEDISABLE_BLUE                        1
689   uint32_t                             SurfaceFormat;
690   uint32_t                             DataReturnFormat;
691#define DATA_RETURN_FLOAT32                      0
692#define DATA_RETURN_S114                         1
693   uint32_t                             SurfaceType;
694#define SURFTYPE_1D                              0
695#define SURFTYPE_2D                              1
696#define SURFTYPE_3D                              2
697#define SURFTYPE_CUBE                            3
698#define SURFTYPE_BUFFER                          4
699#define SURFTYPE_NULL                            7
700   __gen_address_type                   SurfaceBaseAddress;
701   uint32_t                             RenderTargetRotation;
702#define RTROTATE_0DEG                            0
703#define RTROTATE_90DEG                           1
704#define RTROTATE_270DEG                          3
705   uint32_t                             MIPCountLOD;
706   uint32_t                             Width;
707   uint32_t                             Height;
708   uint32_t                             TileWalk;
709#define TILEWALK_XMAJOR                          0
710#define TILEWALK_YMAJOR                          1
711   uint32_t                             TiledSurface;
712   uint32_t                             SurfacePitch;
713   uint32_t                             Depth;
714   uint32_t                             RenderTargetViewExtent;
715   uint32_t                             MinimumArrayElement;
716   uint32_t                             SurfaceMinLOD;
717   uint32_t                             YOffset;
718   uint32_t                             XOffset;
719};
720
721static inline void
722GEN5_RENDER_SURFACE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
723                               __attribute__((unused)) void * restrict dst,
724                               __attribute__((unused)) const struct GEN5_RENDER_SURFACE_STATE * restrict values)
725{
726   uint32_t * restrict dw = (uint32_t * restrict) dst;
727
728   dw[0] =
729      __gen_uint(values->CubeFaceEnablePositiveZ, 0, 0) |
730      __gen_uint(values->CubeFaceEnableNegativeZ, 1, 1) |
731      __gen_uint(values->CubeFaceEnablePositiveY, 2, 2) |
732      __gen_uint(values->CubeFaceEnableNegativeY, 3, 3) |
733      __gen_uint(values->CubeFaceEnablePositiveX, 4, 4) |
734      __gen_uint(values->CubeFaceEnableNegativeX, 5, 5) |
735      __gen_uint(values->MediaBoundaryPixelMode, 6, 7) |
736      __gen_uint(values->RenderCacheReadWriteMode, 8, 8) |
737      __gen_uint(values->CubeMapCornerMode, 9, 9) |
738      __gen_uint(values->MIPMapLayoutMode, 10, 10) |
739      __gen_uint(values->VerticalLineStrideOffset, 11, 11) |
740      __gen_uint(values->VerticalLineStride, 12, 12) |
741      __gen_uint(values->ColorBlendEnable, 13, 13) |
742      __gen_uint(values->ColorBufferComponentWriteDisables, 14, 17) |
743      __gen_uint(values->SurfaceFormat, 18, 26) |
744      __gen_uint(values->DataReturnFormat, 27, 27) |
745      __gen_uint(values->SurfaceType, 29, 31);
746
747   dw[1] = __gen_combine_address(data, &dw[1], values->SurfaceBaseAddress, 0);
748
749   dw[2] =
750      __gen_uint(values->RenderTargetRotation, 0, 1) |
751      __gen_uint(values->MIPCountLOD, 2, 5) |
752      __gen_uint(values->Width, 6, 18) |
753      __gen_uint(values->Height, 19, 31);
754
755   dw[3] =
756      __gen_uint(values->TileWalk, 0, 0) |
757      __gen_uint(values->TiledSurface, 1, 1) |
758      __gen_uint(values->SurfacePitch, 3, 19) |
759      __gen_uint(values->Depth, 21, 31);
760
761   dw[4] =
762      __gen_uint(values->RenderTargetViewExtent, 8, 16) |
763      __gen_uint(values->MinimumArrayElement, 17, 27) |
764      __gen_uint(values->SurfaceMinLOD, 28, 31);
765
766   dw[5] =
767      __gen_uint(values->YOffset, 20, 23) |
768      __gen_uint(values->XOffset, 25, 31);
769}
770
771#define GEN5_SAMPLER_BORDER_COLOR_STATE_length     12
772struct GEN5_SAMPLER_BORDER_COLOR_STATE {
773   uint32_t                             BorderColorUnormRed;
774   uint32_t                             BorderColorUnormGreen;
775   uint32_t                             BorderColorUnormBlue;
776   uint32_t                             BorderColorUnormAlpha;
777   float                                BorderColorFloatRed;
778   float                                BorderColorFloatGreen;
779   float                                BorderColorFloatBlue;
780   float                                BorderColorFloatAlpha;
781   uint32_t                             BorderColorFloat16Red;
782   uint32_t                             BorderColorFloat16Green;
783   uint32_t                             BorderColorFloat16Blue;
784   uint32_t                             BorderColorFloat16Alpha;
785   uint32_t                             BorderColorUnorm16Red;
786   uint32_t                             BorderColorUnorm16Green;
787   uint32_t                             BorderColorUnorm16Blue;
788   uint32_t                             BorderColorUnorm16Alpha;
789   int32_t                              BorderColorSnorm16Red;
790   int32_t                              BorderColorSnorm16Green;
791   int32_t                              BorderColorSnorm16Blue;
792   int32_t                              BorderColorSnorm16Alpha;
793   int32_t                              BorderColorSnorm8Red;
794   int32_t                              BorderColorSnorm8Green;
795   int32_t                              BorderColorSnorm8Blue;
796   int32_t                              BorderColorSnorm8Alpha;
797};
798
799static inline void
800GEN5_SAMPLER_BORDER_COLOR_STATE_pack(__attribute__((unused)) __gen_user_data *data,
801                                     __attribute__((unused)) void * restrict dst,
802                                     __attribute__((unused)) const struct GEN5_SAMPLER_BORDER_COLOR_STATE * restrict values)
803{
804   uint32_t * restrict dw = (uint32_t * restrict) dst;
805
806   dw[0] =
807      __gen_uint(values->BorderColorUnormRed, 0, 7) |
808      __gen_uint(values->BorderColorUnormGreen, 8, 15) |
809      __gen_uint(values->BorderColorUnormBlue, 16, 23) |
810      __gen_uint(values->BorderColorUnormAlpha, 24, 31);
811
812   dw[1] =
813      __gen_float(values->BorderColorFloatRed);
814
815   dw[2] =
816      __gen_float(values->BorderColorFloatGreen);
817
818   dw[3] =
819      __gen_float(values->BorderColorFloatBlue);
820
821   dw[4] =
822      __gen_float(values->BorderColorFloatAlpha);
823
824   dw[5] =
825      __gen_uint(values->BorderColorFloat16Red, 0, 15) |
826      __gen_uint(values->BorderColorFloat16Green, 16, 31);
827
828   dw[6] =
829      __gen_uint(values->BorderColorFloat16Blue, 0, 15) |
830      __gen_uint(values->BorderColorFloat16Alpha, 16, 31);
831
832   dw[7] =
833      __gen_uint(values->BorderColorUnorm16Red, 0, 15) |
834      __gen_uint(values->BorderColorUnorm16Green, 16, 31);
835
836   dw[8] =
837      __gen_uint(values->BorderColorUnorm16Blue, 0, 15) |
838      __gen_uint(values->BorderColorUnorm16Alpha, 16, 31);
839
840   dw[9] =
841      __gen_sint(values->BorderColorSnorm16Red, 0, 15) |
842      __gen_sint(values->BorderColorSnorm16Green, 16, 31);
843
844   dw[10] =
845      __gen_sint(values->BorderColorSnorm16Blue, 0, 15) |
846      __gen_sint(values->BorderColorSnorm16Alpha, 16, 31);
847
848   dw[11] =
849      __gen_sint(values->BorderColorSnorm8Red, 0, 7) |
850      __gen_sint(values->BorderColorSnorm8Green, 8, 15) |
851      __gen_sint(values->BorderColorSnorm8Blue, 16, 23) |
852      __gen_sint(values->BorderColorSnorm8Alpha, 24, 31);
853}
854
855#define GEN5_SAMPLER_STATE_length              4
856struct GEN5_SAMPLER_STATE {
857   uint32_t                             ShadowFunction;
858#define PREFILTEROP_ALWAYS                       0
859#define PREFILTEROP_NEVER                        1
860#define PREFILTEROP_LESS                         2
861#define PREFILTEROP_EQUAL                        3
862#define PREFILTEROP_LEQUAL                       4
863#define PREFILTEROP_GREATER                      5
864#define PREFILTEROP_NOTEQUAL                     6
865#define PREFILTEROP_GEQUAL                       7
866   float                                TextureLODBias;
867   uint32_t                             MinModeFilter;
868   uint32_t                             MagModeFilter;
869#define MAPFILTER_NEAREST                        0
870#define MAPFILTER_LINEAR                         1
871#define MAPFILTER_ANISOTROPIC                    2
872#define MAPFILTER_MONO                           6
873   uint32_t                             MipModeFilter;
874#define MIPFILTER_NONE                           0
875#define MIPFILTER_NEAREST                        1
876#define MIPFILTER_LINEAR                         3
877   float                                BaseMipLevel;
878   bool                                 LODPreClampEnable;
879   bool                                 SamplerDisable;
880   enum GEN5_Texture_Coordinate_Mode    TCZAddressControlMode;
881   enum GEN5_Texture_Coordinate_Mode    TCYAddressControlMode;
882   enum GEN5_Texture_Coordinate_Mode    TCXAddressControlMode;
883   uint32_t                             CubeSurfaceControlMode;
884#define CUBECTRLMODE_PROGRAMMED                  0
885#define CUBECTRLMODE_OVERRIDE                    1
886   float                                MaxLOD;
887   float                                MinLOD;
888   __gen_address_type                   BorderColorPointer;
889   bool                                 RAddressMinFilterRoundingEnable;
890   bool                                 RAddressMagFilterRoundingEnable;
891   bool                                 VAddressMinFilterRoundingEnable;
892   bool                                 VAddressMagFilterRoundingEnable;
893   bool                                 UAddressMinFilterRoundingEnable;
894   bool                                 UAddressMagFilterRoundingEnable;
895   uint32_t                             MaximumAnisotropy;
896#define RATIO21                                  0
897#define RATIO41                                  1
898#define RATIO61                                  2
899#define RATIO81                                  3
900#define RATIO101                                 4
901#define RATIO121                                 5
902#define RATIO141                                 6
903#define RATIO161                                 7
904   uint32_t                             ChromaKeyMode;
905#define KEYFILTER_KILL_ON_ANY_MATCH              0
906#define KEYFILTER_REPLACE_BLACK                  1
907   uint32_t                             ChromaKeyIndex;
908   bool                                 ChromaKeyEnable;
909   uint32_t                             MonochromeFilterWidth;
910   uint32_t                             MonochromeFilterHeight;
911};
912
913static inline void
914GEN5_SAMPLER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
915                        __attribute__((unused)) void * restrict dst,
916                        __attribute__((unused)) const struct GEN5_SAMPLER_STATE * restrict values)
917{
918   uint32_t * restrict dw = (uint32_t * restrict) dst;
919
920   dw[0] =
921      __gen_uint(values->ShadowFunction, 0, 2) |
922      __gen_sfixed(values->TextureLODBias, 3, 13, 6) |
923      __gen_uint(values->MinModeFilter, 14, 16) |
924      __gen_uint(values->MagModeFilter, 17, 19) |
925      __gen_uint(values->MipModeFilter, 20, 21) |
926      __gen_ufixed(values->BaseMipLevel, 22, 26, 1) |
927      __gen_uint(values->LODPreClampEnable, 28, 28) |
928      __gen_uint(values->SamplerDisable, 31, 31);
929
930   dw[1] =
931      __gen_uint(values->TCZAddressControlMode, 0, 2) |
932      __gen_uint(values->TCYAddressControlMode, 3, 5) |
933      __gen_uint(values->TCXAddressControlMode, 6, 8) |
934      __gen_uint(values->CubeSurfaceControlMode, 9, 9) |
935      __gen_ufixed(values->MaxLOD, 12, 21, 6) |
936      __gen_ufixed(values->MinLOD, 22, 31, 6);
937
938   dw[2] = __gen_combine_address(data, &dw[2], values->BorderColorPointer, 0);
939
940   dw[3] =
941      __gen_uint(values->RAddressMinFilterRoundingEnable, 13, 13) |
942      __gen_uint(values->RAddressMagFilterRoundingEnable, 14, 14) |
943      __gen_uint(values->VAddressMinFilterRoundingEnable, 15, 15) |
944      __gen_uint(values->VAddressMagFilterRoundingEnable, 16, 16) |
945      __gen_uint(values->UAddressMinFilterRoundingEnable, 17, 17) |
946      __gen_uint(values->UAddressMagFilterRoundingEnable, 18, 18) |
947      __gen_uint(values->MaximumAnisotropy, 19, 21) |
948      __gen_uint(values->ChromaKeyMode, 22, 22) |
949      __gen_uint(values->ChromaKeyIndex, 23, 24) |
950      __gen_uint(values->ChromaKeyEnable, 25, 25) |
951      __gen_uint(values->MonochromeFilterWidth, 26, 28) |
952      __gen_uint(values->MonochromeFilterHeight, 29, 31);
953}
954
955#define GEN5_SCISSOR_RECT_length               2
956struct GEN5_SCISSOR_RECT {
957   uint32_t                             ScissorRectangleXMin;
958   uint32_t                             ScissorRectangleYMin;
959   uint32_t                             ScissorRectangleXMax;
960   uint32_t                             ScissorRectangleYMax;
961};
962
963static inline void
964GEN5_SCISSOR_RECT_pack(__attribute__((unused)) __gen_user_data *data,
965                       __attribute__((unused)) void * restrict dst,
966                       __attribute__((unused)) const struct GEN5_SCISSOR_RECT * restrict values)
967{
968   uint32_t * restrict dw = (uint32_t * restrict) dst;
969
970   dw[0] =
971      __gen_uint(values->ScissorRectangleXMin, 0, 15) |
972      __gen_uint(values->ScissorRectangleYMin, 16, 31);
973
974   dw[1] =
975      __gen_uint(values->ScissorRectangleXMax, 0, 15) |
976      __gen_uint(values->ScissorRectangleYMax, 16, 31);
977}
978
979#define GEN5_SF_STATE_length                   8
980struct GEN5_SF_STATE {
981   uint32_t                             GRFRegisterCount;
982   uint64_t                             KernelStartPointer;
983   bool                                 SoftwareExceptionEnable;
984   bool                                 MaskStackExceptionEnable;
985   bool                                 IllegalOpcodeExceptionEnable;
986   uint32_t                             FloatingPointMode;
987#define FLOATING_POINT_MODE_IEEE754              0
988#define FLOATING_POINT_MODE_Alternate            1
989   uint32_t                             ThreadPriority;
990#define NormalPriority                           0
991#define HighPriority                             1
992   uint32_t                             BindingTableEntryCount;
993   bool                                 SingleProgramFlow;
994   uint32_t                             PerThreadScratchSpace;
995   __gen_address_type                   ScratchSpaceBasePointer;
996   uint32_t                             DispatchGRFStartRegisterForURBData;
997   uint32_t                             VertexURBEntryReadOffset;
998   uint32_t                             VertexURBEntryReadLength;
999   uint32_t                             ConstantURBEntryReadOffset;
1000   uint32_t                             ConstantURBEntryReadLength;
1001   uint32_t                             NumberofURBEntries;
1002   uint32_t                             URBEntryAllocationSize;
1003   uint32_t                             MaximumNumberofThreads;
1004   uint32_t                             FrontWinding;
1005#define FRONTWINDING_CW                          0
1006#define FRONTWINDING_CCW                         1
1007   bool                                 ViewportTransformEnable;
1008   __gen_address_type                   SetupViewportStateOffset;
1009   float                                DestinationOriginVerticalBias;
1010   float                                DestinationOriginHorizontalBias;
1011   bool                                 ScissorRectangleEnable;
1012   bool                                 _2x2PixelTriangleFilterDisable;
1013   bool                                 ZeroPixelTriangleFilterDisable;
1014   uint32_t                             PointRasterizationRule;
1015#define RASTRULE_UPPER_LEFT                      0
1016#define RASTRULE_UPPER_RIGHT                     1
1017   uint32_t                             LineEndCapAntialiasingRegionWidth;
1018#define _05pixels                                0
1019#define _10pixels                                1
1020#define _20pixels                                2
1021#define _40pixels                                3
1022   float                                LineWidth;
1023   bool                                 FastScissorClipDisable;
1024   uint32_t                             CullMode;
1025#define CULLMODE_BOTH                            0
1026#define CULLMODE_NONE                            1
1027#define CULLMODE_FRONT                           2
1028#define CULLMODE_BACK                            3
1029   bool                                 AntiAliasingEnable;
1030   float                                PointWidth;
1031   uint32_t                             PointWidthSource;
1032#define Vertex                                   0
1033#define State                                    1
1034   uint32_t                             VertexSubPixelPrecisionSelect;
1035#define _8SubPixelPrecisionBits                  0
1036#define _4SubPixelPrecisionBits                  1
1037   bool                                 SpritePointEnable;
1038   uint32_t                             AALineDistanceMode;
1039#define AALINEDISTANCE_MANHATTAN                 0
1040#define AALINEDISTANCE_TRUE                      1
1041   uint32_t                             TriangleFanProvokingVertexSelect;
1042#define Vertex0                                  0
1043#define Vertex1                                  1
1044#define Vertex2                                  2
1045   uint32_t                             LineStripListProvokingVertexSelect;
1046#define Vertex0                                  0
1047#define Vertex1                                  1
1048   uint32_t                             TriangleStripListProvokingVertexSelect;
1049#define Vertex0                                  0
1050#define Vertex1                                  1
1051#define Vertex2                                  2
1052   bool                                 LastPixelEnable;
1053};
1054
1055static inline void
1056GEN5_SF_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1057                   __attribute__((unused)) void * restrict dst,
1058                   __attribute__((unused)) const struct GEN5_SF_STATE * restrict values)
1059{
1060   uint32_t * restrict dw = (uint32_t * restrict) dst;
1061
1062   dw[0] =
1063      __gen_uint(values->GRFRegisterCount, 1, 3) |
1064      __gen_offset(values->KernelStartPointer, 6, 31);
1065
1066   dw[1] =
1067      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
1068      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
1069      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
1070      __gen_uint(values->FloatingPointMode, 16, 16) |
1071      __gen_uint(values->ThreadPriority, 17, 17) |
1072      __gen_uint(values->BindingTableEntryCount, 18, 25) |
1073      __gen_uint(values->SingleProgramFlow, 31, 31);
1074
1075   const uint32_t v2 =
1076      __gen_uint(values->PerThreadScratchSpace, 0, 3);
1077   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
1078
1079   dw[3] =
1080      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
1081      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
1082      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
1083      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
1084      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
1085
1086   dw[4] =
1087      __gen_uint(values->NumberofURBEntries, 11, 18) |
1088      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
1089      __gen_uint(values->MaximumNumberofThreads, 25, 30);
1090
1091   const uint32_t v5 =
1092      __gen_uint(values->FrontWinding, 0, 0) |
1093      __gen_uint(values->ViewportTransformEnable, 1, 1);
1094   dw[5] = __gen_combine_address(data, &dw[5], values->SetupViewportStateOffset, v5);
1095
1096   dw[6] =
1097      __gen_ufixed(values->DestinationOriginVerticalBias, 9, 12, 4) |
1098      __gen_ufixed(values->DestinationOriginHorizontalBias, 13, 16, 4) |
1099      __gen_uint(values->ScissorRectangleEnable, 17, 17) |
1100      __gen_uint(values->_2x2PixelTriangleFilterDisable, 18, 18) |
1101      __gen_uint(values->ZeroPixelTriangleFilterDisable, 19, 19) |
1102      __gen_uint(values->PointRasterizationRule, 20, 21) |
1103      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 22, 23) |
1104      __gen_ufixed(values->LineWidth, 24, 27, 1) |
1105      __gen_uint(values->FastScissorClipDisable, 28, 28) |
1106      __gen_uint(values->CullMode, 29, 30) |
1107      __gen_uint(values->AntiAliasingEnable, 31, 31);
1108
1109   dw[7] =
1110      __gen_ufixed(values->PointWidth, 0, 10, 3) |
1111      __gen_uint(values->PointWidthSource, 11, 11) |
1112      __gen_uint(values->VertexSubPixelPrecisionSelect, 12, 12) |
1113      __gen_uint(values->SpritePointEnable, 13, 13) |
1114      __gen_uint(values->AALineDistanceMode, 14, 14) |
1115      __gen_uint(values->TriangleFanProvokingVertexSelect, 25, 26) |
1116      __gen_uint(values->LineStripListProvokingVertexSelect, 27, 28) |
1117      __gen_uint(values->TriangleStripListProvokingVertexSelect, 29, 30) |
1118      __gen_uint(values->LastPixelEnable, 31, 31);
1119}
1120
1121#define GEN5_SF_VIEWPORT_length                8
1122struct GEN5_SF_VIEWPORT {
1123   float                                ViewportMatrixElementm00;
1124   float                                ViewportMatrixElementm11;
1125   float                                ViewportMatrixElementm22;
1126   float                                ViewportMatrixElementm30;
1127   float                                ViewportMatrixElementm31;
1128   float                                ViewportMatrixElementm32;
1129   struct GEN5_SCISSOR_RECT             ScissorRectangle;
1130};
1131
1132static inline void
1133GEN5_SF_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
1134                      __attribute__((unused)) void * restrict dst,
1135                      __attribute__((unused)) const struct GEN5_SF_VIEWPORT * restrict values)
1136{
1137   uint32_t * restrict dw = (uint32_t * restrict) dst;
1138
1139   dw[0] =
1140      __gen_float(values->ViewportMatrixElementm00);
1141
1142   dw[1] =
1143      __gen_float(values->ViewportMatrixElementm11);
1144
1145   dw[2] =
1146      __gen_float(values->ViewportMatrixElementm22);
1147
1148   dw[3] =
1149      __gen_float(values->ViewportMatrixElementm30);
1150
1151   dw[4] =
1152      __gen_float(values->ViewportMatrixElementm31);
1153
1154   dw[5] =
1155      __gen_float(values->ViewportMatrixElementm32);
1156
1157   GEN5_SCISSOR_RECT_pack(data, &dw[6], &values->ScissorRectangle);
1158}
1159
1160#define GEN5_VERTEX_BUFFER_STATE_length        4
1161struct GEN5_VERTEX_BUFFER_STATE {
1162   uint32_t                             BufferPitch;
1163   bool                                 NullVertexBuffer;
1164   uint32_t                             BufferAccessType;
1165#define VERTEXDATA                               0
1166#define INSTANCEDATA                             1
1167   uint32_t                             VertexBufferIndex;
1168   __gen_address_type                   BufferStartingAddress;
1169   __gen_address_type                   EndAddress;
1170   uint32_t                             InstanceDataStepRate;
1171};
1172
1173static inline void
1174GEN5_VERTEX_BUFFER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1175                              __attribute__((unused)) void * restrict dst,
1176                              __attribute__((unused)) const struct GEN5_VERTEX_BUFFER_STATE * restrict values)
1177{
1178   uint32_t * restrict dw = (uint32_t * restrict) dst;
1179
1180   dw[0] =
1181      __gen_uint(values->BufferPitch, 0, 11) |
1182      __gen_uint(values->NullVertexBuffer, 13, 13) |
1183      __gen_uint(values->BufferAccessType, 26, 26) |
1184      __gen_uint(values->VertexBufferIndex, 27, 31);
1185
1186   dw[1] = __gen_combine_address(data, &dw[1], values->BufferStartingAddress, 0);
1187
1188   dw[2] = __gen_combine_address(data, &dw[2], values->EndAddress, 0);
1189
1190   dw[3] =
1191      __gen_uint(values->InstanceDataStepRate, 0, 31);
1192}
1193
1194#define GEN5_VERTEX_ELEMENT_STATE_length       2
1195struct GEN5_VERTEX_ELEMENT_STATE {
1196   uint32_t                             SourceElementOffset;
1197   uint32_t                             SourceElementFormat;
1198   bool                                 Valid;
1199   uint32_t                             VertexBufferIndex;
1200   uint32_t                             DestinationElementOffset;
1201   enum GEN5_3D_Vertex_Component_Control Component3Control;
1202   enum GEN5_3D_Vertex_Component_Control Component2Control;
1203   enum GEN5_3D_Vertex_Component_Control Component1Control;
1204   enum GEN5_3D_Vertex_Component_Control Component0Control;
1205};
1206
1207static inline void
1208GEN5_VERTEX_ELEMENT_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1209                               __attribute__((unused)) void * restrict dst,
1210                               __attribute__((unused)) const struct GEN5_VERTEX_ELEMENT_STATE * restrict values)
1211{
1212   uint32_t * restrict dw = (uint32_t * restrict) dst;
1213
1214   dw[0] =
1215      __gen_uint(values->SourceElementOffset, 0, 10) |
1216      __gen_uint(values->SourceElementFormat, 16, 24) |
1217      __gen_uint(values->Valid, 26, 26) |
1218      __gen_uint(values->VertexBufferIndex, 27, 31);
1219
1220   dw[1] =
1221      __gen_uint(values->DestinationElementOffset, 0, 7) |
1222      __gen_uint(values->Component3Control, 16, 18) |
1223      __gen_uint(values->Component2Control, 20, 22) |
1224      __gen_uint(values->Component1Control, 24, 26) |
1225      __gen_uint(values->Component0Control, 28, 30);
1226}
1227
1228#define GEN5_VS_STATE_length                   7
1229struct GEN5_VS_STATE {
1230   uint32_t                             GRFRegisterCount;
1231   uint64_t                             KernelStartPointer;
1232   bool                                 SoftwareExceptionEnable;
1233   bool                                 MaskStackExceptionEnable;
1234   bool                                 IllegalOpcodeExceptionEnable;
1235   uint32_t                             FloatingPointMode;
1236#define FLOATING_POINT_MODE_IEEE754              0
1237#define FLOATING_POINT_MODE_Alternate            1
1238   uint32_t                             ThreadPriority;
1239#define NormalPriority                           0
1240#define HighPriority                             1
1241   uint32_t                             BindingTableEntryCount;
1242   bool                                 SingleProgramFlow;
1243   uint32_t                             PerThreadScratchSpace;
1244   __gen_address_type                   ScratchSpaceBasePointer;
1245   uint32_t                             DispatchGRFStartRegisterForURBData;
1246   uint32_t                             VertexURBEntryReadOffset;
1247   uint32_t                             VertexURBEntryReadLength;
1248   uint32_t                             ConstantURBEntryReadOffset;
1249   uint32_t                             ConstantURBEntryReadLength;
1250   bool                                 StatisticsEnable;
1251   uint32_t                             NumberofURBEntries;
1252   uint32_t                             URBEntryAllocationSize;
1253   uint32_t                             MaximumNumberofThreads;
1254   uint32_t                             SamplerCount;
1255   __gen_address_type                   SamplerStatePointer;
1256   bool                                 Enable;
1257   bool                                 VertexCacheDisable;
1258};
1259
1260static inline void
1261GEN5_VS_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1262                   __attribute__((unused)) void * restrict dst,
1263                   __attribute__((unused)) const struct GEN5_VS_STATE * restrict values)
1264{
1265   uint32_t * restrict dw = (uint32_t * restrict) dst;
1266
1267   dw[0] =
1268      __gen_uint(values->GRFRegisterCount, 1, 3) |
1269      __gen_offset(values->KernelStartPointer, 6, 31);
1270
1271   dw[1] =
1272      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
1273      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
1274      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
1275      __gen_uint(values->FloatingPointMode, 16, 16) |
1276      __gen_uint(values->ThreadPriority, 17, 17) |
1277      __gen_uint(values->BindingTableEntryCount, 18, 25) |
1278      __gen_uint(values->SingleProgramFlow, 31, 31);
1279
1280   const uint32_t v2 =
1281      __gen_uint(values->PerThreadScratchSpace, 0, 3);
1282   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
1283
1284   dw[3] =
1285      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
1286      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
1287      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
1288      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
1289      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
1290
1291   dw[4] =
1292      __gen_uint(values->StatisticsEnable, 10, 10) |
1293      __gen_uint(values->NumberofURBEntries, 11, 18) |
1294      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
1295      __gen_uint(values->MaximumNumberofThreads, 25, 30);
1296
1297   const uint32_t v5 =
1298      __gen_uint(values->SamplerCount, 0, 2);
1299   dw[5] = __gen_combine_address(data, &dw[5], values->SamplerStatePointer, v5);
1300
1301   dw[6] =
1302      __gen_uint(values->Enable, 0, 0) |
1303      __gen_uint(values->VertexCacheDisable, 1, 1);
1304}
1305
1306#define GEN5_WM_STATE_length                  11
1307struct GEN5_WM_STATE {
1308   uint32_t                             GRFRegisterCount0;
1309   uint64_t                             KernelStartPointer0;
1310   bool                                 SoftwareExceptionEnable;
1311   bool                                 MaskStackExceptionEnable;
1312   bool                                 IllegalOpcodeExceptionEnable;
1313   uint32_t                             DepthCoefficientURBReadOffset;
1314   uint32_t                             FloatingPointMode;
1315#define FLOATING_POINT_MODE_IEEE754              0
1316#define FLOATING_POINT_MODE_Alternate            1
1317   uint32_t                             ThreadPriority;
1318#define High                                     1
1319   uint32_t                             BindingTableEntryCount;
1320   bool                                 SingleProgramFlow;
1321   uint32_t                             PerThreadScratchSpace;
1322   __gen_address_type                   ScratchSpaceBasePointer;
1323   uint32_t                             DispatchGRFStartRegisterForConstantSetupData0;
1324   uint32_t                             SetupURBEntryReadOffset;
1325   uint32_t                             SetupURBEntryReadLength;
1326   uint32_t                             ConstantURBEntryReadOffset;
1327   uint32_t                             ConstantURBEntryReadLength;
1328   bool                                 StatisticsEnable;
1329   uint32_t                             SamplerCount;
1330   __gen_address_type                   SamplerStatePointer;
1331   bool                                 _8PixelDispatchEnable;
1332   bool                                 _16PixelDispatchEnable;
1333   bool                                 _32PixelDispatchEnable;
1334   bool                                 Contiguous32PixelDispatchEnable;
1335   bool                                 Contiguous64PixelDispatchEnable;
1336   bool                                 FastSpanCoverageEnable;
1337   bool                                 DepthBufferClear;
1338   bool                                 DepthBufferResolveEnable;
1339   bool                                 HierarchicalDepthBufferResolveEnable;
1340   bool                                 LegacyGlobalDepthBiasEnable;
1341   bool                                 LineStippleEnable;
1342   bool                                 GlobalDepthOffsetEnable;
1343   bool                                 PolygonStippleEnable;
1344   uint32_t                             LineAntialiasingRegionWidth;
1345#define _05pixels                                0
1346#define _10pixels                                1
1347#define _20pixels                                2
1348#define _40pixels                                3
1349   uint32_t                             LineEndCapAntialiasingRegionWidth;
1350#define _05pixels                                0
1351#define _10pixels                                1
1352#define _20pixels                                2
1353#define _40pixels                                3
1354   bool                                 EarlyDepthTestEnable;
1355   bool                                 ThreadDispatchEnable;
1356   bool                                 PixelShaderUsesSourceDepth;
1357   bool                                 PixelShaderComputedDepth;
1358   bool                                 PixelShaderKillsPixel;
1359   bool                                 LegacyDiamondLineRasterization;
1360   uint32_t                             MaximumNumberofThreads;
1361   float                                GlobalDepthOffsetConstant;
1362   float                                GlobalDepthOffsetScale;
1363   uint32_t                             GRFRegisterCount1;
1364   uint64_t                             KernelStartPointer1;
1365   uint32_t                             GRFRegisterCount2;
1366   uint64_t                             KernelStartPointer2;
1367   uint32_t                             GRFRegisterCount3;
1368   uint64_t                             KernelStartPointer3;
1369};
1370
1371static inline void
1372GEN5_WM_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1373                   __attribute__((unused)) void * restrict dst,
1374                   __attribute__((unused)) const struct GEN5_WM_STATE * restrict values)
1375{
1376   uint32_t * restrict dw = (uint32_t * restrict) dst;
1377
1378   dw[0] =
1379      __gen_uint(values->GRFRegisterCount0, 1, 3) |
1380      __gen_offset(values->KernelStartPointer0, 6, 31);
1381
1382   dw[1] =
1383      __gen_uint(values->SoftwareExceptionEnable, 1, 1) |
1384      __gen_uint(values->MaskStackExceptionEnable, 2, 2) |
1385      __gen_uint(values->IllegalOpcodeExceptionEnable, 4, 4) |
1386      __gen_uint(values->DepthCoefficientURBReadOffset, 8, 13) |
1387      __gen_uint(values->FloatingPointMode, 16, 16) |
1388      __gen_uint(values->ThreadPriority, 17, 17) |
1389      __gen_uint(values->BindingTableEntryCount, 18, 25) |
1390      __gen_uint(values->SingleProgramFlow, 31, 31);
1391
1392   const uint32_t v2 =
1393      __gen_uint(values->PerThreadScratchSpace, 0, 3);
1394   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
1395
1396   dw[3] =
1397      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData0, 0, 3) |
1398      __gen_uint(values->SetupURBEntryReadOffset, 4, 9) |
1399      __gen_uint(values->SetupURBEntryReadLength, 11, 16) |
1400      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
1401      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
1402
1403   const uint32_t v4 =
1404      __gen_uint(values->StatisticsEnable, 0, 0) |
1405      __gen_uint(values->SamplerCount, 2, 4);
1406   dw[4] = __gen_combine_address(data, &dw[4], values->SamplerStatePointer, v4);
1407
1408   dw[5] =
1409      __gen_uint(values->_8PixelDispatchEnable, 0, 0) |
1410      __gen_uint(values->_16PixelDispatchEnable, 1, 1) |
1411      __gen_uint(values->_32PixelDispatchEnable, 2, 2) |
1412      __gen_uint(values->Contiguous32PixelDispatchEnable, 3, 3) |
1413      __gen_uint(values->Contiguous64PixelDispatchEnable, 4, 4) |
1414      __gen_uint(values->FastSpanCoverageEnable, 6, 6) |
1415      __gen_uint(values->DepthBufferClear, 7, 7) |
1416      __gen_uint(values->DepthBufferResolveEnable, 8, 8) |
1417      __gen_uint(values->HierarchicalDepthBufferResolveEnable, 9, 9) |
1418      __gen_uint(values->LegacyGlobalDepthBiasEnable, 10, 10) |
1419      __gen_uint(values->LineStippleEnable, 11, 11) |
1420      __gen_uint(values->GlobalDepthOffsetEnable, 12, 12) |
1421      __gen_uint(values->PolygonStippleEnable, 13, 13) |
1422      __gen_uint(values->LineAntialiasingRegionWidth, 14, 15) |
1423      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 16, 17) |
1424      __gen_uint(values->EarlyDepthTestEnable, 18, 18) |
1425      __gen_uint(values->ThreadDispatchEnable, 19, 19) |
1426      __gen_uint(values->PixelShaderUsesSourceDepth, 20, 20) |
1427      __gen_uint(values->PixelShaderComputedDepth, 21, 21) |
1428      __gen_uint(values->PixelShaderKillsPixel, 22, 22) |
1429      __gen_uint(values->LegacyDiamondLineRasterization, 23, 23) |
1430      __gen_uint(values->MaximumNumberofThreads, 25, 31);
1431
1432   dw[6] =
1433      __gen_float(values->GlobalDepthOffsetConstant);
1434
1435   dw[7] =
1436      __gen_float(values->GlobalDepthOffsetScale);
1437
1438   dw[8] =
1439      __gen_uint(values->GRFRegisterCount1, 1, 3) |
1440      __gen_offset(values->KernelStartPointer1, 6, 31);
1441
1442   dw[9] =
1443      __gen_uint(values->GRFRegisterCount2, 1, 3) |
1444      __gen_offset(values->KernelStartPointer2, 6, 31);
1445
1446   dw[10] =
1447      __gen_uint(values->GRFRegisterCount3, 1, 3) |
1448      __gen_offset(values->KernelStartPointer3, 6, 31);
1449}
1450
1451#define GEN5_3DPRIMITIVE_length                6
1452#define GEN5_3DPRIMITIVE_length_bias           2
1453#define GEN5_3DPRIMITIVE_header                 \
1454   .DWordLength                         =      4,  \
1455   ._3DCommandSubOpcode                 =      0,  \
1456   ._3DCommandOpcode                    =      3,  \
1457   .CommandSubType                      =      3,  \
1458   .CommandType                         =      3
1459
1460struct GEN5_3DPRIMITIVE {
1461   uint32_t                             DWordLength;
1462   uint32_t                             IndirectVertexCount;
1463   enum GEN5_3D_Prim_Topo_Type          PrimitiveTopologyType;
1464   uint32_t                             VertexAccessType;
1465#define SEQUENTIAL                               0
1466#define RANDOM                                   1
1467   uint32_t                             _3DCommandSubOpcode;
1468   uint32_t                             _3DCommandOpcode;
1469   uint32_t                             CommandSubType;
1470   uint32_t                             CommandType;
1471   uint32_t                             VertexCountPerInstance;
1472   uint32_t                             StartVertexLocation;
1473   uint32_t                             InstanceCount;
1474   uint32_t                             StartInstanceLocation;
1475   int32_t                              BaseVertexLocation;
1476};
1477
1478static inline void
1479GEN5_3DPRIMITIVE_pack(__attribute__((unused)) __gen_user_data *data,
1480                      __attribute__((unused)) void * restrict dst,
1481                      __attribute__((unused)) const struct GEN5_3DPRIMITIVE * restrict values)
1482{
1483   uint32_t * restrict dw = (uint32_t * restrict) dst;
1484
1485   dw[0] =
1486      __gen_uint(values->DWordLength, 0, 7) |
1487      __gen_uint(values->IndirectVertexCount, 9, 9) |
1488      __gen_uint(values->PrimitiveTopologyType, 10, 14) |
1489      __gen_uint(values->VertexAccessType, 15, 15) |
1490      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1491      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1492      __gen_uint(values->CommandSubType, 27, 28) |
1493      __gen_uint(values->CommandType, 29, 31);
1494
1495   dw[1] =
1496      __gen_uint(values->VertexCountPerInstance, 0, 31);
1497
1498   dw[2] =
1499      __gen_uint(values->StartVertexLocation, 0, 31);
1500
1501   dw[3] =
1502      __gen_uint(values->InstanceCount, 0, 31);
1503
1504   dw[4] =
1505      __gen_uint(values->StartInstanceLocation, 0, 31);
1506
1507   dw[5] =
1508      __gen_sint(values->BaseVertexLocation, 0, 31);
1509}
1510
1511#define GEN5_3DSTATE_AA_LINE_PARAMETERS_length      3
1512#define GEN5_3DSTATE_AA_LINE_PARAMETERS_length_bias      2
1513#define GEN5_3DSTATE_AA_LINE_PARAMETERS_header  \
1514   .DWordLength                         =      1,  \
1515   ._3DCommandSubOpcode                 =     10,  \
1516   ._3DCommandOpcode                    =      1,  \
1517   .CommandSubType                      =      3,  \
1518   .CommandType                         =      3
1519
1520struct GEN5_3DSTATE_AA_LINE_PARAMETERS {
1521   uint32_t                             DWordLength;
1522   uint32_t                             _3DCommandSubOpcode;
1523   uint32_t                             _3DCommandOpcode;
1524   uint32_t                             CommandSubType;
1525   uint32_t                             CommandType;
1526   float                                AACoverageSlope;
1527   float                                AACoverageBias;
1528   float                                AACoverageEndCapSlope;
1529   float                                AACoverageEndCapBias;
1530};
1531
1532static inline void
1533GEN5_3DSTATE_AA_LINE_PARAMETERS_pack(__attribute__((unused)) __gen_user_data *data,
1534                                     __attribute__((unused)) void * restrict dst,
1535                                     __attribute__((unused)) const struct GEN5_3DSTATE_AA_LINE_PARAMETERS * restrict values)
1536{
1537   uint32_t * restrict dw = (uint32_t * restrict) dst;
1538
1539   dw[0] =
1540      __gen_uint(values->DWordLength, 0, 7) |
1541      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1542      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1543      __gen_uint(values->CommandSubType, 27, 28) |
1544      __gen_uint(values->CommandType, 29, 31);
1545
1546   dw[1] =
1547      __gen_ufixed(values->AACoverageSlope, 0, 7, 8) |
1548      __gen_ufixed(values->AACoverageBias, 16, 23, 8);
1549
1550   dw[2] =
1551      __gen_ufixed(values->AACoverageEndCapSlope, 0, 7, 8) |
1552      __gen_ufixed(values->AACoverageEndCapBias, 16, 23, 8);
1553}
1554
1555#define GEN5_3DSTATE_BINDING_TABLE_POINTERS_length      6
1556#define GEN5_3DSTATE_BINDING_TABLE_POINTERS_length_bias      2
1557#define GEN5_3DSTATE_BINDING_TABLE_POINTERS_header\
1558   .DWordLength                         =      4,  \
1559   ._3DCommandSubOpcode                 =      1,  \
1560   ._3DCommandOpcode                    =      0,  \
1561   .CommandSubType                      =      3,  \
1562   .CommandType                         =      3
1563
1564struct GEN5_3DSTATE_BINDING_TABLE_POINTERS {
1565   uint32_t                             DWordLength;
1566   uint32_t                             _3DCommandSubOpcode;
1567   uint32_t                             _3DCommandOpcode;
1568   uint32_t                             CommandSubType;
1569   uint32_t                             CommandType;
1570   uint64_t                             PointertoVSBindingTable;
1571   uint64_t                             PointertoGSBindingTable;
1572   uint64_t                             PointertoCLIPBindingTable;
1573   uint64_t                             PointertoSFBindingTable;
1574   uint64_t                             PointertoPSBindingTable;
1575};
1576
1577static inline void
1578GEN5_3DSTATE_BINDING_TABLE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
1579                                         __attribute__((unused)) void * restrict dst,
1580                                         __attribute__((unused)) const struct GEN5_3DSTATE_BINDING_TABLE_POINTERS * restrict values)
1581{
1582   uint32_t * restrict dw = (uint32_t * restrict) dst;
1583
1584   dw[0] =
1585      __gen_uint(values->DWordLength, 0, 7) |
1586      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1587      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1588      __gen_uint(values->CommandSubType, 27, 28) |
1589      __gen_uint(values->CommandType, 29, 31);
1590
1591   dw[1] =
1592      __gen_offset(values->PointertoVSBindingTable, 5, 31);
1593
1594   dw[2] =
1595      __gen_offset(values->PointertoGSBindingTable, 5, 31);
1596
1597   dw[3] =
1598      __gen_offset(values->PointertoCLIPBindingTable, 5, 31);
1599
1600   dw[4] =
1601      __gen_offset(values->PointertoSFBindingTable, 5, 31);
1602
1603   dw[5] =
1604      __gen_offset(values->PointertoPSBindingTable, 5, 31);
1605}
1606
1607#define GEN5_3DSTATE_CLEAR_PARAMS_length       2
1608#define GEN5_3DSTATE_CLEAR_PARAMS_length_bias      2
1609#define GEN5_3DSTATE_CLEAR_PARAMS_header        \
1610   .DWordLength                         =      0,  \
1611   ._3DCommandSubOpcode                 =     16,  \
1612   ._3DCommandOpcode                    =      1,  \
1613   .CommandSubType                      =      3,  \
1614   .CommandType                         =      3
1615
1616struct GEN5_3DSTATE_CLEAR_PARAMS {
1617   uint32_t                             DWordLength;
1618   bool                                 DepthClearValueValid;
1619   uint32_t                             _3DCommandSubOpcode;
1620   uint32_t                             _3DCommandOpcode;
1621   uint32_t                             CommandSubType;
1622   uint32_t                             CommandType;
1623   uint32_t                             DepthClearValue;
1624};
1625
1626static inline void
1627GEN5_3DSTATE_CLEAR_PARAMS_pack(__attribute__((unused)) __gen_user_data *data,
1628                               __attribute__((unused)) void * restrict dst,
1629                               __attribute__((unused)) const struct GEN5_3DSTATE_CLEAR_PARAMS * restrict values)
1630{
1631   uint32_t * restrict dw = (uint32_t * restrict) dst;
1632
1633   dw[0] =
1634      __gen_uint(values->DWordLength, 0, 7) |
1635      __gen_uint(values->DepthClearValueValid, 15, 15) |
1636      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1637      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1638      __gen_uint(values->CommandSubType, 27, 28) |
1639      __gen_uint(values->CommandType, 29, 31);
1640
1641   dw[1] =
1642      __gen_uint(values->DepthClearValue, 0, 31);
1643}
1644
1645#define GEN5_3DSTATE_CONSTANT_COLOR_length      5
1646#define GEN5_3DSTATE_CONSTANT_COLOR_length_bias      2
1647#define GEN5_3DSTATE_CONSTANT_COLOR_header      \
1648   .DWordLength                         =      3,  \
1649   ._3DCommandSubOpcode                 =      1,  \
1650   ._3DCommandOpcode                    =      1,  \
1651   .CommandSubType                      =      3,  \
1652   .CommandType                         =      3
1653
1654struct GEN5_3DSTATE_CONSTANT_COLOR {
1655   uint32_t                             DWordLength;
1656   uint32_t                             _3DCommandSubOpcode;
1657   uint32_t                             _3DCommandOpcode;
1658   uint32_t                             CommandSubType;
1659   uint32_t                             CommandType;
1660   float                                BlendConstantColorRed;
1661   float                                BlendConstantColorGreen;
1662   float                                BlendConstantColorBlue;
1663   float                                BlendConstantColorAlpha;
1664};
1665
1666static inline void
1667GEN5_3DSTATE_CONSTANT_COLOR_pack(__attribute__((unused)) __gen_user_data *data,
1668                                 __attribute__((unused)) void * restrict dst,
1669                                 __attribute__((unused)) const struct GEN5_3DSTATE_CONSTANT_COLOR * restrict values)
1670{
1671   uint32_t * restrict dw = (uint32_t * restrict) dst;
1672
1673   dw[0] =
1674      __gen_uint(values->DWordLength, 0, 7) |
1675      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1676      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1677      __gen_uint(values->CommandSubType, 27, 28) |
1678      __gen_uint(values->CommandType, 29, 31);
1679
1680   dw[1] =
1681      __gen_float(values->BlendConstantColorRed);
1682
1683   dw[2] =
1684      __gen_float(values->BlendConstantColorGreen);
1685
1686   dw[3] =
1687      __gen_float(values->BlendConstantColorBlue);
1688
1689   dw[4] =
1690      __gen_float(values->BlendConstantColorAlpha);
1691}
1692
1693#define GEN5_3DSTATE_DEPTH_BUFFER_length       6
1694#define GEN5_3DSTATE_DEPTH_BUFFER_length_bias      2
1695#define GEN5_3DSTATE_DEPTH_BUFFER_header        \
1696   .DWordLength                         =      4,  \
1697   ._3DCommandSubOpcode                 =      5,  \
1698   ._3DCommandOpcode                    =      1,  \
1699   .CommandSubType                      =      3,  \
1700   .CommandType                         =      3
1701
1702struct GEN5_3DSTATE_DEPTH_BUFFER {
1703   uint32_t                             DWordLength;
1704   uint32_t                             _3DCommandSubOpcode;
1705   uint32_t                             _3DCommandOpcode;
1706   uint32_t                             CommandSubType;
1707   uint32_t                             CommandType;
1708   uint32_t                             SurfacePitch;
1709   uint32_t                             SurfaceFormat;
1710#define D32_FLOAT_S8X24_UINT                     0
1711#define D32_FLOAT                                1
1712#define D24_UNORM_S8_UINT                        2
1713#define D24_UNORM_X8_UINT                        3
1714#define D16_UNORM                                5
1715   bool                                 SeparateStencilBufferEnable;
1716   bool                                 HierarchicalDepthBufferEnable;
1717   uint32_t                             SoftwareTiledRenderingMode;
1718#define NORMAL                                   0
1719#define STR1                                     1
1720#define STR2                                     3
1721   uint32_t                             TileWalk;
1722#define TILEWALK_YMAJOR                          1
1723   bool                                 TiledSurface;
1724   uint32_t                             SurfaceType;
1725#define SURFTYPE_1D                              0
1726#define SURFTYPE_2D                              1
1727#define SURFTYPE_3D                              2
1728#define SURFTYPE_CUBE                            3
1729#define SURFTYPE_NULL                            7
1730   __gen_address_type                   SurfaceBaseAddress;
1731   uint32_t                             MIPMapLayoutMode;
1732#define MIPLAYOUT_BELOW                          0
1733#define MIPLAYOUT_RIGHT                          1
1734   uint32_t                             LOD;
1735   uint32_t                             Width;
1736   uint32_t                             Height;
1737   uint32_t                             RenderTargetViewExtent;
1738   uint32_t                             MinimumArrayElement;
1739   uint32_t                             Depth;
1740   int32_t                              DepthCoordinateOffsetX;
1741   int32_t                              DepthCoordinateOffsetY;
1742};
1743
1744static inline void
1745GEN5_3DSTATE_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
1746                               __attribute__((unused)) void * restrict dst,
1747                               __attribute__((unused)) const struct GEN5_3DSTATE_DEPTH_BUFFER * restrict values)
1748{
1749   uint32_t * restrict dw = (uint32_t * restrict) dst;
1750
1751   dw[0] =
1752      __gen_uint(values->DWordLength, 0, 7) |
1753      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1754      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1755      __gen_uint(values->CommandSubType, 27, 28) |
1756      __gen_uint(values->CommandType, 29, 31);
1757
1758   dw[1] =
1759      __gen_uint(values->SurfacePitch, 0, 16) |
1760      __gen_uint(values->SurfaceFormat, 18, 20) |
1761      __gen_uint(values->SeparateStencilBufferEnable, 21, 21) |
1762      __gen_uint(values->HierarchicalDepthBufferEnable, 22, 22) |
1763      __gen_uint(values->SoftwareTiledRenderingMode, 23, 24) |
1764      __gen_uint(values->TileWalk, 26, 26) |
1765      __gen_uint(values->TiledSurface, 27, 27) |
1766      __gen_uint(values->SurfaceType, 29, 31);
1767
1768   dw[2] = __gen_combine_address(data, &dw[2], values->SurfaceBaseAddress, 0);
1769
1770   dw[3] =
1771      __gen_uint(values->MIPMapLayoutMode, 1, 1) |
1772      __gen_uint(values->LOD, 2, 5) |
1773      __gen_uint(values->Width, 6, 18) |
1774      __gen_uint(values->Height, 19, 31);
1775
1776   dw[4] =
1777      __gen_uint(values->RenderTargetViewExtent, 1, 9) |
1778      __gen_uint(values->MinimumArrayElement, 10, 20) |
1779      __gen_uint(values->Depth, 21, 31);
1780
1781   dw[5] =
1782      __gen_sint(values->DepthCoordinateOffsetX, 0, 15) |
1783      __gen_sint(values->DepthCoordinateOffsetY, 16, 31);
1784}
1785
1786#define GEN5_3DSTATE_DRAWING_RECTANGLE_length      4
1787#define GEN5_3DSTATE_DRAWING_RECTANGLE_length_bias      2
1788#define GEN5_3DSTATE_DRAWING_RECTANGLE_header   \
1789   .DWordLength                         =      2,  \
1790   ._3DCommandSubOpcode                 =      0,  \
1791   ._3DCommandOpcode                    =      1,  \
1792   .CommandSubType                      =      3,  \
1793   .CommandType                         =      3
1794
1795struct GEN5_3DSTATE_DRAWING_RECTANGLE {
1796   uint32_t                             DWordLength;
1797   uint32_t                             _3DCommandSubOpcode;
1798   uint32_t                             _3DCommandOpcode;
1799   uint32_t                             CommandSubType;
1800   uint32_t                             CommandType;
1801   uint32_t                             ClippedDrawingRectangleXMin;
1802   uint32_t                             ClippedDrawingRectangleYMin;
1803   uint32_t                             ClippedDrawingRectangleXMax;
1804   uint32_t                             ClippedDrawingRectangleYMax;
1805   int32_t                              DrawingRectangleOriginX;
1806   int32_t                              DrawingRectangleOriginY;
1807};
1808
1809static inline void
1810GEN5_3DSTATE_DRAWING_RECTANGLE_pack(__attribute__((unused)) __gen_user_data *data,
1811                                    __attribute__((unused)) void * restrict dst,
1812                                    __attribute__((unused)) const struct GEN5_3DSTATE_DRAWING_RECTANGLE * restrict values)
1813{
1814   uint32_t * restrict dw = (uint32_t * restrict) dst;
1815
1816   dw[0] =
1817      __gen_uint(values->DWordLength, 0, 7) |
1818      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1819      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1820      __gen_uint(values->CommandSubType, 27, 28) |
1821      __gen_uint(values->CommandType, 29, 31);
1822
1823   dw[1] =
1824      __gen_uint(values->ClippedDrawingRectangleXMin, 0, 15) |
1825      __gen_uint(values->ClippedDrawingRectangleYMin, 16, 31);
1826
1827   dw[2] =
1828      __gen_uint(values->ClippedDrawingRectangleXMax, 0, 15) |
1829      __gen_uint(values->ClippedDrawingRectangleYMax, 16, 31);
1830
1831   dw[3] =
1832      __gen_sint(values->DrawingRectangleOriginX, 0, 15) |
1833      __gen_sint(values->DrawingRectangleOriginY, 16, 31);
1834}
1835
1836#define GEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length      2
1837#define GEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length_bias      2
1838#define GEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_header\
1839   .DWordLength                         =      0,  \
1840   ._3DCommandSubOpcode                 =      9,  \
1841   ._3DCommandOpcode                    =      1,  \
1842   .CommandSubType                      =      3,  \
1843   .CommandType                         =      3
1844
1845struct GEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP {
1846   uint32_t                             DWordLength;
1847   uint32_t                             _3DCommandSubOpcode;
1848   uint32_t                             _3DCommandOpcode;
1849   uint32_t                             CommandSubType;
1850   uint32_t                             CommandType;
1851   float                                GlobalDepthOffsetClamp;
1852};
1853
1854static inline void
1855GEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_pack(__attribute__((unused)) __gen_user_data *data,
1856                                            __attribute__((unused)) void * restrict dst,
1857                                            __attribute__((unused)) const struct GEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP * restrict values)
1858{
1859   uint32_t * restrict dw = (uint32_t * restrict) dst;
1860
1861   dw[0] =
1862      __gen_uint(values->DWordLength, 0, 7) |
1863      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1864      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1865      __gen_uint(values->CommandSubType, 27, 28) |
1866      __gen_uint(values->CommandType, 29, 31);
1867
1868   dw[1] =
1869      __gen_float(values->GlobalDepthOffsetClamp);
1870}
1871
1872#define GEN5_3DSTATE_HIER_DEPTH_BUFFER_length      3
1873#define GEN5_3DSTATE_HIER_DEPTH_BUFFER_length_bias      2
1874#define GEN5_3DSTATE_HIER_DEPTH_BUFFER_header   \
1875   .DWordLength                         =      1,  \
1876   ._3DCommandSubOpcode                 =     15,  \
1877   ._3DCommandOpcode                    =      1,  \
1878   .CommandSubType                      =      3,  \
1879   .CommandType                         =      3
1880
1881struct GEN5_3DSTATE_HIER_DEPTH_BUFFER {
1882   uint32_t                             DWordLength;
1883   uint32_t                             _3DCommandSubOpcode;
1884   uint32_t                             _3DCommandOpcode;
1885   uint32_t                             CommandSubType;
1886   uint32_t                             CommandType;
1887   uint32_t                             SurfacePitch;
1888   __gen_address_type                   SurfaceBaseAddress;
1889};
1890
1891static inline void
1892GEN5_3DSTATE_HIER_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
1893                                    __attribute__((unused)) void * restrict dst,
1894                                    __attribute__((unused)) const struct GEN5_3DSTATE_HIER_DEPTH_BUFFER * restrict values)
1895{
1896   uint32_t * restrict dw = (uint32_t * restrict) dst;
1897
1898   dw[0] =
1899      __gen_uint(values->DWordLength, 0, 7) |
1900      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1901      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1902      __gen_uint(values->CommandSubType, 27, 28) |
1903      __gen_uint(values->CommandType, 29, 31);
1904
1905   dw[1] =
1906      __gen_uint(values->SurfacePitch, 0, 16);
1907
1908   dw[2] = __gen_combine_address(data, &dw[2], values->SurfaceBaseAddress, 0);
1909}
1910
1911#define GEN5_3DSTATE_INDEX_BUFFER_length       3
1912#define GEN5_3DSTATE_INDEX_BUFFER_length_bias      2
1913#define GEN5_3DSTATE_INDEX_BUFFER_header        \
1914   .DWordLength                         =      1,  \
1915   ._3DCommandSubOpcode                 =     10,  \
1916   ._3DCommandOpcode                    =      0,  \
1917   .CommandSubType                      =      3,  \
1918   .CommandType                         =      3
1919
1920struct GEN5_3DSTATE_INDEX_BUFFER {
1921   uint32_t                             DWordLength;
1922   uint32_t                             IndexFormat;
1923#define INDEX_BYTE                               0
1924#define INDEX_WORD                               1
1925#define INDEX_DWORD                              2
1926   bool                                 CutIndexEnable;
1927   uint32_t                             _3DCommandSubOpcode;
1928   uint32_t                             _3DCommandOpcode;
1929   uint32_t                             CommandSubType;
1930   uint32_t                             CommandType;
1931   __gen_address_type                   BufferStartingAddress;
1932   __gen_address_type                   BufferEndingAddress;
1933};
1934
1935static inline void
1936GEN5_3DSTATE_INDEX_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
1937                               __attribute__((unused)) void * restrict dst,
1938                               __attribute__((unused)) const struct GEN5_3DSTATE_INDEX_BUFFER * restrict values)
1939{
1940   uint32_t * restrict dw = (uint32_t * restrict) dst;
1941
1942   dw[0] =
1943      __gen_uint(values->DWordLength, 0, 7) |
1944      __gen_uint(values->IndexFormat, 8, 9) |
1945      __gen_uint(values->CutIndexEnable, 10, 10) |
1946      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1947      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1948      __gen_uint(values->CommandSubType, 27, 28) |
1949      __gen_uint(values->CommandType, 29, 31);
1950
1951   dw[1] = __gen_combine_address(data, &dw[1], values->BufferStartingAddress, 0);
1952
1953   dw[2] = __gen_combine_address(data, &dw[2], values->BufferEndingAddress, 0);
1954}
1955
1956#define GEN5_3DSTATE_LINE_STIPPLE_length       3
1957#define GEN5_3DSTATE_LINE_STIPPLE_length_bias      2
1958#define GEN5_3DSTATE_LINE_STIPPLE_header        \
1959   .DWordLength                         =      1,  \
1960   ._3DCommandSubOpcode                 =      8,  \
1961   ._3DCommandOpcode                    =      1,  \
1962   .CommandSubType                      =      3,  \
1963   .CommandType                         =      3
1964
1965struct GEN5_3DSTATE_LINE_STIPPLE {
1966   uint32_t                             DWordLength;
1967   uint32_t                             _3DCommandSubOpcode;
1968   uint32_t                             _3DCommandOpcode;
1969   uint32_t                             CommandSubType;
1970   uint32_t                             CommandType;
1971   uint32_t                             LineStipplePattern;
1972   uint32_t                             CurrentStippleIndex;
1973   uint32_t                             CurrentRepeatCounter;
1974   bool                                 ModifyEnable;
1975   uint32_t                             LineStippleRepeatCount;
1976   float                                LineStippleInverseRepeatCount;
1977};
1978
1979static inline void
1980GEN5_3DSTATE_LINE_STIPPLE_pack(__attribute__((unused)) __gen_user_data *data,
1981                               __attribute__((unused)) void * restrict dst,
1982                               __attribute__((unused)) const struct GEN5_3DSTATE_LINE_STIPPLE * restrict values)
1983{
1984   uint32_t * restrict dw = (uint32_t * restrict) dst;
1985
1986   dw[0] =
1987      __gen_uint(values->DWordLength, 0, 7) |
1988      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1989      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1990      __gen_uint(values->CommandSubType, 27, 28) |
1991      __gen_uint(values->CommandType, 29, 31);
1992
1993   dw[1] =
1994      __gen_uint(values->LineStipplePattern, 0, 15) |
1995      __gen_uint(values->CurrentStippleIndex, 16, 19) |
1996      __gen_uint(values->CurrentRepeatCounter, 21, 29) |
1997      __gen_uint(values->ModifyEnable, 31, 31);
1998
1999   dw[2] =
2000      __gen_uint(values->LineStippleRepeatCount, 0, 8) |
2001      __gen_ufixed(values->LineStippleInverseRepeatCount, 16, 31, 13);
2002}
2003
2004#define GEN5_3DSTATE_PIPELINED_POINTERS_length      7
2005#define GEN5_3DSTATE_PIPELINED_POINTERS_length_bias      2
2006#define GEN5_3DSTATE_PIPELINED_POINTERS_header  \
2007   .DWordLength                         =      5,  \
2008   ._3DCommandSubOpcode                 =      0,  \
2009   ._3DCommandOpcode                    =      0,  \
2010   .CommandSubType                      =      3,  \
2011   .CommandType                         =      3
2012
2013struct GEN5_3DSTATE_PIPELINED_POINTERS {
2014   uint32_t                             DWordLength;
2015   uint32_t                             _3DCommandSubOpcode;
2016   uint32_t                             _3DCommandOpcode;
2017   uint32_t                             CommandSubType;
2018   uint32_t                             CommandType;
2019   __gen_address_type                   PointertoVSState;
2020   bool                                 GSEnable;
2021   __gen_address_type                   PointertoGSState;
2022   bool                                 ClipEnable;
2023   __gen_address_type                   PointertoCLIPState;
2024   __gen_address_type                   PointertoSFState;
2025   __gen_address_type                   PointertoWMState;
2026   __gen_address_type                   PointertoColorCalcState;
2027};
2028
2029static inline void
2030GEN5_3DSTATE_PIPELINED_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
2031                                     __attribute__((unused)) void * restrict dst,
2032                                     __attribute__((unused)) const struct GEN5_3DSTATE_PIPELINED_POINTERS * restrict values)
2033{
2034   uint32_t * restrict dw = (uint32_t * restrict) dst;
2035
2036   dw[0] =
2037      __gen_uint(values->DWordLength, 0, 7) |
2038      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2039      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2040      __gen_uint(values->CommandSubType, 27, 28) |
2041      __gen_uint(values->CommandType, 29, 31);
2042
2043   dw[1] = __gen_combine_address(data, &dw[1], values->PointertoVSState, 0);
2044
2045   const uint32_t v2 =
2046      __gen_uint(values->GSEnable, 0, 0);
2047   dw[2] = __gen_combine_address(data, &dw[2], values->PointertoGSState, v2);
2048
2049   const uint32_t v3 =
2050      __gen_uint(values->ClipEnable, 0, 0);
2051   dw[3] = __gen_combine_address(data, &dw[3], values->PointertoCLIPState, v3);
2052
2053   dw[4] = __gen_combine_address(data, &dw[4], values->PointertoSFState, 0);
2054
2055   dw[5] = __gen_combine_address(data, &dw[5], values->PointertoWMState, 0);
2056
2057   dw[6] = __gen_combine_address(data, &dw[6], values->PointertoColorCalcState, 0);
2058}
2059
2060#define GEN5_3DSTATE_POLY_STIPPLE_OFFSET_length      2
2061#define GEN5_3DSTATE_POLY_STIPPLE_OFFSET_length_bias      2
2062#define GEN5_3DSTATE_POLY_STIPPLE_OFFSET_header \
2063   .DWordLength                         =      0,  \
2064   ._3DCommandSubOpcode                 =      6,  \
2065   ._3DCommandOpcode                    =      1,  \
2066   .CommandSubType                      =      3,  \
2067   .CommandType                         =      3
2068
2069struct GEN5_3DSTATE_POLY_STIPPLE_OFFSET {
2070   uint32_t                             DWordLength;
2071   uint32_t                             _3DCommandSubOpcode;
2072   uint32_t                             _3DCommandOpcode;
2073   uint32_t                             CommandSubType;
2074   uint32_t                             CommandType;
2075   uint32_t                             PolygonStippleYOffset;
2076   uint32_t                             PolygonStippleXOffset;
2077};
2078
2079static inline void
2080GEN5_3DSTATE_POLY_STIPPLE_OFFSET_pack(__attribute__((unused)) __gen_user_data *data,
2081                                      __attribute__((unused)) void * restrict dst,
2082                                      __attribute__((unused)) const struct GEN5_3DSTATE_POLY_STIPPLE_OFFSET * restrict values)
2083{
2084   uint32_t * restrict dw = (uint32_t * restrict) dst;
2085
2086   dw[0] =
2087      __gen_uint(values->DWordLength, 0, 7) |
2088      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2089      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2090      __gen_uint(values->CommandSubType, 27, 28) |
2091      __gen_uint(values->CommandType, 29, 31);
2092
2093   dw[1] =
2094      __gen_uint(values->PolygonStippleYOffset, 0, 4) |
2095      __gen_uint(values->PolygonStippleXOffset, 8, 12);
2096}
2097
2098#define GEN5_3DSTATE_POLY_STIPPLE_PATTERN_length     33
2099#define GEN5_3DSTATE_POLY_STIPPLE_PATTERN_length_bias      2
2100#define GEN5_3DSTATE_POLY_STIPPLE_PATTERN_header\
2101   .DWordLength                         =     31,  \
2102   ._3DCommandSubOpcode                 =      7,  \
2103   ._3DCommandOpcode                    =      1,  \
2104   .CommandSubType                      =      3,  \
2105   .CommandType                         =      3
2106
2107struct GEN5_3DSTATE_POLY_STIPPLE_PATTERN {
2108   uint32_t                             DWordLength;
2109   uint32_t                             _3DCommandSubOpcode;
2110   uint32_t                             _3DCommandOpcode;
2111   uint32_t                             CommandSubType;
2112   uint32_t                             CommandType;
2113   uint32_t                             PatternRow[32];
2114};
2115
2116static inline void
2117GEN5_3DSTATE_POLY_STIPPLE_PATTERN_pack(__attribute__((unused)) __gen_user_data *data,
2118                                       __attribute__((unused)) void * restrict dst,
2119                                       __attribute__((unused)) const struct GEN5_3DSTATE_POLY_STIPPLE_PATTERN * restrict values)
2120{
2121   uint32_t * restrict dw = (uint32_t * restrict) dst;
2122
2123   dw[0] =
2124      __gen_uint(values->DWordLength, 0, 7) |
2125      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2126      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2127      __gen_uint(values->CommandSubType, 27, 28) |
2128      __gen_uint(values->CommandType, 29, 31);
2129
2130   dw[1] =
2131      __gen_uint(values->PatternRow[0], 0, 31);
2132
2133   dw[2] =
2134      __gen_uint(values->PatternRow[1], 0, 31);
2135
2136   dw[3] =
2137      __gen_uint(values->PatternRow[2], 0, 31);
2138
2139   dw[4] =
2140      __gen_uint(values->PatternRow[3], 0, 31);
2141
2142   dw[5] =
2143      __gen_uint(values->PatternRow[4], 0, 31);
2144
2145   dw[6] =
2146      __gen_uint(values->PatternRow[5], 0, 31);
2147
2148   dw[7] =
2149      __gen_uint(values->PatternRow[6], 0, 31);
2150
2151   dw[8] =
2152      __gen_uint(values->PatternRow[7], 0, 31);
2153
2154   dw[9] =
2155      __gen_uint(values->PatternRow[8], 0, 31);
2156
2157   dw[10] =
2158      __gen_uint(values->PatternRow[9], 0, 31);
2159
2160   dw[11] =
2161      __gen_uint(values->PatternRow[10], 0, 31);
2162
2163   dw[12] =
2164      __gen_uint(values->PatternRow[11], 0, 31);
2165
2166   dw[13] =
2167      __gen_uint(values->PatternRow[12], 0, 31);
2168
2169   dw[14] =
2170      __gen_uint(values->PatternRow[13], 0, 31);
2171
2172   dw[15] =
2173      __gen_uint(values->PatternRow[14], 0, 31);
2174
2175   dw[16] =
2176      __gen_uint(values->PatternRow[15], 0, 31);
2177
2178   dw[17] =
2179      __gen_uint(values->PatternRow[16], 0, 31);
2180
2181   dw[18] =
2182      __gen_uint(values->PatternRow[17], 0, 31);
2183
2184   dw[19] =
2185      __gen_uint(values->PatternRow[18], 0, 31);
2186
2187   dw[20] =
2188      __gen_uint(values->PatternRow[19], 0, 31);
2189
2190   dw[21] =
2191      __gen_uint(values->PatternRow[20], 0, 31);
2192
2193   dw[22] =
2194      __gen_uint(values->PatternRow[21], 0, 31);
2195
2196   dw[23] =
2197      __gen_uint(values->PatternRow[22], 0, 31);
2198
2199   dw[24] =
2200      __gen_uint(values->PatternRow[23], 0, 31);
2201
2202   dw[25] =
2203      __gen_uint(values->PatternRow[24], 0, 31);
2204
2205   dw[26] =
2206      __gen_uint(values->PatternRow[25], 0, 31);
2207
2208   dw[27] =
2209      __gen_uint(values->PatternRow[26], 0, 31);
2210
2211   dw[28] =
2212      __gen_uint(values->PatternRow[27], 0, 31);
2213
2214   dw[29] =
2215      __gen_uint(values->PatternRow[28], 0, 31);
2216
2217   dw[30] =
2218      __gen_uint(values->PatternRow[29], 0, 31);
2219
2220   dw[31] =
2221      __gen_uint(values->PatternRow[30], 0, 31);
2222
2223   dw[32] =
2224      __gen_uint(values->PatternRow[31], 0, 31);
2225}
2226
2227#define GEN5_3DSTATE_STENCIL_BUFFER_length      3
2228#define GEN5_3DSTATE_STENCIL_BUFFER_length_bias      2
2229#define GEN5_3DSTATE_STENCIL_BUFFER_header      \
2230   .DWordLength                         =      1,  \
2231   ._3DCommandSubOpcode                 =     14,  \
2232   ._3DCommandOpcode                    =      1,  \
2233   .CommandSubType                      =      3,  \
2234   .CommandType                         =      3
2235
2236struct GEN5_3DSTATE_STENCIL_BUFFER {
2237   uint32_t                             DWordLength;
2238   uint32_t                             _3DCommandSubOpcode;
2239   uint32_t                             _3DCommandOpcode;
2240   uint32_t                             CommandSubType;
2241   uint32_t                             CommandType;
2242   uint32_t                             SurfacePitch;
2243   __gen_address_type                   SurfaceBaseAddress;
2244};
2245
2246static inline void
2247GEN5_3DSTATE_STENCIL_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2248                                 __attribute__((unused)) void * restrict dst,
2249                                 __attribute__((unused)) const struct GEN5_3DSTATE_STENCIL_BUFFER * restrict values)
2250{
2251   uint32_t * restrict dw = (uint32_t * restrict) dst;
2252
2253   dw[0] =
2254      __gen_uint(values->DWordLength, 0, 7) |
2255      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2256      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2257      __gen_uint(values->CommandSubType, 27, 28) |
2258      __gen_uint(values->CommandType, 29, 31);
2259
2260   dw[1] =
2261      __gen_uint(values->SurfacePitch, 0, 16);
2262
2263   dw[2] = __gen_combine_address(data, &dw[2], values->SurfaceBaseAddress, 0);
2264}
2265
2266#define GEN5_3DSTATE_VERTEX_BUFFERS_length_bias      2
2267#define GEN5_3DSTATE_VERTEX_BUFFERS_header      \
2268   .DWordLength                         =      3,  \
2269   ._3DCommandSubOpcode                 =      8,  \
2270   ._3DCommandOpcode                    =      0,  \
2271   .CommandSubType                      =      3,  \
2272   .CommandType                         =      3
2273
2274struct GEN5_3DSTATE_VERTEX_BUFFERS {
2275   uint32_t                             DWordLength;
2276   uint32_t                             _3DCommandSubOpcode;
2277   uint32_t                             _3DCommandOpcode;
2278   uint32_t                             CommandSubType;
2279   uint32_t                             CommandType;
2280   /* variable length fields follow */
2281};
2282
2283static inline void
2284GEN5_3DSTATE_VERTEX_BUFFERS_pack(__attribute__((unused)) __gen_user_data *data,
2285                                 __attribute__((unused)) void * restrict dst,
2286                                 __attribute__((unused)) const struct GEN5_3DSTATE_VERTEX_BUFFERS * restrict values)
2287{
2288   uint32_t * restrict dw = (uint32_t * restrict) dst;
2289
2290   dw[0] =
2291      __gen_uint(values->DWordLength, 0, 7) |
2292      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2293      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2294      __gen_uint(values->CommandSubType, 27, 28) |
2295      __gen_uint(values->CommandType, 29, 31);
2296}
2297
2298#define GEN5_3DSTATE_VERTEX_ELEMENTS_length_bias      2
2299#define GEN5_3DSTATE_VERTEX_ELEMENTS_header     \
2300   .DWordLength                         =      1,  \
2301   ._3DCommandSubOpcode                 =      9,  \
2302   ._3DCommandOpcode                    =      0,  \
2303   .CommandSubType                      =      3,  \
2304   .CommandType                         =      3
2305
2306struct GEN5_3DSTATE_VERTEX_ELEMENTS {
2307   uint32_t                             DWordLength;
2308   uint32_t                             _3DCommandSubOpcode;
2309   uint32_t                             _3DCommandOpcode;
2310   uint32_t                             CommandSubType;
2311   uint32_t                             CommandType;
2312   /* variable length fields follow */
2313};
2314
2315static inline void
2316GEN5_3DSTATE_VERTEX_ELEMENTS_pack(__attribute__((unused)) __gen_user_data *data,
2317                                  __attribute__((unused)) void * restrict dst,
2318                                  __attribute__((unused)) const struct GEN5_3DSTATE_VERTEX_ELEMENTS * restrict values)
2319{
2320   uint32_t * restrict dw = (uint32_t * restrict) dst;
2321
2322   dw[0] =
2323      __gen_uint(values->DWordLength, 0, 7) |
2324      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2325      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2326      __gen_uint(values->CommandSubType, 27, 28) |
2327      __gen_uint(values->CommandType, 29, 31);
2328}
2329
2330#define GEN5_3DSTATE_VF_STATISTICS_length      1
2331#define GEN5_3DSTATE_VF_STATISTICS_length_bias      1
2332#define GEN5_3DSTATE_VF_STATISTICS_header       \
2333   ._3DCommandSubOpcode                 =     11,  \
2334   ._3DCommandOpcode                    =      0,  \
2335   .CommandSubType                      =      1,  \
2336   .CommandType                         =      3
2337
2338struct GEN5_3DSTATE_VF_STATISTICS {
2339   bool                                 StatisticsEnable;
2340   uint32_t                             _3DCommandSubOpcode;
2341   uint32_t                             _3DCommandOpcode;
2342   uint32_t                             CommandSubType;
2343   uint32_t                             CommandType;
2344};
2345
2346static inline void
2347GEN5_3DSTATE_VF_STATISTICS_pack(__attribute__((unused)) __gen_user_data *data,
2348                                __attribute__((unused)) void * restrict dst,
2349                                __attribute__((unused)) const struct GEN5_3DSTATE_VF_STATISTICS * restrict values)
2350{
2351   uint32_t * restrict dw = (uint32_t * restrict) dst;
2352
2353   dw[0] =
2354      __gen_uint(values->StatisticsEnable, 0, 0) |
2355      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2356      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2357      __gen_uint(values->CommandSubType, 27, 28) |
2358      __gen_uint(values->CommandType, 29, 31);
2359}
2360
2361#define GEN5_CONSTANT_BUFFER_length            2
2362#define GEN5_CONSTANT_BUFFER_length_bias       2
2363#define GEN5_CONSTANT_BUFFER_header             \
2364   .DWordLength                         =      0,  \
2365   ._3DCommandSubOpcode                 =      2,  \
2366   ._3DCommandOpcode                    =      0,  \
2367   .CommandSubType                      =      0,  \
2368   .CommandType                         =      3
2369
2370struct GEN5_CONSTANT_BUFFER {
2371   uint32_t                             DWordLength;
2372   bool                                 Valid;
2373   uint32_t                             _3DCommandSubOpcode;
2374   uint32_t                             _3DCommandOpcode;
2375   uint32_t                             CommandSubType;
2376   uint32_t                             CommandType;
2377   uint32_t                             BufferLength;
2378   __gen_address_type                   BufferStartingAddress;
2379};
2380
2381static inline void
2382GEN5_CONSTANT_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2383                          __attribute__((unused)) void * restrict dst,
2384                          __attribute__((unused)) const struct GEN5_CONSTANT_BUFFER * restrict values)
2385{
2386   uint32_t * restrict dw = (uint32_t * restrict) dst;
2387
2388   dw[0] =
2389      __gen_uint(values->DWordLength, 0, 7) |
2390      __gen_uint(values->Valid, 8, 8) |
2391      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2392      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2393      __gen_uint(values->CommandSubType, 27, 28) |
2394      __gen_uint(values->CommandType, 29, 31);
2395
2396   const uint32_t v1 =
2397      __gen_uint(values->BufferLength, 0, 5);
2398   dw[1] = __gen_combine_address(data, &dw[1], values->BufferStartingAddress, v1);
2399}
2400
2401#define GEN5_CS_URB_STATE_length               2
2402#define GEN5_CS_URB_STATE_length_bias          2
2403#define GEN5_CS_URB_STATE_header                \
2404   .DWordLength                         =      0,  \
2405   ._3DCommandSubOpcode                 =      1,  \
2406   ._3DCommandOpcode                    =      0,  \
2407   .CommandSubType                      =      0,  \
2408   .CommandType                         =      3
2409
2410struct GEN5_CS_URB_STATE {
2411   uint32_t                             DWordLength;
2412   uint32_t                             _3DCommandSubOpcode;
2413   uint32_t                             _3DCommandOpcode;
2414   uint32_t                             CommandSubType;
2415   uint32_t                             CommandType;
2416   uint32_t                             NumberofURBEntries;
2417   uint32_t                             URBEntryAllocationSize;
2418};
2419
2420static inline void
2421GEN5_CS_URB_STATE_pack(__attribute__((unused)) __gen_user_data *data,
2422                       __attribute__((unused)) void * restrict dst,
2423                       __attribute__((unused)) const struct GEN5_CS_URB_STATE * restrict values)
2424{
2425   uint32_t * restrict dw = (uint32_t * restrict) dst;
2426
2427   dw[0] =
2428      __gen_uint(values->DWordLength, 0, 7) |
2429      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2430      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2431      __gen_uint(values->CommandSubType, 27, 28) |
2432      __gen_uint(values->CommandType, 29, 31);
2433
2434   dw[1] =
2435      __gen_uint(values->NumberofURBEntries, 0, 2) |
2436      __gen_uint(values->URBEntryAllocationSize, 4, 8);
2437}
2438
2439#define GEN5_MI_FLUSH_length                   1
2440#define GEN5_MI_FLUSH_length_bias              1
2441#define GEN5_MI_FLUSH_header                    \
2442   .MICommandOpcode                     =      4,  \
2443   .CommandType                         =      0
2444
2445struct GEN5_MI_FLUSH {
2446   uint32_t                             StateInstructionCacheInvalidate;
2447#define DontInvalidate                           0
2448#define Invalidate                               1
2449   uint32_t                             RenderCacheFlushInhibit;
2450#define Flush                                    0
2451#define DontFlush                                1
2452   uint32_t                             GlobalSnapshotCountReset;
2453#define DontReset                                0
2454#define Reset                                    1
2455   bool                                 GenericMediaStateClear;
2456   bool                                 IndirectStatePointersDisable;
2457   bool                                 ProtectedMemoryEnable;
2458   uint32_t                             MICommandOpcode;
2459   uint32_t                             CommandType;
2460};
2461
2462static inline void
2463GEN5_MI_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
2464                   __attribute__((unused)) void * restrict dst,
2465                   __attribute__((unused)) const struct GEN5_MI_FLUSH * restrict values)
2466{
2467   uint32_t * restrict dw = (uint32_t * restrict) dst;
2468
2469   dw[0] =
2470      __gen_uint(values->StateInstructionCacheInvalidate, 1, 1) |
2471      __gen_uint(values->RenderCacheFlushInhibit, 2, 2) |
2472      __gen_uint(values->GlobalSnapshotCountReset, 3, 3) |
2473      __gen_uint(values->GenericMediaStateClear, 4, 4) |
2474      __gen_uint(values->IndirectStatePointersDisable, 5, 5) |
2475      __gen_uint(values->ProtectedMemoryEnable, 6, 6) |
2476      __gen_uint(values->MICommandOpcode, 23, 28) |
2477      __gen_uint(values->CommandType, 29, 31);
2478}
2479
2480#define GEN5_MI_LOAD_REGISTER_IMM_length       3
2481#define GEN5_MI_LOAD_REGISTER_IMM_length_bias      2
2482#define GEN5_MI_LOAD_REGISTER_IMM_header        \
2483   .DWordLength                         =      1,  \
2484   .MICommandOpcode                     =     34,  \
2485   .CommandType                         =      0
2486
2487struct GEN5_MI_LOAD_REGISTER_IMM {
2488   uint32_t                             DWordLength;
2489   uint32_t                             ByteWriteDisables;
2490   uint32_t                             MICommandOpcode;
2491   uint32_t                             CommandType;
2492   uint64_t                             RegisterOffset;
2493   uint32_t                             DataDWord;
2494   /* variable length fields follow */
2495};
2496
2497static inline void
2498GEN5_MI_LOAD_REGISTER_IMM_pack(__attribute__((unused)) __gen_user_data *data,
2499                               __attribute__((unused)) void * restrict dst,
2500                               __attribute__((unused)) const struct GEN5_MI_LOAD_REGISTER_IMM * restrict values)
2501{
2502   uint32_t * restrict dw = (uint32_t * restrict) dst;
2503
2504   dw[0] =
2505      __gen_uint(values->DWordLength, 0, 5) |
2506      __gen_uint(values->ByteWriteDisables, 8, 11) |
2507      __gen_uint(values->MICommandOpcode, 23, 28) |
2508      __gen_uint(values->CommandType, 29, 31);
2509
2510   dw[1] =
2511      __gen_offset(values->RegisterOffset, 2, 31);
2512
2513   dw[2] =
2514      __gen_uint(values->DataDWord, 0, 31);
2515}
2516
2517#define GEN5_MI_STORE_DATA_IMM_length          5
2518#define GEN5_MI_STORE_DATA_IMM_length_bias      2
2519#define GEN5_MI_STORE_DATA_IMM_header           \
2520   .DWordLength                         =      2,  \
2521   .MICommandOpcode                     =     32,  \
2522   .CommandType                         =      0
2523
2524struct GEN5_MI_STORE_DATA_IMM {
2525   uint32_t                             DWordLength;
2526   bool                                 MemoryAddressType;
2527   uint32_t                             MICommandOpcode;
2528   uint32_t                             CommandType;
2529   __gen_address_type                   PhysicalStartAddressExtension;
2530   __gen_address_type                   Address;
2531   uint32_t                             DataDWord0;
2532   uint32_t                             DataDWord1;
2533};
2534
2535static inline void
2536GEN5_MI_STORE_DATA_IMM_pack(__attribute__((unused)) __gen_user_data *data,
2537                            __attribute__((unused)) void * restrict dst,
2538                            __attribute__((unused)) const struct GEN5_MI_STORE_DATA_IMM * restrict values)
2539{
2540   uint32_t * restrict dw = (uint32_t * restrict) dst;
2541
2542   dw[0] =
2543      __gen_uint(values->DWordLength, 0, 5) |
2544      __gen_uint(values->MemoryAddressType, 22, 22) |
2545      __gen_uint(values->MICommandOpcode, 23, 28) |
2546      __gen_uint(values->CommandType, 29, 31);
2547
2548   dw[1] = __gen_combine_address(data, &dw[1], values->PhysicalStartAddressExtension, 0);
2549
2550   dw[2] = __gen_combine_address(data, &dw[2], values->Address, 0);
2551
2552   dw[3] =
2553      __gen_uint(values->DataDWord0, 0, 31);
2554
2555   dw[4] =
2556      __gen_uint(values->DataDWord1, 0, 31);
2557}
2558
2559#define GEN5_MI_STORE_REGISTER_MEM_length      3
2560#define GEN5_MI_STORE_REGISTER_MEM_length_bias      2
2561#define GEN5_MI_STORE_REGISTER_MEM_header       \
2562   .DWordLength                         =      1,  \
2563   .MICommandOpcode                     =     36,  \
2564   .CommandType                         =      0
2565
2566struct GEN5_MI_STORE_REGISTER_MEM {
2567   uint32_t                             DWordLength;
2568   bool                                 UseGlobalGTT;
2569   uint32_t                             MICommandOpcode;
2570   uint32_t                             CommandType;
2571   uint64_t                             RegisterAddress;
2572   __gen_address_type                   MemoryAddress;
2573};
2574
2575static inline void
2576GEN5_MI_STORE_REGISTER_MEM_pack(__attribute__((unused)) __gen_user_data *data,
2577                                __attribute__((unused)) void * restrict dst,
2578                                __attribute__((unused)) const struct GEN5_MI_STORE_REGISTER_MEM * restrict values)
2579{
2580   uint32_t * restrict dw = (uint32_t * restrict) dst;
2581
2582   dw[0] =
2583      __gen_uint(values->DWordLength, 0, 7) |
2584      __gen_uint(values->UseGlobalGTT, 22, 22) |
2585      __gen_uint(values->MICommandOpcode, 23, 28) |
2586      __gen_uint(values->CommandType, 29, 31);
2587
2588   dw[1] =
2589      __gen_offset(values->RegisterAddress, 2, 25);
2590
2591   dw[2] = __gen_combine_address(data, &dw[2], values->MemoryAddress, 0);
2592}
2593
2594#define GEN5_PIPELINE_SELECT_length            1
2595#define GEN5_PIPELINE_SELECT_length_bias       1
2596#define GEN5_PIPELINE_SELECT_header             \
2597   ._3DCommandSubOpcode                 =      4,  \
2598   ._3DCommandOpcode                    =      1,  \
2599   .CommandSubType                      =      1,  \
2600   .CommandType                         =      3
2601
2602struct GEN5_PIPELINE_SELECT {
2603   uint32_t                             PipelineSelection;
2604#define _3D                                      0
2605#define Media                                    1
2606#define GPGPU                                    2
2607   uint32_t                             _3DCommandSubOpcode;
2608   uint32_t                             _3DCommandOpcode;
2609   uint32_t                             CommandSubType;
2610   uint32_t                             CommandType;
2611};
2612
2613static inline void
2614GEN5_PIPELINE_SELECT_pack(__attribute__((unused)) __gen_user_data *data,
2615                          __attribute__((unused)) void * restrict dst,
2616                          __attribute__((unused)) const struct GEN5_PIPELINE_SELECT * restrict values)
2617{
2618   uint32_t * restrict dw = (uint32_t * restrict) dst;
2619
2620   dw[0] =
2621      __gen_uint(values->PipelineSelection, 0, 1) |
2622      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2623      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2624      __gen_uint(values->CommandSubType, 27, 28) |
2625      __gen_uint(values->CommandType, 29, 31);
2626}
2627
2628#define GEN5_PIPE_CONTROL_length               4
2629#define GEN5_PIPE_CONTROL_length_bias          2
2630#define GEN5_PIPE_CONTROL_header                \
2631   .DWordLength                         =      2,  \
2632   ._3DCommandSubOpcode                 =      0,  \
2633   ._3DCommandOpcode                    =      2,  \
2634   .CommandSubType                      =      3,  \
2635   .CommandType                         =      3
2636
2637struct GEN5_PIPE_CONTROL {
2638   uint32_t                             DWordLength;
2639   bool                                 NotifyEnable;
2640   bool                                 IndirectStatePointersDisable;
2641   bool                                 TextureCacheFlushEnable;
2642   bool                                 InstructionCacheInvalidateEnable;
2643   bool                                 WriteCacheFlush;
2644   bool                                 DepthStallEnable;
2645   uint32_t                             PostSyncOperation;
2646#define NoWrite                                  0
2647#define WriteImmediateData                       1
2648#define WritePSDepthCount                        2
2649#define WriteTimestamp                           3
2650   uint32_t                             _3DCommandSubOpcode;
2651   uint32_t                             _3DCommandOpcode;
2652   uint32_t                             CommandSubType;
2653   uint32_t                             CommandType;
2654   uint32_t                             DepthCacheFlushInhibit;
2655#define Flushed                                  0
2656#define NotFlushed                               1
2657   bool                                 StallAtPixelScoreboard;
2658   uint32_t                             DestinationAddressType;
2659#define DAT_PGTT                                 0
2660#define DAT_GGTT                                 1
2661   __gen_address_type                   Address;
2662   uint64_t                             ImmediateData;
2663};
2664
2665static inline void
2666GEN5_PIPE_CONTROL_pack(__attribute__((unused)) __gen_user_data *data,
2667                       __attribute__((unused)) void * restrict dst,
2668                       __attribute__((unused)) const struct GEN5_PIPE_CONTROL * restrict values)
2669{
2670   uint32_t * restrict dw = (uint32_t * restrict) dst;
2671
2672   dw[0] =
2673      __gen_uint(values->DWordLength, 0, 7) |
2674      __gen_uint(values->NotifyEnable, 8, 8) |
2675      __gen_uint(values->IndirectStatePointersDisable, 9, 9) |
2676      __gen_uint(values->TextureCacheFlushEnable, 10, 10) |
2677      __gen_uint(values->InstructionCacheInvalidateEnable, 11, 11) |
2678      __gen_uint(values->WriteCacheFlush, 12, 12) |
2679      __gen_uint(values->DepthStallEnable, 13, 13) |
2680      __gen_uint(values->PostSyncOperation, 14, 15) |
2681      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2682      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2683      __gen_uint(values->CommandSubType, 27, 28) |
2684      __gen_uint(values->CommandType, 29, 31);
2685
2686   const uint32_t v1 =
2687      __gen_uint(values->DepthCacheFlushInhibit, 0, 0) |
2688      __gen_uint(values->StallAtPixelScoreboard, 1, 1) |
2689      __gen_uint(values->DestinationAddressType, 2, 2);
2690   dw[1] = __gen_combine_address(data, &dw[1], values->Address, v1);
2691
2692   const uint64_t v2 =
2693      __gen_uint(values->ImmediateData, 0, 63);
2694   dw[2] = v2;
2695   dw[3] = v2 >> 32;
2696}
2697
2698#define GEN5_STATE_BASE_ADDRESS_length         8
2699#define GEN5_STATE_BASE_ADDRESS_length_bias      2
2700#define GEN5_STATE_BASE_ADDRESS_header          \
2701   .DWordLength                         =      6,  \
2702   ._3DCommandSubOpcode                 =      1,  \
2703   ._3DCommandOpcode                    =      1,  \
2704   .CommandSubType                      =      0,  \
2705   .CommandType                         =      3
2706
2707struct GEN5_STATE_BASE_ADDRESS {
2708   uint32_t                             DWordLength;
2709   uint32_t                             _3DCommandSubOpcode;
2710   uint32_t                             _3DCommandOpcode;
2711   uint32_t                             CommandSubType;
2712   uint32_t                             CommandType;
2713   bool                                 GeneralStateBaseAddressModifyEnable;
2714   __gen_address_type                   GeneralStateBaseAddress;
2715   bool                                 SurfaceStateBaseAddressModifyEnable;
2716   __gen_address_type                   SurfaceStateBaseAddress;
2717   bool                                 IndirectObjectBaseAddressModifyEnable;
2718   __gen_address_type                   IndirectObjectBaseAddress;
2719   bool                                 InstructionBaseAddressModifyEnable;
2720   __gen_address_type                   InstructionBaseAddress;
2721   bool                                 GeneralStateAccessUpperBoundModifyEnable;
2722   __gen_address_type                   GeneralStateAccessUpperBound;
2723   bool                                 IndirectObjectAccessUpperBoundModifyEnable;
2724   __gen_address_type                   IndirectObjectAccessUpperBound;
2725   bool                                 InstructionAccessUpperBoundModifyEnable;
2726   __gen_address_type                   InstructionAccessUpperBound;
2727};
2728
2729static inline void
2730GEN5_STATE_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data,
2731                             __attribute__((unused)) void * restrict dst,
2732                             __attribute__((unused)) const struct GEN5_STATE_BASE_ADDRESS * restrict values)
2733{
2734   uint32_t * restrict dw = (uint32_t * restrict) dst;
2735
2736   dw[0] =
2737      __gen_uint(values->DWordLength, 0, 7) |
2738      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2739      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2740      __gen_uint(values->CommandSubType, 27, 28) |
2741      __gen_uint(values->CommandType, 29, 31);
2742
2743   const uint32_t v1 =
2744      __gen_uint(values->GeneralStateBaseAddressModifyEnable, 0, 0);
2745   dw[1] = __gen_combine_address(data, &dw[1], values->GeneralStateBaseAddress, v1);
2746
2747   const uint32_t v2 =
2748      __gen_uint(values->SurfaceStateBaseAddressModifyEnable, 0, 0);
2749   dw[2] = __gen_combine_address(data, &dw[2], values->SurfaceStateBaseAddress, v2);
2750
2751   const uint32_t v3 =
2752      __gen_uint(values->IndirectObjectBaseAddressModifyEnable, 0, 0);
2753   dw[3] = __gen_combine_address(data, &dw[3], values->IndirectObjectBaseAddress, v3);
2754
2755   const uint32_t v4 =
2756      __gen_uint(values->InstructionBaseAddressModifyEnable, 0, 0);
2757   dw[4] = __gen_combine_address(data, &dw[4], values->InstructionBaseAddress, v4);
2758
2759   const uint32_t v5 =
2760      __gen_uint(values->GeneralStateAccessUpperBoundModifyEnable, 0, 0);
2761   dw[5] = __gen_combine_address(data, &dw[5], values->GeneralStateAccessUpperBound, v5);
2762
2763   const uint32_t v6 =
2764      __gen_uint(values->IndirectObjectAccessUpperBoundModifyEnable, 0, 0);
2765   dw[6] = __gen_combine_address(data, &dw[6], values->IndirectObjectAccessUpperBound, v6);
2766
2767   const uint32_t v7 =
2768      __gen_uint(values->InstructionAccessUpperBoundModifyEnable, 0, 0);
2769   dw[7] = __gen_combine_address(data, &dw[7], values->InstructionAccessUpperBound, v7);
2770}
2771
2772#define GEN5_STATE_SIP_length                  2
2773#define GEN5_STATE_SIP_length_bias             2
2774#define GEN5_STATE_SIP_header                   \
2775   .DWordLength                         =      0,  \
2776   ._3DCommandSubOpcode                 =      2,  \
2777   ._3DCommandOpcode                    =      1,  \
2778   .CommandSubType                      =      0,  \
2779   .CommandType                         =      3
2780
2781struct GEN5_STATE_SIP {
2782   uint32_t                             DWordLength;
2783   uint32_t                             _3DCommandSubOpcode;
2784   uint32_t                             _3DCommandOpcode;
2785   uint32_t                             CommandSubType;
2786   uint32_t                             CommandType;
2787   uint64_t                             SystemInstructionPointer;
2788};
2789
2790static inline void
2791GEN5_STATE_SIP_pack(__attribute__((unused)) __gen_user_data *data,
2792                    __attribute__((unused)) void * restrict dst,
2793                    __attribute__((unused)) const struct GEN5_STATE_SIP * restrict values)
2794{
2795   uint32_t * restrict dw = (uint32_t * restrict) dst;
2796
2797   dw[0] =
2798      __gen_uint(values->DWordLength, 0, 7) |
2799      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2800      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2801      __gen_uint(values->CommandSubType, 27, 28) |
2802      __gen_uint(values->CommandType, 29, 31);
2803
2804   dw[1] =
2805      __gen_offset(values->SystemInstructionPointer, 4, 31);
2806}
2807
2808#define GEN5_URB_FENCE_length                  3
2809#define GEN5_URB_FENCE_length_bias             2
2810#define GEN5_URB_FENCE_header                   \
2811   .DWordLength                         =      1,  \
2812   ._3DCommandSubOpcode                 =      0,  \
2813   ._3DCommandOpcode                    =      0,  \
2814   .CommandSubType                      =      0,  \
2815   .CommandType                         =      3
2816
2817struct GEN5_URB_FENCE {
2818   uint32_t                             DWordLength;
2819   bool                                 VSUnitURBReallocationRequest;
2820   bool                                 GSUnitURBReallocationRequest;
2821   bool                                 CLIPUnitURBReallocationRequest;
2822   bool                                 SFUnitURBReallocationRequest;
2823   bool                                 VFEUnitURBReallocationRequest;
2824   bool                                 CSUnitURBReallocationRequest;
2825   uint32_t                             _3DCommandSubOpcode;
2826   uint32_t                             _3DCommandOpcode;
2827   uint32_t                             CommandSubType;
2828   uint32_t                             CommandType;
2829   uint32_t                             VSFence;
2830   uint32_t                             GSFence;
2831   uint32_t                             CLIPFence;
2832   uint32_t                             SFFence;
2833   uint32_t                             VFEFence;
2834   uint32_t                             CSFence;
2835};
2836
2837static inline void
2838GEN5_URB_FENCE_pack(__attribute__((unused)) __gen_user_data *data,
2839                    __attribute__((unused)) void * restrict dst,
2840                    __attribute__((unused)) const struct GEN5_URB_FENCE * restrict values)
2841{
2842   uint32_t * restrict dw = (uint32_t * restrict) dst;
2843
2844   dw[0] =
2845      __gen_uint(values->DWordLength, 0, 7) |
2846      __gen_uint(values->VSUnitURBReallocationRequest, 8, 8) |
2847      __gen_uint(values->GSUnitURBReallocationRequest, 9, 9) |
2848      __gen_uint(values->CLIPUnitURBReallocationRequest, 10, 10) |
2849      __gen_uint(values->SFUnitURBReallocationRequest, 11, 11) |
2850      __gen_uint(values->VFEUnitURBReallocationRequest, 12, 12) |
2851      __gen_uint(values->CSUnitURBReallocationRequest, 13, 13) |
2852      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2853      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2854      __gen_uint(values->CommandSubType, 27, 28) |
2855      __gen_uint(values->CommandType, 29, 31);
2856
2857   dw[1] =
2858      __gen_uint(values->VSFence, 0, 9) |
2859      __gen_uint(values->GSFence, 10, 19) |
2860      __gen_uint(values->CLIPFence, 20, 29);
2861
2862   dw[2] =
2863      __gen_uint(values->SFFence, 0, 9) |
2864      __gen_uint(values->VFEFence, 10, 19) |
2865      __gen_uint(values->CSFence, 20, 30);
2866}
2867
2868#endif /* GEN5_PACK_H */
2869