1b8e80941Smrg/*
2b8e80941Smrg * Copyright (C) 2016 Intel Corporation
3b8e80941Smrg *
4b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5b8e80941Smrg * copy of this software and associated documentation files (the "Software"),
6b8e80941Smrg * to deal in the Software without restriction, including without limitation
7b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the
9b8e80941Smrg * Software is furnished to do so, subject to the following conditions:
10b8e80941Smrg *
11b8e80941Smrg * The above copyright notice and this permission notice (including the next
12b8e80941Smrg * paragraph) shall be included in all copies or substantial portions of the
13b8e80941Smrg * Software.
14b8e80941Smrg *
15b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20b8e80941Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21b8e80941Smrg * IN THE SOFTWARE.
22b8e80941Smrg */
23b8e80941Smrg
24b8e80941Smrg
25b8e80941Smrg/* Instructions, enums and structures for CTG.
26b8e80941Smrg *
27b8e80941Smrg * This file has been generated, do not hand edit.
28b8e80941Smrg */
29b8e80941Smrg
30b8e80941Smrg#ifndef GEN45_PACK_H
31b8e80941Smrg#define GEN45_PACK_H
32b8e80941Smrg
33b8e80941Smrg#include <stdio.h>
34b8e80941Smrg#include <stdint.h>
35b8e80941Smrg#include <stdbool.h>
36b8e80941Smrg#include <assert.h>
37b8e80941Smrg#include <math.h>
38b8e80941Smrg
39b8e80941Smrg#ifndef __gen_validate_value
40b8e80941Smrg#define __gen_validate_value(x)
41b8e80941Smrg#endif
42b8e80941Smrg
43b8e80941Smrg#ifndef __gen_field_functions
44b8e80941Smrg#define __gen_field_functions
45b8e80941Smrg
46b8e80941Smrg#ifdef NDEBUG
47b8e80941Smrg#define NDEBUG_UNUSED __attribute__((unused))
48b8e80941Smrg#else
49b8e80941Smrg#define NDEBUG_UNUSED
50b8e80941Smrg#endif
51b8e80941Smrg
52b8e80941Smrgunion __gen_value {
53b8e80941Smrg   float f;
54b8e80941Smrg   uint32_t dw;
55b8e80941Smrg};
56b8e80941Smrg
57b8e80941Smrgstatic inline uint64_t
58b8e80941Smrg__gen_mbo(uint32_t start, uint32_t end)
59b8e80941Smrg{
60b8e80941Smrg   return (~0ull >> (64 - (end - start + 1))) << start;
61b8e80941Smrg}
62b8e80941Smrg
63b8e80941Smrgstatic inline uint64_t
64b8e80941Smrg__gen_uint(uint64_t v, uint32_t start, NDEBUG_UNUSED uint32_t end)
65b8e80941Smrg{
66b8e80941Smrg   __gen_validate_value(v);
67b8e80941Smrg
68b8e80941Smrg#ifndef NDEBUG
69b8e80941Smrg   const int width = end - start + 1;
70b8e80941Smrg   if (width < 64) {
71b8e80941Smrg      const uint64_t max = (1ull << width) - 1;
72b8e80941Smrg      assert(v <= max);
73b8e80941Smrg   }
74b8e80941Smrg#endif
75b8e80941Smrg
76b8e80941Smrg   return v << start;
77b8e80941Smrg}
78b8e80941Smrg
79b8e80941Smrgstatic inline uint64_t
80b8e80941Smrg__gen_sint(int64_t v, uint32_t start, uint32_t end)
81b8e80941Smrg{
82b8e80941Smrg   const int width = end - start + 1;
83b8e80941Smrg
84b8e80941Smrg   __gen_validate_value(v);
85b8e80941Smrg
86b8e80941Smrg#ifndef NDEBUG
87b8e80941Smrg   if (width < 64) {
88b8e80941Smrg      const int64_t max = (1ll << (width - 1)) - 1;
89b8e80941Smrg      const int64_t min = -(1ll << (width - 1));
90b8e80941Smrg      assert(min <= v && v <= max);
91b8e80941Smrg   }
92b8e80941Smrg#endif
93b8e80941Smrg
94b8e80941Smrg   const uint64_t mask = ~0ull >> (64 - width);
95b8e80941Smrg
96b8e80941Smrg   return (v & mask) << start;
97b8e80941Smrg}
98b8e80941Smrg
99b8e80941Smrgstatic inline uint64_t
100b8e80941Smrg__gen_offset(uint64_t v, NDEBUG_UNUSED uint32_t start, NDEBUG_UNUSED uint32_t end)
101b8e80941Smrg{
102b8e80941Smrg   __gen_validate_value(v);
103b8e80941Smrg#ifndef NDEBUG
104b8e80941Smrg   uint64_t mask = (~0ull >> (64 - (end - start + 1))) << start;
105b8e80941Smrg
106b8e80941Smrg   assert((v & ~mask) == 0);
107b8e80941Smrg#endif
108b8e80941Smrg
109b8e80941Smrg   return v;
110b8e80941Smrg}
111b8e80941Smrg
112b8e80941Smrgstatic inline uint32_t
113b8e80941Smrg__gen_float(float v)
114b8e80941Smrg{
115b8e80941Smrg   __gen_validate_value(v);
116b8e80941Smrg   return ((union __gen_value) { .f = (v) }).dw;
117b8e80941Smrg}
118b8e80941Smrg
119b8e80941Smrgstatic inline uint64_t
120b8e80941Smrg__gen_sfixed(float v, uint32_t start, uint32_t end, uint32_t fract_bits)
121b8e80941Smrg{
122b8e80941Smrg   __gen_validate_value(v);
123b8e80941Smrg
124b8e80941Smrg   const float factor = (1 << fract_bits);
125b8e80941Smrg
126b8e80941Smrg#ifndef NDEBUG
127b8e80941Smrg   const float max = ((1 << (end - start)) - 1) / factor;
128b8e80941Smrg   const float min = -(1 << (end - start)) / factor;
129b8e80941Smrg   assert(min <= v && v <= max);
130b8e80941Smrg#endif
131b8e80941Smrg
132b8e80941Smrg   const int64_t int_val = llroundf(v * factor);
133b8e80941Smrg   const uint64_t mask = ~0ull >> (64 - (end - start + 1));
134b8e80941Smrg
135b8e80941Smrg   return (int_val & mask) << start;
136b8e80941Smrg}
137b8e80941Smrg
138b8e80941Smrgstatic inline uint64_t
139b8e80941Smrg__gen_ufixed(float v, uint32_t start, NDEBUG_UNUSED uint32_t end, uint32_t fract_bits)
140b8e80941Smrg{
141b8e80941Smrg   __gen_validate_value(v);
142b8e80941Smrg
143b8e80941Smrg   const float factor = (1 << fract_bits);
144b8e80941Smrg
145b8e80941Smrg#ifndef NDEBUG
146b8e80941Smrg   const float max = ((1 << (end - start + 1)) - 1) / factor;
147b8e80941Smrg   const float min = 0.0f;
148b8e80941Smrg   assert(min <= v && v <= max);
149b8e80941Smrg#endif
150b8e80941Smrg
151b8e80941Smrg   const uint64_t uint_val = llroundf(v * factor);
152b8e80941Smrg
153b8e80941Smrg   return uint_val << start;
154b8e80941Smrg}
155b8e80941Smrg
156b8e80941Smrg#ifndef __gen_address_type
157b8e80941Smrg#error #define __gen_address_type before including this file
158b8e80941Smrg#endif
159b8e80941Smrg
160b8e80941Smrg#ifndef __gen_user_data
161b8e80941Smrg#error #define __gen_combine_address before including this file
162b8e80941Smrg#endif
163b8e80941Smrg
164b8e80941Smrg#undef NDEBUG_UNUSED
165b8e80941Smrg
166b8e80941Smrg#endif
167b8e80941Smrg
168b8e80941Smrg
169b8e80941Smrgenum GEN45_3D_Color_Buffer_Blend_Factor {
170b8e80941Smrg   BLENDFACTOR_ONE                      =      1,
171b8e80941Smrg   BLENDFACTOR_SRC_COLOR                =      2,
172b8e80941Smrg   BLENDFACTOR_SRC_ALPHA                =      3,
173b8e80941Smrg   BLENDFACTOR_DST_ALPHA                =      4,
174b8e80941Smrg   BLENDFACTOR_DST_COLOR                =      5,
175b8e80941Smrg   BLENDFACTOR_SRC_ALPHA_SATURATE       =      6,
176b8e80941Smrg   BLENDFACTOR_CONST_COLOR              =      7,
177b8e80941Smrg   BLENDFACTOR_CONST_ALPHA              =      8,
178b8e80941Smrg   BLENDFACTOR_SRC1_COLOR               =      9,
179b8e80941Smrg   BLENDFACTOR_SRC1_ALPHA               =     10,
180b8e80941Smrg   BLENDFACTOR_ZERO                     =     17,
181b8e80941Smrg   BLENDFACTOR_INV_SRC_COLOR            =     18,
182b8e80941Smrg   BLENDFACTOR_INV_SRC_ALPHA            =     19,
183b8e80941Smrg   BLENDFACTOR_INV_DST_ALPHA            =     20,
184b8e80941Smrg   BLENDFACTOR_INV_DST_COLOR            =     21,
185b8e80941Smrg   BLENDFACTOR_INV_CONST_COLOR          =     23,
186b8e80941Smrg   BLENDFACTOR_INV_CONST_ALPHA          =     24,
187b8e80941Smrg   BLENDFACTOR_INV_SRC1_COLOR           =     25,
188b8e80941Smrg   BLENDFACTOR_INV_SRC1_ALPHA           =     26,
189b8e80941Smrg};
190b8e80941Smrg
191b8e80941Smrgenum GEN45_3D_Color_Buffer_Blend_Function {
192b8e80941Smrg   BLENDFUNCTION_ADD                    =      0,
193b8e80941Smrg   BLENDFUNCTION_SUBTRACT               =      1,
194b8e80941Smrg   BLENDFUNCTION_REVERSE_SUBTRACT       =      2,
195b8e80941Smrg   BLENDFUNCTION_MIN                    =      3,
196b8e80941Smrg   BLENDFUNCTION_MAX                    =      4,
197b8e80941Smrg};
198b8e80941Smrg
199b8e80941Smrgenum GEN45_3D_Compare_Function {
200b8e80941Smrg   COMPAREFUNCTION_ALWAYS               =      0,
201b8e80941Smrg   COMPAREFUNCTION_NEVER                =      1,
202b8e80941Smrg   COMPAREFUNCTION_LESS                 =      2,
203b8e80941Smrg   COMPAREFUNCTION_EQUAL                =      3,
204b8e80941Smrg   COMPAREFUNCTION_LEQUAL               =      4,
205b8e80941Smrg   COMPAREFUNCTION_GREATER              =      5,
206b8e80941Smrg   COMPAREFUNCTION_NOTEQUAL             =      6,
207b8e80941Smrg   COMPAREFUNCTION_GEQUAL               =      7,
208b8e80941Smrg};
209b8e80941Smrg
210b8e80941Smrgenum GEN45_3D_Logic_Op_Function {
211b8e80941Smrg   LOGICOP_CLEAR                        =      0,
212b8e80941Smrg   LOGICOP_NOR                          =      1,
213b8e80941Smrg   LOGICOP_AND_INVERTED                 =      2,
214b8e80941Smrg   LOGICOP_COPY_INVERTED                =      3,
215b8e80941Smrg   LOGICOP_AND_REVERSE                  =      4,
216b8e80941Smrg   LOGICOP_INVERT                       =      5,
217b8e80941Smrg   LOGICOP_XOR                          =      6,
218b8e80941Smrg   LOGICOP_NAND                         =      7,
219b8e80941Smrg   LOGICOP_AND                          =      8,
220b8e80941Smrg   LOGICOP_EQUIV                        =      9,
221b8e80941Smrg   LOGICOP_NOOP                         =     10,
222b8e80941Smrg   LOGICOP_OR_INVERTED                  =     11,
223b8e80941Smrg   LOGICOP_COPY                         =     12,
224b8e80941Smrg   LOGICOP_OR_REVERSE                   =     13,
225b8e80941Smrg   LOGICOP_OR                           =     14,
226b8e80941Smrg   LOGICOP_SET                          =     15,
227b8e80941Smrg};
228b8e80941Smrg
229b8e80941Smrgenum GEN45_3D_Prim_Topo_Type {
230b8e80941Smrg   _3DPRIM_POINTLIST                    =      1,
231b8e80941Smrg   _3DPRIM_LINELIST                     =      2,
232b8e80941Smrg   _3DPRIM_LINESTRIP                    =      3,
233b8e80941Smrg   _3DPRIM_TRILIST                      =      4,
234b8e80941Smrg   _3DPRIM_TRISTRIP                     =      5,
235b8e80941Smrg   _3DPRIM_TRIFAN                       =      6,
236b8e80941Smrg   _3DPRIM_QUADLIST                     =      7,
237b8e80941Smrg   _3DPRIM_QUADSTRIP                    =      8,
238b8e80941Smrg   _3DPRIM_LINELIST_ADJ                 =      9,
239b8e80941Smrg   _3DPRIM_LINESTRIP_ADJ                =     10,
240b8e80941Smrg   _3DPRIM_TRILIST_ADJ                  =     11,
241b8e80941Smrg   _3DPRIM_TRISTRIP_ADJ                 =     12,
242b8e80941Smrg   _3DPRIM_TRISTRIP_REVERSE             =     13,
243b8e80941Smrg   _3DPRIM_POLYGON                      =     14,
244b8e80941Smrg   _3DPRIM_RECTLIST                     =     15,
245b8e80941Smrg   _3DPRIM_LINELOOP                     =     16,
246b8e80941Smrg   _3DPRIM_POINTLIST_BF                 =     17,
247b8e80941Smrg   _3DPRIM_LINESTRIP_CONT               =     18,
248b8e80941Smrg   _3DPRIM_LINESTRIP_BF                 =     19,
249b8e80941Smrg   _3DPRIM_LINESTRIP_CONT_BF            =     20,
250b8e80941Smrg   _3DPRIM_TRIFAN_NOSTIPPLE             =     22,
251b8e80941Smrg};
252b8e80941Smrg
253b8e80941Smrgenum GEN45_3D_Stencil_Operation {
254b8e80941Smrg   STENCILOP_KEEP                       =      0,
255b8e80941Smrg   STENCILOP_ZERO                       =      1,
256b8e80941Smrg   STENCILOP_REPLACE                    =      2,
257b8e80941Smrg   STENCILOP_INCRSAT                    =      3,
258b8e80941Smrg   STENCILOP_DECRSAT                    =      4,
259b8e80941Smrg   STENCILOP_INCR                       =      5,
260b8e80941Smrg   STENCILOP_DECR                       =      6,
261b8e80941Smrg   STENCILOP_INVERT                     =      7,
262b8e80941Smrg};
263b8e80941Smrg
264b8e80941Smrgenum GEN45_3D_Vertex_Component_Control {
265b8e80941Smrg   VFCOMP_NOSTORE                       =      0,
266b8e80941Smrg   VFCOMP_STORE_SRC                     =      1,
267b8e80941Smrg   VFCOMP_STORE_0                       =      2,
268b8e80941Smrg   VFCOMP_STORE_1_FP                    =      3,
269b8e80941Smrg   VFCOMP_STORE_1_INT                   =      4,
270b8e80941Smrg   VFCOMP_STORE_VID                     =      5,
271b8e80941Smrg   VFCOMP_STORE_IID                     =      6,
272b8e80941Smrg   VFCOMP_STORE_PID                     =      7,
273b8e80941Smrg};
274b8e80941Smrg
275b8e80941Smrgenum GEN45_Texture_Coordinate_Mode {
276b8e80941Smrg   TCM_WRAP                             =      0,
277b8e80941Smrg   TCM_MIRROR                           =      1,
278b8e80941Smrg   TCM_CLAMP                            =      2,
279b8e80941Smrg   TCM_CUBE                             =      3,
280b8e80941Smrg   TCM_CLAMP_BORDER                     =      4,
281b8e80941Smrg   TCM_MIRROR_ONCE                      =      5,
282b8e80941Smrg};
283b8e80941Smrg
284b8e80941Smrg#define GEN45_CC_VIEWPORT_length               2
285b8e80941Smrgstruct GEN45_CC_VIEWPORT {
286b8e80941Smrg   float                                MinimumDepth;
287b8e80941Smrg   float                                MaximumDepth;
288b8e80941Smrg};
289b8e80941Smrg
290b8e80941Smrgstatic inline void
291b8e80941SmrgGEN45_CC_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
292b8e80941Smrg                       __attribute__((unused)) void * restrict dst,
293b8e80941Smrg                       __attribute__((unused)) const struct GEN45_CC_VIEWPORT * restrict values)
294b8e80941Smrg{
295b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
296b8e80941Smrg
297b8e80941Smrg   dw[0] =
298b8e80941Smrg      __gen_float(values->MinimumDepth);
299b8e80941Smrg
300b8e80941Smrg   dw[1] =
301b8e80941Smrg      __gen_float(values->MaximumDepth);
302b8e80941Smrg}
303b8e80941Smrg
304b8e80941Smrg#define GEN45_CLIP_STATE_length               11
305b8e80941Smrgstruct GEN45_CLIP_STATE {
306b8e80941Smrg   uint32_t                             GRFRegisterCount;
307b8e80941Smrg   __gen_address_type                   KernelStartPointer;
308b8e80941Smrg   bool                                 SoftwareExceptionEnable;
309b8e80941Smrg   bool                                 MaskStackExceptionEnable;
310b8e80941Smrg   bool                                 IllegalOpcodeExceptionEnable;
311b8e80941Smrg   uint32_t                             FloatingPointMode;
312b8e80941Smrg#define FLOATING_POINT_MODE_IEEE754              0
313b8e80941Smrg#define FLOATING_POINT_MODE_Alternate            1
314b8e80941Smrg   uint32_t                             ThreadPriority;
315b8e80941Smrg#define NormalPriority                           0
316b8e80941Smrg#define HighPriority                             1
317b8e80941Smrg   uint32_t                             BindingTableEntryCount;
318b8e80941Smrg   bool                                 SingleProgramFlow;
319b8e80941Smrg   uint32_t                             PerThreadScratchSpace;
320b8e80941Smrg   __gen_address_type                   ScratchSpaceBasePointer;
321b8e80941Smrg   uint32_t                             DispatchGRFStartRegisterForURBData;
322b8e80941Smrg   uint32_t                             VertexURBEntryReadOffset;
323b8e80941Smrg   uint32_t                             VertexURBEntryReadLength;
324b8e80941Smrg   uint32_t                             ConstantURBEntryReadOffset;
325b8e80941Smrg   uint32_t                             ConstantURBEntryReadLength;
326b8e80941Smrg   bool                                 ClipperStatisticsEnable;
327b8e80941Smrg   bool                                 GSOutputObjectStatisticsEnable;
328b8e80941Smrg   uint32_t                             NumberofURBEntries;
329b8e80941Smrg   uint32_t                             URBEntryAllocationSize;
330b8e80941Smrg   uint32_t                             MaximumNumberofThreads;
331b8e80941Smrg   uint32_t                             ClipMode;
332b8e80941Smrg#define CLIPMODE_NORMAL                          0
333b8e80941Smrg#define CLIPMODE_ALL                             1
334b8e80941Smrg#define CLIPMODE_CLIP_NON_REJECTED               2
335b8e80941Smrg#define CLIPMODE_REJECT_ALL                      3
336b8e80941Smrg#define CLIPMODE_ACCEPT_ALL                      4
337b8e80941Smrg   uint32_t                             UserClipDistanceClipTestEnableBitmask;
338b8e80941Smrg   bool                                 UserClipFlagsMustClipEnable;
339b8e80941Smrg   bool                                 NegativeWClipTestEnable;
340b8e80941Smrg   bool                                 GuardbandClipTestEnable;
341b8e80941Smrg   bool                                 ViewportZClipTestEnable;
342b8e80941Smrg   bool                                 ViewportXYClipTestEnable;
343b8e80941Smrg   uint32_t                             VertexPositionSpace;
344b8e80941Smrg#define VPOS_NDCSPACE                            0
345b8e80941Smrg#define VPOS_SCREENSPACE                         1
346b8e80941Smrg   uint32_t                             APIMode;
347b8e80941Smrg#define APIMODE_OGL                              0
348b8e80941Smrg#define APIMODE_D3D                              1
349b8e80941Smrg   __gen_address_type                   ClipperViewportStatePointer;
350b8e80941Smrg   float                                ScreenSpaceViewportXMin;
351b8e80941Smrg   float                                ScreenSpaceViewportXMax;
352b8e80941Smrg   float                                ScreenSpaceViewportYMin;
353b8e80941Smrg   float                                ScreenSpaceViewportYMax;
354b8e80941Smrg};
355b8e80941Smrg
356b8e80941Smrgstatic inline void
357b8e80941SmrgGEN45_CLIP_STATE_pack(__attribute__((unused)) __gen_user_data *data,
358b8e80941Smrg                      __attribute__((unused)) void * restrict dst,
359b8e80941Smrg                      __attribute__((unused)) const struct GEN45_CLIP_STATE * restrict values)
360b8e80941Smrg{
361b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
362b8e80941Smrg
363b8e80941Smrg   const uint32_t v0 =
364b8e80941Smrg      __gen_uint(values->GRFRegisterCount, 1, 3);
365b8e80941Smrg   dw[0] = __gen_combine_address(data, &dw[0], values->KernelStartPointer, v0);
366b8e80941Smrg
367b8e80941Smrg   dw[1] =
368b8e80941Smrg      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
369b8e80941Smrg      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
370b8e80941Smrg      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
371b8e80941Smrg      __gen_uint(values->FloatingPointMode, 16, 16) |
372b8e80941Smrg      __gen_uint(values->ThreadPriority, 17, 17) |
373b8e80941Smrg      __gen_uint(values->BindingTableEntryCount, 18, 25) |
374b8e80941Smrg      __gen_uint(values->SingleProgramFlow, 31, 31);
375b8e80941Smrg
376b8e80941Smrg   const uint32_t v2 =
377b8e80941Smrg      __gen_uint(values->PerThreadScratchSpace, 0, 3);
378b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
379b8e80941Smrg
380b8e80941Smrg   dw[3] =
381b8e80941Smrg      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
382b8e80941Smrg      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
383b8e80941Smrg      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
384b8e80941Smrg      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
385b8e80941Smrg      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
386b8e80941Smrg
387b8e80941Smrg   dw[4] =
388b8e80941Smrg      __gen_uint(values->ClipperStatisticsEnable, 10, 10) |
389b8e80941Smrg      __gen_uint(values->GSOutputObjectStatisticsEnable, 10, 10) |
390b8e80941Smrg      __gen_uint(values->NumberofURBEntries, 11, 18) |
391b8e80941Smrg      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
392b8e80941Smrg      __gen_uint(values->MaximumNumberofThreads, 25, 30);
393b8e80941Smrg
394b8e80941Smrg   dw[5] =
395b8e80941Smrg      __gen_uint(values->ClipMode, 13, 15) |
396b8e80941Smrg      __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 16, 23) |
397b8e80941Smrg      __gen_uint(values->UserClipFlagsMustClipEnable, 24, 24) |
398b8e80941Smrg      __gen_uint(values->NegativeWClipTestEnable, 25, 25) |
399b8e80941Smrg      __gen_uint(values->GuardbandClipTestEnable, 26, 26) |
400b8e80941Smrg      __gen_uint(values->ViewportZClipTestEnable, 27, 27) |
401b8e80941Smrg      __gen_uint(values->ViewportXYClipTestEnable, 28, 28) |
402b8e80941Smrg      __gen_uint(values->VertexPositionSpace, 29, 29) |
403b8e80941Smrg      __gen_uint(values->APIMode, 30, 30);
404b8e80941Smrg
405b8e80941Smrg   dw[6] = __gen_combine_address(data, &dw[6], values->ClipperViewportStatePointer, 0);
406b8e80941Smrg
407b8e80941Smrg   dw[7] =
408b8e80941Smrg      __gen_float(values->ScreenSpaceViewportXMin);
409b8e80941Smrg
410b8e80941Smrg   dw[8] =
411b8e80941Smrg      __gen_float(values->ScreenSpaceViewportXMax);
412b8e80941Smrg
413b8e80941Smrg   dw[9] =
414b8e80941Smrg      __gen_float(values->ScreenSpaceViewportYMin);
415b8e80941Smrg
416b8e80941Smrg   dw[10] =
417b8e80941Smrg      __gen_float(values->ScreenSpaceViewportYMax);
418b8e80941Smrg}
419b8e80941Smrg
420b8e80941Smrg#define GEN45_CLIP_VIEWPORT_length             4
421b8e80941Smrgstruct GEN45_CLIP_VIEWPORT {
422b8e80941Smrg   float                                XMinClipGuardband;
423b8e80941Smrg   float                                XMaxClipGuardband;
424b8e80941Smrg   float                                YMinClipGuardband;
425b8e80941Smrg   float                                YMaxClipGuardband;
426b8e80941Smrg};
427b8e80941Smrg
428b8e80941Smrgstatic inline void
429b8e80941SmrgGEN45_CLIP_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
430b8e80941Smrg                         __attribute__((unused)) void * restrict dst,
431b8e80941Smrg                         __attribute__((unused)) const struct GEN45_CLIP_VIEWPORT * restrict values)
432b8e80941Smrg{
433b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
434b8e80941Smrg
435b8e80941Smrg   dw[0] =
436b8e80941Smrg      __gen_float(values->XMinClipGuardband);
437b8e80941Smrg
438b8e80941Smrg   dw[1] =
439b8e80941Smrg      __gen_float(values->XMaxClipGuardband);
440b8e80941Smrg
441b8e80941Smrg   dw[2] =
442b8e80941Smrg      __gen_float(values->YMinClipGuardband);
443b8e80941Smrg
444b8e80941Smrg   dw[3] =
445b8e80941Smrg      __gen_float(values->YMaxClipGuardband);
446b8e80941Smrg}
447b8e80941Smrg
448b8e80941Smrg#define GEN45_COLOR_CALC_STATE_length          8
449b8e80941Smrgstruct GEN45_COLOR_CALC_STATE {
450b8e80941Smrg   enum GEN45_3D_Stencil_Operation      BackfaceStencilPassDepthPassOp;
451b8e80941Smrg   enum GEN45_3D_Stencil_Operation      BackfaceStencilPassDepthFailOp;
452b8e80941Smrg   enum GEN45_3D_Stencil_Operation      BackfaceStencilFailOp;
453b8e80941Smrg   enum GEN45_3D_Compare_Function       BackfaceStencilTestFunction;
454b8e80941Smrg   bool                                 DoubleSidedStencilEnable;
455b8e80941Smrg   bool                                 StencilBufferWriteEnable;
456b8e80941Smrg   enum GEN45_3D_Stencil_Operation      StencilPassDepthPassOp;
457b8e80941Smrg   enum GEN45_3D_Stencil_Operation      StencilPassDepthFailOp;
458b8e80941Smrg   enum GEN45_3D_Stencil_Operation      StencilFailOp;
459b8e80941Smrg   enum GEN45_3D_Compare_Function       StencilTestFunction;
460b8e80941Smrg   bool                                 StencilTestEnable;
461b8e80941Smrg   uint32_t                             BackfaceStencilReferenceValue;
462b8e80941Smrg   uint32_t                             StencilWriteMask;
463b8e80941Smrg   uint32_t                             StencilTestMask;
464b8e80941Smrg   uint32_t                             StencilReferenceValue;
465b8e80941Smrg   bool                                 LogicOpEnable;
466b8e80941Smrg   bool                                 DepthBufferWriteEnable;
467b8e80941Smrg   enum GEN45_3D_Compare_Function       DepthTestFunction;
468b8e80941Smrg   bool                                 DepthTestEnable;
469b8e80941Smrg   uint32_t                             BackfaceStencilWriteMask;
470b8e80941Smrg   uint32_t                             BackfaceStencilTestMask;
471b8e80941Smrg   enum GEN45_3D_Compare_Function       AlphaTestFunction;
472b8e80941Smrg   bool                                 AlphaTestEnable;
473b8e80941Smrg   bool                                 ColorBufferBlendEnable;
474b8e80941Smrg   bool                                 IndependentAlphaBlendEnable;
475b8e80941Smrg   uint32_t                             AlphaTestFormat;
476b8e80941Smrg#define ALPHATEST_UNORM8                         0
477b8e80941Smrg#define ALPHATEST_FLOAT32                        1
478b8e80941Smrg   __gen_address_type                   CCViewportStatePointer;
479b8e80941Smrg   enum GEN45_3D_Color_Buffer_Blend_Factor DestinationAlphaBlendFactor;
480b8e80941Smrg   enum GEN45_3D_Color_Buffer_Blend_Factor SourceAlphaBlendFactor;
481b8e80941Smrg   enum GEN45_3D_Color_Buffer_Blend_Function AlphaBlendFunction;
482b8e80941Smrg   bool                                 StatisticsEnable;
483b8e80941Smrg   enum GEN45_3D_Logic_Op_Function      LogicOpFunction;
484b8e80941Smrg   bool                                 RoundDisableFunctionDisable;
485b8e80941Smrg   bool                                 ColorDitherEnable;
486b8e80941Smrg   bool                                 PostBlendColorClampEnable;
487b8e80941Smrg   bool                                 PreBlendColorClampEnable;
488b8e80941Smrg   uint32_t                             ColorClampRange;
489b8e80941Smrg#define COLORCLAMP_UNORM                         0
490b8e80941Smrg#define COLORCLAMP_SNORM                         1
491b8e80941Smrg#define COLORCLAMP_RTFORMAT                      2
492b8e80941Smrg   uint32_t                             YDitherOffset;
493b8e80941Smrg   uint32_t                             XDitherOffset;
494b8e80941Smrg   enum GEN45_3D_Color_Buffer_Blend_Factor DestinationBlendFactor;
495b8e80941Smrg   enum GEN45_3D_Color_Buffer_Blend_Factor SourceBlendFactor;
496b8e80941Smrg   enum GEN45_3D_Color_Buffer_Blend_Function ColorBlendFunction;
497b8e80941Smrg   uint32_t                             AlphaReferenceValueAsUNORM8;
498b8e80941Smrg   float                                AlphaReferenceValueAsFLOAT32;
499b8e80941Smrg};
500b8e80941Smrg
501b8e80941Smrgstatic inline void
502b8e80941SmrgGEN45_COLOR_CALC_STATE_pack(__attribute__((unused)) __gen_user_data *data,
503b8e80941Smrg                            __attribute__((unused)) void * restrict dst,
504b8e80941Smrg                            __attribute__((unused)) const struct GEN45_COLOR_CALC_STATE * restrict values)
505b8e80941Smrg{
506b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
507b8e80941Smrg
508b8e80941Smrg   dw[0] =
509b8e80941Smrg      __gen_uint(values->BackfaceStencilPassDepthPassOp, 3, 5) |
510b8e80941Smrg      __gen_uint(values->BackfaceStencilPassDepthFailOp, 6, 8) |
511b8e80941Smrg      __gen_uint(values->BackfaceStencilFailOp, 9, 11) |
512b8e80941Smrg      __gen_uint(values->BackfaceStencilTestFunction, 12, 14) |
513b8e80941Smrg      __gen_uint(values->DoubleSidedStencilEnable, 15, 15) |
514b8e80941Smrg      __gen_uint(values->StencilBufferWriteEnable, 18, 18) |
515b8e80941Smrg      __gen_uint(values->StencilPassDepthPassOp, 19, 21) |
516b8e80941Smrg      __gen_uint(values->StencilPassDepthFailOp, 22, 24) |
517b8e80941Smrg      __gen_uint(values->StencilFailOp, 25, 27) |
518b8e80941Smrg      __gen_uint(values->StencilTestFunction, 28, 30) |
519b8e80941Smrg      __gen_uint(values->StencilTestEnable, 31, 31);
520b8e80941Smrg
521b8e80941Smrg   dw[1] =
522b8e80941Smrg      __gen_uint(values->BackfaceStencilReferenceValue, 0, 7) |
523b8e80941Smrg      __gen_uint(values->StencilWriteMask, 8, 15) |
524b8e80941Smrg      __gen_uint(values->StencilTestMask, 16, 23) |
525b8e80941Smrg      __gen_uint(values->StencilReferenceValue, 24, 31);
526b8e80941Smrg
527b8e80941Smrg   dw[2] =
528b8e80941Smrg      __gen_uint(values->LogicOpEnable, 0, 0) |
529b8e80941Smrg      __gen_uint(values->DepthBufferWriteEnable, 11, 11) |
530b8e80941Smrg      __gen_uint(values->DepthTestFunction, 12, 14) |
531b8e80941Smrg      __gen_uint(values->DepthTestEnable, 15, 15) |
532b8e80941Smrg      __gen_uint(values->BackfaceStencilWriteMask, 16, 23) |
533b8e80941Smrg      __gen_uint(values->BackfaceStencilTestMask, 24, 31);
534b8e80941Smrg
535b8e80941Smrg   dw[3] =
536b8e80941Smrg      __gen_uint(values->AlphaTestFunction, 8, 10) |
537b8e80941Smrg      __gen_uint(values->AlphaTestEnable, 11, 11) |
538b8e80941Smrg      __gen_uint(values->ColorBufferBlendEnable, 12, 12) |
539b8e80941Smrg      __gen_uint(values->IndependentAlphaBlendEnable, 13, 13) |
540b8e80941Smrg      __gen_uint(values->AlphaTestFormat, 15, 15);
541b8e80941Smrg
542b8e80941Smrg   dw[4] = __gen_combine_address(data, &dw[4], values->CCViewportStatePointer, 0);
543b8e80941Smrg
544b8e80941Smrg   dw[5] =
545b8e80941Smrg      __gen_uint(values->DestinationAlphaBlendFactor, 2, 6) |
546b8e80941Smrg      __gen_uint(values->SourceAlphaBlendFactor, 7, 11) |
547b8e80941Smrg      __gen_uint(values->AlphaBlendFunction, 12, 14) |
548b8e80941Smrg      __gen_uint(values->StatisticsEnable, 15, 15) |
549b8e80941Smrg      __gen_uint(values->LogicOpFunction, 16, 19) |
550b8e80941Smrg      __gen_uint(values->RoundDisableFunctionDisable, 30, 30) |
551b8e80941Smrg      __gen_uint(values->ColorDitherEnable, 31, 31);
552b8e80941Smrg
553b8e80941Smrg   dw[6] =
554b8e80941Smrg      __gen_uint(values->PostBlendColorClampEnable, 0, 0) |
555b8e80941Smrg      __gen_uint(values->PreBlendColorClampEnable, 1, 1) |
556b8e80941Smrg      __gen_uint(values->ColorClampRange, 2, 3) |
557b8e80941Smrg      __gen_uint(values->YDitherOffset, 15, 16) |
558b8e80941Smrg      __gen_uint(values->XDitherOffset, 17, 18) |
559b8e80941Smrg      __gen_uint(values->DestinationBlendFactor, 19, 23) |
560b8e80941Smrg      __gen_uint(values->SourceBlendFactor, 24, 28) |
561b8e80941Smrg      __gen_uint(values->ColorBlendFunction, 29, 31);
562b8e80941Smrg
563b8e80941Smrg   dw[7] =
564b8e80941Smrg      __gen_uint(values->AlphaReferenceValueAsUNORM8, 0, 31) |
565b8e80941Smrg      __gen_float(values->AlphaReferenceValueAsFLOAT32);
566b8e80941Smrg}
567b8e80941Smrg
568b8e80941Smrg#define GEN45_GS_STATE_length                  7
569b8e80941Smrgstruct GEN45_GS_STATE {
570b8e80941Smrg   uint32_t                             GRFRegisterCount;
571b8e80941Smrg   __gen_address_type                   KernelStartPointer;
572b8e80941Smrg   bool                                 SoftwareExceptionEnable;
573b8e80941Smrg   bool                                 MaskStackExceptionEnable;
574b8e80941Smrg   bool                                 IllegalOpcodeExceptionEnable;
575b8e80941Smrg   uint32_t                             FloatingPointMode;
576b8e80941Smrg#define FLOATING_POINT_MODE_IEEE754              0
577b8e80941Smrg#define FLOATING_POINT_MODE_Alternate            1
578b8e80941Smrg   uint32_t                             BindingTableEntryCount;
579b8e80941Smrg   bool                                 SingleProgramFlow;
580b8e80941Smrg   uint32_t                             PerThreadScratchSpace;
581b8e80941Smrg   __gen_address_type                   ScratchSpaceBasePointer;
582b8e80941Smrg   uint32_t                             DispatchGRFStartRegisterForURBData;
583b8e80941Smrg   uint32_t                             VertexURBEntryReadOffset;
584b8e80941Smrg   uint32_t                             VertexURBEntryReadLength;
585b8e80941Smrg   uint32_t                             ConstantURBEntryReadOffset;
586b8e80941Smrg   uint32_t                             ConstantURBEntryReadLength;
587b8e80941Smrg   bool                                 RenderingEnable;
588b8e80941Smrg   bool                                 GSStatisticsEnable;
589b8e80941Smrg   uint32_t                             NumberofURBEntries;
590b8e80941Smrg   uint32_t                             URBEntryAllocationSize;
591b8e80941Smrg   uint32_t                             MaximumNumberofThreads;
592b8e80941Smrg   uint32_t                             SamplerCount;
593b8e80941Smrg   __gen_address_type                   SamplerStatePointer;
594b8e80941Smrg   uint32_t                             MaximumVPIndex;
595b8e80941Smrg   bool                                 DiscardAdjacency;
596b8e80941Smrg   bool                                 ReorderEnable;
597b8e80941Smrg};
598b8e80941Smrg
599b8e80941Smrgstatic inline void
600b8e80941SmrgGEN45_GS_STATE_pack(__attribute__((unused)) __gen_user_data *data,
601b8e80941Smrg                    __attribute__((unused)) void * restrict dst,
602b8e80941Smrg                    __attribute__((unused)) const struct GEN45_GS_STATE * restrict values)
603b8e80941Smrg{
604b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
605b8e80941Smrg
606b8e80941Smrg   const uint32_t v0 =
607b8e80941Smrg      __gen_uint(values->GRFRegisterCount, 1, 3);
608b8e80941Smrg   dw[0] = __gen_combine_address(data, &dw[0], values->KernelStartPointer, v0);
609b8e80941Smrg
610b8e80941Smrg   dw[1] =
611b8e80941Smrg      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
612b8e80941Smrg      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
613b8e80941Smrg      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
614b8e80941Smrg      __gen_uint(values->FloatingPointMode, 16, 16) |
615b8e80941Smrg      __gen_uint(values->BindingTableEntryCount, 18, 25) |
616b8e80941Smrg      __gen_uint(values->SingleProgramFlow, 31, 31);
617b8e80941Smrg
618b8e80941Smrg   const uint32_t v2 =
619b8e80941Smrg      __gen_uint(values->PerThreadScratchSpace, 0, 3);
620b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
621b8e80941Smrg
622b8e80941Smrg   dw[3] =
623b8e80941Smrg      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
624b8e80941Smrg      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
625b8e80941Smrg      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
626b8e80941Smrg      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
627b8e80941Smrg      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
628b8e80941Smrg
629b8e80941Smrg   dw[4] =
630b8e80941Smrg      __gen_uint(values->RenderingEnable, 8, 8) |
631b8e80941Smrg      __gen_uint(values->GSStatisticsEnable, 10, 10) |
632b8e80941Smrg      __gen_uint(values->NumberofURBEntries, 11, 18) |
633b8e80941Smrg      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
634b8e80941Smrg      __gen_uint(values->MaximumNumberofThreads, 25, 30);
635b8e80941Smrg
636b8e80941Smrg   const uint32_t v5 =
637b8e80941Smrg      __gen_uint(values->SamplerCount, 0, 2);
638b8e80941Smrg   dw[5] = __gen_combine_address(data, &dw[5], values->SamplerStatePointer, v5);
639b8e80941Smrg
640b8e80941Smrg   dw[6] =
641b8e80941Smrg      __gen_uint(values->MaximumVPIndex, 0, 3) |
642b8e80941Smrg      __gen_uint(values->DiscardAdjacency, 29, 29) |
643b8e80941Smrg      __gen_uint(values->ReorderEnable, 30, 30);
644b8e80941Smrg}
645b8e80941Smrg
646b8e80941Smrg#define GEN45_RENDER_SURFACE_STATE_length      6
647b8e80941Smrgstruct GEN45_RENDER_SURFACE_STATE {
648b8e80941Smrg   bool                                 CubeFaceEnablePositiveZ;
649b8e80941Smrg   bool                                 CubeFaceEnableNegativeZ;
650b8e80941Smrg   bool                                 CubeFaceEnablePositiveY;
651b8e80941Smrg   bool                                 CubeFaceEnableNegativeY;
652b8e80941Smrg   bool                                 CubeFaceEnablePositiveX;
653b8e80941Smrg   bool                                 CubeFaceEnableNegativeX;
654b8e80941Smrg   uint32_t                             MediaBoundaryPixelMode;
655b8e80941Smrg#define NORMAL_MODE                              0
656b8e80941Smrg#define PROGRESSIVE_FRAME                        2
657b8e80941Smrg#define INTERLACED_FRAME                         3
658b8e80941Smrg   uint32_t                             RenderCacheReadWriteMode;
659b8e80941Smrg#define WRITE_ONLY                               0
660b8e80941Smrg#define READ_WRITE                               1
661b8e80941Smrg   uint32_t                             MIPMapLayoutMode;
662b8e80941Smrg#define MIPLAYOUT_BELOW                          0
663b8e80941Smrg#define MIPLAYOUT_RIGHT                          1
664b8e80941Smrg   uint32_t                             VerticalLineStrideOffset;
665b8e80941Smrg   uint32_t                             VerticalLineStride;
666b8e80941Smrg   bool                                 ColorBlendEnable;
667b8e80941Smrg   uint32_t                             ColorBufferComponentWriteDisables;
668b8e80941Smrg#define WRITEDISABLE_ALPHA                       8
669b8e80941Smrg#define WRITEDISABLE_RED                         4
670b8e80941Smrg#define WRITEDISABLE_GREEN                       2
671b8e80941Smrg#define WRITEDISABLE_BLUE                        1
672b8e80941Smrg   uint32_t                             SurfaceFormat;
673b8e80941Smrg   uint32_t                             DataReturnFormat;
674b8e80941Smrg#define DATA_RETURN_FLOAT32                      0
675b8e80941Smrg#define DATA_RETURN_S114                         1
676b8e80941Smrg   uint32_t                             SurfaceType;
677b8e80941Smrg#define SURFTYPE_1D                              0
678b8e80941Smrg#define SURFTYPE_2D                              1
679b8e80941Smrg#define SURFTYPE_3D                              2
680b8e80941Smrg#define SURFTYPE_CUBE                            3
681b8e80941Smrg#define SURFTYPE_BUFFER                          4
682b8e80941Smrg#define SURFTYPE_NULL                            7
683b8e80941Smrg   __gen_address_type                   SurfaceBaseAddress;
684b8e80941Smrg   uint32_t                             MIPCountLOD;
685b8e80941Smrg   uint32_t                             Width;
686b8e80941Smrg   uint32_t                             Height;
687b8e80941Smrg   uint32_t                             TileWalk;
688b8e80941Smrg#define TILEWALK_XMAJOR                          0
689b8e80941Smrg#define TILEWALK_YMAJOR                          1
690b8e80941Smrg   uint32_t                             TiledSurface;
691b8e80941Smrg   uint32_t                             SurfacePitch;
692b8e80941Smrg   uint32_t                             Depth;
693b8e80941Smrg   uint32_t                             RenderTargetViewExtent;
694b8e80941Smrg   uint32_t                             MinimumArrayElement;
695b8e80941Smrg   uint32_t                             SurfaceMinLOD;
696b8e80941Smrg   uint32_t                             YOffset;
697b8e80941Smrg   uint32_t                             XOffset;
698b8e80941Smrg};
699b8e80941Smrg
700b8e80941Smrgstatic inline void
701b8e80941SmrgGEN45_RENDER_SURFACE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
702b8e80941Smrg                                __attribute__((unused)) void * restrict dst,
703b8e80941Smrg                                __attribute__((unused)) const struct GEN45_RENDER_SURFACE_STATE * restrict values)
704b8e80941Smrg{
705b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
706b8e80941Smrg
707b8e80941Smrg   dw[0] =
708b8e80941Smrg      __gen_uint(values->CubeFaceEnablePositiveZ, 0, 0) |
709b8e80941Smrg      __gen_uint(values->CubeFaceEnableNegativeZ, 1, 1) |
710b8e80941Smrg      __gen_uint(values->CubeFaceEnablePositiveY, 2, 2) |
711b8e80941Smrg      __gen_uint(values->CubeFaceEnableNegativeY, 3, 3) |
712b8e80941Smrg      __gen_uint(values->CubeFaceEnablePositiveX, 4, 4) |
713b8e80941Smrg      __gen_uint(values->CubeFaceEnableNegativeX, 5, 5) |
714b8e80941Smrg      __gen_uint(values->MediaBoundaryPixelMode, 6, 7) |
715b8e80941Smrg      __gen_uint(values->RenderCacheReadWriteMode, 8, 8) |
716b8e80941Smrg      __gen_uint(values->MIPMapLayoutMode, 10, 10) |
717b8e80941Smrg      __gen_uint(values->VerticalLineStrideOffset, 11, 11) |
718b8e80941Smrg      __gen_uint(values->VerticalLineStride, 12, 12) |
719b8e80941Smrg      __gen_uint(values->ColorBlendEnable, 13, 13) |
720b8e80941Smrg      __gen_uint(values->ColorBufferComponentWriteDisables, 14, 17) |
721b8e80941Smrg      __gen_uint(values->SurfaceFormat, 18, 26) |
722b8e80941Smrg      __gen_uint(values->DataReturnFormat, 27, 27) |
723b8e80941Smrg      __gen_uint(values->SurfaceType, 29, 31);
724b8e80941Smrg
725b8e80941Smrg   dw[1] = __gen_combine_address(data, &dw[1], values->SurfaceBaseAddress, 0);
726b8e80941Smrg
727b8e80941Smrg   dw[2] =
728b8e80941Smrg      __gen_uint(values->MIPCountLOD, 2, 5) |
729b8e80941Smrg      __gen_uint(values->Width, 6, 18) |
730b8e80941Smrg      __gen_uint(values->Height, 19, 31);
731b8e80941Smrg
732b8e80941Smrg   dw[3] =
733b8e80941Smrg      __gen_uint(values->TileWalk, 0, 0) |
734b8e80941Smrg      __gen_uint(values->TiledSurface, 1, 1) |
735b8e80941Smrg      __gen_uint(values->SurfacePitch, 3, 19) |
736b8e80941Smrg      __gen_uint(values->Depth, 21, 31);
737b8e80941Smrg
738b8e80941Smrg   dw[4] =
739b8e80941Smrg      __gen_uint(values->RenderTargetViewExtent, 8, 16) |
740b8e80941Smrg      __gen_uint(values->MinimumArrayElement, 17, 27) |
741b8e80941Smrg      __gen_uint(values->SurfaceMinLOD, 28, 31);
742b8e80941Smrg
743b8e80941Smrg   dw[5] =
744b8e80941Smrg      __gen_uint(values->YOffset, 20, 23) |
745b8e80941Smrg      __gen_uint(values->XOffset, 25, 31);
746b8e80941Smrg}
747b8e80941Smrg
748b8e80941Smrg#define GEN45_SAMPLER_BORDER_COLOR_STATE_length     12
749b8e80941Smrgstruct GEN45_SAMPLER_BORDER_COLOR_STATE {
750b8e80941Smrg   float                                BorderColorRed;
751b8e80941Smrg   float                                BorderColorGreen;
752b8e80941Smrg   float                                BorderColorBlue;
753b8e80941Smrg   float                                BorderColorAlpha;
754b8e80941Smrg};
755b8e80941Smrg
756b8e80941Smrgstatic inline void
757b8e80941SmrgGEN45_SAMPLER_BORDER_COLOR_STATE_pack(__attribute__((unused)) __gen_user_data *data,
758b8e80941Smrg                                      __attribute__((unused)) void * restrict dst,
759b8e80941Smrg                                      __attribute__((unused)) const struct GEN45_SAMPLER_BORDER_COLOR_STATE * restrict values)
760b8e80941Smrg{
761b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
762b8e80941Smrg
763b8e80941Smrg   dw[0] =
764b8e80941Smrg      __gen_float(values->BorderColorRed);
765b8e80941Smrg
766b8e80941Smrg   dw[1] =
767b8e80941Smrg      __gen_float(values->BorderColorGreen);
768b8e80941Smrg
769b8e80941Smrg   dw[2] =
770b8e80941Smrg      __gen_float(values->BorderColorBlue);
771b8e80941Smrg
772b8e80941Smrg   dw[3] =
773b8e80941Smrg      __gen_float(values->BorderColorAlpha);
774b8e80941Smrg
775b8e80941Smrg   dw[4] = 0;
776b8e80941Smrg
777b8e80941Smrg   dw[5] = 0;
778b8e80941Smrg
779b8e80941Smrg   dw[6] = 0;
780b8e80941Smrg
781b8e80941Smrg   dw[7] = 0;
782b8e80941Smrg
783b8e80941Smrg   dw[8] = 0;
784b8e80941Smrg
785b8e80941Smrg   dw[9] = 0;
786b8e80941Smrg
787b8e80941Smrg   dw[10] = 0;
788b8e80941Smrg
789b8e80941Smrg   dw[11] = 0;
790b8e80941Smrg}
791b8e80941Smrg
792b8e80941Smrg#define GEN45_SAMPLER_STATE_length             4
793b8e80941Smrgstruct GEN45_SAMPLER_STATE {
794b8e80941Smrg   uint32_t                             ShadowFunction;
795b8e80941Smrg#define PREFILTEROP_ALWAYS                       0
796b8e80941Smrg#define PREFILTEROP_NEVER                        1
797b8e80941Smrg#define PREFILTEROP_LESS                         2
798b8e80941Smrg#define PREFILTEROP_EQUAL                        3
799b8e80941Smrg#define PREFILTEROP_LEQUAL                       4
800b8e80941Smrg#define PREFILTEROP_GREATER                      5
801b8e80941Smrg#define PREFILTEROP_NOTEQUAL                     6
802b8e80941Smrg#define PREFILTEROP_GEQUAL                       7
803b8e80941Smrg   float                                TextureLODBias;
804b8e80941Smrg   uint32_t                             MinModeFilter;
805b8e80941Smrg   uint32_t                             MagModeFilter;
806b8e80941Smrg#define MAPFILTER_NEAREST                        0
807b8e80941Smrg#define MAPFILTER_LINEAR                         1
808b8e80941Smrg#define MAPFILTER_ANISOTROPIC                    2
809b8e80941Smrg#define MAPFILTER_MONO                           6
810b8e80941Smrg   uint32_t                             MipModeFilter;
811b8e80941Smrg#define MIPFILTER_NONE                           0
812b8e80941Smrg#define MIPFILTER_NEAREST                        1
813b8e80941Smrg#define MIPFILTER_LINEAR                         3
814b8e80941Smrg   float                                BaseMipLevel;
815b8e80941Smrg   bool                                 LODPreClampEnable;
816b8e80941Smrg   bool                                 SamplerDisable;
817b8e80941Smrg   enum GEN45_Texture_Coordinate_Mode   TCZAddressControlMode;
818b8e80941Smrg   enum GEN45_Texture_Coordinate_Mode   TCYAddressControlMode;
819b8e80941Smrg   enum GEN45_Texture_Coordinate_Mode   TCXAddressControlMode;
820b8e80941Smrg   uint32_t                             CubeSurfaceControlMode;
821b8e80941Smrg#define CUBECTRLMODE_PROGRAMMED                  0
822b8e80941Smrg#define CUBECTRLMODE_OVERRIDE                    1
823b8e80941Smrg   float                                MaxLOD;
824b8e80941Smrg   float                                MinLOD;
825b8e80941Smrg   __gen_address_type                   BorderColorPointer;
826b8e80941Smrg   bool                                 RAddressMinFilterRoundingEnable;
827b8e80941Smrg   bool                                 RAddressMagFilterRoundingEnable;
828b8e80941Smrg   bool                                 VAddressMinFilterRoundingEnable;
829b8e80941Smrg   bool                                 VAddressMagFilterRoundingEnable;
830b8e80941Smrg   bool                                 UAddressMinFilterRoundingEnable;
831b8e80941Smrg   bool                                 UAddressMagFilterRoundingEnable;
832b8e80941Smrg   uint32_t                             MaximumAnisotropy;
833b8e80941Smrg#define RATIO21                                  0
834b8e80941Smrg#define RATIO41                                  1
835b8e80941Smrg#define RATIO61                                  2
836b8e80941Smrg#define RATIO81                                  3
837b8e80941Smrg#define RATIO101                                 4
838b8e80941Smrg#define RATIO121                                 5
839b8e80941Smrg#define RATIO141                                 6
840b8e80941Smrg#define RATIO161                                 7
841b8e80941Smrg   uint32_t                             ChromaKeyMode;
842b8e80941Smrg#define KEYFILTER_KILL_ON_ANY_MATCH              0
843b8e80941Smrg#define KEYFILTER_REPLACE_BLACK                  1
844b8e80941Smrg   uint32_t                             ChromaKeyIndex;
845b8e80941Smrg   bool                                 ChromaKeyEnable;
846b8e80941Smrg   uint32_t                             MonochromeFilterWidth;
847b8e80941Smrg   uint32_t                             MonochromeFilterHeight;
848b8e80941Smrg};
849b8e80941Smrg
850b8e80941Smrgstatic inline void
851b8e80941SmrgGEN45_SAMPLER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
852b8e80941Smrg                         __attribute__((unused)) void * restrict dst,
853b8e80941Smrg                         __attribute__((unused)) const struct GEN45_SAMPLER_STATE * restrict values)
854b8e80941Smrg{
855b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
856b8e80941Smrg
857b8e80941Smrg   dw[0] =
858b8e80941Smrg      __gen_uint(values->ShadowFunction, 0, 2) |
859b8e80941Smrg      __gen_sfixed(values->TextureLODBias, 3, 13, 6) |
860b8e80941Smrg      __gen_uint(values->MinModeFilter, 14, 16) |
861b8e80941Smrg      __gen_uint(values->MagModeFilter, 17, 19) |
862b8e80941Smrg      __gen_uint(values->MipModeFilter, 20, 21) |
863b8e80941Smrg      __gen_ufixed(values->BaseMipLevel, 22, 26, 1) |
864b8e80941Smrg      __gen_uint(values->LODPreClampEnable, 28, 28) |
865b8e80941Smrg      __gen_uint(values->SamplerDisable, 31, 31);
866b8e80941Smrg
867b8e80941Smrg   dw[1] =
868b8e80941Smrg      __gen_uint(values->TCZAddressControlMode, 0, 2) |
869b8e80941Smrg      __gen_uint(values->TCYAddressControlMode, 3, 5) |
870b8e80941Smrg      __gen_uint(values->TCXAddressControlMode, 6, 8) |
871b8e80941Smrg      __gen_uint(values->CubeSurfaceControlMode, 9, 9) |
872b8e80941Smrg      __gen_ufixed(values->MaxLOD, 12, 21, 6) |
873b8e80941Smrg      __gen_ufixed(values->MinLOD, 22, 31, 6);
874b8e80941Smrg
875b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->BorderColorPointer, 0);
876b8e80941Smrg
877b8e80941Smrg   dw[3] =
878b8e80941Smrg      __gen_uint(values->RAddressMinFilterRoundingEnable, 13, 13) |
879b8e80941Smrg      __gen_uint(values->RAddressMagFilterRoundingEnable, 14, 14) |
880b8e80941Smrg      __gen_uint(values->VAddressMinFilterRoundingEnable, 15, 15) |
881b8e80941Smrg      __gen_uint(values->VAddressMagFilterRoundingEnable, 16, 16) |
882b8e80941Smrg      __gen_uint(values->UAddressMinFilterRoundingEnable, 17, 17) |
883b8e80941Smrg      __gen_uint(values->UAddressMagFilterRoundingEnable, 18, 18) |
884b8e80941Smrg      __gen_uint(values->MaximumAnisotropy, 19, 21) |
885b8e80941Smrg      __gen_uint(values->ChromaKeyMode, 22, 22) |
886b8e80941Smrg      __gen_uint(values->ChromaKeyIndex, 23, 24) |
887b8e80941Smrg      __gen_uint(values->ChromaKeyEnable, 25, 25) |
888b8e80941Smrg      __gen_uint(values->MonochromeFilterWidth, 26, 28) |
889b8e80941Smrg      __gen_uint(values->MonochromeFilterHeight, 29, 31);
890b8e80941Smrg}
891b8e80941Smrg
892b8e80941Smrg#define GEN45_SCISSOR_RECT_length              2
893b8e80941Smrgstruct GEN45_SCISSOR_RECT {
894b8e80941Smrg   uint32_t                             ScissorRectangleXMin;
895b8e80941Smrg   uint32_t                             ScissorRectangleYMin;
896b8e80941Smrg   uint32_t                             ScissorRectangleXMax;
897b8e80941Smrg   uint32_t                             ScissorRectangleYMax;
898b8e80941Smrg};
899b8e80941Smrg
900b8e80941Smrgstatic inline void
901b8e80941SmrgGEN45_SCISSOR_RECT_pack(__attribute__((unused)) __gen_user_data *data,
902b8e80941Smrg                        __attribute__((unused)) void * restrict dst,
903b8e80941Smrg                        __attribute__((unused)) const struct GEN45_SCISSOR_RECT * restrict values)
904b8e80941Smrg{
905b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
906b8e80941Smrg
907b8e80941Smrg   dw[0] =
908b8e80941Smrg      __gen_uint(values->ScissorRectangleXMin, 0, 15) |
909b8e80941Smrg      __gen_uint(values->ScissorRectangleYMin, 16, 31);
910b8e80941Smrg
911b8e80941Smrg   dw[1] =
912b8e80941Smrg      __gen_uint(values->ScissorRectangleXMax, 0, 15) |
913b8e80941Smrg      __gen_uint(values->ScissorRectangleYMax, 16, 31);
914b8e80941Smrg}
915b8e80941Smrg
916b8e80941Smrg#define GEN45_SF_STATE_length                  8
917b8e80941Smrgstruct GEN45_SF_STATE {
918b8e80941Smrg   uint32_t                             GRFRegisterCount;
919b8e80941Smrg   __gen_address_type                   KernelStartPointer;
920b8e80941Smrg   bool                                 SoftwareExceptionEnable;
921b8e80941Smrg   bool                                 MaskStackExceptionEnable;
922b8e80941Smrg   bool                                 IllegalOpcodeExceptionEnable;
923b8e80941Smrg   uint32_t                             FloatingPointMode;
924b8e80941Smrg#define FLOATING_POINT_MODE_IEEE754              0
925b8e80941Smrg#define FLOATING_POINT_MODE_Alternate            1
926b8e80941Smrg   uint32_t                             ThreadPriority;
927b8e80941Smrg#define NormalPriority                           0
928b8e80941Smrg#define HighPriority                             1
929b8e80941Smrg   uint32_t                             BindingTableEntryCount;
930b8e80941Smrg   bool                                 SingleProgramFlow;
931b8e80941Smrg   uint32_t                             PerThreadScratchSpace;
932b8e80941Smrg   __gen_address_type                   ScratchSpaceBasePointer;
933b8e80941Smrg   uint32_t                             DispatchGRFStartRegisterForURBData;
934b8e80941Smrg   uint32_t                             VertexURBEntryReadOffset;
935b8e80941Smrg   uint32_t                             VertexURBEntryReadLength;
936b8e80941Smrg   uint32_t                             ConstantURBEntryReadOffset;
937b8e80941Smrg   uint32_t                             ConstantURBEntryReadLength;
938b8e80941Smrg   bool                                 StatisticsEnable;
939b8e80941Smrg   uint32_t                             NumberofURBEntries;
940b8e80941Smrg   uint32_t                             URBEntryAllocationSize;
941b8e80941Smrg   uint32_t                             MaximumNumberofThreads;
942b8e80941Smrg   uint32_t                             FrontWinding;
943b8e80941Smrg#define FRONTWINDING_CW                          0
944b8e80941Smrg#define FRONTWINDING_CCW                         1
945b8e80941Smrg   bool                                 ViewportTransformEnable;
946b8e80941Smrg   __gen_address_type                   SetupViewportStateOffset;
947b8e80941Smrg   float                                DestinationOriginVerticalBias;
948b8e80941Smrg   float                                DestinationOriginHorizontalBias;
949b8e80941Smrg   bool                                 ScissorRectangleEnable;
950b8e80941Smrg   bool                                 _2x2PixelTriangleFilterDisable;
951b8e80941Smrg   bool                                 ZeroPixelTriangleFilterDisable;
952b8e80941Smrg   uint32_t                             PointRasterizationRule;
953b8e80941Smrg#define RASTRULE_UPPER_LEFT                      0
954b8e80941Smrg#define RASTRULE_UPPER_RIGHT                     1
955b8e80941Smrg   uint32_t                             LineEndCapAntialiasingRegionWidth;
956b8e80941Smrg#define _05pixels                                0
957b8e80941Smrg#define _10pixels                                1
958b8e80941Smrg#define _20pixels                                2
959b8e80941Smrg#define _40pixels                                3
960b8e80941Smrg   float                                LineWidth;
961b8e80941Smrg   bool                                 FastScissorClipDisable;
962b8e80941Smrg   uint32_t                             CullMode;
963b8e80941Smrg#define CULLMODE_BOTH                            0
964b8e80941Smrg#define CULLMODE_NONE                            1
965b8e80941Smrg#define CULLMODE_FRONT                           2
966b8e80941Smrg#define CULLMODE_BACK                            3
967b8e80941Smrg   bool                                 AntiAliasingEnable;
968b8e80941Smrg   float                                PointWidth;
969b8e80941Smrg   uint32_t                             PointWidthSource;
970b8e80941Smrg#define Vertex                                   0
971b8e80941Smrg#define State                                    1
972b8e80941Smrg   uint32_t                             VertexSubPixelPrecisionSelect;
973b8e80941Smrg#define _8SubPixelPrecisionBits                  0
974b8e80941Smrg#define _4SubPixelPrecisionBits                  1
975b8e80941Smrg   bool                                 SpritePointEnable;
976b8e80941Smrg   uint32_t                             AALineDistanceMode;
977b8e80941Smrg#define AALINEDISTANCE_MANHATTAN                 0
978b8e80941Smrg#define AALINEDISTANCE_TRUE                      1
979b8e80941Smrg   uint32_t                             TriangleFanProvokingVertexSelect;
980b8e80941Smrg#define Vertex0                                  0
981b8e80941Smrg#define Vertex1                                  1
982b8e80941Smrg#define Vertex2                                  2
983b8e80941Smrg   uint32_t                             LineStripListProvokingVertexSelect;
984b8e80941Smrg#define Vertex0                                  0
985b8e80941Smrg#define Vertex1                                  1
986b8e80941Smrg   uint32_t                             TriangleStripListProvokingVertexSelect;
987b8e80941Smrg#define Vertex0                                  0
988b8e80941Smrg#define Vertex1                                  1
989b8e80941Smrg#define Vertex2                                  2
990b8e80941Smrg   bool                                 LastPixelEnable;
991b8e80941Smrg};
992b8e80941Smrg
993b8e80941Smrgstatic inline void
994b8e80941SmrgGEN45_SF_STATE_pack(__attribute__((unused)) __gen_user_data *data,
995b8e80941Smrg                    __attribute__((unused)) void * restrict dst,
996b8e80941Smrg                    __attribute__((unused)) const struct GEN45_SF_STATE * restrict values)
997b8e80941Smrg{
998b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
999b8e80941Smrg
1000b8e80941Smrg   const uint32_t v0 =
1001b8e80941Smrg      __gen_uint(values->GRFRegisterCount, 1, 3);
1002b8e80941Smrg   dw[0] = __gen_combine_address(data, &dw[0], values->KernelStartPointer, v0);
1003b8e80941Smrg
1004b8e80941Smrg   dw[1] =
1005b8e80941Smrg      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
1006b8e80941Smrg      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
1007b8e80941Smrg      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
1008b8e80941Smrg      __gen_uint(values->FloatingPointMode, 16, 16) |
1009b8e80941Smrg      __gen_uint(values->ThreadPriority, 17, 17) |
1010b8e80941Smrg      __gen_uint(values->BindingTableEntryCount, 18, 25) |
1011b8e80941Smrg      __gen_uint(values->SingleProgramFlow, 31, 31);
1012b8e80941Smrg
1013b8e80941Smrg   const uint32_t v2 =
1014b8e80941Smrg      __gen_uint(values->PerThreadScratchSpace, 0, 3);
1015b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
1016b8e80941Smrg
1017b8e80941Smrg   dw[3] =
1018b8e80941Smrg      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
1019b8e80941Smrg      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
1020b8e80941Smrg      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
1021b8e80941Smrg      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
1022b8e80941Smrg      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
1023b8e80941Smrg
1024b8e80941Smrg   dw[4] =
1025b8e80941Smrg      __gen_uint(values->StatisticsEnable, 10, 10) |
1026b8e80941Smrg      __gen_uint(values->NumberofURBEntries, 11, 18) |
1027b8e80941Smrg      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
1028b8e80941Smrg      __gen_uint(values->MaximumNumberofThreads, 25, 30);
1029b8e80941Smrg
1030b8e80941Smrg   const uint32_t v5 =
1031b8e80941Smrg      __gen_uint(values->FrontWinding, 0, 0) |
1032b8e80941Smrg      __gen_uint(values->ViewportTransformEnable, 1, 1);
1033b8e80941Smrg   dw[5] = __gen_combine_address(data, &dw[5], values->SetupViewportStateOffset, v5);
1034b8e80941Smrg
1035b8e80941Smrg   dw[6] =
1036b8e80941Smrg      __gen_ufixed(values->DestinationOriginVerticalBias, 9, 12, 4) |
1037b8e80941Smrg      __gen_ufixed(values->DestinationOriginHorizontalBias, 13, 16, 4) |
1038b8e80941Smrg      __gen_uint(values->ScissorRectangleEnable, 17, 17) |
1039b8e80941Smrg      __gen_uint(values->_2x2PixelTriangleFilterDisable, 18, 18) |
1040b8e80941Smrg      __gen_uint(values->ZeroPixelTriangleFilterDisable, 19, 19) |
1041b8e80941Smrg      __gen_uint(values->PointRasterizationRule, 20, 21) |
1042b8e80941Smrg      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 22, 23) |
1043b8e80941Smrg      __gen_ufixed(values->LineWidth, 24, 27, 1) |
1044b8e80941Smrg      __gen_uint(values->FastScissorClipDisable, 28, 28) |
1045b8e80941Smrg      __gen_uint(values->CullMode, 29, 30) |
1046b8e80941Smrg      __gen_uint(values->AntiAliasingEnable, 31, 31);
1047b8e80941Smrg
1048b8e80941Smrg   dw[7] =
1049b8e80941Smrg      __gen_ufixed(values->PointWidth, 0, 10, 3) |
1050b8e80941Smrg      __gen_uint(values->PointWidthSource, 11, 11) |
1051b8e80941Smrg      __gen_uint(values->VertexSubPixelPrecisionSelect, 12, 12) |
1052b8e80941Smrg      __gen_uint(values->SpritePointEnable, 13, 13) |
1053b8e80941Smrg      __gen_uint(values->AALineDistanceMode, 14, 14) |
1054b8e80941Smrg      __gen_uint(values->TriangleFanProvokingVertexSelect, 25, 26) |
1055b8e80941Smrg      __gen_uint(values->LineStripListProvokingVertexSelect, 27, 28) |
1056b8e80941Smrg      __gen_uint(values->TriangleStripListProvokingVertexSelect, 29, 30) |
1057b8e80941Smrg      __gen_uint(values->LastPixelEnable, 31, 31);
1058b8e80941Smrg}
1059b8e80941Smrg
1060b8e80941Smrg#define GEN45_SF_VIEWPORT_length               8
1061b8e80941Smrgstruct GEN45_SF_VIEWPORT {
1062b8e80941Smrg   float                                ViewportMatrixElementm00;
1063b8e80941Smrg   float                                ViewportMatrixElementm11;
1064b8e80941Smrg   float                                ViewportMatrixElementm22;
1065b8e80941Smrg   float                                ViewportMatrixElementm30;
1066b8e80941Smrg   float                                ViewportMatrixElementm31;
1067b8e80941Smrg   float                                ViewportMatrixElementm32;
1068b8e80941Smrg   struct GEN45_SCISSOR_RECT            ScissorRectangle;
1069b8e80941Smrg};
1070b8e80941Smrg
1071b8e80941Smrgstatic inline void
1072b8e80941SmrgGEN45_SF_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
1073b8e80941Smrg                       __attribute__((unused)) void * restrict dst,
1074b8e80941Smrg                       __attribute__((unused)) const struct GEN45_SF_VIEWPORT * restrict values)
1075b8e80941Smrg{
1076b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1077b8e80941Smrg
1078b8e80941Smrg   dw[0] =
1079b8e80941Smrg      __gen_float(values->ViewportMatrixElementm00);
1080b8e80941Smrg
1081b8e80941Smrg   dw[1] =
1082b8e80941Smrg      __gen_float(values->ViewportMatrixElementm11);
1083b8e80941Smrg
1084b8e80941Smrg   dw[2] =
1085b8e80941Smrg      __gen_float(values->ViewportMatrixElementm22);
1086b8e80941Smrg
1087b8e80941Smrg   dw[3] =
1088b8e80941Smrg      __gen_float(values->ViewportMatrixElementm30);
1089b8e80941Smrg
1090b8e80941Smrg   dw[4] =
1091b8e80941Smrg      __gen_float(values->ViewportMatrixElementm31);
1092b8e80941Smrg
1093b8e80941Smrg   dw[5] =
1094b8e80941Smrg      __gen_float(values->ViewportMatrixElementm32);
1095b8e80941Smrg
1096b8e80941Smrg   GEN45_SCISSOR_RECT_pack(data, &dw[6], &values->ScissorRectangle);
1097b8e80941Smrg}
1098b8e80941Smrg
1099b8e80941Smrg#define GEN45_VERTEX_BUFFER_STATE_length       4
1100b8e80941Smrgstruct GEN45_VERTEX_BUFFER_STATE {
1101b8e80941Smrg   uint32_t                             BufferPitch;
1102b8e80941Smrg   uint32_t                             BufferAccessType;
1103b8e80941Smrg#define VERTEXDATA                               0
1104b8e80941Smrg#define INSTANCEDATA                             1
1105b8e80941Smrg   uint32_t                             VertexBufferIndex;
1106b8e80941Smrg   __gen_address_type                   BufferStartingAddress;
1107b8e80941Smrg   uint32_t                             MaxIndex;
1108b8e80941Smrg   uint32_t                             InstanceDataStepRate;
1109b8e80941Smrg};
1110b8e80941Smrg
1111b8e80941Smrgstatic inline void
1112b8e80941SmrgGEN45_VERTEX_BUFFER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1113b8e80941Smrg                               __attribute__((unused)) void * restrict dst,
1114b8e80941Smrg                               __attribute__((unused)) const struct GEN45_VERTEX_BUFFER_STATE * restrict values)
1115b8e80941Smrg{
1116b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1117b8e80941Smrg
1118b8e80941Smrg   dw[0] =
1119b8e80941Smrg      __gen_uint(values->BufferPitch, 0, 10) |
1120b8e80941Smrg      __gen_uint(values->BufferAccessType, 26, 26) |
1121b8e80941Smrg      __gen_uint(values->VertexBufferIndex, 27, 31);
1122b8e80941Smrg
1123b8e80941Smrg   dw[1] = __gen_combine_address(data, &dw[1], values->BufferStartingAddress, 0);
1124b8e80941Smrg
1125b8e80941Smrg   dw[2] =
1126b8e80941Smrg      __gen_uint(values->MaxIndex, 0, 31);
1127b8e80941Smrg
1128b8e80941Smrg   dw[3] =
1129b8e80941Smrg      __gen_uint(values->InstanceDataStepRate, 0, 31);
1130b8e80941Smrg}
1131b8e80941Smrg
1132b8e80941Smrg#define GEN45_VERTEX_ELEMENT_STATE_length      2
1133b8e80941Smrgstruct GEN45_VERTEX_ELEMENT_STATE {
1134b8e80941Smrg   uint32_t                             SourceElementOffset;
1135b8e80941Smrg   uint32_t                             SourceElementFormat;
1136b8e80941Smrg   bool                                 Valid;
1137b8e80941Smrg   uint32_t                             VertexBufferIndex;
1138b8e80941Smrg   uint32_t                             DestinationElementOffset;
1139b8e80941Smrg   enum GEN45_3D_Vertex_Component_Control Component3Control;
1140b8e80941Smrg   enum GEN45_3D_Vertex_Component_Control Component2Control;
1141b8e80941Smrg   enum GEN45_3D_Vertex_Component_Control Component1Control;
1142b8e80941Smrg   enum GEN45_3D_Vertex_Component_Control Component0Control;
1143b8e80941Smrg};
1144b8e80941Smrg
1145b8e80941Smrgstatic inline void
1146b8e80941SmrgGEN45_VERTEX_ELEMENT_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1147b8e80941Smrg                                __attribute__((unused)) void * restrict dst,
1148b8e80941Smrg                                __attribute__((unused)) const struct GEN45_VERTEX_ELEMENT_STATE * restrict values)
1149b8e80941Smrg{
1150b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1151b8e80941Smrg
1152b8e80941Smrg   dw[0] =
1153b8e80941Smrg      __gen_uint(values->SourceElementOffset, 0, 10) |
1154b8e80941Smrg      __gen_uint(values->SourceElementFormat, 16, 24) |
1155b8e80941Smrg      __gen_uint(values->Valid, 26, 26) |
1156b8e80941Smrg      __gen_uint(values->VertexBufferIndex, 27, 31);
1157b8e80941Smrg
1158b8e80941Smrg   dw[1] =
1159b8e80941Smrg      __gen_uint(values->DestinationElementOffset, 0, 7) |
1160b8e80941Smrg      __gen_uint(values->Component3Control, 16, 18) |
1161b8e80941Smrg      __gen_uint(values->Component2Control, 20, 22) |
1162b8e80941Smrg      __gen_uint(values->Component1Control, 24, 26) |
1163b8e80941Smrg      __gen_uint(values->Component0Control, 28, 30);
1164b8e80941Smrg}
1165b8e80941Smrg
1166b8e80941Smrg#define GEN45_VS_STATE_length                  7
1167b8e80941Smrgstruct GEN45_VS_STATE {
1168b8e80941Smrg   uint32_t                             GRFRegisterCount;
1169b8e80941Smrg   __gen_address_type                   KernelStartPointer;
1170b8e80941Smrg   bool                                 SoftwareExceptionEnable;
1171b8e80941Smrg   bool                                 MaskStackExceptionEnable;
1172b8e80941Smrg   bool                                 IllegalOpcodeExceptionEnable;
1173b8e80941Smrg   uint32_t                             FloatingPointMode;
1174b8e80941Smrg#define FLOATING_POINT_MODE_IEEE754              0
1175b8e80941Smrg#define FLOATING_POINT_MODE_Alternate            1
1176b8e80941Smrg   uint32_t                             ThreadPriority;
1177b8e80941Smrg#define NormalPriority                           0
1178b8e80941Smrg#define HighPriority                             1
1179b8e80941Smrg   uint32_t                             BindingTableEntryCount;
1180b8e80941Smrg   bool                                 SingleProgramFlow;
1181b8e80941Smrg   uint32_t                             PerThreadScratchSpace;
1182b8e80941Smrg   __gen_address_type                   ScratchSpaceBasePointer;
1183b8e80941Smrg   uint32_t                             DispatchGRFStartRegisterForURBData;
1184b8e80941Smrg   uint32_t                             VertexURBEntryReadOffset;
1185b8e80941Smrg   uint32_t                             VertexURBEntryReadLength;
1186b8e80941Smrg   uint32_t                             ConstantURBEntryReadOffset;
1187b8e80941Smrg   uint32_t                             ConstantURBEntryReadLength;
1188b8e80941Smrg   bool                                 StatisticsEnable;
1189b8e80941Smrg   uint32_t                             NumberofURBEntries;
1190b8e80941Smrg   uint32_t                             URBEntryAllocationSize;
1191b8e80941Smrg   uint32_t                             MaximumNumberofThreads;
1192b8e80941Smrg   uint32_t                             SamplerCount;
1193b8e80941Smrg   __gen_address_type                   SamplerStatePointer;
1194b8e80941Smrg   bool                                 Enable;
1195b8e80941Smrg   bool                                 VertexCacheDisable;
1196b8e80941Smrg};
1197b8e80941Smrg
1198b8e80941Smrgstatic inline void
1199b8e80941SmrgGEN45_VS_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1200b8e80941Smrg                    __attribute__((unused)) void * restrict dst,
1201b8e80941Smrg                    __attribute__((unused)) const struct GEN45_VS_STATE * restrict values)
1202b8e80941Smrg{
1203b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1204b8e80941Smrg
1205b8e80941Smrg   const uint32_t v0 =
1206b8e80941Smrg      __gen_uint(values->GRFRegisterCount, 1, 3);
1207b8e80941Smrg   dw[0] = __gen_combine_address(data, &dw[0], values->KernelStartPointer, v0);
1208b8e80941Smrg
1209b8e80941Smrg   dw[1] =
1210b8e80941Smrg      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
1211b8e80941Smrg      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
1212b8e80941Smrg      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
1213b8e80941Smrg      __gen_uint(values->FloatingPointMode, 16, 16) |
1214b8e80941Smrg      __gen_uint(values->ThreadPriority, 17, 17) |
1215b8e80941Smrg      __gen_uint(values->BindingTableEntryCount, 18, 25) |
1216b8e80941Smrg      __gen_uint(values->SingleProgramFlow, 31, 31);
1217b8e80941Smrg
1218b8e80941Smrg   const uint32_t v2 =
1219b8e80941Smrg      __gen_uint(values->PerThreadScratchSpace, 0, 3);
1220b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
1221b8e80941Smrg
1222b8e80941Smrg   dw[3] =
1223b8e80941Smrg      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
1224b8e80941Smrg      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
1225b8e80941Smrg      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
1226b8e80941Smrg      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
1227b8e80941Smrg      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
1228b8e80941Smrg
1229b8e80941Smrg   dw[4] =
1230b8e80941Smrg      __gen_uint(values->StatisticsEnable, 10, 10) |
1231b8e80941Smrg      __gen_uint(values->NumberofURBEntries, 11, 18) |
1232b8e80941Smrg      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
1233b8e80941Smrg      __gen_uint(values->MaximumNumberofThreads, 25, 30);
1234b8e80941Smrg
1235b8e80941Smrg   const uint32_t v5 =
1236b8e80941Smrg      __gen_uint(values->SamplerCount, 0, 2);
1237b8e80941Smrg   dw[5] = __gen_combine_address(data, &dw[5], values->SamplerStatePointer, v5);
1238b8e80941Smrg
1239b8e80941Smrg   dw[6] =
1240b8e80941Smrg      __gen_uint(values->Enable, 0, 0) |
1241b8e80941Smrg      __gen_uint(values->VertexCacheDisable, 1, 1);
1242b8e80941Smrg}
1243b8e80941Smrg
1244b8e80941Smrg#define GEN45_WM_STATE_length                  8
1245b8e80941Smrgstruct GEN45_WM_STATE {
1246b8e80941Smrg   uint32_t                             GRFRegisterCount0;
1247b8e80941Smrg   __gen_address_type                   KernelStartPointer0;
1248b8e80941Smrg   bool                                 SoftwareExceptionEnable;
1249b8e80941Smrg   bool                                 MaskStackExceptionEnable;
1250b8e80941Smrg   bool                                 IllegalOpcodeExceptionEnable;
1251b8e80941Smrg   uint32_t                             DepthCoefficientURBReadOffset;
1252b8e80941Smrg   uint32_t                             FloatingPointMode;
1253b8e80941Smrg#define FLOATING_POINT_MODE_IEEE754              0
1254b8e80941Smrg#define FLOATING_POINT_MODE_Alternate            1
1255b8e80941Smrg   uint32_t                             ThreadPriority;
1256b8e80941Smrg#define Normal                                   0
1257b8e80941Smrg#define High                                     1
1258b8e80941Smrg   uint32_t                             BindingTableEntryCount;
1259b8e80941Smrg   bool                                 SingleProgramFlow;
1260b8e80941Smrg   uint32_t                             PerThreadScratchSpace;
1261b8e80941Smrg   __gen_address_type                   ScratchSpaceBasePointer;
1262b8e80941Smrg   uint32_t                             DispatchGRFStartRegisterForConstantSetupData0;
1263b8e80941Smrg   uint32_t                             SetupURBEntryReadOffset;
1264b8e80941Smrg   uint32_t                             SetupURBEntryReadLength;
1265b8e80941Smrg   uint32_t                             ConstantURBEntryReadOffset;
1266b8e80941Smrg   uint32_t                             ConstantURBEntryReadLength;
1267b8e80941Smrg   bool                                 StatisticsEnable;
1268b8e80941Smrg   uint32_t                             SamplerCount;
1269b8e80941Smrg   __gen_address_type                   SamplerStatePointer;
1270b8e80941Smrg   bool                                 _8PixelDispatchEnable;
1271b8e80941Smrg   bool                                 _16PixelDispatchEnable;
1272b8e80941Smrg   bool                                 _32PixelDispatchEnable;
1273b8e80941Smrg   bool                                 Contiguous32PixelDispatchEnable;
1274b8e80941Smrg   bool                                 Contiguous64PixelDispatchEnable;
1275b8e80941Smrg   bool                                 LegacyGlobalDepthBiasEnable;
1276b8e80941Smrg   bool                                 LineStippleEnable;
1277b8e80941Smrg   bool                                 GlobalDepthOffsetEnable;
1278b8e80941Smrg   bool                                 PolygonStippleEnable;
1279b8e80941Smrg   uint32_t                             LineAntialiasingRegionWidth;
1280b8e80941Smrg#define _05pixels                                0
1281b8e80941Smrg#define _10pixels                                1
1282b8e80941Smrg#define _20pixels                                2
1283b8e80941Smrg#define _40pixels                                3
1284b8e80941Smrg   uint32_t                             LineEndCapAntialiasingRegionWidth;
1285b8e80941Smrg#define _05pixels                                0
1286b8e80941Smrg#define _10pixels                                1
1287b8e80941Smrg#define _20pixels                                2
1288b8e80941Smrg#define _40pixels                                3
1289b8e80941Smrg   bool                                 EarlyDepthTestEnable;
1290b8e80941Smrg   bool                                 ThreadDispatchEnable;
1291b8e80941Smrg   bool                                 PixelShaderUsesSourceDepth;
1292b8e80941Smrg   bool                                 PixelShaderComputedDepth;
1293b8e80941Smrg   bool                                 PixelShaderKillsPixel;
1294b8e80941Smrg   bool                                 LegacyDiamondLineRasterization;
1295b8e80941Smrg   uint32_t                             MaximumNumberofThreads;
1296b8e80941Smrg   float                                GlobalDepthOffsetConstant;
1297b8e80941Smrg   float                                GlobalDepthOffsetScale;
1298b8e80941Smrg};
1299b8e80941Smrg
1300b8e80941Smrgstatic inline void
1301b8e80941SmrgGEN45_WM_STATE_pack(__attribute__((unused)) __gen_user_data *data,
1302b8e80941Smrg                    __attribute__((unused)) void * restrict dst,
1303b8e80941Smrg                    __attribute__((unused)) const struct GEN45_WM_STATE * restrict values)
1304b8e80941Smrg{
1305b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1306b8e80941Smrg
1307b8e80941Smrg   const uint32_t v0 =
1308b8e80941Smrg      __gen_uint(values->GRFRegisterCount0, 1, 3);
1309b8e80941Smrg   dw[0] = __gen_combine_address(data, &dw[0], values->KernelStartPointer0, v0);
1310b8e80941Smrg
1311b8e80941Smrg   dw[1] =
1312b8e80941Smrg      __gen_uint(values->SoftwareExceptionEnable, 1, 1) |
1313b8e80941Smrg      __gen_uint(values->MaskStackExceptionEnable, 2, 2) |
1314b8e80941Smrg      __gen_uint(values->IllegalOpcodeExceptionEnable, 4, 4) |
1315b8e80941Smrg      __gen_uint(values->DepthCoefficientURBReadOffset, 8, 13) |
1316b8e80941Smrg      __gen_uint(values->FloatingPointMode, 16, 16) |
1317b8e80941Smrg      __gen_uint(values->ThreadPriority, 17, 17) |
1318b8e80941Smrg      __gen_uint(values->BindingTableEntryCount, 18, 25) |
1319b8e80941Smrg      __gen_uint(values->SingleProgramFlow, 31, 31);
1320b8e80941Smrg
1321b8e80941Smrg   const uint32_t v2 =
1322b8e80941Smrg      __gen_uint(values->PerThreadScratchSpace, 0, 3);
1323b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
1324b8e80941Smrg
1325b8e80941Smrg   dw[3] =
1326b8e80941Smrg      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData0, 0, 3) |
1327b8e80941Smrg      __gen_uint(values->SetupURBEntryReadOffset, 4, 9) |
1328b8e80941Smrg      __gen_uint(values->SetupURBEntryReadLength, 11, 16) |
1329b8e80941Smrg      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
1330b8e80941Smrg      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
1331b8e80941Smrg
1332b8e80941Smrg   const uint32_t v4 =
1333b8e80941Smrg      __gen_uint(values->StatisticsEnable, 0, 0) |
1334b8e80941Smrg      __gen_uint(values->SamplerCount, 2, 4);
1335b8e80941Smrg   dw[4] = __gen_combine_address(data, &dw[4], values->SamplerStatePointer, v4);
1336b8e80941Smrg
1337b8e80941Smrg   dw[5] =
1338b8e80941Smrg      __gen_uint(values->_8PixelDispatchEnable, 0, 0) |
1339b8e80941Smrg      __gen_uint(values->_16PixelDispatchEnable, 1, 1) |
1340b8e80941Smrg      __gen_uint(values->_32PixelDispatchEnable, 2, 2) |
1341b8e80941Smrg      __gen_uint(values->Contiguous32PixelDispatchEnable, 3, 3) |
1342b8e80941Smrg      __gen_uint(values->Contiguous64PixelDispatchEnable, 4, 4) |
1343b8e80941Smrg      __gen_uint(values->LegacyGlobalDepthBiasEnable, 10, 10) |
1344b8e80941Smrg      __gen_uint(values->LineStippleEnable, 11, 11) |
1345b8e80941Smrg      __gen_uint(values->GlobalDepthOffsetEnable, 12, 12) |
1346b8e80941Smrg      __gen_uint(values->PolygonStippleEnable, 13, 13) |
1347b8e80941Smrg      __gen_uint(values->LineAntialiasingRegionWidth, 14, 15) |
1348b8e80941Smrg      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 16, 17) |
1349b8e80941Smrg      __gen_uint(values->EarlyDepthTestEnable, 18, 18) |
1350b8e80941Smrg      __gen_uint(values->ThreadDispatchEnable, 19, 19) |
1351b8e80941Smrg      __gen_uint(values->PixelShaderUsesSourceDepth, 20, 20) |
1352b8e80941Smrg      __gen_uint(values->PixelShaderComputedDepth, 21, 21) |
1353b8e80941Smrg      __gen_uint(values->PixelShaderKillsPixel, 22, 22) |
1354b8e80941Smrg      __gen_uint(values->LegacyDiamondLineRasterization, 23, 23) |
1355b8e80941Smrg      __gen_uint(values->MaximumNumberofThreads, 25, 31);
1356b8e80941Smrg
1357b8e80941Smrg   dw[6] =
1358b8e80941Smrg      __gen_float(values->GlobalDepthOffsetConstant);
1359b8e80941Smrg
1360b8e80941Smrg   dw[7] =
1361b8e80941Smrg      __gen_float(values->GlobalDepthOffsetScale);
1362b8e80941Smrg}
1363b8e80941Smrg
1364b8e80941Smrg#define GEN45_3DPRIMITIVE_length               6
1365b8e80941Smrg#define GEN45_3DPRIMITIVE_length_bias          2
1366b8e80941Smrg#define GEN45_3DPRIMITIVE_header                \
1367b8e80941Smrg   .DWordLength                         =      4,  \
1368b8e80941Smrg   ._3DCommandSubOpcode                 =      0,  \
1369b8e80941Smrg   ._3DCommandOpcode                    =      3,  \
1370b8e80941Smrg   .CommandSubType                      =      3,  \
1371b8e80941Smrg   .CommandType                         =      3
1372b8e80941Smrg
1373b8e80941Smrgstruct GEN45_3DPRIMITIVE {
1374b8e80941Smrg   uint32_t                             DWordLength;
1375b8e80941Smrg   uint32_t                             IndirectVertexCount;
1376b8e80941Smrg   enum GEN45_3D_Prim_Topo_Type         PrimitiveTopologyType;
1377b8e80941Smrg   uint32_t                             VertexAccessType;
1378b8e80941Smrg#define SEQUENTIAL                               0
1379b8e80941Smrg#define RANDOM                                   1
1380b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1381b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1382b8e80941Smrg   uint32_t                             CommandSubType;
1383b8e80941Smrg   uint32_t                             CommandType;
1384b8e80941Smrg   uint32_t                             VertexCountPerInstance;
1385b8e80941Smrg   uint32_t                             StartVertexLocation;
1386b8e80941Smrg   uint32_t                             InstanceCount;
1387b8e80941Smrg   uint32_t                             StartInstanceLocation;
1388b8e80941Smrg   int32_t                              BaseVertexLocation;
1389b8e80941Smrg};
1390b8e80941Smrg
1391b8e80941Smrgstatic inline void
1392b8e80941SmrgGEN45_3DPRIMITIVE_pack(__attribute__((unused)) __gen_user_data *data,
1393b8e80941Smrg                       __attribute__((unused)) void * restrict dst,
1394b8e80941Smrg                       __attribute__((unused)) const struct GEN45_3DPRIMITIVE * restrict values)
1395b8e80941Smrg{
1396b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1397b8e80941Smrg
1398b8e80941Smrg   dw[0] =
1399b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1400b8e80941Smrg      __gen_uint(values->IndirectVertexCount, 9, 9) |
1401b8e80941Smrg      __gen_uint(values->PrimitiveTopologyType, 10, 14) |
1402b8e80941Smrg      __gen_uint(values->VertexAccessType, 15, 15) |
1403b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1404b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1405b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1406b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1407b8e80941Smrg
1408b8e80941Smrg   dw[1] =
1409b8e80941Smrg      __gen_uint(values->VertexCountPerInstance, 0, 31);
1410b8e80941Smrg
1411b8e80941Smrg   dw[2] =
1412b8e80941Smrg      __gen_uint(values->StartVertexLocation, 0, 31);
1413b8e80941Smrg
1414b8e80941Smrg   dw[3] =
1415b8e80941Smrg      __gen_uint(values->InstanceCount, 0, 31);
1416b8e80941Smrg
1417b8e80941Smrg   dw[4] =
1418b8e80941Smrg      __gen_uint(values->StartInstanceLocation, 0, 31);
1419b8e80941Smrg
1420b8e80941Smrg   dw[5] =
1421b8e80941Smrg      __gen_sint(values->BaseVertexLocation, 0, 31);
1422b8e80941Smrg}
1423b8e80941Smrg
1424b8e80941Smrg#define GEN45_3DSTATE_AA_LINE_PARAMETERS_length      3
1425b8e80941Smrg#define GEN45_3DSTATE_AA_LINE_PARAMETERS_length_bias      2
1426b8e80941Smrg#define GEN45_3DSTATE_AA_LINE_PARAMETERS_header \
1427b8e80941Smrg   .DWordLength                         =      1,  \
1428b8e80941Smrg   ._3DCommandSubOpcode                 =     10,  \
1429b8e80941Smrg   ._3DCommandOpcode                    =      1,  \
1430b8e80941Smrg   .CommandSubType                      =      3,  \
1431b8e80941Smrg   .CommandType                         =      3
1432b8e80941Smrg
1433b8e80941Smrgstruct GEN45_3DSTATE_AA_LINE_PARAMETERS {
1434b8e80941Smrg   uint32_t                             DWordLength;
1435b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1436b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1437b8e80941Smrg   uint32_t                             CommandSubType;
1438b8e80941Smrg   uint32_t                             CommandType;
1439b8e80941Smrg   float                                AACoverageSlope;
1440b8e80941Smrg   float                                AACoverageBias;
1441b8e80941Smrg   float                                AACoverageEndCapSlope;
1442b8e80941Smrg   float                                AACoverageEndCapBias;
1443b8e80941Smrg};
1444b8e80941Smrg
1445b8e80941Smrgstatic inline void
1446b8e80941SmrgGEN45_3DSTATE_AA_LINE_PARAMETERS_pack(__attribute__((unused)) __gen_user_data *data,
1447b8e80941Smrg                                      __attribute__((unused)) void * restrict dst,
1448b8e80941Smrg                                      __attribute__((unused)) const struct GEN45_3DSTATE_AA_LINE_PARAMETERS * restrict values)
1449b8e80941Smrg{
1450b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1451b8e80941Smrg
1452b8e80941Smrg   dw[0] =
1453b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1454b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1455b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1456b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1457b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1458b8e80941Smrg
1459b8e80941Smrg   dw[1] =
1460b8e80941Smrg      __gen_ufixed(values->AACoverageSlope, 0, 7, 8) |
1461b8e80941Smrg      __gen_ufixed(values->AACoverageBias, 16, 23, 8);
1462b8e80941Smrg
1463b8e80941Smrg   dw[2] =
1464b8e80941Smrg      __gen_ufixed(values->AACoverageEndCapSlope, 0, 7, 8) |
1465b8e80941Smrg      __gen_ufixed(values->AACoverageEndCapBias, 16, 23, 8);
1466b8e80941Smrg}
1467b8e80941Smrg
1468b8e80941Smrg#define GEN45_3DSTATE_BINDING_TABLE_POINTERS_length      6
1469b8e80941Smrg#define GEN45_3DSTATE_BINDING_TABLE_POINTERS_length_bias      2
1470b8e80941Smrg#define GEN45_3DSTATE_BINDING_TABLE_POINTERS_header\
1471b8e80941Smrg   .DWordLength                         =      4,  \
1472b8e80941Smrg   ._3DCommandSubOpcode                 =      1,  \
1473b8e80941Smrg   ._3DCommandOpcode                    =      0,  \
1474b8e80941Smrg   .CommandSubType                      =      3,  \
1475b8e80941Smrg   .CommandType                         =      3
1476b8e80941Smrg
1477b8e80941Smrgstruct GEN45_3DSTATE_BINDING_TABLE_POINTERS {
1478b8e80941Smrg   uint32_t                             DWordLength;
1479b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1480b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1481b8e80941Smrg   uint32_t                             CommandSubType;
1482b8e80941Smrg   uint32_t                             CommandType;
1483b8e80941Smrg   uint64_t                             PointertoVSBindingTable;
1484b8e80941Smrg   uint64_t                             PointertoGSBindingTable;
1485b8e80941Smrg   uint64_t                             PointertoCLIPBindingTable;
1486b8e80941Smrg   uint64_t                             PointertoSFBindingTable;
1487b8e80941Smrg   uint64_t                             PointertoPSBindingTable;
1488b8e80941Smrg};
1489b8e80941Smrg
1490b8e80941Smrgstatic inline void
1491b8e80941SmrgGEN45_3DSTATE_BINDING_TABLE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
1492b8e80941Smrg                                          __attribute__((unused)) void * restrict dst,
1493b8e80941Smrg                                          __attribute__((unused)) const struct GEN45_3DSTATE_BINDING_TABLE_POINTERS * restrict values)
1494b8e80941Smrg{
1495b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1496b8e80941Smrg
1497b8e80941Smrg   dw[0] =
1498b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1499b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1500b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1501b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1502b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1503b8e80941Smrg
1504b8e80941Smrg   dw[1] =
1505b8e80941Smrg      __gen_offset(values->PointertoVSBindingTable, 5, 31);
1506b8e80941Smrg
1507b8e80941Smrg   dw[2] =
1508b8e80941Smrg      __gen_offset(values->PointertoGSBindingTable, 5, 31);
1509b8e80941Smrg
1510b8e80941Smrg   dw[3] =
1511b8e80941Smrg      __gen_offset(values->PointertoCLIPBindingTable, 5, 31);
1512b8e80941Smrg
1513b8e80941Smrg   dw[4] =
1514b8e80941Smrg      __gen_offset(values->PointertoSFBindingTable, 5, 31);
1515b8e80941Smrg
1516b8e80941Smrg   dw[5] =
1517b8e80941Smrg      __gen_offset(values->PointertoPSBindingTable, 5, 31);
1518b8e80941Smrg}
1519b8e80941Smrg
1520b8e80941Smrg#define GEN45_3DSTATE_CONSTANT_COLOR_length      5
1521b8e80941Smrg#define GEN45_3DSTATE_CONSTANT_COLOR_length_bias      2
1522b8e80941Smrg#define GEN45_3DSTATE_CONSTANT_COLOR_header     \
1523b8e80941Smrg   .DWordLength                         =      3,  \
1524b8e80941Smrg   ._3DCommandSubOpcode                 =      1,  \
1525b8e80941Smrg   ._3DCommandOpcode                    =      1,  \
1526b8e80941Smrg   .CommandSubType                      =      3,  \
1527b8e80941Smrg   .CommandType                         =      3
1528b8e80941Smrg
1529b8e80941Smrgstruct GEN45_3DSTATE_CONSTANT_COLOR {
1530b8e80941Smrg   uint32_t                             DWordLength;
1531b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1532b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1533b8e80941Smrg   uint32_t                             CommandSubType;
1534b8e80941Smrg   uint32_t                             CommandType;
1535b8e80941Smrg   float                                BlendConstantColorRed;
1536b8e80941Smrg   float                                BlendConstantColorGreen;
1537b8e80941Smrg   float                                BlendConstantColorBlue;
1538b8e80941Smrg   float                                BlendConstantColorAlpha;
1539b8e80941Smrg};
1540b8e80941Smrg
1541b8e80941Smrgstatic inline void
1542b8e80941SmrgGEN45_3DSTATE_CONSTANT_COLOR_pack(__attribute__((unused)) __gen_user_data *data,
1543b8e80941Smrg                                  __attribute__((unused)) void * restrict dst,
1544b8e80941Smrg                                  __attribute__((unused)) const struct GEN45_3DSTATE_CONSTANT_COLOR * restrict values)
1545b8e80941Smrg{
1546b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1547b8e80941Smrg
1548b8e80941Smrg   dw[0] =
1549b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1550b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1551b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1552b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1553b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1554b8e80941Smrg
1555b8e80941Smrg   dw[1] =
1556b8e80941Smrg      __gen_float(values->BlendConstantColorRed);
1557b8e80941Smrg
1558b8e80941Smrg   dw[2] =
1559b8e80941Smrg      __gen_float(values->BlendConstantColorGreen);
1560b8e80941Smrg
1561b8e80941Smrg   dw[3] =
1562b8e80941Smrg      __gen_float(values->BlendConstantColorBlue);
1563b8e80941Smrg
1564b8e80941Smrg   dw[4] =
1565b8e80941Smrg      __gen_float(values->BlendConstantColorAlpha);
1566b8e80941Smrg}
1567b8e80941Smrg
1568b8e80941Smrg#define GEN45_3DSTATE_DEPTH_BUFFER_length      6
1569b8e80941Smrg#define GEN45_3DSTATE_DEPTH_BUFFER_length_bias      2
1570b8e80941Smrg#define GEN45_3DSTATE_DEPTH_BUFFER_header       \
1571b8e80941Smrg   .DWordLength                         =      4,  \
1572b8e80941Smrg   ._3DCommandSubOpcode                 =      5,  \
1573b8e80941Smrg   ._3DCommandOpcode                    =      1,  \
1574b8e80941Smrg   .CommandSubType                      =      3,  \
1575b8e80941Smrg   .CommandType                         =      3
1576b8e80941Smrg
1577b8e80941Smrgstruct GEN45_3DSTATE_DEPTH_BUFFER {
1578b8e80941Smrg   uint32_t                             DWordLength;
1579b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1580b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1581b8e80941Smrg   uint32_t                             CommandSubType;
1582b8e80941Smrg   uint32_t                             CommandType;
1583b8e80941Smrg   uint32_t                             SurfacePitch;
1584b8e80941Smrg   uint32_t                             SurfaceFormat;
1585b8e80941Smrg#define D32_FLOAT_S8X24_UINT                     0
1586b8e80941Smrg#define D32_FLOAT                                1
1587b8e80941Smrg#define D24_UNORM_S8_UINT                        2
1588b8e80941Smrg#define D24_UNORM_X8_UINT                        3
1589b8e80941Smrg#define D16_UNORM                                5
1590b8e80941Smrg   uint32_t                             SoftwareTiledRenderingMode;
1591b8e80941Smrg#define NORMAL                                   0
1592b8e80941Smrg#define STR1                                     1
1593b8e80941Smrg#define STR2                                     3
1594b8e80941Smrg   bool                                 DepthBufferCoordinateOffsetDisable;
1595b8e80941Smrg   uint32_t                             TileWalk;
1596b8e80941Smrg#define TILEWALK_YMAJOR                          1
1597b8e80941Smrg   bool                                 TiledSurface;
1598b8e80941Smrg   uint32_t                             SurfaceType;
1599b8e80941Smrg#define SURFTYPE_1D                              0
1600b8e80941Smrg#define SURFTYPE_2D                              1
1601b8e80941Smrg#define SURFTYPE_3D                              2
1602b8e80941Smrg#define SURFTYPE_CUBE                            3
1603b8e80941Smrg#define SURFTYPE_NULL                            7
1604b8e80941Smrg   __gen_address_type                   SurfaceBaseAddress;
1605b8e80941Smrg   uint32_t                             MIPMapLayoutMode;
1606b8e80941Smrg#define MIPLAYOUT_BELOW                          0
1607b8e80941Smrg#define MIPLAYOUT_RIGHT                          1
1608b8e80941Smrg   uint32_t                             LOD;
1609b8e80941Smrg   uint32_t                             Width;
1610b8e80941Smrg   uint32_t                             Height;
1611b8e80941Smrg#define SURFTYPE_1Dmustbezero                    0
1612b8e80941Smrg   uint32_t                             RenderTargetViewExtent;
1613b8e80941Smrg   uint32_t                             MinimumArrayElement;
1614b8e80941Smrg   uint32_t                             Depth;
1615b8e80941Smrg#define SURFTYPE_CUBEmustbezero                  0
1616b8e80941Smrg   int32_t                              DepthCoordinateOffsetX;
1617b8e80941Smrg   int32_t                              DepthCoordinateOffsetY;
1618b8e80941Smrg};
1619b8e80941Smrg
1620b8e80941Smrgstatic inline void
1621b8e80941SmrgGEN45_3DSTATE_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
1622b8e80941Smrg                                __attribute__((unused)) void * restrict dst,
1623b8e80941Smrg                                __attribute__((unused)) const struct GEN45_3DSTATE_DEPTH_BUFFER * restrict values)
1624b8e80941Smrg{
1625b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1626b8e80941Smrg
1627b8e80941Smrg   dw[0] =
1628b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1629b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1630b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1631b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1632b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1633b8e80941Smrg
1634b8e80941Smrg   dw[1] =
1635b8e80941Smrg      __gen_uint(values->SurfacePitch, 0, 16) |
1636b8e80941Smrg      __gen_uint(values->SurfaceFormat, 18, 20) |
1637b8e80941Smrg      __gen_uint(values->SoftwareTiledRenderingMode, 23, 24) |
1638b8e80941Smrg      __gen_uint(values->DepthBufferCoordinateOffsetDisable, 25, 25) |
1639b8e80941Smrg      __gen_uint(values->TileWalk, 26, 26) |
1640b8e80941Smrg      __gen_uint(values->TiledSurface, 27, 27) |
1641b8e80941Smrg      __gen_uint(values->SurfaceType, 29, 31);
1642b8e80941Smrg
1643b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->SurfaceBaseAddress, 0);
1644b8e80941Smrg
1645b8e80941Smrg   dw[3] =
1646b8e80941Smrg      __gen_uint(values->MIPMapLayoutMode, 1, 1) |
1647b8e80941Smrg      __gen_uint(values->LOD, 2, 5) |
1648b8e80941Smrg      __gen_uint(values->Width, 6, 18) |
1649b8e80941Smrg      __gen_uint(values->Height, 19, 31);
1650b8e80941Smrg
1651b8e80941Smrg   dw[4] =
1652b8e80941Smrg      __gen_uint(values->RenderTargetViewExtent, 1, 9) |
1653b8e80941Smrg      __gen_uint(values->MinimumArrayElement, 10, 20) |
1654b8e80941Smrg      __gen_uint(values->Depth, 21, 31);
1655b8e80941Smrg
1656b8e80941Smrg   dw[5] =
1657b8e80941Smrg      __gen_sint(values->DepthCoordinateOffsetX, 0, 15) |
1658b8e80941Smrg      __gen_sint(values->DepthCoordinateOffsetY, 16, 31);
1659b8e80941Smrg}
1660b8e80941Smrg
1661b8e80941Smrg#define GEN45_3DSTATE_DRAWING_RECTANGLE_length      4
1662b8e80941Smrg#define GEN45_3DSTATE_DRAWING_RECTANGLE_length_bias      2
1663b8e80941Smrg#define GEN45_3DSTATE_DRAWING_RECTANGLE_header  \
1664b8e80941Smrg   .DWordLength                         =      2,  \
1665b8e80941Smrg   ._3DCommandSubOpcode                 =      0,  \
1666b8e80941Smrg   ._3DCommandOpcode                    =      1,  \
1667b8e80941Smrg   .CommandSubType                      =      3,  \
1668b8e80941Smrg   .CommandType                         =      3
1669b8e80941Smrg
1670b8e80941Smrgstruct GEN45_3DSTATE_DRAWING_RECTANGLE {
1671b8e80941Smrg   uint32_t                             DWordLength;
1672b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1673b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1674b8e80941Smrg   uint32_t                             CommandSubType;
1675b8e80941Smrg   uint32_t                             CommandType;
1676b8e80941Smrg   uint32_t                             ClippedDrawingRectangleXMin;
1677b8e80941Smrg   uint32_t                             ClippedDrawingRectangleYMin;
1678b8e80941Smrg   uint32_t                             ClippedDrawingRectangleXMax;
1679b8e80941Smrg   uint32_t                             ClippedDrawingRectangleYMax;
1680b8e80941Smrg   int32_t                              DrawingRectangleOriginX;
1681b8e80941Smrg   int32_t                              DrawingRectangleOriginY;
1682b8e80941Smrg};
1683b8e80941Smrg
1684b8e80941Smrgstatic inline void
1685b8e80941SmrgGEN45_3DSTATE_DRAWING_RECTANGLE_pack(__attribute__((unused)) __gen_user_data *data,
1686b8e80941Smrg                                     __attribute__((unused)) void * restrict dst,
1687b8e80941Smrg                                     __attribute__((unused)) const struct GEN45_3DSTATE_DRAWING_RECTANGLE * restrict values)
1688b8e80941Smrg{
1689b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1690b8e80941Smrg
1691b8e80941Smrg   dw[0] =
1692b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1693b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1694b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1695b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1696b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1697b8e80941Smrg
1698b8e80941Smrg   dw[1] =
1699b8e80941Smrg      __gen_uint(values->ClippedDrawingRectangleXMin, 0, 15) |
1700b8e80941Smrg      __gen_uint(values->ClippedDrawingRectangleYMin, 16, 31);
1701b8e80941Smrg
1702b8e80941Smrg   dw[2] =
1703b8e80941Smrg      __gen_uint(values->ClippedDrawingRectangleXMax, 0, 15) |
1704b8e80941Smrg      __gen_uint(values->ClippedDrawingRectangleYMax, 16, 31);
1705b8e80941Smrg
1706b8e80941Smrg   dw[3] =
1707b8e80941Smrg      __gen_sint(values->DrawingRectangleOriginX, 0, 15) |
1708b8e80941Smrg      __gen_sint(values->DrawingRectangleOriginY, 16, 31);
1709b8e80941Smrg}
1710b8e80941Smrg
1711b8e80941Smrg#define GEN45_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length      2
1712b8e80941Smrg#define GEN45_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length_bias      2
1713b8e80941Smrg#define GEN45_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_header\
1714b8e80941Smrg   .DWordLength                         =      0,  \
1715b8e80941Smrg   ._3DCommandSubOpcode                 =      9,  \
1716b8e80941Smrg   ._3DCommandOpcode                    =      1,  \
1717b8e80941Smrg   .CommandSubType                      =      3,  \
1718b8e80941Smrg   .CommandType                         =      3
1719b8e80941Smrg
1720b8e80941Smrgstruct GEN45_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP {
1721b8e80941Smrg   uint32_t                             DWordLength;
1722b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1723b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1724b8e80941Smrg   uint32_t                             CommandSubType;
1725b8e80941Smrg   uint32_t                             CommandType;
1726b8e80941Smrg   float                                GlobalDepthOffsetClamp;
1727b8e80941Smrg};
1728b8e80941Smrg
1729b8e80941Smrgstatic inline void
1730b8e80941SmrgGEN45_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_pack(__attribute__((unused)) __gen_user_data *data,
1731b8e80941Smrg                                             __attribute__((unused)) void * restrict dst,
1732b8e80941Smrg                                             __attribute__((unused)) const struct GEN45_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP * restrict values)
1733b8e80941Smrg{
1734b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1735b8e80941Smrg
1736b8e80941Smrg   dw[0] =
1737b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1738b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1739b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1740b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1741b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1742b8e80941Smrg
1743b8e80941Smrg   dw[1] =
1744b8e80941Smrg      __gen_float(values->GlobalDepthOffsetClamp);
1745b8e80941Smrg}
1746b8e80941Smrg
1747b8e80941Smrg#define GEN45_3DSTATE_INDEX_BUFFER_length      3
1748b8e80941Smrg#define GEN45_3DSTATE_INDEX_BUFFER_length_bias      2
1749b8e80941Smrg#define GEN45_3DSTATE_INDEX_BUFFER_header       \
1750b8e80941Smrg   .DWordLength                         =      1,  \
1751b8e80941Smrg   ._3DCommandSubOpcode                 =     10,  \
1752b8e80941Smrg   ._3DCommandOpcode                    =      0,  \
1753b8e80941Smrg   .CommandSubType                      =      3,  \
1754b8e80941Smrg   .CommandType                         =      3
1755b8e80941Smrg
1756b8e80941Smrgstruct GEN45_3DSTATE_INDEX_BUFFER {
1757b8e80941Smrg   uint32_t                             DWordLength;
1758b8e80941Smrg   uint32_t                             IndexFormat;
1759b8e80941Smrg#define INDEX_BYTE                               0
1760b8e80941Smrg#define INDEX_WORD                               1
1761b8e80941Smrg#define INDEX_DWORD                              2
1762b8e80941Smrg   bool                                 CutIndexEnable;
1763b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1764b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1765b8e80941Smrg   uint32_t                             CommandSubType;
1766b8e80941Smrg   uint32_t                             CommandType;
1767b8e80941Smrg   __gen_address_type                   BufferStartingAddress;
1768b8e80941Smrg   __gen_address_type                   BufferEndingAddress;
1769b8e80941Smrg};
1770b8e80941Smrg
1771b8e80941Smrgstatic inline void
1772b8e80941SmrgGEN45_3DSTATE_INDEX_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
1773b8e80941Smrg                                __attribute__((unused)) void * restrict dst,
1774b8e80941Smrg                                __attribute__((unused)) const struct GEN45_3DSTATE_INDEX_BUFFER * restrict values)
1775b8e80941Smrg{
1776b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1777b8e80941Smrg
1778b8e80941Smrg   dw[0] =
1779b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1780b8e80941Smrg      __gen_uint(values->IndexFormat, 8, 9) |
1781b8e80941Smrg      __gen_uint(values->CutIndexEnable, 10, 10) |
1782b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1783b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1784b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1785b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1786b8e80941Smrg
1787b8e80941Smrg   dw[1] = __gen_combine_address(data, &dw[1], values->BufferStartingAddress, 0);
1788b8e80941Smrg
1789b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->BufferEndingAddress, 0);
1790b8e80941Smrg}
1791b8e80941Smrg
1792b8e80941Smrg#define GEN45_3DSTATE_LINE_STIPPLE_length      3
1793b8e80941Smrg#define GEN45_3DSTATE_LINE_STIPPLE_length_bias      2
1794b8e80941Smrg#define GEN45_3DSTATE_LINE_STIPPLE_header       \
1795b8e80941Smrg   .DWordLength                         =      1,  \
1796b8e80941Smrg   ._3DCommandSubOpcode                 =      8,  \
1797b8e80941Smrg   ._3DCommandOpcode                    =      1,  \
1798b8e80941Smrg   .CommandSubType                      =      3,  \
1799b8e80941Smrg   .CommandType                         =      3
1800b8e80941Smrg
1801b8e80941Smrgstruct GEN45_3DSTATE_LINE_STIPPLE {
1802b8e80941Smrg   uint32_t                             DWordLength;
1803b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1804b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1805b8e80941Smrg   uint32_t                             CommandSubType;
1806b8e80941Smrg   uint32_t                             CommandType;
1807b8e80941Smrg   uint32_t                             LineStipplePattern;
1808b8e80941Smrg   uint32_t                             CurrentStippleIndex;
1809b8e80941Smrg   uint32_t                             CurrentRepeatCounter;
1810b8e80941Smrg   bool                                 ModifyEnableCurrentRepeatCounterCurrentStippleIndex;
1811b8e80941Smrg   uint32_t                             LineStippleRepeatCount;
1812b8e80941Smrg   float                                LineStippleInverseRepeatCount;
1813b8e80941Smrg};
1814b8e80941Smrg
1815b8e80941Smrgstatic inline void
1816b8e80941SmrgGEN45_3DSTATE_LINE_STIPPLE_pack(__attribute__((unused)) __gen_user_data *data,
1817b8e80941Smrg                                __attribute__((unused)) void * restrict dst,
1818b8e80941Smrg                                __attribute__((unused)) const struct GEN45_3DSTATE_LINE_STIPPLE * restrict values)
1819b8e80941Smrg{
1820b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1821b8e80941Smrg
1822b8e80941Smrg   dw[0] =
1823b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1824b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1825b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1826b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1827b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1828b8e80941Smrg
1829b8e80941Smrg   dw[1] =
1830b8e80941Smrg      __gen_uint(values->LineStipplePattern, 0, 15) |
1831b8e80941Smrg      __gen_uint(values->CurrentStippleIndex, 16, 19) |
1832b8e80941Smrg      __gen_uint(values->CurrentRepeatCounter, 21, 29) |
1833b8e80941Smrg      __gen_uint(values->ModifyEnableCurrentRepeatCounterCurrentStippleIndex, 31, 31);
1834b8e80941Smrg
1835b8e80941Smrg   dw[2] =
1836b8e80941Smrg      __gen_uint(values->LineStippleRepeatCount, 0, 8) |
1837b8e80941Smrg      __gen_ufixed(values->LineStippleInverseRepeatCount, 16, 31, 13);
1838b8e80941Smrg}
1839b8e80941Smrg
1840b8e80941Smrg#define GEN45_3DSTATE_PIPELINED_POINTERS_length      7
1841b8e80941Smrg#define GEN45_3DSTATE_PIPELINED_POINTERS_length_bias      2
1842b8e80941Smrg#define GEN45_3DSTATE_PIPELINED_POINTERS_header \
1843b8e80941Smrg   .DWordLength                         =      5,  \
1844b8e80941Smrg   ._3DCommandSubOpcode                 =      0,  \
1845b8e80941Smrg   ._3DCommandOpcode                    =      0,  \
1846b8e80941Smrg   .CommandSubType                      =      3,  \
1847b8e80941Smrg   .CommandType                         =      3
1848b8e80941Smrg
1849b8e80941Smrgstruct GEN45_3DSTATE_PIPELINED_POINTERS {
1850b8e80941Smrg   uint32_t                             DWordLength;
1851b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1852b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1853b8e80941Smrg   uint32_t                             CommandSubType;
1854b8e80941Smrg   uint32_t                             CommandType;
1855b8e80941Smrg   __gen_address_type                   PointertoVSState;
1856b8e80941Smrg   bool                                 GSEnable;
1857b8e80941Smrg   __gen_address_type                   PointertoGSState;
1858b8e80941Smrg   bool                                 ClipEnable;
1859b8e80941Smrg   __gen_address_type                   PointertoCLIPState;
1860b8e80941Smrg   __gen_address_type                   PointertoSFState;
1861b8e80941Smrg   __gen_address_type                   PointertoWMState;
1862b8e80941Smrg   __gen_address_type                   PointertoColorCalcState;
1863b8e80941Smrg};
1864b8e80941Smrg
1865b8e80941Smrgstatic inline void
1866b8e80941SmrgGEN45_3DSTATE_PIPELINED_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
1867b8e80941Smrg                                      __attribute__((unused)) void * restrict dst,
1868b8e80941Smrg                                      __attribute__((unused)) const struct GEN45_3DSTATE_PIPELINED_POINTERS * restrict values)
1869b8e80941Smrg{
1870b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1871b8e80941Smrg
1872b8e80941Smrg   dw[0] =
1873b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1874b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1875b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1876b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1877b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1878b8e80941Smrg
1879b8e80941Smrg   dw[1] = __gen_combine_address(data, &dw[1], values->PointertoVSState, 0);
1880b8e80941Smrg
1881b8e80941Smrg   const uint32_t v2 =
1882b8e80941Smrg      __gen_uint(values->GSEnable, 0, 0);
1883b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->PointertoGSState, v2);
1884b8e80941Smrg
1885b8e80941Smrg   const uint32_t v3 =
1886b8e80941Smrg      __gen_uint(values->ClipEnable, 0, 0);
1887b8e80941Smrg   dw[3] = __gen_combine_address(data, &dw[3], values->PointertoCLIPState, v3);
1888b8e80941Smrg
1889b8e80941Smrg   dw[4] = __gen_combine_address(data, &dw[4], values->PointertoSFState, 0);
1890b8e80941Smrg
1891b8e80941Smrg   dw[5] = __gen_combine_address(data, &dw[5], values->PointertoWMState, 0);
1892b8e80941Smrg
1893b8e80941Smrg   dw[6] = __gen_combine_address(data, &dw[6], values->PointertoColorCalcState, 0);
1894b8e80941Smrg}
1895b8e80941Smrg
1896b8e80941Smrg#define GEN45_3DSTATE_POLY_STIPPLE_OFFSET_length      2
1897b8e80941Smrg#define GEN45_3DSTATE_POLY_STIPPLE_OFFSET_length_bias      2
1898b8e80941Smrg#define GEN45_3DSTATE_POLY_STIPPLE_OFFSET_header\
1899b8e80941Smrg   .DWordLength                         =      0,  \
1900b8e80941Smrg   ._3DCommandSubOpcode                 =      6,  \
1901b8e80941Smrg   ._3DCommandOpcode                    =      1,  \
1902b8e80941Smrg   .CommandSubType                      =      3,  \
1903b8e80941Smrg   .CommandType                         =      3
1904b8e80941Smrg
1905b8e80941Smrgstruct GEN45_3DSTATE_POLY_STIPPLE_OFFSET {
1906b8e80941Smrg   uint32_t                             DWordLength;
1907b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1908b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1909b8e80941Smrg   uint32_t                             CommandSubType;
1910b8e80941Smrg   uint32_t                             CommandType;
1911b8e80941Smrg   uint32_t                             PolygonStippleYOffset;
1912b8e80941Smrg   uint32_t                             PolygonStippleXOffset;
1913b8e80941Smrg};
1914b8e80941Smrg
1915b8e80941Smrgstatic inline void
1916b8e80941SmrgGEN45_3DSTATE_POLY_STIPPLE_OFFSET_pack(__attribute__((unused)) __gen_user_data *data,
1917b8e80941Smrg                                       __attribute__((unused)) void * restrict dst,
1918b8e80941Smrg                                       __attribute__((unused)) const struct GEN45_3DSTATE_POLY_STIPPLE_OFFSET * restrict values)
1919b8e80941Smrg{
1920b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1921b8e80941Smrg
1922b8e80941Smrg   dw[0] =
1923b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1924b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1925b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1926b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1927b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1928b8e80941Smrg
1929b8e80941Smrg   dw[1] =
1930b8e80941Smrg      __gen_uint(values->PolygonStippleYOffset, 0, 4) |
1931b8e80941Smrg      __gen_uint(values->PolygonStippleXOffset, 8, 12);
1932b8e80941Smrg}
1933b8e80941Smrg
1934b8e80941Smrg#define GEN45_3DSTATE_POLY_STIPPLE_PATTERN_length     33
1935b8e80941Smrg#define GEN45_3DSTATE_POLY_STIPPLE_PATTERN_length_bias      2
1936b8e80941Smrg#define GEN45_3DSTATE_POLY_STIPPLE_PATTERN_header\
1937b8e80941Smrg   .DWordLength                         =     31,  \
1938b8e80941Smrg   ._3DCommandSubOpcode                 =      7,  \
1939b8e80941Smrg   ._3DCommandOpcode                    =      1,  \
1940b8e80941Smrg   .CommandSubType                      =      3,  \
1941b8e80941Smrg   .CommandType                         =      3
1942b8e80941Smrg
1943b8e80941Smrgstruct GEN45_3DSTATE_POLY_STIPPLE_PATTERN {
1944b8e80941Smrg   uint32_t                             DWordLength;
1945b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
1946b8e80941Smrg   uint32_t                             _3DCommandOpcode;
1947b8e80941Smrg   uint32_t                             CommandSubType;
1948b8e80941Smrg   uint32_t                             CommandType;
1949b8e80941Smrg   uint32_t                             PatternRow[32];
1950b8e80941Smrg};
1951b8e80941Smrg
1952b8e80941Smrgstatic inline void
1953b8e80941SmrgGEN45_3DSTATE_POLY_STIPPLE_PATTERN_pack(__attribute__((unused)) __gen_user_data *data,
1954b8e80941Smrg                                        __attribute__((unused)) void * restrict dst,
1955b8e80941Smrg                                        __attribute__((unused)) const struct GEN45_3DSTATE_POLY_STIPPLE_PATTERN * restrict values)
1956b8e80941Smrg{
1957b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
1958b8e80941Smrg
1959b8e80941Smrg   dw[0] =
1960b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
1961b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
1962b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
1963b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
1964b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
1965b8e80941Smrg
1966b8e80941Smrg   dw[1] =
1967b8e80941Smrg      __gen_uint(values->PatternRow[0], 0, 31);
1968b8e80941Smrg
1969b8e80941Smrg   dw[2] =
1970b8e80941Smrg      __gen_uint(values->PatternRow[1], 0, 31);
1971b8e80941Smrg
1972b8e80941Smrg   dw[3] =
1973b8e80941Smrg      __gen_uint(values->PatternRow[2], 0, 31);
1974b8e80941Smrg
1975b8e80941Smrg   dw[4] =
1976b8e80941Smrg      __gen_uint(values->PatternRow[3], 0, 31);
1977b8e80941Smrg
1978b8e80941Smrg   dw[5] =
1979b8e80941Smrg      __gen_uint(values->PatternRow[4], 0, 31);
1980b8e80941Smrg
1981b8e80941Smrg   dw[6] =
1982b8e80941Smrg      __gen_uint(values->PatternRow[5], 0, 31);
1983b8e80941Smrg
1984b8e80941Smrg   dw[7] =
1985b8e80941Smrg      __gen_uint(values->PatternRow[6], 0, 31);
1986b8e80941Smrg
1987b8e80941Smrg   dw[8] =
1988b8e80941Smrg      __gen_uint(values->PatternRow[7], 0, 31);
1989b8e80941Smrg
1990b8e80941Smrg   dw[9] =
1991b8e80941Smrg      __gen_uint(values->PatternRow[8], 0, 31);
1992b8e80941Smrg
1993b8e80941Smrg   dw[10] =
1994b8e80941Smrg      __gen_uint(values->PatternRow[9], 0, 31);
1995b8e80941Smrg
1996b8e80941Smrg   dw[11] =
1997b8e80941Smrg      __gen_uint(values->PatternRow[10], 0, 31);
1998b8e80941Smrg
1999b8e80941Smrg   dw[12] =
2000b8e80941Smrg      __gen_uint(values->PatternRow[11], 0, 31);
2001b8e80941Smrg
2002b8e80941Smrg   dw[13] =
2003b8e80941Smrg      __gen_uint(values->PatternRow[12], 0, 31);
2004b8e80941Smrg
2005b8e80941Smrg   dw[14] =
2006b8e80941Smrg      __gen_uint(values->PatternRow[13], 0, 31);
2007b8e80941Smrg
2008b8e80941Smrg   dw[15] =
2009b8e80941Smrg      __gen_uint(values->PatternRow[14], 0, 31);
2010b8e80941Smrg
2011b8e80941Smrg   dw[16] =
2012b8e80941Smrg      __gen_uint(values->PatternRow[15], 0, 31);
2013b8e80941Smrg
2014b8e80941Smrg   dw[17] =
2015b8e80941Smrg      __gen_uint(values->PatternRow[16], 0, 31);
2016b8e80941Smrg
2017b8e80941Smrg   dw[18] =
2018b8e80941Smrg      __gen_uint(values->PatternRow[17], 0, 31);
2019b8e80941Smrg
2020b8e80941Smrg   dw[19] =
2021b8e80941Smrg      __gen_uint(values->PatternRow[18], 0, 31);
2022b8e80941Smrg
2023b8e80941Smrg   dw[20] =
2024b8e80941Smrg      __gen_uint(values->PatternRow[19], 0, 31);
2025b8e80941Smrg
2026b8e80941Smrg   dw[21] =
2027b8e80941Smrg      __gen_uint(values->PatternRow[20], 0, 31);
2028b8e80941Smrg
2029b8e80941Smrg   dw[22] =
2030b8e80941Smrg      __gen_uint(values->PatternRow[21], 0, 31);
2031b8e80941Smrg
2032b8e80941Smrg   dw[23] =
2033b8e80941Smrg      __gen_uint(values->PatternRow[22], 0, 31);
2034b8e80941Smrg
2035b8e80941Smrg   dw[24] =
2036b8e80941Smrg      __gen_uint(values->PatternRow[23], 0, 31);
2037b8e80941Smrg
2038b8e80941Smrg   dw[25] =
2039b8e80941Smrg      __gen_uint(values->PatternRow[24], 0, 31);
2040b8e80941Smrg
2041b8e80941Smrg   dw[26] =
2042b8e80941Smrg      __gen_uint(values->PatternRow[25], 0, 31);
2043b8e80941Smrg
2044b8e80941Smrg   dw[27] =
2045b8e80941Smrg      __gen_uint(values->PatternRow[26], 0, 31);
2046b8e80941Smrg
2047b8e80941Smrg   dw[28] =
2048b8e80941Smrg      __gen_uint(values->PatternRow[27], 0, 31);
2049b8e80941Smrg
2050b8e80941Smrg   dw[29] =
2051b8e80941Smrg      __gen_uint(values->PatternRow[28], 0, 31);
2052b8e80941Smrg
2053b8e80941Smrg   dw[30] =
2054b8e80941Smrg      __gen_uint(values->PatternRow[29], 0, 31);
2055b8e80941Smrg
2056b8e80941Smrg   dw[31] =
2057b8e80941Smrg      __gen_uint(values->PatternRow[30], 0, 31);
2058b8e80941Smrg
2059b8e80941Smrg   dw[32] =
2060b8e80941Smrg      __gen_uint(values->PatternRow[31], 0, 31);
2061b8e80941Smrg}
2062b8e80941Smrg
2063b8e80941Smrg#define GEN45_3DSTATE_VERTEX_BUFFERS_length_bias      2
2064b8e80941Smrg#define GEN45_3DSTATE_VERTEX_BUFFERS_header     \
2065b8e80941Smrg   .DWordLength                         =      3,  \
2066b8e80941Smrg   ._3DCommandSubOpcode                 =      8,  \
2067b8e80941Smrg   ._3DCommandOpcode                    =      0,  \
2068b8e80941Smrg   .CommandSubType                      =      3,  \
2069b8e80941Smrg   .CommandType                         =      3
2070b8e80941Smrg
2071b8e80941Smrgstruct GEN45_3DSTATE_VERTEX_BUFFERS {
2072b8e80941Smrg   uint32_t                             DWordLength;
2073b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
2074b8e80941Smrg   uint32_t                             _3DCommandOpcode;
2075b8e80941Smrg   uint32_t                             CommandSubType;
2076b8e80941Smrg   uint32_t                             CommandType;
2077b8e80941Smrg   /* variable length fields follow */
2078b8e80941Smrg};
2079b8e80941Smrg
2080b8e80941Smrgstatic inline void
2081b8e80941SmrgGEN45_3DSTATE_VERTEX_BUFFERS_pack(__attribute__((unused)) __gen_user_data *data,
2082b8e80941Smrg                                  __attribute__((unused)) void * restrict dst,
2083b8e80941Smrg                                  __attribute__((unused)) const struct GEN45_3DSTATE_VERTEX_BUFFERS * restrict values)
2084b8e80941Smrg{
2085b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2086b8e80941Smrg
2087b8e80941Smrg   dw[0] =
2088b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
2089b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2090b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2091b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
2092b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2093b8e80941Smrg}
2094b8e80941Smrg
2095b8e80941Smrg#define GEN45_3DSTATE_VERTEX_ELEMENTS_length_bias      2
2096b8e80941Smrg#define GEN45_3DSTATE_VERTEX_ELEMENTS_header    \
2097b8e80941Smrg   .DWordLength                         =      1,  \
2098b8e80941Smrg   ._3DCommandSubOpcode                 =      9,  \
2099b8e80941Smrg   ._3DCommandOpcode                    =      0,  \
2100b8e80941Smrg   .CommandSubType                      =      3,  \
2101b8e80941Smrg   .CommandType                         =      3
2102b8e80941Smrg
2103b8e80941Smrgstruct GEN45_3DSTATE_VERTEX_ELEMENTS {
2104b8e80941Smrg   uint32_t                             DWordLength;
2105b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
2106b8e80941Smrg   uint32_t                             _3DCommandOpcode;
2107b8e80941Smrg   uint32_t                             CommandSubType;
2108b8e80941Smrg   uint32_t                             CommandType;
2109b8e80941Smrg   /* variable length fields follow */
2110b8e80941Smrg};
2111b8e80941Smrg
2112b8e80941Smrgstatic inline void
2113b8e80941SmrgGEN45_3DSTATE_VERTEX_ELEMENTS_pack(__attribute__((unused)) __gen_user_data *data,
2114b8e80941Smrg                                   __attribute__((unused)) void * restrict dst,
2115b8e80941Smrg                                   __attribute__((unused)) const struct GEN45_3DSTATE_VERTEX_ELEMENTS * restrict values)
2116b8e80941Smrg{
2117b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2118b8e80941Smrg
2119b8e80941Smrg   dw[0] =
2120b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
2121b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2122b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2123b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
2124b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2125b8e80941Smrg}
2126b8e80941Smrg
2127b8e80941Smrg#define GEN45_3DSTATE_VF_STATISTICS_length      1
2128b8e80941Smrg#define GEN45_3DSTATE_VF_STATISTICS_length_bias      1
2129b8e80941Smrg#define GEN45_3DSTATE_VF_STATISTICS_header      \
2130b8e80941Smrg   ._3DCommandSubOpcode                 =     11,  \
2131b8e80941Smrg   ._3DCommandOpcode                    =      0,  \
2132b8e80941Smrg   .CommandSubType                      =      1,  \
2133b8e80941Smrg   .CommandType                         =      3
2134b8e80941Smrg
2135b8e80941Smrgstruct GEN45_3DSTATE_VF_STATISTICS {
2136b8e80941Smrg   bool                                 StatisticsEnable;
2137b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
2138b8e80941Smrg   uint32_t                             _3DCommandOpcode;
2139b8e80941Smrg   uint32_t                             CommandSubType;
2140b8e80941Smrg   uint32_t                             CommandType;
2141b8e80941Smrg};
2142b8e80941Smrg
2143b8e80941Smrgstatic inline void
2144b8e80941SmrgGEN45_3DSTATE_VF_STATISTICS_pack(__attribute__((unused)) __gen_user_data *data,
2145b8e80941Smrg                                 __attribute__((unused)) void * restrict dst,
2146b8e80941Smrg                                 __attribute__((unused)) const struct GEN45_3DSTATE_VF_STATISTICS * restrict values)
2147b8e80941Smrg{
2148b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2149b8e80941Smrg
2150b8e80941Smrg   dw[0] =
2151b8e80941Smrg      __gen_uint(values->StatisticsEnable, 0, 0) |
2152b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2153b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2154b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
2155b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2156b8e80941Smrg}
2157b8e80941Smrg
2158b8e80941Smrg#define GEN45_CONSTANT_BUFFER_length           2
2159b8e80941Smrg#define GEN45_CONSTANT_BUFFER_length_bias      2
2160b8e80941Smrg#define GEN45_CONSTANT_BUFFER_header            \
2161b8e80941Smrg   .DWordLength                         =      0,  \
2162b8e80941Smrg   .Valid                               =      0,  \
2163b8e80941Smrg   ._3DCommandSubOpcode                 =      2,  \
2164b8e80941Smrg   ._3DCommandOpcode                    =      0,  \
2165b8e80941Smrg   .CommandSubType                      =      0,  \
2166b8e80941Smrg   .CommandType                         =      3
2167b8e80941Smrg
2168b8e80941Smrgstruct GEN45_CONSTANT_BUFFER {
2169b8e80941Smrg   uint32_t                             DWordLength;
2170b8e80941Smrg   bool                                 Valid;
2171b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
2172b8e80941Smrg   uint32_t                             _3DCommandOpcode;
2173b8e80941Smrg   uint32_t                             CommandSubType;
2174b8e80941Smrg   uint32_t                             CommandType;
2175b8e80941Smrg   uint32_t                             BufferLength;
2176b8e80941Smrg   __gen_address_type                   BufferStartingAddress;
2177b8e80941Smrg};
2178b8e80941Smrg
2179b8e80941Smrgstatic inline void
2180b8e80941SmrgGEN45_CONSTANT_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
2181b8e80941Smrg                           __attribute__((unused)) void * restrict dst,
2182b8e80941Smrg                           __attribute__((unused)) const struct GEN45_CONSTANT_BUFFER * restrict values)
2183b8e80941Smrg{
2184b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2185b8e80941Smrg
2186b8e80941Smrg   dw[0] =
2187b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
2188b8e80941Smrg      __gen_uint(values->Valid, 8, 8) |
2189b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2190b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2191b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
2192b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2193b8e80941Smrg
2194b8e80941Smrg   const uint32_t v1 =
2195b8e80941Smrg      __gen_uint(values->BufferLength, 0, 5);
2196b8e80941Smrg   dw[1] = __gen_combine_address(data, &dw[1], values->BufferStartingAddress, v1);
2197b8e80941Smrg}
2198b8e80941Smrg
2199b8e80941Smrg#define GEN45_CS_URB_STATE_length              2
2200b8e80941Smrg#define GEN45_CS_URB_STATE_length_bias         2
2201b8e80941Smrg#define GEN45_CS_URB_STATE_header               \
2202b8e80941Smrg   .DWordLength                         =      0,  \
2203b8e80941Smrg   ._3DCommandSubOpcode                 =      1,  \
2204b8e80941Smrg   ._3DCommandOpcode                    =      0,  \
2205b8e80941Smrg   .CommandSubType                      =      0,  \
2206b8e80941Smrg   .CommandType                         =      3
2207b8e80941Smrg
2208b8e80941Smrgstruct GEN45_CS_URB_STATE {
2209b8e80941Smrg   uint32_t                             DWordLength;
2210b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
2211b8e80941Smrg   uint32_t                             _3DCommandOpcode;
2212b8e80941Smrg   uint32_t                             CommandSubType;
2213b8e80941Smrg   uint32_t                             CommandType;
2214b8e80941Smrg   uint32_t                             NumberofURBEntries;
2215b8e80941Smrg   uint32_t                             URBEntryAllocationSize;
2216b8e80941Smrg};
2217b8e80941Smrg
2218b8e80941Smrgstatic inline void
2219b8e80941SmrgGEN45_CS_URB_STATE_pack(__attribute__((unused)) __gen_user_data *data,
2220b8e80941Smrg                        __attribute__((unused)) void * restrict dst,
2221b8e80941Smrg                        __attribute__((unused)) const struct GEN45_CS_URB_STATE * restrict values)
2222b8e80941Smrg{
2223b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2224b8e80941Smrg
2225b8e80941Smrg   dw[0] =
2226b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
2227b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2228b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2229b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
2230b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2231b8e80941Smrg
2232b8e80941Smrg   dw[1] =
2233b8e80941Smrg      __gen_uint(values->NumberofURBEntries, 0, 2) |
2234b8e80941Smrg      __gen_uint(values->URBEntryAllocationSize, 4, 8);
2235b8e80941Smrg}
2236b8e80941Smrg
2237b8e80941Smrg#define GEN45_MI_FLUSH_length                  1
2238b8e80941Smrg#define GEN45_MI_FLUSH_length_bias             1
2239b8e80941Smrg#define GEN45_MI_FLUSH_header                   \
2240b8e80941Smrg   .MICommandOpcode                     =      4,  \
2241b8e80941Smrg   .CommandType                         =      0
2242b8e80941Smrg
2243b8e80941Smrgstruct GEN45_MI_FLUSH {
2244b8e80941Smrg   uint32_t                             StateInstructionCacheInvalidate;
2245b8e80941Smrg#define DontInvalidate                           0
2246b8e80941Smrg#define Invalidate                               1
2247b8e80941Smrg   uint32_t                             RenderCacheFlushInhibit;
2248b8e80941Smrg#define Flush                                    0
2249b8e80941Smrg#define DontFlush                                1
2250b8e80941Smrg   uint32_t                             GlobalSnapshotCountReset;
2251b8e80941Smrg#define DontReset                                0
2252b8e80941Smrg#define Reset                                    1
2253b8e80941Smrg   uint32_t                             MICommandOpcode;
2254b8e80941Smrg   uint32_t                             CommandType;
2255b8e80941Smrg};
2256b8e80941Smrg
2257b8e80941Smrgstatic inline void
2258b8e80941SmrgGEN45_MI_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
2259b8e80941Smrg                    __attribute__((unused)) void * restrict dst,
2260b8e80941Smrg                    __attribute__((unused)) const struct GEN45_MI_FLUSH * restrict values)
2261b8e80941Smrg{
2262b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2263b8e80941Smrg
2264b8e80941Smrg   dw[0] =
2265b8e80941Smrg      __gen_uint(values->StateInstructionCacheInvalidate, 1, 1) |
2266b8e80941Smrg      __gen_uint(values->RenderCacheFlushInhibit, 2, 2) |
2267b8e80941Smrg      __gen_uint(values->GlobalSnapshotCountReset, 3, 3) |
2268b8e80941Smrg      __gen_uint(values->MICommandOpcode, 23, 28) |
2269b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2270b8e80941Smrg}
2271b8e80941Smrg
2272b8e80941Smrg#define GEN45_MI_LOAD_REGISTER_IMM_length      3
2273b8e80941Smrg#define GEN45_MI_LOAD_REGISTER_IMM_length_bias      2
2274b8e80941Smrg#define GEN45_MI_LOAD_REGISTER_IMM_header       \
2275b8e80941Smrg   .DWordLength                         =      1,  \
2276b8e80941Smrg   .MICommandOpcode                     =     34,  \
2277b8e80941Smrg   .CommandType                         =      0
2278b8e80941Smrg
2279b8e80941Smrgstruct GEN45_MI_LOAD_REGISTER_IMM {
2280b8e80941Smrg   uint32_t                             DWordLength;
2281b8e80941Smrg   uint32_t                             ByteWriteDisables;
2282b8e80941Smrg   uint32_t                             MICommandOpcode;
2283b8e80941Smrg   uint32_t                             CommandType;
2284b8e80941Smrg   uint64_t                             RegisterOffset;
2285b8e80941Smrg   uint32_t                             DataDWord;
2286b8e80941Smrg   /* variable length fields follow */
2287b8e80941Smrg};
2288b8e80941Smrg
2289b8e80941Smrgstatic inline void
2290b8e80941SmrgGEN45_MI_LOAD_REGISTER_IMM_pack(__attribute__((unused)) __gen_user_data *data,
2291b8e80941Smrg                                __attribute__((unused)) void * restrict dst,
2292b8e80941Smrg                                __attribute__((unused)) const struct GEN45_MI_LOAD_REGISTER_IMM * restrict values)
2293b8e80941Smrg{
2294b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2295b8e80941Smrg
2296b8e80941Smrg   dw[0] =
2297b8e80941Smrg      __gen_uint(values->DWordLength, 0, 5) |
2298b8e80941Smrg      __gen_uint(values->ByteWriteDisables, 8, 11) |
2299b8e80941Smrg      __gen_uint(values->MICommandOpcode, 23, 28) |
2300b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2301b8e80941Smrg
2302b8e80941Smrg   dw[1] =
2303b8e80941Smrg      __gen_offset(values->RegisterOffset, 2, 31);
2304b8e80941Smrg
2305b8e80941Smrg   dw[2] =
2306b8e80941Smrg      __gen_uint(values->DataDWord, 0, 31);
2307b8e80941Smrg}
2308b8e80941Smrg
2309b8e80941Smrg#define GEN45_MI_STORE_DATA_IMM_length         5
2310b8e80941Smrg#define GEN45_MI_STORE_DATA_IMM_length_bias      2
2311b8e80941Smrg#define GEN45_MI_STORE_DATA_IMM_header          \
2312b8e80941Smrg   .DWordLength                         =      2,  \
2313b8e80941Smrg   .MICommandOpcode                     =     32,  \
2314b8e80941Smrg   .CommandType                         =      0
2315b8e80941Smrg
2316b8e80941Smrgstruct GEN45_MI_STORE_DATA_IMM {
2317b8e80941Smrg   uint32_t                             DWordLength;
2318b8e80941Smrg   uint32_t                             BitFieldName;
2319b8e80941Smrg   bool                                 MemoryAddressType;
2320b8e80941Smrg   uint32_t                             MICommandOpcode;
2321b8e80941Smrg   uint32_t                             CommandType;
2322b8e80941Smrg   __gen_address_type                   PhysicalStartAddressExtension;
2323b8e80941Smrg   __gen_address_type                   Address;
2324b8e80941Smrg   uint32_t                             DataDWord0;
2325b8e80941Smrg   uint32_t                             DataDWord1;
2326b8e80941Smrg};
2327b8e80941Smrg
2328b8e80941Smrgstatic inline void
2329b8e80941SmrgGEN45_MI_STORE_DATA_IMM_pack(__attribute__((unused)) __gen_user_data *data,
2330b8e80941Smrg                             __attribute__((unused)) void * restrict dst,
2331b8e80941Smrg                             __attribute__((unused)) const struct GEN45_MI_STORE_DATA_IMM * restrict values)
2332b8e80941Smrg{
2333b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2334b8e80941Smrg
2335b8e80941Smrg   dw[0] =
2336b8e80941Smrg      __gen_uint(values->DWordLength, 0, 5) |
2337b8e80941Smrg      __gen_uint(values->BitFieldName, 21, 21) |
2338b8e80941Smrg      __gen_uint(values->MemoryAddressType, 22, 22) |
2339b8e80941Smrg      __gen_uint(values->MICommandOpcode, 23, 28) |
2340b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2341b8e80941Smrg
2342b8e80941Smrg   dw[1] = __gen_combine_address(data, &dw[1], values->PhysicalStartAddressExtension, 0);
2343b8e80941Smrg
2344b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->Address, 0);
2345b8e80941Smrg
2346b8e80941Smrg   dw[3] =
2347b8e80941Smrg      __gen_uint(values->DataDWord0, 0, 31);
2348b8e80941Smrg
2349b8e80941Smrg   dw[4] =
2350b8e80941Smrg      __gen_uint(values->DataDWord1, 0, 31);
2351b8e80941Smrg}
2352b8e80941Smrg
2353b8e80941Smrg#define GEN45_MI_STORE_REGISTER_MEM_length      3
2354b8e80941Smrg#define GEN45_MI_STORE_REGISTER_MEM_length_bias      2
2355b8e80941Smrg#define GEN45_MI_STORE_REGISTER_MEM_header      \
2356b8e80941Smrg   .DWordLength                         =      1,  \
2357b8e80941Smrg   .MICommandOpcode                     =     36,  \
2358b8e80941Smrg   .CommandType                         =      0
2359b8e80941Smrg
2360b8e80941Smrgstruct GEN45_MI_STORE_REGISTER_MEM {
2361b8e80941Smrg   uint32_t                             DWordLength;
2362b8e80941Smrg   bool                                 UseGlobalGTT;
2363b8e80941Smrg   uint32_t                             MICommandOpcode;
2364b8e80941Smrg   uint32_t                             CommandType;
2365b8e80941Smrg   uint64_t                             RegisterAddress;
2366b8e80941Smrg   __gen_address_type                   PhysicalStartAddressExtension;
2367b8e80941Smrg   __gen_address_type                   MemoryAddress;
2368b8e80941Smrg};
2369b8e80941Smrg
2370b8e80941Smrgstatic inline void
2371b8e80941SmrgGEN45_MI_STORE_REGISTER_MEM_pack(__attribute__((unused)) __gen_user_data *data,
2372b8e80941Smrg                                 __attribute__((unused)) void * restrict dst,
2373b8e80941Smrg                                 __attribute__((unused)) const struct GEN45_MI_STORE_REGISTER_MEM * restrict values)
2374b8e80941Smrg{
2375b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2376b8e80941Smrg
2377b8e80941Smrg   dw[0] =
2378b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
2379b8e80941Smrg      __gen_uint(values->UseGlobalGTT, 22, 22) |
2380b8e80941Smrg      __gen_uint(values->MICommandOpcode, 23, 28) |
2381b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2382b8e80941Smrg
2383b8e80941Smrg   const uint32_t v1 =
2384b8e80941Smrg      __gen_offset(values->RegisterAddress, 2, 22);
2385b8e80941Smrg   dw[1] = __gen_combine_address(data, &dw[1], values->PhysicalStartAddressExtension, v1);
2386b8e80941Smrg
2387b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->MemoryAddress, 0);
2388b8e80941Smrg}
2389b8e80941Smrg
2390b8e80941Smrg#define GEN45_PIPELINE_SELECT_length           1
2391b8e80941Smrg#define GEN45_PIPELINE_SELECT_length_bias      1
2392b8e80941Smrg#define GEN45_PIPELINE_SELECT_header            \
2393b8e80941Smrg   ._3DCommandSubOpcode                 =      4,  \
2394b8e80941Smrg   ._3DCommandOpcode                    =      1,  \
2395b8e80941Smrg   .CommandSubType                      =      1,  \
2396b8e80941Smrg   .CommandType                         =      3
2397b8e80941Smrg
2398b8e80941Smrgstruct GEN45_PIPELINE_SELECT {
2399b8e80941Smrg   uint32_t                             PipelineSelection;
2400b8e80941Smrg#define _3D                                      0
2401b8e80941Smrg#define Media                                    1
2402b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
2403b8e80941Smrg   uint32_t                             _3DCommandOpcode;
2404b8e80941Smrg   uint32_t                             CommandSubType;
2405b8e80941Smrg   uint32_t                             CommandType;
2406b8e80941Smrg};
2407b8e80941Smrg
2408b8e80941Smrgstatic inline void
2409b8e80941SmrgGEN45_PIPELINE_SELECT_pack(__attribute__((unused)) __gen_user_data *data,
2410b8e80941Smrg                           __attribute__((unused)) void * restrict dst,
2411b8e80941Smrg                           __attribute__((unused)) const struct GEN45_PIPELINE_SELECT * restrict values)
2412b8e80941Smrg{
2413b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2414b8e80941Smrg
2415b8e80941Smrg   dw[0] =
2416b8e80941Smrg      __gen_uint(values->PipelineSelection, 0, 1) |
2417b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2418b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2419b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
2420b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2421b8e80941Smrg}
2422b8e80941Smrg
2423b8e80941Smrg#define GEN45_PIPE_CONTROL_length              4
2424b8e80941Smrg#define GEN45_PIPE_CONTROL_length_bias         2
2425b8e80941Smrg#define GEN45_PIPE_CONTROL_header               \
2426b8e80941Smrg   .DWordLength                         =      2,  \
2427b8e80941Smrg   ._3DCommandSubOpcode                 =      0,  \
2428b8e80941Smrg   ._3DCommandOpcode                    =      2,  \
2429b8e80941Smrg   .CommandSubType                      =      3,  \
2430b8e80941Smrg   .CommandType                         =      3
2431b8e80941Smrg
2432b8e80941Smrgstruct GEN45_PIPE_CONTROL {
2433b8e80941Smrg   uint32_t                             DWordLength;
2434b8e80941Smrg   bool                                 NotifyEnable;
2435b8e80941Smrg   bool                                 IndirectStatePointersDisable;
2436b8e80941Smrg   bool                                 TextureCacheFlushEnable;
2437b8e80941Smrg   bool                                 InstructionCacheInvalidateEnable;
2438b8e80941Smrg   bool                                 WriteCacheFlush;
2439b8e80941Smrg   bool                                 DepthStallEnable;
2440b8e80941Smrg   uint32_t                             PostSyncOperation;
2441b8e80941Smrg#define NoWrite                                  0
2442b8e80941Smrg#define WriteImmediateData                       1
2443b8e80941Smrg#define WritePSDepthCount                        2
2444b8e80941Smrg#define WriteTimestamp                           3
2445b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
2446b8e80941Smrg   uint32_t                             _3DCommandOpcode;
2447b8e80941Smrg   uint32_t                             CommandSubType;
2448b8e80941Smrg   uint32_t                             CommandType;
2449b8e80941Smrg   uint32_t                             DestinationAddressType;
2450b8e80941Smrg#define DAT_PGTT                                 0
2451b8e80941Smrg#define DAT_GGTT                                 1
2452b8e80941Smrg   __gen_address_type                   Address;
2453b8e80941Smrg   uint64_t                             ImmediateData;
2454b8e80941Smrg};
2455b8e80941Smrg
2456b8e80941Smrgstatic inline void
2457b8e80941SmrgGEN45_PIPE_CONTROL_pack(__attribute__((unused)) __gen_user_data *data,
2458b8e80941Smrg                        __attribute__((unused)) void * restrict dst,
2459b8e80941Smrg                        __attribute__((unused)) const struct GEN45_PIPE_CONTROL * restrict values)
2460b8e80941Smrg{
2461b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2462b8e80941Smrg
2463b8e80941Smrg   dw[0] =
2464b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
2465b8e80941Smrg      __gen_uint(values->NotifyEnable, 8, 8) |
2466b8e80941Smrg      __gen_uint(values->IndirectStatePointersDisable, 9, 9) |
2467b8e80941Smrg      __gen_uint(values->TextureCacheFlushEnable, 10, 10) |
2468b8e80941Smrg      __gen_uint(values->InstructionCacheInvalidateEnable, 11, 11) |
2469b8e80941Smrg      __gen_uint(values->WriteCacheFlush, 12, 12) |
2470b8e80941Smrg      __gen_uint(values->DepthStallEnable, 13, 13) |
2471b8e80941Smrg      __gen_uint(values->PostSyncOperation, 14, 15) |
2472b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2473b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2474b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
2475b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2476b8e80941Smrg
2477b8e80941Smrg   const uint32_t v1 =
2478b8e80941Smrg      __gen_uint(values->DestinationAddressType, 2, 2);
2479b8e80941Smrg   dw[1] = __gen_combine_address(data, &dw[1], values->Address, v1);
2480b8e80941Smrg
2481b8e80941Smrg   const uint64_t v2 =
2482b8e80941Smrg      __gen_uint(values->ImmediateData, 0, 63);
2483b8e80941Smrg   dw[2] = v2;
2484b8e80941Smrg   dw[3] = v2 >> 32;
2485b8e80941Smrg}
2486b8e80941Smrg
2487b8e80941Smrg#define GEN45_STATE_BASE_ADDRESS_length        6
2488b8e80941Smrg#define GEN45_STATE_BASE_ADDRESS_length_bias      2
2489b8e80941Smrg#define GEN45_STATE_BASE_ADDRESS_header         \
2490b8e80941Smrg   .DWordLength                         =      4,  \
2491b8e80941Smrg   ._3DCommandSubOpcode                 =      1,  \
2492b8e80941Smrg   ._3DCommandOpcode                    =      1,  \
2493b8e80941Smrg   .CommandSubType                      =      0,  \
2494b8e80941Smrg   .CommandType                         =      3
2495b8e80941Smrg
2496b8e80941Smrgstruct GEN45_STATE_BASE_ADDRESS {
2497b8e80941Smrg   uint32_t                             DWordLength;
2498b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
2499b8e80941Smrg   uint32_t                             _3DCommandOpcode;
2500b8e80941Smrg   uint32_t                             CommandSubType;
2501b8e80941Smrg   uint32_t                             CommandType;
2502b8e80941Smrg   bool                                 GeneralStateBaseAddressModifyEnable;
2503b8e80941Smrg   __gen_address_type                   GeneralStateBaseAddress;
2504b8e80941Smrg   bool                                 SurfaceStateBaseAddressModifyEnable;
2505b8e80941Smrg   __gen_address_type                   SurfaceStateBaseAddress;
2506b8e80941Smrg   bool                                 IndirectObjectBaseAddressModifyEnable;
2507b8e80941Smrg   __gen_address_type                   IndirectObjectBaseAddress;
2508b8e80941Smrg   bool                                 GeneralStateAccessUpperBoundModifyEnable;
2509b8e80941Smrg   __gen_address_type                   GeneralStateAccessUpperBound;
2510b8e80941Smrg   bool                                 IndirectObjectAccessUpperBoundModifyEnable;
2511b8e80941Smrg   __gen_address_type                   IndirectObjectAccessUpperBound;
2512b8e80941Smrg};
2513b8e80941Smrg
2514b8e80941Smrgstatic inline void
2515b8e80941SmrgGEN45_STATE_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data,
2516b8e80941Smrg                              __attribute__((unused)) void * restrict dst,
2517b8e80941Smrg                              __attribute__((unused)) const struct GEN45_STATE_BASE_ADDRESS * restrict values)
2518b8e80941Smrg{
2519b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2520b8e80941Smrg
2521b8e80941Smrg   dw[0] =
2522b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
2523b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2524b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2525b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
2526b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2527b8e80941Smrg
2528b8e80941Smrg   const uint32_t v1 =
2529b8e80941Smrg      __gen_uint(values->GeneralStateBaseAddressModifyEnable, 0, 0);
2530b8e80941Smrg   dw[1] = __gen_combine_address(data, &dw[1], values->GeneralStateBaseAddress, v1);
2531b8e80941Smrg
2532b8e80941Smrg   const uint32_t v2 =
2533b8e80941Smrg      __gen_uint(values->SurfaceStateBaseAddressModifyEnable, 0, 0);
2534b8e80941Smrg   dw[2] = __gen_combine_address(data, &dw[2], values->SurfaceStateBaseAddress, v2);
2535b8e80941Smrg
2536b8e80941Smrg   const uint32_t v3 =
2537b8e80941Smrg      __gen_uint(values->IndirectObjectBaseAddressModifyEnable, 0, 0);
2538b8e80941Smrg   dw[3] = __gen_combine_address(data, &dw[3], values->IndirectObjectBaseAddress, v3);
2539b8e80941Smrg
2540b8e80941Smrg   const uint32_t v4 =
2541b8e80941Smrg      __gen_uint(values->GeneralStateAccessUpperBoundModifyEnable, 0, 0);
2542b8e80941Smrg   dw[4] = __gen_combine_address(data, &dw[4], values->GeneralStateAccessUpperBound, v4);
2543b8e80941Smrg
2544b8e80941Smrg   const uint32_t v5 =
2545b8e80941Smrg      __gen_uint(values->IndirectObjectAccessUpperBoundModifyEnable, 0, 0);
2546b8e80941Smrg   dw[5] = __gen_combine_address(data, &dw[5], values->IndirectObjectAccessUpperBound, v5);
2547b8e80941Smrg}
2548b8e80941Smrg
2549b8e80941Smrg#define GEN45_STATE_SIP_length                 2
2550b8e80941Smrg#define GEN45_STATE_SIP_length_bias            2
2551b8e80941Smrg#define GEN45_STATE_SIP_header                  \
2552b8e80941Smrg   .DWordLength                         =      0,  \
2553b8e80941Smrg   ._3DCommandSubOpcode                 =      2,  \
2554b8e80941Smrg   ._3DCommandOpcode                    =      1,  \
2555b8e80941Smrg   .CommandSubType                      =      0,  \
2556b8e80941Smrg   .CommandType                         =      3
2557b8e80941Smrg
2558b8e80941Smrgstruct GEN45_STATE_SIP {
2559b8e80941Smrg   uint32_t                             DWordLength;
2560b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
2561b8e80941Smrg   uint32_t                             _3DCommandOpcode;
2562b8e80941Smrg   uint32_t                             CommandSubType;
2563b8e80941Smrg   uint32_t                             CommandType;
2564b8e80941Smrg   uint64_t                             SystemInstructionPointer;
2565b8e80941Smrg};
2566b8e80941Smrg
2567b8e80941Smrgstatic inline void
2568b8e80941SmrgGEN45_STATE_SIP_pack(__attribute__((unused)) __gen_user_data *data,
2569b8e80941Smrg                     __attribute__((unused)) void * restrict dst,
2570b8e80941Smrg                     __attribute__((unused)) const struct GEN45_STATE_SIP * restrict values)
2571b8e80941Smrg{
2572b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2573b8e80941Smrg
2574b8e80941Smrg   dw[0] =
2575b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
2576b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2577b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2578b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
2579b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2580b8e80941Smrg
2581b8e80941Smrg   dw[1] =
2582b8e80941Smrg      __gen_offset(values->SystemInstructionPointer, 4, 31);
2583b8e80941Smrg}
2584b8e80941Smrg
2585b8e80941Smrg#define GEN45_URB_FENCE_length                 3
2586b8e80941Smrg#define GEN45_URB_FENCE_length_bias            2
2587b8e80941Smrg#define GEN45_URB_FENCE_header                  \
2588b8e80941Smrg   .DWordLength                         =      1,  \
2589b8e80941Smrg   ._3DCommandSubOpcode                 =      0,  \
2590b8e80941Smrg   ._3DCommandOpcode                    =      0,  \
2591b8e80941Smrg   .CommandSubType                      =      0,  \
2592b8e80941Smrg   .CommandType                         =      3
2593b8e80941Smrg
2594b8e80941Smrgstruct GEN45_URB_FENCE {
2595b8e80941Smrg   uint32_t                             DWordLength;
2596b8e80941Smrg   bool                                 VSUnitURBReallocationRequest;
2597b8e80941Smrg   bool                                 GSUnitURBReallocationRequest;
2598b8e80941Smrg   bool                                 CLIPUnitURBReallocationRequest;
2599b8e80941Smrg   bool                                 SFUnitURBReallocationRequest;
2600b8e80941Smrg   bool                                 VFEUnitURBReallocationRequest;
2601b8e80941Smrg   bool                                 CSUnitURBReallocationRequest;
2602b8e80941Smrg   uint32_t                             _3DCommandSubOpcode;
2603b8e80941Smrg   uint32_t                             _3DCommandOpcode;
2604b8e80941Smrg   uint32_t                             CommandSubType;
2605b8e80941Smrg   uint32_t                             CommandType;
2606b8e80941Smrg   uint32_t                             VSFence;
2607b8e80941Smrg   uint32_t                             GSFence;
2608b8e80941Smrg   uint32_t                             CLIPFence;
2609b8e80941Smrg   uint32_t                             SFFence;
2610b8e80941Smrg   uint32_t                             VFEFence;
2611b8e80941Smrg   uint32_t                             CSFence;
2612b8e80941Smrg};
2613b8e80941Smrg
2614b8e80941Smrgstatic inline void
2615b8e80941SmrgGEN45_URB_FENCE_pack(__attribute__((unused)) __gen_user_data *data,
2616b8e80941Smrg                     __attribute__((unused)) void * restrict dst,
2617b8e80941Smrg                     __attribute__((unused)) const struct GEN45_URB_FENCE * restrict values)
2618b8e80941Smrg{
2619b8e80941Smrg   uint32_t * restrict dw = (uint32_t * restrict) dst;
2620b8e80941Smrg
2621b8e80941Smrg   dw[0] =
2622b8e80941Smrg      __gen_uint(values->DWordLength, 0, 7) |
2623b8e80941Smrg      __gen_uint(values->VSUnitURBReallocationRequest, 8, 8) |
2624b8e80941Smrg      __gen_uint(values->GSUnitURBReallocationRequest, 9, 9) |
2625b8e80941Smrg      __gen_uint(values->CLIPUnitURBReallocationRequest, 10, 10) |
2626b8e80941Smrg      __gen_uint(values->SFUnitURBReallocationRequest, 11, 11) |
2627b8e80941Smrg      __gen_uint(values->VFEUnitURBReallocationRequest, 12, 12) |
2628b8e80941Smrg      __gen_uint(values->CSUnitURBReallocationRequest, 13, 13) |
2629b8e80941Smrg      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
2630b8e80941Smrg      __gen_uint(values->_3DCommandOpcode, 24, 26) |
2631b8e80941Smrg      __gen_uint(values->CommandSubType, 27, 28) |
2632b8e80941Smrg      __gen_uint(values->CommandType, 29, 31);
2633b8e80941Smrg
2634b8e80941Smrg   dw[1] =
2635b8e80941Smrg      __gen_uint(values->VSFence, 0, 9) |
2636b8e80941Smrg      __gen_uint(values->GSFence, 10, 19) |
2637b8e80941Smrg      __gen_uint(values->CLIPFence, 20, 29);
2638b8e80941Smrg
2639b8e80941Smrg   dw[2] =
2640b8e80941Smrg      __gen_uint(values->SFFence, 0, 9) |
2641b8e80941Smrg      __gen_uint(values->VFEFence, 10, 19) |
2642b8e80941Smrg      __gen_uint(values->CSFence, 20, 30);
2643b8e80941Smrg}
2644b8e80941Smrg
2645b8e80941Smrg#endif /* GEN45_PACK_H */
2646