gen5_pack.h revision 10e230b6
110e230b6Smaya/*
210e230b6Smaya * Copyright (C) 2016 Intel Corporation
310e230b6Smaya *
410e230b6Smaya * Permission is hereby granted, free of charge, to any person obtaining a
510e230b6Smaya * copy of this software and associated documentation files (the "Software"),
610e230b6Smaya * to deal in the Software without restriction, including without limitation
710e230b6Smaya * the rights to use, copy, modify, merge, publish, distribute, sublicense,
810e230b6Smaya * and/or sell copies of the Software, and to permit persons to whom the
910e230b6Smaya * Software is furnished to do so, subject to the following conditions:
1010e230b6Smaya *
1110e230b6Smaya * The above copyright notice and this permission notice (including the next
1210e230b6Smaya * paragraph) shall be included in all copies or substantial portions of the
1310e230b6Smaya * Software.
1410e230b6Smaya *
1510e230b6Smaya * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1610e230b6Smaya * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1710e230b6Smaya * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1810e230b6Smaya * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1910e230b6Smaya * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2010e230b6Smaya * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2110e230b6Smaya * IN THE SOFTWARE.
2210e230b6Smaya */
2310e230b6Smaya
2410e230b6Smaya
2510e230b6Smaya/* Instructions, enums and structures for ILK.
2610e230b6Smaya *
2710e230b6Smaya * This file has been generated, do not hand edit.
2810e230b6Smaya */
2910e230b6Smaya
3010e230b6Smaya#ifndef GEN5_PACK_H
3110e230b6Smaya#define GEN5_PACK_H
3210e230b6Smaya
3310e230b6Smaya#include <stdio.h>
3410e230b6Smaya#include <stdint.h>
3510e230b6Smaya#include <stdbool.h>
3610e230b6Smaya#include <assert.h>
3710e230b6Smaya#include <math.h>
3810e230b6Smaya
3910e230b6Smaya#ifndef __gen_validate_value
4010e230b6Smaya#define __gen_validate_value(x)
4110e230b6Smaya#endif
4210e230b6Smaya
4310e230b6Smaya#ifndef __gen_field_functions
4410e230b6Smaya#define __gen_field_functions
4510e230b6Smaya
4610e230b6Smaya#ifdef NDEBUG
4710e230b6Smaya#define NDEBUG_UNUSED __attribute__((unused))
4810e230b6Smaya#else
4910e230b6Smaya#define NDEBUG_UNUSED
5010e230b6Smaya#endif
5110e230b6Smaya
5210e230b6Smayaunion __gen_value {
5310e230b6Smaya   float f;
5410e230b6Smaya   uint32_t dw;
5510e230b6Smaya};
5610e230b6Smaya
5710e230b6Smayastatic inline uint64_t
5810e230b6Smaya__gen_mbo(uint32_t start, uint32_t end)
5910e230b6Smaya{
6010e230b6Smaya   return (~0ull >> (64 - (end - start + 1))) << start;
6110e230b6Smaya}
6210e230b6Smaya
6310e230b6Smayastatic inline uint64_t
6410e230b6Smaya__gen_uint(uint64_t v, uint32_t start, NDEBUG_UNUSED uint32_t end)
6510e230b6Smaya{
6610e230b6Smaya   __gen_validate_value(v);
6710e230b6Smaya
6810e230b6Smaya#ifndef NDEBUG
6910e230b6Smaya   const int width = end - start + 1;
7010e230b6Smaya   if (width < 64) {
7110e230b6Smaya      const uint64_t max = (1ull << width) - 1;
7210e230b6Smaya      assert(v <= max);
7310e230b6Smaya   }
7410e230b6Smaya#endif
7510e230b6Smaya
7610e230b6Smaya   return v << start;
7710e230b6Smaya}
7810e230b6Smaya
7910e230b6Smayastatic inline uint64_t
8010e230b6Smaya__gen_sint(int64_t v, uint32_t start, uint32_t end)
8110e230b6Smaya{
8210e230b6Smaya   const int width = end - start + 1;
8310e230b6Smaya
8410e230b6Smaya   __gen_validate_value(v);
8510e230b6Smaya
8610e230b6Smaya#ifndef NDEBUG
8710e230b6Smaya   if (width < 64) {
8810e230b6Smaya      const int64_t max = (1ll << (width - 1)) - 1;
8910e230b6Smaya      const int64_t min = -(1ll << (width - 1));
9010e230b6Smaya      assert(min <= v && v <= max);
9110e230b6Smaya   }
9210e230b6Smaya#endif
9310e230b6Smaya
9410e230b6Smaya   const uint64_t mask = ~0ull >> (64 - width);
9510e230b6Smaya
9610e230b6Smaya   return (v & mask) << start;
9710e230b6Smaya}
9810e230b6Smaya
9910e230b6Smayastatic inline uint64_t
10010e230b6Smaya__gen_offset(uint64_t v, NDEBUG_UNUSED uint32_t start, NDEBUG_UNUSED uint32_t end)
10110e230b6Smaya{
10210e230b6Smaya   __gen_validate_value(v);
10310e230b6Smaya#ifndef NDEBUG
10410e230b6Smaya   uint64_t mask = (~0ull >> (64 - (end - start + 1))) << start;
10510e230b6Smaya
10610e230b6Smaya   assert((v & ~mask) == 0);
10710e230b6Smaya#endif
10810e230b6Smaya
10910e230b6Smaya   return v;
11010e230b6Smaya}
11110e230b6Smaya
11210e230b6Smayastatic inline uint32_t
11310e230b6Smaya__gen_float(float v)
11410e230b6Smaya{
11510e230b6Smaya   __gen_validate_value(v);
11610e230b6Smaya   return ((union __gen_value) { .f = (v) }).dw;
11710e230b6Smaya}
11810e230b6Smaya
11910e230b6Smayastatic inline uint64_t
12010e230b6Smaya__gen_sfixed(float v, uint32_t start, uint32_t end, uint32_t fract_bits)
12110e230b6Smaya{
12210e230b6Smaya   __gen_validate_value(v);
12310e230b6Smaya
12410e230b6Smaya   const float factor = (1 << fract_bits);
12510e230b6Smaya
12610e230b6Smaya#ifndef NDEBUG
12710e230b6Smaya   const float max = ((1 << (end - start)) - 1) / factor;
12810e230b6Smaya   const float min = -(1 << (end - start)) / factor;
12910e230b6Smaya   assert(min <= v && v <= max);
13010e230b6Smaya#endif
13110e230b6Smaya
13210e230b6Smaya   const int64_t int_val = llroundf(v * factor);
13310e230b6Smaya   const uint64_t mask = ~0ull >> (64 - (end - start + 1));
13410e230b6Smaya
13510e230b6Smaya   return (int_val & mask) << start;
13610e230b6Smaya}
13710e230b6Smaya
13810e230b6Smayastatic inline uint64_t
13910e230b6Smaya__gen_ufixed(float v, uint32_t start, NDEBUG_UNUSED uint32_t end, uint32_t fract_bits)
14010e230b6Smaya{
14110e230b6Smaya   __gen_validate_value(v);
14210e230b6Smaya
14310e230b6Smaya   const float factor = (1 << fract_bits);
14410e230b6Smaya
14510e230b6Smaya#ifndef NDEBUG
14610e230b6Smaya   const float max = ((1 << (end - start + 1)) - 1) / factor;
14710e230b6Smaya   const float min = 0.0f;
14810e230b6Smaya   assert(min <= v && v <= max);
14910e230b6Smaya#endif
15010e230b6Smaya
15110e230b6Smaya   const uint64_t uint_val = llroundf(v * factor);
15210e230b6Smaya
15310e230b6Smaya   return uint_val << start;
15410e230b6Smaya}
15510e230b6Smaya
15610e230b6Smaya#ifndef __gen_address_type
15710e230b6Smaya#error #define __gen_address_type before including this file
15810e230b6Smaya#endif
15910e230b6Smaya
16010e230b6Smaya#ifndef __gen_user_data
16110e230b6Smaya#error #define __gen_combine_address before including this file
16210e230b6Smaya#endif
16310e230b6Smaya
16410e230b6Smaya#undef NDEBUG_UNUSED
16510e230b6Smaya
16610e230b6Smaya#endif
16710e230b6Smaya
16810e230b6Smaya
16910e230b6Smayaenum GEN5_3D_Color_Buffer_Blend_Factor {
17010e230b6Smaya   BLENDFACTOR_ONE                      =      1,
17110e230b6Smaya   BLENDFACTOR_SRC_COLOR                =      2,
17210e230b6Smaya   BLENDFACTOR_SRC_ALPHA                =      3,
17310e230b6Smaya   BLENDFACTOR_DST_ALPHA                =      4,
17410e230b6Smaya   BLENDFACTOR_DST_COLOR                =      5,
17510e230b6Smaya   BLENDFACTOR_SRC_ALPHA_SATURATE       =      6,
17610e230b6Smaya   BLENDFACTOR_CONST_COLOR              =      7,
17710e230b6Smaya   BLENDFACTOR_CONST_ALPHA              =      8,
17810e230b6Smaya   BLENDFACTOR_SRC1_COLOR               =      9,
17910e230b6Smaya   BLENDFACTOR_SRC1_ALPHA               =     10,
18010e230b6Smaya   BLENDFACTOR_ZERO                     =     17,
18110e230b6Smaya   BLENDFACTOR_INV_SRC_COLOR            =     18,
18210e230b6Smaya   BLENDFACTOR_INV_SRC_ALPHA            =     19,
18310e230b6Smaya   BLENDFACTOR_INV_DST_ALPHA            =     20,
18410e230b6Smaya   BLENDFACTOR_INV_DST_COLOR            =     21,
18510e230b6Smaya   BLENDFACTOR_INV_CONST_COLOR          =     23,
18610e230b6Smaya   BLENDFACTOR_INV_CONST_ALPHA          =     24,
18710e230b6Smaya   BLENDFACTOR_INV_SRC1_COLOR           =     25,
18810e230b6Smaya   BLENDFACTOR_INV_SRC1_ALPHA           =     26,
18910e230b6Smaya};
19010e230b6Smaya
19110e230b6Smayaenum GEN5_3D_Color_Buffer_Blend_Function {
19210e230b6Smaya   BLENDFUNCTION_ADD                    =      0,
19310e230b6Smaya   BLENDFUNCTION_SUBTRACT               =      1,
19410e230b6Smaya   BLENDFUNCTION_REVERSE_SUBTRACT       =      2,
19510e230b6Smaya   BLENDFUNCTION_MIN                    =      3,
19610e230b6Smaya   BLENDFUNCTION_MAX                    =      4,
19710e230b6Smaya};
19810e230b6Smaya
19910e230b6Smayaenum GEN5_3D_Compare_Function {
20010e230b6Smaya   COMPAREFUNCTION_ALWAYS               =      0,
20110e230b6Smaya   COMPAREFUNCTION_NEVER                =      1,
20210e230b6Smaya   COMPAREFUNCTION_LESS                 =      2,
20310e230b6Smaya   COMPAREFUNCTION_EQUAL                =      3,
20410e230b6Smaya   COMPAREFUNCTION_LEQUAL               =      4,
20510e230b6Smaya   COMPAREFUNCTION_GREATER              =      5,
20610e230b6Smaya   COMPAREFUNCTION_NOTEQUAL             =      6,
20710e230b6Smaya   COMPAREFUNCTION_GEQUAL               =      7,
20810e230b6Smaya};
20910e230b6Smaya
21010e230b6Smayaenum GEN5_3D_Logic_Op_Function {
21110e230b6Smaya   LOGICOP_CLEAR                        =      0,
21210e230b6Smaya   LOGICOP_NOR                          =      1,
21310e230b6Smaya   LOGICOP_AND_INVERTED                 =      2,
21410e230b6Smaya   LOGICOP_COPY_INVERTED                =      3,
21510e230b6Smaya   LOGICOP_AND_REVERSE                  =      4,
21610e230b6Smaya   LOGICOP_INVERT                       =      5,
21710e230b6Smaya   LOGICOP_XOR                          =      6,
21810e230b6Smaya   LOGICOP_NAND                         =      7,
21910e230b6Smaya   LOGICOP_AND                          =      8,
22010e230b6Smaya   LOGICOP_EQUIV                        =      9,
22110e230b6Smaya   LOGICOP_NOOP                         =     10,
22210e230b6Smaya   LOGICOP_OR_INVERTED                  =     11,
22310e230b6Smaya   LOGICOP_COPY                         =     12,
22410e230b6Smaya   LOGICOP_OR_REVERSE                   =     13,
22510e230b6Smaya   LOGICOP_OR                           =     14,
22610e230b6Smaya   LOGICOP_SET                          =     15,
22710e230b6Smaya};
22810e230b6Smaya
22910e230b6Smayaenum GEN5_3D_Prim_Topo_Type {
23010e230b6Smaya   _3DPRIM_POINTLIST                    =      1,
23110e230b6Smaya   _3DPRIM_LINELIST                     =      2,
23210e230b6Smaya   _3DPRIM_LINESTRIP                    =      3,
23310e230b6Smaya   _3DPRIM_TRILIST                      =      4,
23410e230b6Smaya   _3DPRIM_TRISTRIP                     =      5,
23510e230b6Smaya   _3DPRIM_TRIFAN                       =      6,
23610e230b6Smaya   _3DPRIM_QUADLIST                     =      7,
23710e230b6Smaya   _3DPRIM_QUADSTRIP                    =      8,
23810e230b6Smaya   _3DPRIM_LINELIST_ADJ                 =      9,
23910e230b6Smaya   _3DPRIM_LINESTRIP_ADJ                =     10,
24010e230b6Smaya   _3DPRIM_TRILIST_ADJ                  =     11,
24110e230b6Smaya   _3DPRIM_TRISTRIP_ADJ                 =     12,
24210e230b6Smaya   _3DPRIM_TRISTRIP_REVERSE             =     13,
24310e230b6Smaya   _3DPRIM_POLYGON                      =     14,
24410e230b6Smaya   _3DPRIM_RECTLIST                     =     15,
24510e230b6Smaya   _3DPRIM_LINELOOP                     =     16,
24610e230b6Smaya   _3DPRIM_POINTLIST_BF                 =     17,
24710e230b6Smaya   _3DPRIM_LINESTRIP_CONT               =     18,
24810e230b6Smaya   _3DPRIM_LINESTRIP_BF                 =     19,
24910e230b6Smaya   _3DPRIM_LINESTRIP_CONT_BF            =     20,
25010e230b6Smaya   _3DPRIM_TRIFAN_NOSTIPPLE             =     22,
25110e230b6Smaya};
25210e230b6Smaya
25310e230b6Smayaenum GEN5_3D_Stencil_Operation {
25410e230b6Smaya   STENCILOP_KEEP                       =      0,
25510e230b6Smaya   STENCILOP_ZERO                       =      1,
25610e230b6Smaya   STENCILOP_REPLACE                    =      2,
25710e230b6Smaya   STENCILOP_INCRSAT                    =      3,
25810e230b6Smaya   STENCILOP_DECRSAT                    =      4,
25910e230b6Smaya   STENCILOP_INCR                       =      5,
26010e230b6Smaya   STENCILOP_DECR                       =      6,
26110e230b6Smaya   STENCILOP_INVERT                     =      7,
26210e230b6Smaya};
26310e230b6Smaya
26410e230b6Smayaenum GEN5_3D_Vertex_Component_Control {
26510e230b6Smaya   VFCOMP_NOSTORE                       =      0,
26610e230b6Smaya   VFCOMP_STORE_SRC                     =      1,
26710e230b6Smaya   VFCOMP_STORE_0                       =      2,
26810e230b6Smaya   VFCOMP_STORE_1_FP                    =      3,
26910e230b6Smaya   VFCOMP_STORE_1_INT                   =      4,
27010e230b6Smaya   VFCOMP_STORE_VID                     =      5,
27110e230b6Smaya   VFCOMP_STORE_IID                     =      6,
27210e230b6Smaya   VFCOMP_STORE_PID                     =      7,
27310e230b6Smaya};
27410e230b6Smaya
27510e230b6Smayaenum GEN5_Texture_Coordinate_Mode {
27610e230b6Smaya   TCM_WRAP                             =      0,
27710e230b6Smaya   TCM_MIRROR                           =      1,
27810e230b6Smaya   TCM_CLAMP                            =      2,
27910e230b6Smaya   TCM_CUBE                             =      3,
28010e230b6Smaya   TCM_CLAMP_BORDER                     =      4,
28110e230b6Smaya   TCM_MIRROR_ONCE                      =      5,
28210e230b6Smaya};
28310e230b6Smaya
28410e230b6Smaya#define GEN5_CC_VIEWPORT_length                2
28510e230b6Smayastruct GEN5_CC_VIEWPORT {
28610e230b6Smaya   float                                MinimumDepth;
28710e230b6Smaya   float                                MaximumDepth;
28810e230b6Smaya};
28910e230b6Smaya
29010e230b6Smayastatic inline void
29110e230b6SmayaGEN5_CC_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
29210e230b6Smaya                      __attribute__((unused)) void * restrict dst,
29310e230b6Smaya                      __attribute__((unused)) const struct GEN5_CC_VIEWPORT * restrict values)
29410e230b6Smaya{
29510e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
29610e230b6Smaya
29710e230b6Smaya   dw[0] =
29810e230b6Smaya      __gen_float(values->MinimumDepth);
29910e230b6Smaya
30010e230b6Smaya   dw[1] =
30110e230b6Smaya      __gen_float(values->MaximumDepth);
30210e230b6Smaya}
30310e230b6Smaya
30410e230b6Smaya#define GEN5_CLIP_STATE_length                11
30510e230b6Smayastruct GEN5_CLIP_STATE {
30610e230b6Smaya   uint32_t                             GRFRegisterCount;
30710e230b6Smaya   uint64_t                             KernelStartPointer;
30810e230b6Smaya   bool                                 SoftwareExceptionEnable;
30910e230b6Smaya   bool                                 MaskStackExceptionEnable;
31010e230b6Smaya   bool                                 IllegalOpcodeExceptionEnable;
31110e230b6Smaya   uint32_t                             FloatingPointMode;
31210e230b6Smaya#define FLOATING_POINT_MODE_IEEE754              0
31310e230b6Smaya#define FLOATING_POINT_MODE_Alternate            1
31410e230b6Smaya   uint32_t                             ThreadPriority;
31510e230b6Smaya#define NormalPriority                           0
31610e230b6Smaya#define HighPriority                             1
31710e230b6Smaya   uint32_t                             BindingTableEntryCount;
31810e230b6Smaya   bool                                 SingleProgramFlow;
31910e230b6Smaya   uint32_t                             PerThreadScratchSpace;
32010e230b6Smaya   __gen_address_type                   ScratchSpaceBasePointer;
32110e230b6Smaya   uint32_t                             DispatchGRFStartRegisterForURBData;
32210e230b6Smaya   uint32_t                             VertexURBEntryReadOffset;
32310e230b6Smaya   uint32_t                             VertexURBEntryReadLength;
32410e230b6Smaya   uint32_t                             ConstantURBEntryReadOffset;
32510e230b6Smaya   uint32_t                             ConstantURBEntryReadLength;
32610e230b6Smaya   uint32_t                             NumberofURBEntries;
32710e230b6Smaya   uint32_t                             URBEntryAllocationSize;
32810e230b6Smaya   uint32_t                             MaximumNumberofThreads;
32910e230b6Smaya   uint32_t                             ClipMode;
33010e230b6Smaya#define CLIPMODE_NORMAL                          0
33110e230b6Smaya#define CLIPMODE_ALL                             1
33210e230b6Smaya#define CLIPMODE_CLIP_NON_REJECTED               2
33310e230b6Smaya#define CLIPMODE_REJECT_ALL                      3
33410e230b6Smaya#define CLIPMODE_ACCEPT_ALL                      4
33510e230b6Smaya   uint32_t                             UserClipDistanceClipTestEnableBitmask;
33610e230b6Smaya   bool                                 UserClipFlagsMustClipEnable;
33710e230b6Smaya   bool                                 NegativeWClipTestEnable;
33810e230b6Smaya   bool                                 GuardbandClipTestEnable;
33910e230b6Smaya   bool                                 ViewportZClipTestEnable;
34010e230b6Smaya   bool                                 ViewportXYClipTestEnable;
34110e230b6Smaya   uint32_t                             VertexPositionSpace;
34210e230b6Smaya#define VPOS_NDCSPACE                            0
34310e230b6Smaya#define VPOS_SCREENSPACE                         1
34410e230b6Smaya   uint32_t                             APIMode;
34510e230b6Smaya#define APIMODE_OGL                              0
34610e230b6Smaya#define APIMODE_D3D                              1
34710e230b6Smaya   __gen_address_type                   ClipperViewportStatePointer;
34810e230b6Smaya   float                                ScreenSpaceViewportXMin;
34910e230b6Smaya   float                                ScreenSpaceViewportXMax;
35010e230b6Smaya   float                                ScreenSpaceViewportYMin;
35110e230b6Smaya   float                                ScreenSpaceViewportYMax;
35210e230b6Smaya};
35310e230b6Smaya
35410e230b6Smayastatic inline void
35510e230b6SmayaGEN5_CLIP_STATE_pack(__attribute__((unused)) __gen_user_data *data,
35610e230b6Smaya                     __attribute__((unused)) void * restrict dst,
35710e230b6Smaya                     __attribute__((unused)) const struct GEN5_CLIP_STATE * restrict values)
35810e230b6Smaya{
35910e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
36010e230b6Smaya
36110e230b6Smaya   dw[0] =
36210e230b6Smaya      __gen_uint(values->GRFRegisterCount, 1, 3) |
36310e230b6Smaya      __gen_offset(values->KernelStartPointer, 6, 31);
36410e230b6Smaya
36510e230b6Smaya   dw[1] =
36610e230b6Smaya      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
36710e230b6Smaya      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
36810e230b6Smaya      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
36910e230b6Smaya      __gen_uint(values->FloatingPointMode, 16, 16) |
37010e230b6Smaya      __gen_uint(values->ThreadPriority, 17, 17) |
37110e230b6Smaya      __gen_uint(values->BindingTableEntryCount, 18, 25) |
37210e230b6Smaya      __gen_uint(values->SingleProgramFlow, 31, 31);
37310e230b6Smaya
37410e230b6Smaya   const uint32_t v2 =
37510e230b6Smaya      __gen_uint(values->PerThreadScratchSpace, 0, 3);
37610e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
37710e230b6Smaya
37810e230b6Smaya   dw[3] =
37910e230b6Smaya      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
38010e230b6Smaya      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
38110e230b6Smaya      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
38210e230b6Smaya      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
38310e230b6Smaya      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
38410e230b6Smaya
38510e230b6Smaya   dw[4] =
38610e230b6Smaya      __gen_uint(values->NumberofURBEntries, 11, 18) |
38710e230b6Smaya      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
38810e230b6Smaya      __gen_uint(values->MaximumNumberofThreads, 25, 30);
38910e230b6Smaya
39010e230b6Smaya   dw[5] =
39110e230b6Smaya      __gen_uint(values->ClipMode, 13, 15) |
39210e230b6Smaya      __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 16, 23) |
39310e230b6Smaya      __gen_uint(values->UserClipFlagsMustClipEnable, 24, 24) |
39410e230b6Smaya      __gen_uint(values->NegativeWClipTestEnable, 25, 25) |
39510e230b6Smaya      __gen_uint(values->GuardbandClipTestEnable, 26, 26) |
39610e230b6Smaya      __gen_uint(values->ViewportZClipTestEnable, 27, 27) |
39710e230b6Smaya      __gen_uint(values->ViewportXYClipTestEnable, 28, 28) |
39810e230b6Smaya      __gen_uint(values->VertexPositionSpace, 29, 29) |
39910e230b6Smaya      __gen_uint(values->APIMode, 30, 30);
40010e230b6Smaya
40110e230b6Smaya   dw[6] = __gen_combine_address(data, &dw[6], values->ClipperViewportStatePointer, 0);
40210e230b6Smaya
40310e230b6Smaya   dw[7] =
40410e230b6Smaya      __gen_float(values->ScreenSpaceViewportXMin);
40510e230b6Smaya
40610e230b6Smaya   dw[8] =
40710e230b6Smaya      __gen_float(values->ScreenSpaceViewportXMax);
40810e230b6Smaya
40910e230b6Smaya   dw[9] =
41010e230b6Smaya      __gen_float(values->ScreenSpaceViewportYMin);
41110e230b6Smaya
41210e230b6Smaya   dw[10] =
41310e230b6Smaya      __gen_float(values->ScreenSpaceViewportYMax);
41410e230b6Smaya}
41510e230b6Smaya
41610e230b6Smaya#define GEN5_CLIP_VIEWPORT_length              4
41710e230b6Smayastruct GEN5_CLIP_VIEWPORT {
41810e230b6Smaya   float                                XMinClipGuardband;
41910e230b6Smaya   float                                XMaxClipGuardband;
42010e230b6Smaya   float                                YMinClipGuardband;
42110e230b6Smaya   float                                YMaxClipGuardband;
42210e230b6Smaya};
42310e230b6Smaya
42410e230b6Smayastatic inline void
42510e230b6SmayaGEN5_CLIP_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
42610e230b6Smaya                        __attribute__((unused)) void * restrict dst,
42710e230b6Smaya                        __attribute__((unused)) const struct GEN5_CLIP_VIEWPORT * restrict values)
42810e230b6Smaya{
42910e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
43010e230b6Smaya
43110e230b6Smaya   dw[0] =
43210e230b6Smaya      __gen_float(values->XMinClipGuardband);
43310e230b6Smaya
43410e230b6Smaya   dw[1] =
43510e230b6Smaya      __gen_float(values->XMaxClipGuardband);
43610e230b6Smaya
43710e230b6Smaya   dw[2] =
43810e230b6Smaya      __gen_float(values->YMinClipGuardband);
43910e230b6Smaya
44010e230b6Smaya   dw[3] =
44110e230b6Smaya      __gen_float(values->YMaxClipGuardband);
44210e230b6Smaya}
44310e230b6Smaya
44410e230b6Smaya#define GEN5_COLOR_CALC_STATE_length           8
44510e230b6Smayastruct GEN5_COLOR_CALC_STATE {
44610e230b6Smaya   enum GEN5_3D_Stencil_Operation       BackfaceStencilPassDepthPassOp;
44710e230b6Smaya   enum GEN5_3D_Stencil_Operation       BackfaceStencilPassDepthFailOp;
44810e230b6Smaya   enum GEN5_3D_Stencil_Operation       BackfaceStencilFailOp;
44910e230b6Smaya   enum GEN5_3D_Compare_Function        BackfaceStencilTestFunction;
45010e230b6Smaya   bool                                 DoubleSidedStencilEnable;
45110e230b6Smaya   bool                                 StencilBufferWriteEnable;
45210e230b6Smaya   enum GEN5_3D_Stencil_Operation       StencilPassDepthPassOp;
45310e230b6Smaya   enum GEN5_3D_Stencil_Operation       StencilPassDepthFailOp;
45410e230b6Smaya   enum GEN5_3D_Stencil_Operation       StencilFailOp;
45510e230b6Smaya   enum GEN5_3D_Compare_Function        StencilTestFunction;
45610e230b6Smaya   bool                                 StencilTestEnable;
45710e230b6Smaya   uint32_t                             BackfaceStencilReferenceValue;
45810e230b6Smaya   uint32_t                             StencilWriteMask;
45910e230b6Smaya   uint32_t                             StencilTestMask;
46010e230b6Smaya   uint32_t                             StencilReferenceValue;
46110e230b6Smaya   bool                                 LogicOpEnable;
46210e230b6Smaya   bool                                 DepthBufferWriteEnable;
46310e230b6Smaya   enum GEN5_3D_Compare_Function        DepthTestFunction;
46410e230b6Smaya   bool                                 DepthTestEnable;
46510e230b6Smaya   uint32_t                             BackfaceStencilWriteMask;
46610e230b6Smaya   uint32_t                             BackfaceStencilTestMask;
46710e230b6Smaya   enum GEN5_3D_Compare_Function        AlphaTestFunction;
46810e230b6Smaya   bool                                 AlphaTestEnable;
46910e230b6Smaya   bool                                 ColorBufferBlendEnable;
47010e230b6Smaya   bool                                 IndependentAlphaBlendEnable;
47110e230b6Smaya   uint32_t                             AlphaTestFormat;
47210e230b6Smaya#define ALPHATEST_UNORM8                         0
47310e230b6Smaya#define ALPHATEST_FLOAT32                        1
47410e230b6Smaya   __gen_address_type                   CCViewportStatePointer;
47510e230b6Smaya   enum GEN5_3D_Color_Buffer_Blend_Factor DestinationAlphaBlendFactor;
47610e230b6Smaya   enum GEN5_3D_Color_Buffer_Blend_Factor SourceAlphaBlendFactor;
47710e230b6Smaya   enum GEN5_3D_Color_Buffer_Blend_Function AlphaBlendFunction;
47810e230b6Smaya   bool                                 StatisticsEnable;
47910e230b6Smaya   enum GEN5_3D_Logic_Op_Function       LogicOpFunction;
48010e230b6Smaya   bool                                 RoundDisableFunctionDisable;
48110e230b6Smaya   bool                                 ColorDitherEnable;
48210e230b6Smaya   bool                                 PostBlendColorClampEnable;
48310e230b6Smaya   bool                                 PreBlendColorClampEnable;
48410e230b6Smaya   uint32_t                             ColorClampRange;
48510e230b6Smaya#define COLORCLAMP_UNORM                         0
48610e230b6Smaya#define COLORCLAMP_SNORM                         1
48710e230b6Smaya#define COLORCLAMP_RTFORMAT                      2
48810e230b6Smaya   uint32_t                             YDitherOffset;
48910e230b6Smaya   uint32_t                             XDitherOffset;
49010e230b6Smaya   enum GEN5_3D_Color_Buffer_Blend_Factor DestinationBlendFactor;
49110e230b6Smaya   enum GEN5_3D_Color_Buffer_Blend_Factor SourceBlendFactor;
49210e230b6Smaya   enum GEN5_3D_Color_Buffer_Blend_Function ColorBlendFunction;
49310e230b6Smaya   uint32_t                             AlphaReferenceValueAsUNORM8;
49410e230b6Smaya   float                                AlphaReferenceValueAsFLOAT32;
49510e230b6Smaya};
49610e230b6Smaya
49710e230b6Smayastatic inline void
49810e230b6SmayaGEN5_COLOR_CALC_STATE_pack(__attribute__((unused)) __gen_user_data *data,
49910e230b6Smaya                           __attribute__((unused)) void * restrict dst,
50010e230b6Smaya                           __attribute__((unused)) const struct GEN5_COLOR_CALC_STATE * restrict values)
50110e230b6Smaya{
50210e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
50310e230b6Smaya
50410e230b6Smaya   dw[0] =
50510e230b6Smaya      __gen_uint(values->BackfaceStencilPassDepthPassOp, 3, 5) |
50610e230b6Smaya      __gen_uint(values->BackfaceStencilPassDepthFailOp, 6, 8) |
50710e230b6Smaya      __gen_uint(values->BackfaceStencilFailOp, 9, 11) |
50810e230b6Smaya      __gen_uint(values->BackfaceStencilTestFunction, 12, 14) |
50910e230b6Smaya      __gen_uint(values->DoubleSidedStencilEnable, 15, 15) |
51010e230b6Smaya      __gen_uint(values->StencilBufferWriteEnable, 18, 18) |
51110e230b6Smaya      __gen_uint(values->StencilPassDepthPassOp, 19, 21) |
51210e230b6Smaya      __gen_uint(values->StencilPassDepthFailOp, 22, 24) |
51310e230b6Smaya      __gen_uint(values->StencilFailOp, 25, 27) |
51410e230b6Smaya      __gen_uint(values->StencilTestFunction, 28, 30) |
51510e230b6Smaya      __gen_uint(values->StencilTestEnable, 31, 31);
51610e230b6Smaya
51710e230b6Smaya   dw[1] =
51810e230b6Smaya      __gen_uint(values->BackfaceStencilReferenceValue, 0, 7) |
51910e230b6Smaya      __gen_uint(values->StencilWriteMask, 8, 15) |
52010e230b6Smaya      __gen_uint(values->StencilTestMask, 16, 23) |
52110e230b6Smaya      __gen_uint(values->StencilReferenceValue, 24, 31);
52210e230b6Smaya
52310e230b6Smaya   dw[2] =
52410e230b6Smaya      __gen_uint(values->LogicOpEnable, 0, 0) |
52510e230b6Smaya      __gen_uint(values->DepthBufferWriteEnable, 11, 11) |
52610e230b6Smaya      __gen_uint(values->DepthTestFunction, 12, 14) |
52710e230b6Smaya      __gen_uint(values->DepthTestEnable, 15, 15) |
52810e230b6Smaya      __gen_uint(values->BackfaceStencilWriteMask, 16, 23) |
52910e230b6Smaya      __gen_uint(values->BackfaceStencilTestMask, 24, 31);
53010e230b6Smaya
53110e230b6Smaya   dw[3] =
53210e230b6Smaya      __gen_uint(values->AlphaTestFunction, 8, 10) |
53310e230b6Smaya      __gen_uint(values->AlphaTestEnable, 11, 11) |
53410e230b6Smaya      __gen_uint(values->ColorBufferBlendEnable, 12, 12) |
53510e230b6Smaya      __gen_uint(values->IndependentAlphaBlendEnable, 13, 13) |
53610e230b6Smaya      __gen_uint(values->AlphaTestFormat, 15, 15);
53710e230b6Smaya
53810e230b6Smaya   dw[4] = __gen_combine_address(data, &dw[4], values->CCViewportStatePointer, 0);
53910e230b6Smaya
54010e230b6Smaya   dw[5] =
54110e230b6Smaya      __gen_uint(values->DestinationAlphaBlendFactor, 2, 6) |
54210e230b6Smaya      __gen_uint(values->SourceAlphaBlendFactor, 7, 11) |
54310e230b6Smaya      __gen_uint(values->AlphaBlendFunction, 12, 14) |
54410e230b6Smaya      __gen_uint(values->StatisticsEnable, 15, 15) |
54510e230b6Smaya      __gen_uint(values->LogicOpFunction, 16, 19) |
54610e230b6Smaya      __gen_uint(values->RoundDisableFunctionDisable, 30, 30) |
54710e230b6Smaya      __gen_uint(values->ColorDitherEnable, 31, 31);
54810e230b6Smaya
54910e230b6Smaya   dw[6] =
55010e230b6Smaya      __gen_uint(values->PostBlendColorClampEnable, 0, 0) |
55110e230b6Smaya      __gen_uint(values->PreBlendColorClampEnable, 1, 1) |
55210e230b6Smaya      __gen_uint(values->ColorClampRange, 2, 3) |
55310e230b6Smaya      __gen_uint(values->YDitherOffset, 15, 16) |
55410e230b6Smaya      __gen_uint(values->XDitherOffset, 17, 18) |
55510e230b6Smaya      __gen_uint(values->DestinationBlendFactor, 19, 23) |
55610e230b6Smaya      __gen_uint(values->SourceBlendFactor, 24, 28) |
55710e230b6Smaya      __gen_uint(values->ColorBlendFunction, 29, 31);
55810e230b6Smaya
55910e230b6Smaya   dw[7] =
56010e230b6Smaya      __gen_uint(values->AlphaReferenceValueAsUNORM8, 0, 31) |
56110e230b6Smaya      __gen_float(values->AlphaReferenceValueAsFLOAT32);
56210e230b6Smaya}
56310e230b6Smaya
56410e230b6Smaya#define GEN5_GS_STATE_length                   7
56510e230b6Smayastruct GEN5_GS_STATE {
56610e230b6Smaya   uint32_t                             GRFRegisterCount;
56710e230b6Smaya   uint64_t                             KernelStartPointer;
56810e230b6Smaya   bool                                 SoftwareExceptionEnable;
56910e230b6Smaya   bool                                 MaskStackExceptionEnable;
57010e230b6Smaya   bool                                 IllegalOpcodeExceptionEnable;
57110e230b6Smaya   uint32_t                             FloatingPointMode;
57210e230b6Smaya#define FLOATING_POINT_MODE_IEEE754              0
57310e230b6Smaya#define FLOATING_POINT_MODE_Alternate            1
57410e230b6Smaya   uint32_t                             BindingTableEntryCount;
57510e230b6Smaya   bool                                 SingleProgramFlow;
57610e230b6Smaya   uint32_t                             PerThreadScratchSpace;
57710e230b6Smaya   __gen_address_type                   ScratchSpaceBasePointer;
57810e230b6Smaya   uint32_t                             DispatchGRFStartRegisterForURBData;
57910e230b6Smaya   uint32_t                             VertexURBEntryReadOffset;
58010e230b6Smaya   uint32_t                             VertexURBEntryReadLength;
58110e230b6Smaya   uint32_t                             ConstantURBEntryReadOffset;
58210e230b6Smaya   uint32_t                             ConstantURBEntryReadLength;
58310e230b6Smaya   bool                                 RenderingEnabled;
58410e230b6Smaya   bool                                 SOStatisticsEnable;
58510e230b6Smaya   bool                                 GSStatisticsEnable;
58610e230b6Smaya   uint32_t                             NumberofURBEntries;
58710e230b6Smaya   uint32_t                             URBEntryAllocationSize;
58810e230b6Smaya   uint32_t                             MaximumNumberofThreads;
58910e230b6Smaya   uint32_t                             SamplerCount;
59010e230b6Smaya   __gen_address_type                   SamplerStatePointer;
59110e230b6Smaya   uint32_t                             MaximumVPIndex;
59210e230b6Smaya   bool                                 ReorderEnable;
59310e230b6Smaya};
59410e230b6Smaya
59510e230b6Smayastatic inline void
59610e230b6SmayaGEN5_GS_STATE_pack(__attribute__((unused)) __gen_user_data *data,
59710e230b6Smaya                   __attribute__((unused)) void * restrict dst,
59810e230b6Smaya                   __attribute__((unused)) const struct GEN5_GS_STATE * restrict values)
59910e230b6Smaya{
60010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
60110e230b6Smaya
60210e230b6Smaya   dw[0] =
60310e230b6Smaya      __gen_uint(values->GRFRegisterCount, 1, 3) |
60410e230b6Smaya      __gen_offset(values->KernelStartPointer, 6, 31);
60510e230b6Smaya
60610e230b6Smaya   dw[1] =
60710e230b6Smaya      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
60810e230b6Smaya      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
60910e230b6Smaya      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
61010e230b6Smaya      __gen_uint(values->FloatingPointMode, 16, 16) |
61110e230b6Smaya      __gen_uint(values->BindingTableEntryCount, 18, 25) |
61210e230b6Smaya      __gen_uint(values->SingleProgramFlow, 31, 31);
61310e230b6Smaya
61410e230b6Smaya   const uint32_t v2 =
61510e230b6Smaya      __gen_uint(values->PerThreadScratchSpace, 0, 3);
61610e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
61710e230b6Smaya
61810e230b6Smaya   dw[3] =
61910e230b6Smaya      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
62010e230b6Smaya      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
62110e230b6Smaya      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
62210e230b6Smaya      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
62310e230b6Smaya      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
62410e230b6Smaya
62510e230b6Smaya   dw[4] =
62610e230b6Smaya      __gen_uint(values->RenderingEnabled, 8, 8) |
62710e230b6Smaya      __gen_uint(values->SOStatisticsEnable, 9, 9) |
62810e230b6Smaya      __gen_uint(values->GSStatisticsEnable, 10, 10) |
62910e230b6Smaya      __gen_uint(values->NumberofURBEntries, 11, 18) |
63010e230b6Smaya      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
63110e230b6Smaya      __gen_uint(values->MaximumNumberofThreads, 25, 30);
63210e230b6Smaya
63310e230b6Smaya   const uint32_t v5 =
63410e230b6Smaya      __gen_uint(values->SamplerCount, 0, 2);
63510e230b6Smaya   dw[5] = __gen_combine_address(data, &dw[5], values->SamplerStatePointer, v5);
63610e230b6Smaya
63710e230b6Smaya   dw[6] =
63810e230b6Smaya      __gen_uint(values->MaximumVPIndex, 0, 3) |
63910e230b6Smaya      __gen_uint(values->ReorderEnable, 30, 30);
64010e230b6Smaya}
64110e230b6Smaya
64210e230b6Smaya#define GEN5_MEMORY_OBJECT_CONTROL_STATE_length      1
64310e230b6Smayastruct GEN5_MEMORY_OBJECT_CONTROL_STATE {
64410e230b6Smaya   uint32_t                             CacheabilityControl;
64510e230b6Smaya   uint32_t                             GraphicsDataTypeGFDT;
64610e230b6Smaya   bool                                 EncryptedData;
64710e230b6Smaya};
64810e230b6Smaya
64910e230b6Smayastatic inline void
65010e230b6SmayaGEN5_MEMORY_OBJECT_CONTROL_STATE_pack(__attribute__((unused)) __gen_user_data *data,
65110e230b6Smaya                                      __attribute__((unused)) void * restrict dst,
65210e230b6Smaya                                      __attribute__((unused)) const struct GEN5_MEMORY_OBJECT_CONTROL_STATE * restrict values)
65310e230b6Smaya{
65410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
65510e230b6Smaya
65610e230b6Smaya   dw[0] =
65710e230b6Smaya      __gen_uint(values->CacheabilityControl, 0, 1) |
65810e230b6Smaya      __gen_uint(values->GraphicsDataTypeGFDT, 2, 2) |
65910e230b6Smaya      __gen_uint(values->EncryptedData, 3, 3);
66010e230b6Smaya}
66110e230b6Smaya
66210e230b6Smaya#define GEN5_RENDER_SURFACE_STATE_length       6
66310e230b6Smayastruct GEN5_RENDER_SURFACE_STATE {
66410e230b6Smaya   bool                                 CubeFaceEnablePositiveZ;
66510e230b6Smaya   bool                                 CubeFaceEnableNegativeZ;
66610e230b6Smaya   bool                                 CubeFaceEnablePositiveY;
66710e230b6Smaya   bool                                 CubeFaceEnableNegativeY;
66810e230b6Smaya   bool                                 CubeFaceEnablePositiveX;
66910e230b6Smaya   bool                                 CubeFaceEnableNegativeX;
67010e230b6Smaya   uint32_t                             MediaBoundaryPixelMode;
67110e230b6Smaya#define NORMAL_MODE                              0
67210e230b6Smaya   uint32_t                             RenderCacheReadWriteMode;
67310e230b6Smaya#define WRITE_ONLY                               0
67410e230b6Smaya#define READ_WRITE                               1
67510e230b6Smaya   uint32_t                             CubeMapCornerMode;
67610e230b6Smaya#define CUBE_REPLICATE                           0
67710e230b6Smaya#define CUBE_AVERAGE                             1
67810e230b6Smaya   uint32_t                             MIPMapLayoutMode;
67910e230b6Smaya#define MIPLAYOUT_BELOW                          0
68010e230b6Smaya#define MIPLAYOUT_RIGHT                          1
68110e230b6Smaya   uint32_t                             VerticalLineStrideOffset;
68210e230b6Smaya   uint32_t                             VerticalLineStride;
68310e230b6Smaya   bool                                 ColorBlendEnable;
68410e230b6Smaya   uint32_t                             ColorBufferComponentWriteDisables;
68510e230b6Smaya#define WRITEDISABLE_ALPHA                       8
68610e230b6Smaya#define WRITEDISABLE_RED                         4
68710e230b6Smaya#define WRITEDISABLE_GREEN                       2
68810e230b6Smaya#define WRITEDISABLE_BLUE                        1
68910e230b6Smaya   uint32_t                             SurfaceFormat;
69010e230b6Smaya   uint32_t                             DataReturnFormat;
69110e230b6Smaya#define DATA_RETURN_FLOAT32                      0
69210e230b6Smaya#define DATA_RETURN_S114                         1
69310e230b6Smaya   uint32_t                             SurfaceType;
69410e230b6Smaya#define SURFTYPE_1D                              0
69510e230b6Smaya#define SURFTYPE_2D                              1
69610e230b6Smaya#define SURFTYPE_3D                              2
69710e230b6Smaya#define SURFTYPE_CUBE                            3
69810e230b6Smaya#define SURFTYPE_BUFFER                          4
69910e230b6Smaya#define SURFTYPE_NULL                            7
70010e230b6Smaya   __gen_address_type                   SurfaceBaseAddress;
70110e230b6Smaya   uint32_t                             RenderTargetRotation;
70210e230b6Smaya#define RTROTATE_0DEG                            0
70310e230b6Smaya#define RTROTATE_90DEG                           1
70410e230b6Smaya#define RTROTATE_270DEG                          3
70510e230b6Smaya   uint32_t                             MIPCountLOD;
70610e230b6Smaya   uint32_t                             Width;
70710e230b6Smaya   uint32_t                             Height;
70810e230b6Smaya   uint32_t                             TileWalk;
70910e230b6Smaya#define TILEWALK_XMAJOR                          0
71010e230b6Smaya#define TILEWALK_YMAJOR                          1
71110e230b6Smaya   uint32_t                             TiledSurface;
71210e230b6Smaya   uint32_t                             SurfacePitch;
71310e230b6Smaya   uint32_t                             Depth;
71410e230b6Smaya   uint32_t                             RenderTargetViewExtent;
71510e230b6Smaya   uint32_t                             MinimumArrayElement;
71610e230b6Smaya   uint32_t                             SurfaceMinLOD;
71710e230b6Smaya   uint32_t                             YOffset;
71810e230b6Smaya   uint32_t                             XOffset;
71910e230b6Smaya};
72010e230b6Smaya
72110e230b6Smayastatic inline void
72210e230b6SmayaGEN5_RENDER_SURFACE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
72310e230b6Smaya                               __attribute__((unused)) void * restrict dst,
72410e230b6Smaya                               __attribute__((unused)) const struct GEN5_RENDER_SURFACE_STATE * restrict values)
72510e230b6Smaya{
72610e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
72710e230b6Smaya
72810e230b6Smaya   dw[0] =
72910e230b6Smaya      __gen_uint(values->CubeFaceEnablePositiveZ, 0, 0) |
73010e230b6Smaya      __gen_uint(values->CubeFaceEnableNegativeZ, 1, 1) |
73110e230b6Smaya      __gen_uint(values->CubeFaceEnablePositiveY, 2, 2) |
73210e230b6Smaya      __gen_uint(values->CubeFaceEnableNegativeY, 3, 3) |
73310e230b6Smaya      __gen_uint(values->CubeFaceEnablePositiveX, 4, 4) |
73410e230b6Smaya      __gen_uint(values->CubeFaceEnableNegativeX, 5, 5) |
73510e230b6Smaya      __gen_uint(values->MediaBoundaryPixelMode, 6, 7) |
73610e230b6Smaya      __gen_uint(values->RenderCacheReadWriteMode, 8, 8) |
73710e230b6Smaya      __gen_uint(values->CubeMapCornerMode, 9, 9) |
73810e230b6Smaya      __gen_uint(values->MIPMapLayoutMode, 10, 10) |
73910e230b6Smaya      __gen_uint(values->VerticalLineStrideOffset, 11, 11) |
74010e230b6Smaya      __gen_uint(values->VerticalLineStride, 12, 12) |
74110e230b6Smaya      __gen_uint(values->ColorBlendEnable, 13, 13) |
74210e230b6Smaya      __gen_uint(values->ColorBufferComponentWriteDisables, 14, 17) |
74310e230b6Smaya      __gen_uint(values->SurfaceFormat, 18, 26) |
74410e230b6Smaya      __gen_uint(values->DataReturnFormat, 27, 27) |
74510e230b6Smaya      __gen_uint(values->SurfaceType, 29, 31);
74610e230b6Smaya
74710e230b6Smaya   dw[1] = __gen_combine_address(data, &dw[1], values->SurfaceBaseAddress, 0);
74810e230b6Smaya
74910e230b6Smaya   dw[2] =
75010e230b6Smaya      __gen_uint(values->RenderTargetRotation, 0, 1) |
75110e230b6Smaya      __gen_uint(values->MIPCountLOD, 2, 5) |
75210e230b6Smaya      __gen_uint(values->Width, 6, 18) |
75310e230b6Smaya      __gen_uint(values->Height, 19, 31);
75410e230b6Smaya
75510e230b6Smaya   dw[3] =
75610e230b6Smaya      __gen_uint(values->TileWalk, 0, 0) |
75710e230b6Smaya      __gen_uint(values->TiledSurface, 1, 1) |
75810e230b6Smaya      __gen_uint(values->SurfacePitch, 3, 19) |
75910e230b6Smaya      __gen_uint(values->Depth, 21, 31);
76010e230b6Smaya
76110e230b6Smaya   dw[4] =
76210e230b6Smaya      __gen_uint(values->RenderTargetViewExtent, 8, 16) |
76310e230b6Smaya      __gen_uint(values->MinimumArrayElement, 17, 27) |
76410e230b6Smaya      __gen_uint(values->SurfaceMinLOD, 28, 31);
76510e230b6Smaya
76610e230b6Smaya   dw[5] =
76710e230b6Smaya      __gen_uint(values->YOffset, 20, 23) |
76810e230b6Smaya      __gen_uint(values->XOffset, 25, 31);
76910e230b6Smaya}
77010e230b6Smaya
77110e230b6Smaya#define GEN5_SAMPLER_BORDER_COLOR_STATE_length     12
77210e230b6Smayastruct GEN5_SAMPLER_BORDER_COLOR_STATE {
77310e230b6Smaya   uint32_t                             BorderColorUnormRed;
77410e230b6Smaya   uint32_t                             BorderColorUnormGreen;
77510e230b6Smaya   uint32_t                             BorderColorUnormBlue;
77610e230b6Smaya   uint32_t                             BorderColorUnormAlpha;
77710e230b6Smaya   float                                BorderColorFloatRed;
77810e230b6Smaya   float                                BorderColorFloatGreen;
77910e230b6Smaya   float                                BorderColorFloatBlue;
78010e230b6Smaya   float                                BorderColorFloatAlpha;
78110e230b6Smaya   uint32_t                             BorderColorFloat16Red;
78210e230b6Smaya   uint32_t                             BorderColorFloat16Green;
78310e230b6Smaya   uint32_t                             BorderColorFloat16Blue;
78410e230b6Smaya   uint32_t                             BorderColorFloat16Alpha;
78510e230b6Smaya   uint32_t                             BorderColorUnorm16Red;
78610e230b6Smaya   uint32_t                             BorderColorUnorm16Green;
78710e230b6Smaya   uint32_t                             BorderColorUnorm16Blue;
78810e230b6Smaya   uint32_t                             BorderColorUnorm16Alpha;
78910e230b6Smaya   int32_t                              BorderColorSnorm16Red;
79010e230b6Smaya   int32_t                              BorderColorSnorm16Green;
79110e230b6Smaya   int32_t                              BorderColorSnorm16Blue;
79210e230b6Smaya   int32_t                              BorderColorSnorm16Alpha;
79310e230b6Smaya   int32_t                              BorderColorSnorm8Red;
79410e230b6Smaya   int32_t                              BorderColorSnorm8Green;
79510e230b6Smaya   int32_t                              BorderColorSnorm8Blue;
79610e230b6Smaya   int32_t                              BorderColorSnorm8Alpha;
79710e230b6Smaya};
79810e230b6Smaya
79910e230b6Smayastatic inline void
80010e230b6SmayaGEN5_SAMPLER_BORDER_COLOR_STATE_pack(__attribute__((unused)) __gen_user_data *data,
80110e230b6Smaya                                     __attribute__((unused)) void * restrict dst,
80210e230b6Smaya                                     __attribute__((unused)) const struct GEN5_SAMPLER_BORDER_COLOR_STATE * restrict values)
80310e230b6Smaya{
80410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
80510e230b6Smaya
80610e230b6Smaya   dw[0] =
80710e230b6Smaya      __gen_uint(values->BorderColorUnormRed, 0, 7) |
80810e230b6Smaya      __gen_uint(values->BorderColorUnormGreen, 8, 15) |
80910e230b6Smaya      __gen_uint(values->BorderColorUnormBlue, 16, 23) |
81010e230b6Smaya      __gen_uint(values->BorderColorUnormAlpha, 24, 31);
81110e230b6Smaya
81210e230b6Smaya   dw[1] =
81310e230b6Smaya      __gen_float(values->BorderColorFloatRed);
81410e230b6Smaya
81510e230b6Smaya   dw[2] =
81610e230b6Smaya      __gen_float(values->BorderColorFloatGreen);
81710e230b6Smaya
81810e230b6Smaya   dw[3] =
81910e230b6Smaya      __gen_float(values->BorderColorFloatBlue);
82010e230b6Smaya
82110e230b6Smaya   dw[4] =
82210e230b6Smaya      __gen_float(values->BorderColorFloatAlpha);
82310e230b6Smaya
82410e230b6Smaya   dw[5] =
82510e230b6Smaya      __gen_uint(values->BorderColorFloat16Red, 0, 15) |
82610e230b6Smaya      __gen_uint(values->BorderColorFloat16Green, 16, 31);
82710e230b6Smaya
82810e230b6Smaya   dw[6] =
82910e230b6Smaya      __gen_uint(values->BorderColorFloat16Blue, 0, 15) |
83010e230b6Smaya      __gen_uint(values->BorderColorFloat16Alpha, 16, 31);
83110e230b6Smaya
83210e230b6Smaya   dw[7] =
83310e230b6Smaya      __gen_uint(values->BorderColorUnorm16Red, 0, 15) |
83410e230b6Smaya      __gen_uint(values->BorderColorUnorm16Green, 16, 31);
83510e230b6Smaya
83610e230b6Smaya   dw[8] =
83710e230b6Smaya      __gen_uint(values->BorderColorUnorm16Blue, 0, 15) |
83810e230b6Smaya      __gen_uint(values->BorderColorUnorm16Alpha, 16, 31);
83910e230b6Smaya
84010e230b6Smaya   dw[9] =
84110e230b6Smaya      __gen_sint(values->BorderColorSnorm16Red, 0, 15) |
84210e230b6Smaya      __gen_sint(values->BorderColorSnorm16Green, 16, 31);
84310e230b6Smaya
84410e230b6Smaya   dw[10] =
84510e230b6Smaya      __gen_sint(values->BorderColorSnorm16Blue, 0, 15) |
84610e230b6Smaya      __gen_sint(values->BorderColorSnorm16Alpha, 16, 31);
84710e230b6Smaya
84810e230b6Smaya   dw[11] =
84910e230b6Smaya      __gen_sint(values->BorderColorSnorm8Red, 0, 7) |
85010e230b6Smaya      __gen_sint(values->BorderColorSnorm8Green, 8, 15) |
85110e230b6Smaya      __gen_sint(values->BorderColorSnorm8Blue, 16, 23) |
85210e230b6Smaya      __gen_sint(values->BorderColorSnorm8Alpha, 24, 31);
85310e230b6Smaya}
85410e230b6Smaya
85510e230b6Smaya#define GEN5_SAMPLER_STATE_length              4
85610e230b6Smayastruct GEN5_SAMPLER_STATE {
85710e230b6Smaya   uint32_t                             ShadowFunction;
85810e230b6Smaya#define PREFILTEROP_ALWAYS                       0
85910e230b6Smaya#define PREFILTEROP_NEVER                        1
86010e230b6Smaya#define PREFILTEROP_LESS                         2
86110e230b6Smaya#define PREFILTEROP_EQUAL                        3
86210e230b6Smaya#define PREFILTEROP_LEQUAL                       4
86310e230b6Smaya#define PREFILTEROP_GREATER                      5
86410e230b6Smaya#define PREFILTEROP_NOTEQUAL                     6
86510e230b6Smaya#define PREFILTEROP_GEQUAL                       7
86610e230b6Smaya   float                                TextureLODBias;
86710e230b6Smaya   uint32_t                             MinModeFilter;
86810e230b6Smaya   uint32_t                             MagModeFilter;
86910e230b6Smaya#define MAPFILTER_NEAREST                        0
87010e230b6Smaya#define MAPFILTER_LINEAR                         1
87110e230b6Smaya#define MAPFILTER_ANISOTROPIC                    2
87210e230b6Smaya#define MAPFILTER_MONO                           6
87310e230b6Smaya   uint32_t                             MipModeFilter;
87410e230b6Smaya#define MIPFILTER_NONE                           0
87510e230b6Smaya#define MIPFILTER_NEAREST                        1
87610e230b6Smaya#define MIPFILTER_LINEAR                         3
87710e230b6Smaya   float                                BaseMipLevel;
87810e230b6Smaya   bool                                 LODPreClampEnable;
87910e230b6Smaya   bool                                 SamplerDisable;
88010e230b6Smaya   enum GEN5_Texture_Coordinate_Mode    TCZAddressControlMode;
88110e230b6Smaya   enum GEN5_Texture_Coordinate_Mode    TCYAddressControlMode;
88210e230b6Smaya   enum GEN5_Texture_Coordinate_Mode    TCXAddressControlMode;
88310e230b6Smaya   uint32_t                             CubeSurfaceControlMode;
88410e230b6Smaya#define CUBECTRLMODE_PROGRAMMED                  0
88510e230b6Smaya#define CUBECTRLMODE_OVERRIDE                    1
88610e230b6Smaya   float                                MaxLOD;
88710e230b6Smaya   float                                MinLOD;
88810e230b6Smaya   __gen_address_type                   BorderColorPointer;
88910e230b6Smaya   bool                                 RAddressMinFilterRoundingEnable;
89010e230b6Smaya   bool                                 RAddressMagFilterRoundingEnable;
89110e230b6Smaya   bool                                 VAddressMinFilterRoundingEnable;
89210e230b6Smaya   bool                                 VAddressMagFilterRoundingEnable;
89310e230b6Smaya   bool                                 UAddressMinFilterRoundingEnable;
89410e230b6Smaya   bool                                 UAddressMagFilterRoundingEnable;
89510e230b6Smaya   uint32_t                             MaximumAnisotropy;
89610e230b6Smaya#define RATIO21                                  0
89710e230b6Smaya#define RATIO41                                  1
89810e230b6Smaya#define RATIO61                                  2
89910e230b6Smaya#define RATIO81                                  3
90010e230b6Smaya#define RATIO101                                 4
90110e230b6Smaya#define RATIO121                                 5
90210e230b6Smaya#define RATIO141                                 6
90310e230b6Smaya#define RATIO161                                 7
90410e230b6Smaya   uint32_t                             ChromaKeyMode;
90510e230b6Smaya#define KEYFILTER_KILL_ON_ANY_MATCH              0
90610e230b6Smaya#define KEYFILTER_REPLACE_BLACK                  1
90710e230b6Smaya   uint32_t                             ChromaKeyIndex;
90810e230b6Smaya   bool                                 ChromaKeyEnable;
90910e230b6Smaya   uint32_t                             MonochromeFilterWidth;
91010e230b6Smaya   uint32_t                             MonochromeFilterHeight;
91110e230b6Smaya};
91210e230b6Smaya
91310e230b6Smayastatic inline void
91410e230b6SmayaGEN5_SAMPLER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
91510e230b6Smaya                        __attribute__((unused)) void * restrict dst,
91610e230b6Smaya                        __attribute__((unused)) const struct GEN5_SAMPLER_STATE * restrict values)
91710e230b6Smaya{
91810e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
91910e230b6Smaya
92010e230b6Smaya   dw[0] =
92110e230b6Smaya      __gen_uint(values->ShadowFunction, 0, 2) |
92210e230b6Smaya      __gen_sfixed(values->TextureLODBias, 3, 13, 6) |
92310e230b6Smaya      __gen_uint(values->MinModeFilter, 14, 16) |
92410e230b6Smaya      __gen_uint(values->MagModeFilter, 17, 19) |
92510e230b6Smaya      __gen_uint(values->MipModeFilter, 20, 21) |
92610e230b6Smaya      __gen_ufixed(values->BaseMipLevel, 22, 26, 1) |
92710e230b6Smaya      __gen_uint(values->LODPreClampEnable, 28, 28) |
92810e230b6Smaya      __gen_uint(values->SamplerDisable, 31, 31);
92910e230b6Smaya
93010e230b6Smaya   dw[1] =
93110e230b6Smaya      __gen_uint(values->TCZAddressControlMode, 0, 2) |
93210e230b6Smaya      __gen_uint(values->TCYAddressControlMode, 3, 5) |
93310e230b6Smaya      __gen_uint(values->TCXAddressControlMode, 6, 8) |
93410e230b6Smaya      __gen_uint(values->CubeSurfaceControlMode, 9, 9) |
93510e230b6Smaya      __gen_ufixed(values->MaxLOD, 12, 21, 6) |
93610e230b6Smaya      __gen_ufixed(values->MinLOD, 22, 31, 6);
93710e230b6Smaya
93810e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->BorderColorPointer, 0);
93910e230b6Smaya
94010e230b6Smaya   dw[3] =
94110e230b6Smaya      __gen_uint(values->RAddressMinFilterRoundingEnable, 13, 13) |
94210e230b6Smaya      __gen_uint(values->RAddressMagFilterRoundingEnable, 14, 14) |
94310e230b6Smaya      __gen_uint(values->VAddressMinFilterRoundingEnable, 15, 15) |
94410e230b6Smaya      __gen_uint(values->VAddressMagFilterRoundingEnable, 16, 16) |
94510e230b6Smaya      __gen_uint(values->UAddressMinFilterRoundingEnable, 17, 17) |
94610e230b6Smaya      __gen_uint(values->UAddressMagFilterRoundingEnable, 18, 18) |
94710e230b6Smaya      __gen_uint(values->MaximumAnisotropy, 19, 21) |
94810e230b6Smaya      __gen_uint(values->ChromaKeyMode, 22, 22) |
94910e230b6Smaya      __gen_uint(values->ChromaKeyIndex, 23, 24) |
95010e230b6Smaya      __gen_uint(values->ChromaKeyEnable, 25, 25) |
95110e230b6Smaya      __gen_uint(values->MonochromeFilterWidth, 26, 28) |
95210e230b6Smaya      __gen_uint(values->MonochromeFilterHeight, 29, 31);
95310e230b6Smaya}
95410e230b6Smaya
95510e230b6Smaya#define GEN5_SCISSOR_RECT_length               2
95610e230b6Smayastruct GEN5_SCISSOR_RECT {
95710e230b6Smaya   uint32_t                             ScissorRectangleXMin;
95810e230b6Smaya   uint32_t                             ScissorRectangleYMin;
95910e230b6Smaya   uint32_t                             ScissorRectangleXMax;
96010e230b6Smaya   uint32_t                             ScissorRectangleYMax;
96110e230b6Smaya};
96210e230b6Smaya
96310e230b6Smayastatic inline void
96410e230b6SmayaGEN5_SCISSOR_RECT_pack(__attribute__((unused)) __gen_user_data *data,
96510e230b6Smaya                       __attribute__((unused)) void * restrict dst,
96610e230b6Smaya                       __attribute__((unused)) const struct GEN5_SCISSOR_RECT * restrict values)
96710e230b6Smaya{
96810e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
96910e230b6Smaya
97010e230b6Smaya   dw[0] =
97110e230b6Smaya      __gen_uint(values->ScissorRectangleXMin, 0, 15) |
97210e230b6Smaya      __gen_uint(values->ScissorRectangleYMin, 16, 31);
97310e230b6Smaya
97410e230b6Smaya   dw[1] =
97510e230b6Smaya      __gen_uint(values->ScissorRectangleXMax, 0, 15) |
97610e230b6Smaya      __gen_uint(values->ScissorRectangleYMax, 16, 31);
97710e230b6Smaya}
97810e230b6Smaya
97910e230b6Smaya#define GEN5_SF_STATE_length                   8
98010e230b6Smayastruct GEN5_SF_STATE {
98110e230b6Smaya   uint32_t                             GRFRegisterCount;
98210e230b6Smaya   uint64_t                             KernelStartPointer;
98310e230b6Smaya   bool                                 SoftwareExceptionEnable;
98410e230b6Smaya   bool                                 MaskStackExceptionEnable;
98510e230b6Smaya   bool                                 IllegalOpcodeExceptionEnable;
98610e230b6Smaya   uint32_t                             FloatingPointMode;
98710e230b6Smaya#define FLOATING_POINT_MODE_IEEE754              0
98810e230b6Smaya#define FLOATING_POINT_MODE_Alternate            1
98910e230b6Smaya   uint32_t                             ThreadPriority;
99010e230b6Smaya#define NormalPriority                           0
99110e230b6Smaya#define HighPriority                             1
99210e230b6Smaya   uint32_t                             BindingTableEntryCount;
99310e230b6Smaya   bool                                 SingleProgramFlow;
99410e230b6Smaya   uint32_t                             PerThreadScratchSpace;
99510e230b6Smaya   __gen_address_type                   ScratchSpaceBasePointer;
99610e230b6Smaya   uint32_t                             DispatchGRFStartRegisterForURBData;
99710e230b6Smaya   uint32_t                             VertexURBEntryReadOffset;
99810e230b6Smaya   uint32_t                             VertexURBEntryReadLength;
99910e230b6Smaya   uint32_t                             ConstantURBEntryReadOffset;
100010e230b6Smaya   uint32_t                             ConstantURBEntryReadLength;
100110e230b6Smaya   uint32_t                             NumberofURBEntries;
100210e230b6Smaya   uint32_t                             URBEntryAllocationSize;
100310e230b6Smaya   uint32_t                             MaximumNumberofThreads;
100410e230b6Smaya   uint32_t                             FrontWinding;
100510e230b6Smaya#define FRONTWINDING_CW                          0
100610e230b6Smaya#define FRONTWINDING_CCW                         1
100710e230b6Smaya   bool                                 ViewportTransformEnable;
100810e230b6Smaya   __gen_address_type                   SetupViewportStateOffset;
100910e230b6Smaya   float                                DestinationOriginVerticalBias;
101010e230b6Smaya   float                                DestinationOriginHorizontalBias;
101110e230b6Smaya   bool                                 ScissorRectangleEnable;
101210e230b6Smaya   bool                                 _2x2PixelTriangleFilterDisable;
101310e230b6Smaya   bool                                 ZeroPixelTriangleFilterDisable;
101410e230b6Smaya   uint32_t                             PointRasterizationRule;
101510e230b6Smaya#define RASTRULE_UPPER_LEFT                      0
101610e230b6Smaya#define RASTRULE_UPPER_RIGHT                     1
101710e230b6Smaya   uint32_t                             LineEndCapAntialiasingRegionWidth;
101810e230b6Smaya#define _05pixels                                0
101910e230b6Smaya#define _10pixels                                1
102010e230b6Smaya#define _20pixels                                2
102110e230b6Smaya#define _40pixels                                3
102210e230b6Smaya   float                                LineWidth;
102310e230b6Smaya   bool                                 FastScissorClipDisable;
102410e230b6Smaya   uint32_t                             CullMode;
102510e230b6Smaya#define CULLMODE_BOTH                            0
102610e230b6Smaya#define CULLMODE_NONE                            1
102710e230b6Smaya#define CULLMODE_FRONT                           2
102810e230b6Smaya#define CULLMODE_BACK                            3
102910e230b6Smaya   bool                                 AntiAliasingEnable;
103010e230b6Smaya   float                                PointWidth;
103110e230b6Smaya   uint32_t                             PointWidthSource;
103210e230b6Smaya#define Vertex                                   0
103310e230b6Smaya#define State                                    1
103410e230b6Smaya   uint32_t                             VertexSubPixelPrecisionSelect;
103510e230b6Smaya#define _8SubPixelPrecisionBits                  0
103610e230b6Smaya#define _4SubPixelPrecisionBits                  1
103710e230b6Smaya   bool                                 SpritePointEnable;
103810e230b6Smaya   uint32_t                             AALineDistanceMode;
103910e230b6Smaya#define AALINEDISTANCE_MANHATTAN                 0
104010e230b6Smaya#define AALINEDISTANCE_TRUE                      1
104110e230b6Smaya   uint32_t                             TriangleFanProvokingVertexSelect;
104210e230b6Smaya#define Vertex0                                  0
104310e230b6Smaya#define Vertex1                                  1
104410e230b6Smaya#define Vertex2                                  2
104510e230b6Smaya   uint32_t                             LineStripListProvokingVertexSelect;
104610e230b6Smaya#define Vertex0                                  0
104710e230b6Smaya#define Vertex1                                  1
104810e230b6Smaya   uint32_t                             TriangleStripListProvokingVertexSelect;
104910e230b6Smaya#define Vertex0                                  0
105010e230b6Smaya#define Vertex1                                  1
105110e230b6Smaya#define Vertex2                                  2
105210e230b6Smaya   bool                                 LastPixelEnable;
105310e230b6Smaya};
105410e230b6Smaya
105510e230b6Smayastatic inline void
105610e230b6SmayaGEN5_SF_STATE_pack(__attribute__((unused)) __gen_user_data *data,
105710e230b6Smaya                   __attribute__((unused)) void * restrict dst,
105810e230b6Smaya                   __attribute__((unused)) const struct GEN5_SF_STATE * restrict values)
105910e230b6Smaya{
106010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
106110e230b6Smaya
106210e230b6Smaya   dw[0] =
106310e230b6Smaya      __gen_uint(values->GRFRegisterCount, 1, 3) |
106410e230b6Smaya      __gen_offset(values->KernelStartPointer, 6, 31);
106510e230b6Smaya
106610e230b6Smaya   dw[1] =
106710e230b6Smaya      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
106810e230b6Smaya      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
106910e230b6Smaya      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
107010e230b6Smaya      __gen_uint(values->FloatingPointMode, 16, 16) |
107110e230b6Smaya      __gen_uint(values->ThreadPriority, 17, 17) |
107210e230b6Smaya      __gen_uint(values->BindingTableEntryCount, 18, 25) |
107310e230b6Smaya      __gen_uint(values->SingleProgramFlow, 31, 31);
107410e230b6Smaya
107510e230b6Smaya   const uint32_t v2 =
107610e230b6Smaya      __gen_uint(values->PerThreadScratchSpace, 0, 3);
107710e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
107810e230b6Smaya
107910e230b6Smaya   dw[3] =
108010e230b6Smaya      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
108110e230b6Smaya      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
108210e230b6Smaya      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
108310e230b6Smaya      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
108410e230b6Smaya      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
108510e230b6Smaya
108610e230b6Smaya   dw[4] =
108710e230b6Smaya      __gen_uint(values->NumberofURBEntries, 11, 18) |
108810e230b6Smaya      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
108910e230b6Smaya      __gen_uint(values->MaximumNumberofThreads, 25, 30);
109010e230b6Smaya
109110e230b6Smaya   const uint32_t v5 =
109210e230b6Smaya      __gen_uint(values->FrontWinding, 0, 0) |
109310e230b6Smaya      __gen_uint(values->ViewportTransformEnable, 1, 1);
109410e230b6Smaya   dw[5] = __gen_combine_address(data, &dw[5], values->SetupViewportStateOffset, v5);
109510e230b6Smaya
109610e230b6Smaya   dw[6] =
109710e230b6Smaya      __gen_ufixed(values->DestinationOriginVerticalBias, 9, 12, 4) |
109810e230b6Smaya      __gen_ufixed(values->DestinationOriginHorizontalBias, 13, 16, 4) |
109910e230b6Smaya      __gen_uint(values->ScissorRectangleEnable, 17, 17) |
110010e230b6Smaya      __gen_uint(values->_2x2PixelTriangleFilterDisable, 18, 18) |
110110e230b6Smaya      __gen_uint(values->ZeroPixelTriangleFilterDisable, 19, 19) |
110210e230b6Smaya      __gen_uint(values->PointRasterizationRule, 20, 21) |
110310e230b6Smaya      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 22, 23) |
110410e230b6Smaya      __gen_ufixed(values->LineWidth, 24, 27, 1) |
110510e230b6Smaya      __gen_uint(values->FastScissorClipDisable, 28, 28) |
110610e230b6Smaya      __gen_uint(values->CullMode, 29, 30) |
110710e230b6Smaya      __gen_uint(values->AntiAliasingEnable, 31, 31);
110810e230b6Smaya
110910e230b6Smaya   dw[7] =
111010e230b6Smaya      __gen_ufixed(values->PointWidth, 0, 10, 3) |
111110e230b6Smaya      __gen_uint(values->PointWidthSource, 11, 11) |
111210e230b6Smaya      __gen_uint(values->VertexSubPixelPrecisionSelect, 12, 12) |
111310e230b6Smaya      __gen_uint(values->SpritePointEnable, 13, 13) |
111410e230b6Smaya      __gen_uint(values->AALineDistanceMode, 14, 14) |
111510e230b6Smaya      __gen_uint(values->TriangleFanProvokingVertexSelect, 25, 26) |
111610e230b6Smaya      __gen_uint(values->LineStripListProvokingVertexSelect, 27, 28) |
111710e230b6Smaya      __gen_uint(values->TriangleStripListProvokingVertexSelect, 29, 30) |
111810e230b6Smaya      __gen_uint(values->LastPixelEnable, 31, 31);
111910e230b6Smaya}
112010e230b6Smaya
112110e230b6Smaya#define GEN5_SF_VIEWPORT_length                8
112210e230b6Smayastruct GEN5_SF_VIEWPORT {
112310e230b6Smaya   float                                ViewportMatrixElementm00;
112410e230b6Smaya   float                                ViewportMatrixElementm11;
112510e230b6Smaya   float                                ViewportMatrixElementm22;
112610e230b6Smaya   float                                ViewportMatrixElementm30;
112710e230b6Smaya   float                                ViewportMatrixElementm31;
112810e230b6Smaya   float                                ViewportMatrixElementm32;
112910e230b6Smaya   struct GEN5_SCISSOR_RECT             ScissorRectangle;
113010e230b6Smaya};
113110e230b6Smaya
113210e230b6Smayastatic inline void
113310e230b6SmayaGEN5_SF_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
113410e230b6Smaya                      __attribute__((unused)) void * restrict dst,
113510e230b6Smaya                      __attribute__((unused)) const struct GEN5_SF_VIEWPORT * restrict values)
113610e230b6Smaya{
113710e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
113810e230b6Smaya
113910e230b6Smaya   dw[0] =
114010e230b6Smaya      __gen_float(values->ViewportMatrixElementm00);
114110e230b6Smaya
114210e230b6Smaya   dw[1] =
114310e230b6Smaya      __gen_float(values->ViewportMatrixElementm11);
114410e230b6Smaya
114510e230b6Smaya   dw[2] =
114610e230b6Smaya      __gen_float(values->ViewportMatrixElementm22);
114710e230b6Smaya
114810e230b6Smaya   dw[3] =
114910e230b6Smaya      __gen_float(values->ViewportMatrixElementm30);
115010e230b6Smaya
115110e230b6Smaya   dw[4] =
115210e230b6Smaya      __gen_float(values->ViewportMatrixElementm31);
115310e230b6Smaya
115410e230b6Smaya   dw[5] =
115510e230b6Smaya      __gen_float(values->ViewportMatrixElementm32);
115610e230b6Smaya
115710e230b6Smaya   GEN5_SCISSOR_RECT_pack(data, &dw[6], &values->ScissorRectangle);
115810e230b6Smaya}
115910e230b6Smaya
116010e230b6Smaya#define GEN5_VERTEX_BUFFER_STATE_length        4
116110e230b6Smayastruct GEN5_VERTEX_BUFFER_STATE {
116210e230b6Smaya   uint32_t                             BufferPitch;
116310e230b6Smaya   bool                                 NullVertexBuffer;
116410e230b6Smaya   uint32_t                             BufferAccessType;
116510e230b6Smaya#define VERTEXDATA                               0
116610e230b6Smaya#define INSTANCEDATA                             1
116710e230b6Smaya   uint32_t                             VertexBufferIndex;
116810e230b6Smaya   __gen_address_type                   BufferStartingAddress;
116910e230b6Smaya   __gen_address_type                   EndAddress;
117010e230b6Smaya   uint32_t                             InstanceDataStepRate;
117110e230b6Smaya};
117210e230b6Smaya
117310e230b6Smayastatic inline void
117410e230b6SmayaGEN5_VERTEX_BUFFER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
117510e230b6Smaya                              __attribute__((unused)) void * restrict dst,
117610e230b6Smaya                              __attribute__((unused)) const struct GEN5_VERTEX_BUFFER_STATE * restrict values)
117710e230b6Smaya{
117810e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
117910e230b6Smaya
118010e230b6Smaya   dw[0] =
118110e230b6Smaya      __gen_uint(values->BufferPitch, 0, 11) |
118210e230b6Smaya      __gen_uint(values->NullVertexBuffer, 13, 13) |
118310e230b6Smaya      __gen_uint(values->BufferAccessType, 26, 26) |
118410e230b6Smaya      __gen_uint(values->VertexBufferIndex, 27, 31);
118510e230b6Smaya
118610e230b6Smaya   dw[1] = __gen_combine_address(data, &dw[1], values->BufferStartingAddress, 0);
118710e230b6Smaya
118810e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->EndAddress, 0);
118910e230b6Smaya
119010e230b6Smaya   dw[3] =
119110e230b6Smaya      __gen_uint(values->InstanceDataStepRate, 0, 31);
119210e230b6Smaya}
119310e230b6Smaya
119410e230b6Smaya#define GEN5_VERTEX_ELEMENT_STATE_length       2
119510e230b6Smayastruct GEN5_VERTEX_ELEMENT_STATE {
119610e230b6Smaya   uint32_t                             SourceElementOffset;
119710e230b6Smaya   uint32_t                             SourceElementFormat;
119810e230b6Smaya   bool                                 Valid;
119910e230b6Smaya   uint32_t                             VertexBufferIndex;
120010e230b6Smaya   uint32_t                             DestinationElementOffset;
120110e230b6Smaya   enum GEN5_3D_Vertex_Component_Control Component3Control;
120210e230b6Smaya   enum GEN5_3D_Vertex_Component_Control Component2Control;
120310e230b6Smaya   enum GEN5_3D_Vertex_Component_Control Component1Control;
120410e230b6Smaya   enum GEN5_3D_Vertex_Component_Control Component0Control;
120510e230b6Smaya};
120610e230b6Smaya
120710e230b6Smayastatic inline void
120810e230b6SmayaGEN5_VERTEX_ELEMENT_STATE_pack(__attribute__((unused)) __gen_user_data *data,
120910e230b6Smaya                               __attribute__((unused)) void * restrict dst,
121010e230b6Smaya                               __attribute__((unused)) const struct GEN5_VERTEX_ELEMENT_STATE * restrict values)
121110e230b6Smaya{
121210e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
121310e230b6Smaya
121410e230b6Smaya   dw[0] =
121510e230b6Smaya      __gen_uint(values->SourceElementOffset, 0, 10) |
121610e230b6Smaya      __gen_uint(values->SourceElementFormat, 16, 24) |
121710e230b6Smaya      __gen_uint(values->Valid, 26, 26) |
121810e230b6Smaya      __gen_uint(values->VertexBufferIndex, 27, 31);
121910e230b6Smaya
122010e230b6Smaya   dw[1] =
122110e230b6Smaya      __gen_uint(values->DestinationElementOffset, 0, 7) |
122210e230b6Smaya      __gen_uint(values->Component3Control, 16, 18) |
122310e230b6Smaya      __gen_uint(values->Component2Control, 20, 22) |
122410e230b6Smaya      __gen_uint(values->Component1Control, 24, 26) |
122510e230b6Smaya      __gen_uint(values->Component0Control, 28, 30);
122610e230b6Smaya}
122710e230b6Smaya
122810e230b6Smaya#define GEN5_VS_STATE_length                   7
122910e230b6Smayastruct GEN5_VS_STATE {
123010e230b6Smaya   uint32_t                             GRFRegisterCount;
123110e230b6Smaya   uint64_t                             KernelStartPointer;
123210e230b6Smaya   bool                                 SoftwareExceptionEnable;
123310e230b6Smaya   bool                                 MaskStackExceptionEnable;
123410e230b6Smaya   bool                                 IllegalOpcodeExceptionEnable;
123510e230b6Smaya   uint32_t                             FloatingPointMode;
123610e230b6Smaya#define FLOATING_POINT_MODE_IEEE754              0
123710e230b6Smaya#define FLOATING_POINT_MODE_Alternate            1
123810e230b6Smaya   uint32_t                             ThreadPriority;
123910e230b6Smaya#define NormalPriority                           0
124010e230b6Smaya#define HighPriority                             1
124110e230b6Smaya   uint32_t                             BindingTableEntryCount;
124210e230b6Smaya   bool                                 SingleProgramFlow;
124310e230b6Smaya   uint32_t                             PerThreadScratchSpace;
124410e230b6Smaya   __gen_address_type                   ScratchSpaceBasePointer;
124510e230b6Smaya   uint32_t                             DispatchGRFStartRegisterForURBData;
124610e230b6Smaya   uint32_t                             VertexURBEntryReadOffset;
124710e230b6Smaya   uint32_t                             VertexURBEntryReadLength;
124810e230b6Smaya   uint32_t                             ConstantURBEntryReadOffset;
124910e230b6Smaya   uint32_t                             ConstantURBEntryReadLength;
125010e230b6Smaya   bool                                 StatisticsEnable;
125110e230b6Smaya   uint32_t                             NumberofURBEntries;
125210e230b6Smaya   uint32_t                             URBEntryAllocationSize;
125310e230b6Smaya   uint32_t                             MaximumNumberofThreads;
125410e230b6Smaya   uint32_t                             SamplerCount;
125510e230b6Smaya   __gen_address_type                   SamplerStatePointer;
125610e230b6Smaya   bool                                 Enable;
125710e230b6Smaya   bool                                 VertexCacheDisable;
125810e230b6Smaya};
125910e230b6Smaya
126010e230b6Smayastatic inline void
126110e230b6SmayaGEN5_VS_STATE_pack(__attribute__((unused)) __gen_user_data *data,
126210e230b6Smaya                   __attribute__((unused)) void * restrict dst,
126310e230b6Smaya                   __attribute__((unused)) const struct GEN5_VS_STATE * restrict values)
126410e230b6Smaya{
126510e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
126610e230b6Smaya
126710e230b6Smaya   dw[0] =
126810e230b6Smaya      __gen_uint(values->GRFRegisterCount, 1, 3) |
126910e230b6Smaya      __gen_offset(values->KernelStartPointer, 6, 31);
127010e230b6Smaya
127110e230b6Smaya   dw[1] =
127210e230b6Smaya      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
127310e230b6Smaya      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
127410e230b6Smaya      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
127510e230b6Smaya      __gen_uint(values->FloatingPointMode, 16, 16) |
127610e230b6Smaya      __gen_uint(values->ThreadPriority, 17, 17) |
127710e230b6Smaya      __gen_uint(values->BindingTableEntryCount, 18, 25) |
127810e230b6Smaya      __gen_uint(values->SingleProgramFlow, 31, 31);
127910e230b6Smaya
128010e230b6Smaya   const uint32_t v2 =
128110e230b6Smaya      __gen_uint(values->PerThreadScratchSpace, 0, 3);
128210e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
128310e230b6Smaya
128410e230b6Smaya   dw[3] =
128510e230b6Smaya      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
128610e230b6Smaya      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
128710e230b6Smaya      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
128810e230b6Smaya      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
128910e230b6Smaya      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
129010e230b6Smaya
129110e230b6Smaya   dw[4] =
129210e230b6Smaya      __gen_uint(values->StatisticsEnable, 10, 10) |
129310e230b6Smaya      __gen_uint(values->NumberofURBEntries, 11, 18) |
129410e230b6Smaya      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
129510e230b6Smaya      __gen_uint(values->MaximumNumberofThreads, 25, 30);
129610e230b6Smaya
129710e230b6Smaya   const uint32_t v5 =
129810e230b6Smaya      __gen_uint(values->SamplerCount, 0, 2);
129910e230b6Smaya   dw[5] = __gen_combine_address(data, &dw[5], values->SamplerStatePointer, v5);
130010e230b6Smaya
130110e230b6Smaya   dw[6] =
130210e230b6Smaya      __gen_uint(values->Enable, 0, 0) |
130310e230b6Smaya      __gen_uint(values->VertexCacheDisable, 1, 1);
130410e230b6Smaya}
130510e230b6Smaya
130610e230b6Smaya#define GEN5_WM_STATE_length                  11
130710e230b6Smayastruct GEN5_WM_STATE {
130810e230b6Smaya   uint32_t                             GRFRegisterCount0;
130910e230b6Smaya   uint64_t                             KernelStartPointer0;
131010e230b6Smaya   bool                                 SoftwareExceptionEnable;
131110e230b6Smaya   bool                                 MaskStackExceptionEnable;
131210e230b6Smaya   bool                                 IllegalOpcodeExceptionEnable;
131310e230b6Smaya   uint32_t                             DepthCoefficientURBReadOffset;
131410e230b6Smaya   uint32_t                             FloatingPointMode;
131510e230b6Smaya#define FLOATING_POINT_MODE_IEEE754              0
131610e230b6Smaya#define FLOATING_POINT_MODE_Alternate            1
131710e230b6Smaya   uint32_t                             ThreadPriority;
131810e230b6Smaya#define High                                     1
131910e230b6Smaya   uint32_t                             BindingTableEntryCount;
132010e230b6Smaya   bool                                 SingleProgramFlow;
132110e230b6Smaya   uint32_t                             PerThreadScratchSpace;
132210e230b6Smaya   __gen_address_type                   ScratchSpaceBasePointer;
132310e230b6Smaya   uint32_t                             DispatchGRFStartRegisterForConstantSetupData0;
132410e230b6Smaya   uint32_t                             SetupURBEntryReadOffset;
132510e230b6Smaya   uint32_t                             SetupURBEntryReadLength;
132610e230b6Smaya   uint32_t                             ConstantURBEntryReadOffset;
132710e230b6Smaya   uint32_t                             ConstantURBEntryReadLength;
132810e230b6Smaya   bool                                 StatisticsEnable;
132910e230b6Smaya   uint32_t                             SamplerCount;
133010e230b6Smaya   __gen_address_type                   SamplerStatePointer;
133110e230b6Smaya   bool                                 _8PixelDispatchEnable;
133210e230b6Smaya   bool                                 _16PixelDispatchEnable;
133310e230b6Smaya   bool                                 _32PixelDispatchEnable;
133410e230b6Smaya   bool                                 Contiguous32PixelDispatchEnable;
133510e230b6Smaya   bool                                 Contiguous64PixelDispatchEnable;
133610e230b6Smaya   bool                                 FastSpanCoverageEnable;
133710e230b6Smaya   bool                                 DepthBufferClear;
133810e230b6Smaya   bool                                 DepthBufferResolveEnable;
133910e230b6Smaya   bool                                 HierarchicalDepthBufferResolveEnable;
134010e230b6Smaya   bool                                 LegacyGlobalDepthBiasEnable;
134110e230b6Smaya   bool                                 LineStippleEnable;
134210e230b6Smaya   bool                                 GlobalDepthOffsetEnable;
134310e230b6Smaya   bool                                 PolygonStippleEnable;
134410e230b6Smaya   uint32_t                             LineAntialiasingRegionWidth;
134510e230b6Smaya#define _05pixels                                0
134610e230b6Smaya#define _10pixels                                1
134710e230b6Smaya#define _20pixels                                2
134810e230b6Smaya#define _40pixels                                3
134910e230b6Smaya   uint32_t                             LineEndCapAntialiasingRegionWidth;
135010e230b6Smaya#define _05pixels                                0
135110e230b6Smaya#define _10pixels                                1
135210e230b6Smaya#define _20pixels                                2
135310e230b6Smaya#define _40pixels                                3
135410e230b6Smaya   bool                                 EarlyDepthTestEnable;
135510e230b6Smaya   bool                                 ThreadDispatchEnable;
135610e230b6Smaya   bool                                 PixelShaderUsesSourceDepth;
135710e230b6Smaya   bool                                 PixelShaderComputedDepth;
135810e230b6Smaya   bool                                 PixelShaderKillsPixel;
135910e230b6Smaya   bool                                 LegacyDiamondLineRasterization;
136010e230b6Smaya   uint32_t                             MaximumNumberofThreads;
136110e230b6Smaya   float                                GlobalDepthOffsetConstant;
136210e230b6Smaya   float                                GlobalDepthOffsetScale;
136310e230b6Smaya   uint32_t                             GRFRegisterCount1;
136410e230b6Smaya   uint64_t                             KernelStartPointer1;
136510e230b6Smaya   uint32_t                             GRFRegisterCount2;
136610e230b6Smaya   uint64_t                             KernelStartPointer2;
136710e230b6Smaya   uint32_t                             GRFRegisterCount3;
136810e230b6Smaya   uint64_t                             KernelStartPointer3;
136910e230b6Smaya};
137010e230b6Smaya
137110e230b6Smayastatic inline void
137210e230b6SmayaGEN5_WM_STATE_pack(__attribute__((unused)) __gen_user_data *data,
137310e230b6Smaya                   __attribute__((unused)) void * restrict dst,
137410e230b6Smaya                   __attribute__((unused)) const struct GEN5_WM_STATE * restrict values)
137510e230b6Smaya{
137610e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
137710e230b6Smaya
137810e230b6Smaya   dw[0] =
137910e230b6Smaya      __gen_uint(values->GRFRegisterCount0, 1, 3) |
138010e230b6Smaya      __gen_offset(values->KernelStartPointer0, 6, 31);
138110e230b6Smaya
138210e230b6Smaya   dw[1] =
138310e230b6Smaya      __gen_uint(values->SoftwareExceptionEnable, 1, 1) |
138410e230b6Smaya      __gen_uint(values->MaskStackExceptionEnable, 2, 2) |
138510e230b6Smaya      __gen_uint(values->IllegalOpcodeExceptionEnable, 4, 4) |
138610e230b6Smaya      __gen_uint(values->DepthCoefficientURBReadOffset, 8, 13) |
138710e230b6Smaya      __gen_uint(values->FloatingPointMode, 16, 16) |
138810e230b6Smaya      __gen_uint(values->ThreadPriority, 17, 17) |
138910e230b6Smaya      __gen_uint(values->BindingTableEntryCount, 18, 25) |
139010e230b6Smaya      __gen_uint(values->SingleProgramFlow, 31, 31);
139110e230b6Smaya
139210e230b6Smaya   const uint32_t v2 =
139310e230b6Smaya      __gen_uint(values->PerThreadScratchSpace, 0, 3);
139410e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->ScratchSpaceBasePointer, v2);
139510e230b6Smaya
139610e230b6Smaya   dw[3] =
139710e230b6Smaya      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData0, 0, 3) |
139810e230b6Smaya      __gen_uint(values->SetupURBEntryReadOffset, 4, 9) |
139910e230b6Smaya      __gen_uint(values->SetupURBEntryReadLength, 11, 16) |
140010e230b6Smaya      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
140110e230b6Smaya      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
140210e230b6Smaya
140310e230b6Smaya   const uint32_t v4 =
140410e230b6Smaya      __gen_uint(values->StatisticsEnable, 0, 0) |
140510e230b6Smaya      __gen_uint(values->SamplerCount, 2, 4);
140610e230b6Smaya   dw[4] = __gen_combine_address(data, &dw[4], values->SamplerStatePointer, v4);
140710e230b6Smaya
140810e230b6Smaya   dw[5] =
140910e230b6Smaya      __gen_uint(values->_8PixelDispatchEnable, 0, 0) |
141010e230b6Smaya      __gen_uint(values->_16PixelDispatchEnable, 1, 1) |
141110e230b6Smaya      __gen_uint(values->_32PixelDispatchEnable, 2, 2) |
141210e230b6Smaya      __gen_uint(values->Contiguous32PixelDispatchEnable, 3, 3) |
141310e230b6Smaya      __gen_uint(values->Contiguous64PixelDispatchEnable, 4, 4) |
141410e230b6Smaya      __gen_uint(values->FastSpanCoverageEnable, 6, 6) |
141510e230b6Smaya      __gen_uint(values->DepthBufferClear, 7, 7) |
141610e230b6Smaya      __gen_uint(values->DepthBufferResolveEnable, 8, 8) |
141710e230b6Smaya      __gen_uint(values->HierarchicalDepthBufferResolveEnable, 9, 9) |
141810e230b6Smaya      __gen_uint(values->LegacyGlobalDepthBiasEnable, 10, 10) |
141910e230b6Smaya      __gen_uint(values->LineStippleEnable, 11, 11) |
142010e230b6Smaya      __gen_uint(values->GlobalDepthOffsetEnable, 12, 12) |
142110e230b6Smaya      __gen_uint(values->PolygonStippleEnable, 13, 13) |
142210e230b6Smaya      __gen_uint(values->LineAntialiasingRegionWidth, 14, 15) |
142310e230b6Smaya      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 16, 17) |
142410e230b6Smaya      __gen_uint(values->EarlyDepthTestEnable, 18, 18) |
142510e230b6Smaya      __gen_uint(values->ThreadDispatchEnable, 19, 19) |
142610e230b6Smaya      __gen_uint(values->PixelShaderUsesSourceDepth, 20, 20) |
142710e230b6Smaya      __gen_uint(values->PixelShaderComputedDepth, 21, 21) |
142810e230b6Smaya      __gen_uint(values->PixelShaderKillsPixel, 22, 22) |
142910e230b6Smaya      __gen_uint(values->LegacyDiamondLineRasterization, 23, 23) |
143010e230b6Smaya      __gen_uint(values->MaximumNumberofThreads, 25, 31);
143110e230b6Smaya
143210e230b6Smaya   dw[6] =
143310e230b6Smaya      __gen_float(values->GlobalDepthOffsetConstant);
143410e230b6Smaya
143510e230b6Smaya   dw[7] =
143610e230b6Smaya      __gen_float(values->GlobalDepthOffsetScale);
143710e230b6Smaya
143810e230b6Smaya   dw[8] =
143910e230b6Smaya      __gen_uint(values->GRFRegisterCount1, 1, 3) |
144010e230b6Smaya      __gen_offset(values->KernelStartPointer1, 6, 31);
144110e230b6Smaya
144210e230b6Smaya   dw[9] =
144310e230b6Smaya      __gen_uint(values->GRFRegisterCount2, 1, 3) |
144410e230b6Smaya      __gen_offset(values->KernelStartPointer2, 6, 31);
144510e230b6Smaya
144610e230b6Smaya   dw[10] =
144710e230b6Smaya      __gen_uint(values->GRFRegisterCount3, 1, 3) |
144810e230b6Smaya      __gen_offset(values->KernelStartPointer3, 6, 31);
144910e230b6Smaya}
145010e230b6Smaya
145110e230b6Smaya#define GEN5_3DPRIMITIVE_length                6
145210e230b6Smaya#define GEN5_3DPRIMITIVE_length_bias           2
145310e230b6Smaya#define GEN5_3DPRIMITIVE_header                 \
145410e230b6Smaya   .DWordLength                         =      4,  \
145510e230b6Smaya   ._3DCommandSubOpcode                 =      0,  \
145610e230b6Smaya   ._3DCommandOpcode                    =      3,  \
145710e230b6Smaya   .CommandSubType                      =      3,  \
145810e230b6Smaya   .CommandType                         =      3
145910e230b6Smaya
146010e230b6Smayastruct GEN5_3DPRIMITIVE {
146110e230b6Smaya   uint32_t                             DWordLength;
146210e230b6Smaya   uint32_t                             IndirectVertexCount;
146310e230b6Smaya   enum GEN5_3D_Prim_Topo_Type          PrimitiveTopologyType;
146410e230b6Smaya   uint32_t                             VertexAccessType;
146510e230b6Smaya#define SEQUENTIAL                               0
146610e230b6Smaya#define RANDOM                                   1
146710e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
146810e230b6Smaya   uint32_t                             _3DCommandOpcode;
146910e230b6Smaya   uint32_t                             CommandSubType;
147010e230b6Smaya   uint32_t                             CommandType;
147110e230b6Smaya   uint32_t                             VertexCountPerInstance;
147210e230b6Smaya   uint32_t                             StartVertexLocation;
147310e230b6Smaya   uint32_t                             InstanceCount;
147410e230b6Smaya   uint32_t                             StartInstanceLocation;
147510e230b6Smaya   int32_t                              BaseVertexLocation;
147610e230b6Smaya};
147710e230b6Smaya
147810e230b6Smayastatic inline void
147910e230b6SmayaGEN5_3DPRIMITIVE_pack(__attribute__((unused)) __gen_user_data *data,
148010e230b6Smaya                      __attribute__((unused)) void * restrict dst,
148110e230b6Smaya                      __attribute__((unused)) const struct GEN5_3DPRIMITIVE * restrict values)
148210e230b6Smaya{
148310e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
148410e230b6Smaya
148510e230b6Smaya   dw[0] =
148610e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
148710e230b6Smaya      __gen_uint(values->IndirectVertexCount, 9, 9) |
148810e230b6Smaya      __gen_uint(values->PrimitiveTopologyType, 10, 14) |
148910e230b6Smaya      __gen_uint(values->VertexAccessType, 15, 15) |
149010e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
149110e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
149210e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
149310e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
149410e230b6Smaya
149510e230b6Smaya   dw[1] =
149610e230b6Smaya      __gen_uint(values->VertexCountPerInstance, 0, 31);
149710e230b6Smaya
149810e230b6Smaya   dw[2] =
149910e230b6Smaya      __gen_uint(values->StartVertexLocation, 0, 31);
150010e230b6Smaya
150110e230b6Smaya   dw[3] =
150210e230b6Smaya      __gen_uint(values->InstanceCount, 0, 31);
150310e230b6Smaya
150410e230b6Smaya   dw[4] =
150510e230b6Smaya      __gen_uint(values->StartInstanceLocation, 0, 31);
150610e230b6Smaya
150710e230b6Smaya   dw[5] =
150810e230b6Smaya      __gen_sint(values->BaseVertexLocation, 0, 31);
150910e230b6Smaya}
151010e230b6Smaya
151110e230b6Smaya#define GEN5_3DSTATE_AA_LINE_PARAMETERS_length      3
151210e230b6Smaya#define GEN5_3DSTATE_AA_LINE_PARAMETERS_length_bias      2
151310e230b6Smaya#define GEN5_3DSTATE_AA_LINE_PARAMETERS_header  \
151410e230b6Smaya   .DWordLength                         =      1,  \
151510e230b6Smaya   ._3DCommandSubOpcode                 =     10,  \
151610e230b6Smaya   ._3DCommandOpcode                    =      1,  \
151710e230b6Smaya   .CommandSubType                      =      3,  \
151810e230b6Smaya   .CommandType                         =      3
151910e230b6Smaya
152010e230b6Smayastruct GEN5_3DSTATE_AA_LINE_PARAMETERS {
152110e230b6Smaya   uint32_t                             DWordLength;
152210e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
152310e230b6Smaya   uint32_t                             _3DCommandOpcode;
152410e230b6Smaya   uint32_t                             CommandSubType;
152510e230b6Smaya   uint32_t                             CommandType;
152610e230b6Smaya   float                                AACoverageSlope;
152710e230b6Smaya   float                                AACoverageBias;
152810e230b6Smaya   float                                AACoverageEndCapSlope;
152910e230b6Smaya   float                                AACoverageEndCapBias;
153010e230b6Smaya};
153110e230b6Smaya
153210e230b6Smayastatic inline void
153310e230b6SmayaGEN5_3DSTATE_AA_LINE_PARAMETERS_pack(__attribute__((unused)) __gen_user_data *data,
153410e230b6Smaya                                     __attribute__((unused)) void * restrict dst,
153510e230b6Smaya                                     __attribute__((unused)) const struct GEN5_3DSTATE_AA_LINE_PARAMETERS * restrict values)
153610e230b6Smaya{
153710e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
153810e230b6Smaya
153910e230b6Smaya   dw[0] =
154010e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
154110e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
154210e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
154310e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
154410e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
154510e230b6Smaya
154610e230b6Smaya   dw[1] =
154710e230b6Smaya      __gen_ufixed(values->AACoverageSlope, 0, 7, 8) |
154810e230b6Smaya      __gen_ufixed(values->AACoverageBias, 16, 23, 8);
154910e230b6Smaya
155010e230b6Smaya   dw[2] =
155110e230b6Smaya      __gen_ufixed(values->AACoverageEndCapSlope, 0, 7, 8) |
155210e230b6Smaya      __gen_ufixed(values->AACoverageEndCapBias, 16, 23, 8);
155310e230b6Smaya}
155410e230b6Smaya
155510e230b6Smaya#define GEN5_3DSTATE_BINDING_TABLE_POINTERS_length      6
155610e230b6Smaya#define GEN5_3DSTATE_BINDING_TABLE_POINTERS_length_bias      2
155710e230b6Smaya#define GEN5_3DSTATE_BINDING_TABLE_POINTERS_header\
155810e230b6Smaya   .DWordLength                         =      4,  \
155910e230b6Smaya   ._3DCommandSubOpcode                 =      1,  \
156010e230b6Smaya   ._3DCommandOpcode                    =      0,  \
156110e230b6Smaya   .CommandSubType                      =      3,  \
156210e230b6Smaya   .CommandType                         =      3
156310e230b6Smaya
156410e230b6Smayastruct GEN5_3DSTATE_BINDING_TABLE_POINTERS {
156510e230b6Smaya   uint32_t                             DWordLength;
156610e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
156710e230b6Smaya   uint32_t                             _3DCommandOpcode;
156810e230b6Smaya   uint32_t                             CommandSubType;
156910e230b6Smaya   uint32_t                             CommandType;
157010e230b6Smaya   uint64_t                             PointertoVSBindingTable;
157110e230b6Smaya   uint64_t                             PointertoGSBindingTable;
157210e230b6Smaya   uint64_t                             PointertoCLIPBindingTable;
157310e230b6Smaya   uint64_t                             PointertoSFBindingTable;
157410e230b6Smaya   uint64_t                             PointertoPSBindingTable;
157510e230b6Smaya};
157610e230b6Smaya
157710e230b6Smayastatic inline void
157810e230b6SmayaGEN5_3DSTATE_BINDING_TABLE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
157910e230b6Smaya                                         __attribute__((unused)) void * restrict dst,
158010e230b6Smaya                                         __attribute__((unused)) const struct GEN5_3DSTATE_BINDING_TABLE_POINTERS * restrict values)
158110e230b6Smaya{
158210e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
158310e230b6Smaya
158410e230b6Smaya   dw[0] =
158510e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
158610e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
158710e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
158810e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
158910e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
159010e230b6Smaya
159110e230b6Smaya   dw[1] =
159210e230b6Smaya      __gen_offset(values->PointertoVSBindingTable, 5, 31);
159310e230b6Smaya
159410e230b6Smaya   dw[2] =
159510e230b6Smaya      __gen_offset(values->PointertoGSBindingTable, 5, 31);
159610e230b6Smaya
159710e230b6Smaya   dw[3] =
159810e230b6Smaya      __gen_offset(values->PointertoCLIPBindingTable, 5, 31);
159910e230b6Smaya
160010e230b6Smaya   dw[4] =
160110e230b6Smaya      __gen_offset(values->PointertoSFBindingTable, 5, 31);
160210e230b6Smaya
160310e230b6Smaya   dw[5] =
160410e230b6Smaya      __gen_offset(values->PointertoPSBindingTable, 5, 31);
160510e230b6Smaya}
160610e230b6Smaya
160710e230b6Smaya#define GEN5_3DSTATE_CLEAR_PARAMS_length       2
160810e230b6Smaya#define GEN5_3DSTATE_CLEAR_PARAMS_length_bias      2
160910e230b6Smaya#define GEN5_3DSTATE_CLEAR_PARAMS_header        \
161010e230b6Smaya   .DWordLength                         =      0,  \
161110e230b6Smaya   ._3DCommandSubOpcode                 =     16,  \
161210e230b6Smaya   ._3DCommandOpcode                    =      1,  \
161310e230b6Smaya   .CommandSubType                      =      3,  \
161410e230b6Smaya   .CommandType                         =      3
161510e230b6Smaya
161610e230b6Smayastruct GEN5_3DSTATE_CLEAR_PARAMS {
161710e230b6Smaya   uint32_t                             DWordLength;
161810e230b6Smaya   bool                                 DepthClearValueValid;
161910e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
162010e230b6Smaya   uint32_t                             _3DCommandOpcode;
162110e230b6Smaya   uint32_t                             CommandSubType;
162210e230b6Smaya   uint32_t                             CommandType;
162310e230b6Smaya   uint32_t                             DepthClearValue;
162410e230b6Smaya};
162510e230b6Smaya
162610e230b6Smayastatic inline void
162710e230b6SmayaGEN5_3DSTATE_CLEAR_PARAMS_pack(__attribute__((unused)) __gen_user_data *data,
162810e230b6Smaya                               __attribute__((unused)) void * restrict dst,
162910e230b6Smaya                               __attribute__((unused)) const struct GEN5_3DSTATE_CLEAR_PARAMS * restrict values)
163010e230b6Smaya{
163110e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
163210e230b6Smaya
163310e230b6Smaya   dw[0] =
163410e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
163510e230b6Smaya      __gen_uint(values->DepthClearValueValid, 15, 15) |
163610e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
163710e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
163810e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
163910e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
164010e230b6Smaya
164110e230b6Smaya   dw[1] =
164210e230b6Smaya      __gen_uint(values->DepthClearValue, 0, 31);
164310e230b6Smaya}
164410e230b6Smaya
164510e230b6Smaya#define GEN5_3DSTATE_CONSTANT_COLOR_length      5
164610e230b6Smaya#define GEN5_3DSTATE_CONSTANT_COLOR_length_bias      2
164710e230b6Smaya#define GEN5_3DSTATE_CONSTANT_COLOR_header      \
164810e230b6Smaya   .DWordLength                         =      3,  \
164910e230b6Smaya   ._3DCommandSubOpcode                 =      1,  \
165010e230b6Smaya   ._3DCommandOpcode                    =      1,  \
165110e230b6Smaya   .CommandSubType                      =      3,  \
165210e230b6Smaya   .CommandType                         =      3
165310e230b6Smaya
165410e230b6Smayastruct GEN5_3DSTATE_CONSTANT_COLOR {
165510e230b6Smaya   uint32_t                             DWordLength;
165610e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
165710e230b6Smaya   uint32_t                             _3DCommandOpcode;
165810e230b6Smaya   uint32_t                             CommandSubType;
165910e230b6Smaya   uint32_t                             CommandType;
166010e230b6Smaya   float                                BlendConstantColorRed;
166110e230b6Smaya   float                                BlendConstantColorGreen;
166210e230b6Smaya   float                                BlendConstantColorBlue;
166310e230b6Smaya   float                                BlendConstantColorAlpha;
166410e230b6Smaya};
166510e230b6Smaya
166610e230b6Smayastatic inline void
166710e230b6SmayaGEN5_3DSTATE_CONSTANT_COLOR_pack(__attribute__((unused)) __gen_user_data *data,
166810e230b6Smaya                                 __attribute__((unused)) void * restrict dst,
166910e230b6Smaya                                 __attribute__((unused)) const struct GEN5_3DSTATE_CONSTANT_COLOR * restrict values)
167010e230b6Smaya{
167110e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
167210e230b6Smaya
167310e230b6Smaya   dw[0] =
167410e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
167510e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
167610e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
167710e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
167810e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
167910e230b6Smaya
168010e230b6Smaya   dw[1] =
168110e230b6Smaya      __gen_float(values->BlendConstantColorRed);
168210e230b6Smaya
168310e230b6Smaya   dw[2] =
168410e230b6Smaya      __gen_float(values->BlendConstantColorGreen);
168510e230b6Smaya
168610e230b6Smaya   dw[3] =
168710e230b6Smaya      __gen_float(values->BlendConstantColorBlue);
168810e230b6Smaya
168910e230b6Smaya   dw[4] =
169010e230b6Smaya      __gen_float(values->BlendConstantColorAlpha);
169110e230b6Smaya}
169210e230b6Smaya
169310e230b6Smaya#define GEN5_3DSTATE_DEPTH_BUFFER_length       6
169410e230b6Smaya#define GEN5_3DSTATE_DEPTH_BUFFER_length_bias      2
169510e230b6Smaya#define GEN5_3DSTATE_DEPTH_BUFFER_header        \
169610e230b6Smaya   .DWordLength                         =      4,  \
169710e230b6Smaya   ._3DCommandSubOpcode                 =      5,  \
169810e230b6Smaya   ._3DCommandOpcode                    =      1,  \
169910e230b6Smaya   .CommandSubType                      =      3,  \
170010e230b6Smaya   .CommandType                         =      3
170110e230b6Smaya
170210e230b6Smayastruct GEN5_3DSTATE_DEPTH_BUFFER {
170310e230b6Smaya   uint32_t                             DWordLength;
170410e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
170510e230b6Smaya   uint32_t                             _3DCommandOpcode;
170610e230b6Smaya   uint32_t                             CommandSubType;
170710e230b6Smaya   uint32_t                             CommandType;
170810e230b6Smaya   uint32_t                             SurfacePitch;
170910e230b6Smaya   uint32_t                             SurfaceFormat;
171010e230b6Smaya#define D32_FLOAT_S8X24_UINT                     0
171110e230b6Smaya#define D32_FLOAT                                1
171210e230b6Smaya#define D24_UNORM_S8_UINT                        2
171310e230b6Smaya#define D24_UNORM_X8_UINT                        3
171410e230b6Smaya#define D16_UNORM                                5
171510e230b6Smaya   bool                                 SeparateStencilBufferEnable;
171610e230b6Smaya   bool                                 HierarchicalDepthBufferEnable;
171710e230b6Smaya   uint32_t                             SoftwareTiledRenderingMode;
171810e230b6Smaya#define NORMAL                                   0
171910e230b6Smaya#define STR1                                     1
172010e230b6Smaya#define STR2                                     3
172110e230b6Smaya   uint32_t                             TileWalk;
172210e230b6Smaya#define TILEWALK_YMAJOR                          1
172310e230b6Smaya   bool                                 TiledSurface;
172410e230b6Smaya   uint32_t                             SurfaceType;
172510e230b6Smaya#define SURFTYPE_1D                              0
172610e230b6Smaya#define SURFTYPE_2D                              1
172710e230b6Smaya#define SURFTYPE_3D                              2
172810e230b6Smaya#define SURFTYPE_CUBE                            3
172910e230b6Smaya#define SURFTYPE_NULL                            7
173010e230b6Smaya   __gen_address_type                   SurfaceBaseAddress;
173110e230b6Smaya   uint32_t                             MIPMapLayoutMode;
173210e230b6Smaya#define MIPLAYOUT_BELOW                          0
173310e230b6Smaya#define MIPLAYOUT_RIGHT                          1
173410e230b6Smaya   uint32_t                             LOD;
173510e230b6Smaya   uint32_t                             Width;
173610e230b6Smaya   uint32_t                             Height;
173710e230b6Smaya   uint32_t                             RenderTargetViewExtent;
173810e230b6Smaya   uint32_t                             MinimumArrayElement;
173910e230b6Smaya   uint32_t                             Depth;
174010e230b6Smaya   int32_t                              DepthCoordinateOffsetX;
174110e230b6Smaya   int32_t                              DepthCoordinateOffsetY;
174210e230b6Smaya};
174310e230b6Smaya
174410e230b6Smayastatic inline void
174510e230b6SmayaGEN5_3DSTATE_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
174610e230b6Smaya                               __attribute__((unused)) void * restrict dst,
174710e230b6Smaya                               __attribute__((unused)) const struct GEN5_3DSTATE_DEPTH_BUFFER * restrict values)
174810e230b6Smaya{
174910e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
175010e230b6Smaya
175110e230b6Smaya   dw[0] =
175210e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
175310e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
175410e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
175510e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
175610e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
175710e230b6Smaya
175810e230b6Smaya   dw[1] =
175910e230b6Smaya      __gen_uint(values->SurfacePitch, 0, 16) |
176010e230b6Smaya      __gen_uint(values->SurfaceFormat, 18, 20) |
176110e230b6Smaya      __gen_uint(values->SeparateStencilBufferEnable, 21, 21) |
176210e230b6Smaya      __gen_uint(values->HierarchicalDepthBufferEnable, 22, 22) |
176310e230b6Smaya      __gen_uint(values->SoftwareTiledRenderingMode, 23, 24) |
176410e230b6Smaya      __gen_uint(values->TileWalk, 26, 26) |
176510e230b6Smaya      __gen_uint(values->TiledSurface, 27, 27) |
176610e230b6Smaya      __gen_uint(values->SurfaceType, 29, 31);
176710e230b6Smaya
176810e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->SurfaceBaseAddress, 0);
176910e230b6Smaya
177010e230b6Smaya   dw[3] =
177110e230b6Smaya      __gen_uint(values->MIPMapLayoutMode, 1, 1) |
177210e230b6Smaya      __gen_uint(values->LOD, 2, 5) |
177310e230b6Smaya      __gen_uint(values->Width, 6, 18) |
177410e230b6Smaya      __gen_uint(values->Height, 19, 31);
177510e230b6Smaya
177610e230b6Smaya   dw[4] =
177710e230b6Smaya      __gen_uint(values->RenderTargetViewExtent, 1, 9) |
177810e230b6Smaya      __gen_uint(values->MinimumArrayElement, 10, 20) |
177910e230b6Smaya      __gen_uint(values->Depth, 21, 31);
178010e230b6Smaya
178110e230b6Smaya   dw[5] =
178210e230b6Smaya      __gen_sint(values->DepthCoordinateOffsetX, 0, 15) |
178310e230b6Smaya      __gen_sint(values->DepthCoordinateOffsetY, 16, 31);
178410e230b6Smaya}
178510e230b6Smaya
178610e230b6Smaya#define GEN5_3DSTATE_DRAWING_RECTANGLE_length      4
178710e230b6Smaya#define GEN5_3DSTATE_DRAWING_RECTANGLE_length_bias      2
178810e230b6Smaya#define GEN5_3DSTATE_DRAWING_RECTANGLE_header   \
178910e230b6Smaya   .DWordLength                         =      2,  \
179010e230b6Smaya   ._3DCommandSubOpcode                 =      0,  \
179110e230b6Smaya   ._3DCommandOpcode                    =      1,  \
179210e230b6Smaya   .CommandSubType                      =      3,  \
179310e230b6Smaya   .CommandType                         =      3
179410e230b6Smaya
179510e230b6Smayastruct GEN5_3DSTATE_DRAWING_RECTANGLE {
179610e230b6Smaya   uint32_t                             DWordLength;
179710e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
179810e230b6Smaya   uint32_t                             _3DCommandOpcode;
179910e230b6Smaya   uint32_t                             CommandSubType;
180010e230b6Smaya   uint32_t                             CommandType;
180110e230b6Smaya   uint32_t                             ClippedDrawingRectangleXMin;
180210e230b6Smaya   uint32_t                             ClippedDrawingRectangleYMin;
180310e230b6Smaya   uint32_t                             ClippedDrawingRectangleXMax;
180410e230b6Smaya   uint32_t                             ClippedDrawingRectangleYMax;
180510e230b6Smaya   int32_t                              DrawingRectangleOriginX;
180610e230b6Smaya   int32_t                              DrawingRectangleOriginY;
180710e230b6Smaya};
180810e230b6Smaya
180910e230b6Smayastatic inline void
181010e230b6SmayaGEN5_3DSTATE_DRAWING_RECTANGLE_pack(__attribute__((unused)) __gen_user_data *data,
181110e230b6Smaya                                    __attribute__((unused)) void * restrict dst,
181210e230b6Smaya                                    __attribute__((unused)) const struct GEN5_3DSTATE_DRAWING_RECTANGLE * restrict values)
181310e230b6Smaya{
181410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
181510e230b6Smaya
181610e230b6Smaya   dw[0] =
181710e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
181810e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
181910e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
182010e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
182110e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
182210e230b6Smaya
182310e230b6Smaya   dw[1] =
182410e230b6Smaya      __gen_uint(values->ClippedDrawingRectangleXMin, 0, 15) |
182510e230b6Smaya      __gen_uint(values->ClippedDrawingRectangleYMin, 16, 31);
182610e230b6Smaya
182710e230b6Smaya   dw[2] =
182810e230b6Smaya      __gen_uint(values->ClippedDrawingRectangleXMax, 0, 15) |
182910e230b6Smaya      __gen_uint(values->ClippedDrawingRectangleYMax, 16, 31);
183010e230b6Smaya
183110e230b6Smaya   dw[3] =
183210e230b6Smaya      __gen_sint(values->DrawingRectangleOriginX, 0, 15) |
183310e230b6Smaya      __gen_sint(values->DrawingRectangleOriginY, 16, 31);
183410e230b6Smaya}
183510e230b6Smaya
183610e230b6Smaya#define GEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length      2
183710e230b6Smaya#define GEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length_bias      2
183810e230b6Smaya#define GEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_header\
183910e230b6Smaya   .DWordLength                         =      0,  \
184010e230b6Smaya   ._3DCommandSubOpcode                 =      9,  \
184110e230b6Smaya   ._3DCommandOpcode                    =      1,  \
184210e230b6Smaya   .CommandSubType                      =      3,  \
184310e230b6Smaya   .CommandType                         =      3
184410e230b6Smaya
184510e230b6Smayastruct GEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP {
184610e230b6Smaya   uint32_t                             DWordLength;
184710e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
184810e230b6Smaya   uint32_t                             _3DCommandOpcode;
184910e230b6Smaya   uint32_t                             CommandSubType;
185010e230b6Smaya   uint32_t                             CommandType;
185110e230b6Smaya   float                                GlobalDepthOffsetClamp;
185210e230b6Smaya};
185310e230b6Smaya
185410e230b6Smayastatic inline void
185510e230b6SmayaGEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_pack(__attribute__((unused)) __gen_user_data *data,
185610e230b6Smaya                                            __attribute__((unused)) void * restrict dst,
185710e230b6Smaya                                            __attribute__((unused)) const struct GEN5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP * restrict values)
185810e230b6Smaya{
185910e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
186010e230b6Smaya
186110e230b6Smaya   dw[0] =
186210e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
186310e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
186410e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
186510e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
186610e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
186710e230b6Smaya
186810e230b6Smaya   dw[1] =
186910e230b6Smaya      __gen_float(values->GlobalDepthOffsetClamp);
187010e230b6Smaya}
187110e230b6Smaya
187210e230b6Smaya#define GEN5_3DSTATE_HIER_DEPTH_BUFFER_length      3
187310e230b6Smaya#define GEN5_3DSTATE_HIER_DEPTH_BUFFER_length_bias      2
187410e230b6Smaya#define GEN5_3DSTATE_HIER_DEPTH_BUFFER_header   \
187510e230b6Smaya   .DWordLength                         =      1,  \
187610e230b6Smaya   ._3DCommandSubOpcode                 =     15,  \
187710e230b6Smaya   ._3DCommandOpcode                    =      1,  \
187810e230b6Smaya   .CommandSubType                      =      3,  \
187910e230b6Smaya   .CommandType                         =      3
188010e230b6Smaya
188110e230b6Smayastruct GEN5_3DSTATE_HIER_DEPTH_BUFFER {
188210e230b6Smaya   uint32_t                             DWordLength;
188310e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
188410e230b6Smaya   uint32_t                             _3DCommandOpcode;
188510e230b6Smaya   uint32_t                             CommandSubType;
188610e230b6Smaya   uint32_t                             CommandType;
188710e230b6Smaya   uint32_t                             SurfacePitch;
188810e230b6Smaya   __gen_address_type                   SurfaceBaseAddress;
188910e230b6Smaya};
189010e230b6Smaya
189110e230b6Smayastatic inline void
189210e230b6SmayaGEN5_3DSTATE_HIER_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
189310e230b6Smaya                                    __attribute__((unused)) void * restrict dst,
189410e230b6Smaya                                    __attribute__((unused)) const struct GEN5_3DSTATE_HIER_DEPTH_BUFFER * restrict values)
189510e230b6Smaya{
189610e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
189710e230b6Smaya
189810e230b6Smaya   dw[0] =
189910e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
190010e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
190110e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
190210e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
190310e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
190410e230b6Smaya
190510e230b6Smaya   dw[1] =
190610e230b6Smaya      __gen_uint(values->SurfacePitch, 0, 16);
190710e230b6Smaya
190810e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->SurfaceBaseAddress, 0);
190910e230b6Smaya}
191010e230b6Smaya
191110e230b6Smaya#define GEN5_3DSTATE_INDEX_BUFFER_length       3
191210e230b6Smaya#define GEN5_3DSTATE_INDEX_BUFFER_length_bias      2
191310e230b6Smaya#define GEN5_3DSTATE_INDEX_BUFFER_header        \
191410e230b6Smaya   .DWordLength                         =      1,  \
191510e230b6Smaya   ._3DCommandSubOpcode                 =     10,  \
191610e230b6Smaya   ._3DCommandOpcode                    =      0,  \
191710e230b6Smaya   .CommandSubType                      =      3,  \
191810e230b6Smaya   .CommandType                         =      3
191910e230b6Smaya
192010e230b6Smayastruct GEN5_3DSTATE_INDEX_BUFFER {
192110e230b6Smaya   uint32_t                             DWordLength;
192210e230b6Smaya   uint32_t                             IndexFormat;
192310e230b6Smaya#define INDEX_BYTE                               0
192410e230b6Smaya#define INDEX_WORD                               1
192510e230b6Smaya#define INDEX_DWORD                              2
192610e230b6Smaya   bool                                 CutIndexEnable;
192710e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
192810e230b6Smaya   uint32_t                             _3DCommandOpcode;
192910e230b6Smaya   uint32_t                             CommandSubType;
193010e230b6Smaya   uint32_t                             CommandType;
193110e230b6Smaya   __gen_address_type                   BufferStartingAddress;
193210e230b6Smaya   __gen_address_type                   BufferEndingAddress;
193310e230b6Smaya};
193410e230b6Smaya
193510e230b6Smayastatic inline void
193610e230b6SmayaGEN5_3DSTATE_INDEX_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
193710e230b6Smaya                               __attribute__((unused)) void * restrict dst,
193810e230b6Smaya                               __attribute__((unused)) const struct GEN5_3DSTATE_INDEX_BUFFER * restrict values)
193910e230b6Smaya{
194010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
194110e230b6Smaya
194210e230b6Smaya   dw[0] =
194310e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
194410e230b6Smaya      __gen_uint(values->IndexFormat, 8, 9) |
194510e230b6Smaya      __gen_uint(values->CutIndexEnable, 10, 10) |
194610e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
194710e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
194810e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
194910e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
195010e230b6Smaya
195110e230b6Smaya   dw[1] = __gen_combine_address(data, &dw[1], values->BufferStartingAddress, 0);
195210e230b6Smaya
195310e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->BufferEndingAddress, 0);
195410e230b6Smaya}
195510e230b6Smaya
195610e230b6Smaya#define GEN5_3DSTATE_LINE_STIPPLE_length       3
195710e230b6Smaya#define GEN5_3DSTATE_LINE_STIPPLE_length_bias      2
195810e230b6Smaya#define GEN5_3DSTATE_LINE_STIPPLE_header        \
195910e230b6Smaya   .DWordLength                         =      1,  \
196010e230b6Smaya   ._3DCommandSubOpcode                 =      8,  \
196110e230b6Smaya   ._3DCommandOpcode                    =      1,  \
196210e230b6Smaya   .CommandSubType                      =      3,  \
196310e230b6Smaya   .CommandType                         =      3
196410e230b6Smaya
196510e230b6Smayastruct GEN5_3DSTATE_LINE_STIPPLE {
196610e230b6Smaya   uint32_t                             DWordLength;
196710e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
196810e230b6Smaya   uint32_t                             _3DCommandOpcode;
196910e230b6Smaya   uint32_t                             CommandSubType;
197010e230b6Smaya   uint32_t                             CommandType;
197110e230b6Smaya   uint32_t                             LineStipplePattern;
197210e230b6Smaya   uint32_t                             CurrentStippleIndex;
197310e230b6Smaya   uint32_t                             CurrentRepeatCounter;
197410e230b6Smaya   bool                                 ModifyEnable;
197510e230b6Smaya   uint32_t                             LineStippleRepeatCount;
197610e230b6Smaya   float                                LineStippleInverseRepeatCount;
197710e230b6Smaya};
197810e230b6Smaya
197910e230b6Smayastatic inline void
198010e230b6SmayaGEN5_3DSTATE_LINE_STIPPLE_pack(__attribute__((unused)) __gen_user_data *data,
198110e230b6Smaya                               __attribute__((unused)) void * restrict dst,
198210e230b6Smaya                               __attribute__((unused)) const struct GEN5_3DSTATE_LINE_STIPPLE * restrict values)
198310e230b6Smaya{
198410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
198510e230b6Smaya
198610e230b6Smaya   dw[0] =
198710e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
198810e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
198910e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
199010e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
199110e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
199210e230b6Smaya
199310e230b6Smaya   dw[1] =
199410e230b6Smaya      __gen_uint(values->LineStipplePattern, 0, 15) |
199510e230b6Smaya      __gen_uint(values->CurrentStippleIndex, 16, 19) |
199610e230b6Smaya      __gen_uint(values->CurrentRepeatCounter, 21, 29) |
199710e230b6Smaya      __gen_uint(values->ModifyEnable, 31, 31);
199810e230b6Smaya
199910e230b6Smaya   dw[2] =
200010e230b6Smaya      __gen_uint(values->LineStippleRepeatCount, 0, 8) |
200110e230b6Smaya      __gen_ufixed(values->LineStippleInverseRepeatCount, 16, 31, 13);
200210e230b6Smaya}
200310e230b6Smaya
200410e230b6Smaya#define GEN5_3DSTATE_PIPELINED_POINTERS_length      7
200510e230b6Smaya#define GEN5_3DSTATE_PIPELINED_POINTERS_length_bias      2
200610e230b6Smaya#define GEN5_3DSTATE_PIPELINED_POINTERS_header  \
200710e230b6Smaya   .DWordLength                         =      5,  \
200810e230b6Smaya   ._3DCommandSubOpcode                 =      0,  \
200910e230b6Smaya   ._3DCommandOpcode                    =      0,  \
201010e230b6Smaya   .CommandSubType                      =      3,  \
201110e230b6Smaya   .CommandType                         =      3
201210e230b6Smaya
201310e230b6Smayastruct GEN5_3DSTATE_PIPELINED_POINTERS {
201410e230b6Smaya   uint32_t                             DWordLength;
201510e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
201610e230b6Smaya   uint32_t                             _3DCommandOpcode;
201710e230b6Smaya   uint32_t                             CommandSubType;
201810e230b6Smaya   uint32_t                             CommandType;
201910e230b6Smaya   __gen_address_type                   PointertoVSState;
202010e230b6Smaya   bool                                 GSEnable;
202110e230b6Smaya   __gen_address_type                   PointertoGSState;
202210e230b6Smaya   bool                                 ClipEnable;
202310e230b6Smaya   __gen_address_type                   PointertoCLIPState;
202410e230b6Smaya   __gen_address_type                   PointertoSFState;
202510e230b6Smaya   __gen_address_type                   PointertoWMState;
202610e230b6Smaya   __gen_address_type                   PointertoColorCalcState;
202710e230b6Smaya};
202810e230b6Smaya
202910e230b6Smayastatic inline void
203010e230b6SmayaGEN5_3DSTATE_PIPELINED_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
203110e230b6Smaya                                     __attribute__((unused)) void * restrict dst,
203210e230b6Smaya                                     __attribute__((unused)) const struct GEN5_3DSTATE_PIPELINED_POINTERS * restrict values)
203310e230b6Smaya{
203410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
203510e230b6Smaya
203610e230b6Smaya   dw[0] =
203710e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
203810e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
203910e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
204010e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
204110e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
204210e230b6Smaya
204310e230b6Smaya   dw[1] = __gen_combine_address(data, &dw[1], values->PointertoVSState, 0);
204410e230b6Smaya
204510e230b6Smaya   const uint32_t v2 =
204610e230b6Smaya      __gen_uint(values->GSEnable, 0, 0);
204710e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->PointertoGSState, v2);
204810e230b6Smaya
204910e230b6Smaya   const uint32_t v3 =
205010e230b6Smaya      __gen_uint(values->ClipEnable, 0, 0);
205110e230b6Smaya   dw[3] = __gen_combine_address(data, &dw[3], values->PointertoCLIPState, v3);
205210e230b6Smaya
205310e230b6Smaya   dw[4] = __gen_combine_address(data, &dw[4], values->PointertoSFState, 0);
205410e230b6Smaya
205510e230b6Smaya   dw[5] = __gen_combine_address(data, &dw[5], values->PointertoWMState, 0);
205610e230b6Smaya
205710e230b6Smaya   dw[6] = __gen_combine_address(data, &dw[6], values->PointertoColorCalcState, 0);
205810e230b6Smaya}
205910e230b6Smaya
206010e230b6Smaya#define GEN5_3DSTATE_POLY_STIPPLE_OFFSET_length      2
206110e230b6Smaya#define GEN5_3DSTATE_POLY_STIPPLE_OFFSET_length_bias      2
206210e230b6Smaya#define GEN5_3DSTATE_POLY_STIPPLE_OFFSET_header \
206310e230b6Smaya   .DWordLength                         =      0,  \
206410e230b6Smaya   ._3DCommandSubOpcode                 =      6,  \
206510e230b6Smaya   ._3DCommandOpcode                    =      1,  \
206610e230b6Smaya   .CommandSubType                      =      3,  \
206710e230b6Smaya   .CommandType                         =      3
206810e230b6Smaya
206910e230b6Smayastruct GEN5_3DSTATE_POLY_STIPPLE_OFFSET {
207010e230b6Smaya   uint32_t                             DWordLength;
207110e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
207210e230b6Smaya   uint32_t                             _3DCommandOpcode;
207310e230b6Smaya   uint32_t                             CommandSubType;
207410e230b6Smaya   uint32_t                             CommandType;
207510e230b6Smaya   uint32_t                             PolygonStippleYOffset;
207610e230b6Smaya   uint32_t                             PolygonStippleXOffset;
207710e230b6Smaya};
207810e230b6Smaya
207910e230b6Smayastatic inline void
208010e230b6SmayaGEN5_3DSTATE_POLY_STIPPLE_OFFSET_pack(__attribute__((unused)) __gen_user_data *data,
208110e230b6Smaya                                      __attribute__((unused)) void * restrict dst,
208210e230b6Smaya                                      __attribute__((unused)) const struct GEN5_3DSTATE_POLY_STIPPLE_OFFSET * restrict values)
208310e230b6Smaya{
208410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
208510e230b6Smaya
208610e230b6Smaya   dw[0] =
208710e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
208810e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
208910e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
209010e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
209110e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
209210e230b6Smaya
209310e230b6Smaya   dw[1] =
209410e230b6Smaya      __gen_uint(values->PolygonStippleYOffset, 0, 4) |
209510e230b6Smaya      __gen_uint(values->PolygonStippleXOffset, 8, 12);
209610e230b6Smaya}
209710e230b6Smaya
209810e230b6Smaya#define GEN5_3DSTATE_POLY_STIPPLE_PATTERN_length     33
209910e230b6Smaya#define GEN5_3DSTATE_POLY_STIPPLE_PATTERN_length_bias      2
210010e230b6Smaya#define GEN5_3DSTATE_POLY_STIPPLE_PATTERN_header\
210110e230b6Smaya   .DWordLength                         =     31,  \
210210e230b6Smaya   ._3DCommandSubOpcode                 =      7,  \
210310e230b6Smaya   ._3DCommandOpcode                    =      1,  \
210410e230b6Smaya   .CommandSubType                      =      3,  \
210510e230b6Smaya   .CommandType                         =      3
210610e230b6Smaya
210710e230b6Smayastruct GEN5_3DSTATE_POLY_STIPPLE_PATTERN {
210810e230b6Smaya   uint32_t                             DWordLength;
210910e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
211010e230b6Smaya   uint32_t                             _3DCommandOpcode;
211110e230b6Smaya   uint32_t                             CommandSubType;
211210e230b6Smaya   uint32_t                             CommandType;
211310e230b6Smaya   uint32_t                             PatternRow[32];
211410e230b6Smaya};
211510e230b6Smaya
211610e230b6Smayastatic inline void
211710e230b6SmayaGEN5_3DSTATE_POLY_STIPPLE_PATTERN_pack(__attribute__((unused)) __gen_user_data *data,
211810e230b6Smaya                                       __attribute__((unused)) void * restrict dst,
211910e230b6Smaya                                       __attribute__((unused)) const struct GEN5_3DSTATE_POLY_STIPPLE_PATTERN * restrict values)
212010e230b6Smaya{
212110e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
212210e230b6Smaya
212310e230b6Smaya   dw[0] =
212410e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
212510e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
212610e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
212710e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
212810e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
212910e230b6Smaya
213010e230b6Smaya   dw[1] =
213110e230b6Smaya      __gen_uint(values->PatternRow[0], 0, 31);
213210e230b6Smaya
213310e230b6Smaya   dw[2] =
213410e230b6Smaya      __gen_uint(values->PatternRow[1], 0, 31);
213510e230b6Smaya
213610e230b6Smaya   dw[3] =
213710e230b6Smaya      __gen_uint(values->PatternRow[2], 0, 31);
213810e230b6Smaya
213910e230b6Smaya   dw[4] =
214010e230b6Smaya      __gen_uint(values->PatternRow[3], 0, 31);
214110e230b6Smaya
214210e230b6Smaya   dw[5] =
214310e230b6Smaya      __gen_uint(values->PatternRow[4], 0, 31);
214410e230b6Smaya
214510e230b6Smaya   dw[6] =
214610e230b6Smaya      __gen_uint(values->PatternRow[5], 0, 31);
214710e230b6Smaya
214810e230b6Smaya   dw[7] =
214910e230b6Smaya      __gen_uint(values->PatternRow[6], 0, 31);
215010e230b6Smaya
215110e230b6Smaya   dw[8] =
215210e230b6Smaya      __gen_uint(values->PatternRow[7], 0, 31);
215310e230b6Smaya
215410e230b6Smaya   dw[9] =
215510e230b6Smaya      __gen_uint(values->PatternRow[8], 0, 31);
215610e230b6Smaya
215710e230b6Smaya   dw[10] =
215810e230b6Smaya      __gen_uint(values->PatternRow[9], 0, 31);
215910e230b6Smaya
216010e230b6Smaya   dw[11] =
216110e230b6Smaya      __gen_uint(values->PatternRow[10], 0, 31);
216210e230b6Smaya
216310e230b6Smaya   dw[12] =
216410e230b6Smaya      __gen_uint(values->PatternRow[11], 0, 31);
216510e230b6Smaya
216610e230b6Smaya   dw[13] =
216710e230b6Smaya      __gen_uint(values->PatternRow[12], 0, 31);
216810e230b6Smaya
216910e230b6Smaya   dw[14] =
217010e230b6Smaya      __gen_uint(values->PatternRow[13], 0, 31);
217110e230b6Smaya
217210e230b6Smaya   dw[15] =
217310e230b6Smaya      __gen_uint(values->PatternRow[14], 0, 31);
217410e230b6Smaya
217510e230b6Smaya   dw[16] =
217610e230b6Smaya      __gen_uint(values->PatternRow[15], 0, 31);
217710e230b6Smaya
217810e230b6Smaya   dw[17] =
217910e230b6Smaya      __gen_uint(values->PatternRow[16], 0, 31);
218010e230b6Smaya
218110e230b6Smaya   dw[18] =
218210e230b6Smaya      __gen_uint(values->PatternRow[17], 0, 31);
218310e230b6Smaya
218410e230b6Smaya   dw[19] =
218510e230b6Smaya      __gen_uint(values->PatternRow[18], 0, 31);
218610e230b6Smaya
218710e230b6Smaya   dw[20] =
218810e230b6Smaya      __gen_uint(values->PatternRow[19], 0, 31);
218910e230b6Smaya
219010e230b6Smaya   dw[21] =
219110e230b6Smaya      __gen_uint(values->PatternRow[20], 0, 31);
219210e230b6Smaya
219310e230b6Smaya   dw[22] =
219410e230b6Smaya      __gen_uint(values->PatternRow[21], 0, 31);
219510e230b6Smaya
219610e230b6Smaya   dw[23] =
219710e230b6Smaya      __gen_uint(values->PatternRow[22], 0, 31);
219810e230b6Smaya
219910e230b6Smaya   dw[24] =
220010e230b6Smaya      __gen_uint(values->PatternRow[23], 0, 31);
220110e230b6Smaya
220210e230b6Smaya   dw[25] =
220310e230b6Smaya      __gen_uint(values->PatternRow[24], 0, 31);
220410e230b6Smaya
220510e230b6Smaya   dw[26] =
220610e230b6Smaya      __gen_uint(values->PatternRow[25], 0, 31);
220710e230b6Smaya
220810e230b6Smaya   dw[27] =
220910e230b6Smaya      __gen_uint(values->PatternRow[26], 0, 31);
221010e230b6Smaya
221110e230b6Smaya   dw[28] =
221210e230b6Smaya      __gen_uint(values->PatternRow[27], 0, 31);
221310e230b6Smaya
221410e230b6Smaya   dw[29] =
221510e230b6Smaya      __gen_uint(values->PatternRow[28], 0, 31);
221610e230b6Smaya
221710e230b6Smaya   dw[30] =
221810e230b6Smaya      __gen_uint(values->PatternRow[29], 0, 31);
221910e230b6Smaya
222010e230b6Smaya   dw[31] =
222110e230b6Smaya      __gen_uint(values->PatternRow[30], 0, 31);
222210e230b6Smaya
222310e230b6Smaya   dw[32] =
222410e230b6Smaya      __gen_uint(values->PatternRow[31], 0, 31);
222510e230b6Smaya}
222610e230b6Smaya
222710e230b6Smaya#define GEN5_3DSTATE_STENCIL_BUFFER_length      3
222810e230b6Smaya#define GEN5_3DSTATE_STENCIL_BUFFER_length_bias      2
222910e230b6Smaya#define GEN5_3DSTATE_STENCIL_BUFFER_header      \
223010e230b6Smaya   .DWordLength                         =      1,  \
223110e230b6Smaya   ._3DCommandSubOpcode                 =     14,  \
223210e230b6Smaya   ._3DCommandOpcode                    =      1,  \
223310e230b6Smaya   .CommandSubType                      =      3,  \
223410e230b6Smaya   .CommandType                         =      3
223510e230b6Smaya
223610e230b6Smayastruct GEN5_3DSTATE_STENCIL_BUFFER {
223710e230b6Smaya   uint32_t                             DWordLength;
223810e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
223910e230b6Smaya   uint32_t                             _3DCommandOpcode;
224010e230b6Smaya   uint32_t                             CommandSubType;
224110e230b6Smaya   uint32_t                             CommandType;
224210e230b6Smaya   uint32_t                             SurfacePitch;
224310e230b6Smaya   __gen_address_type                   SurfaceBaseAddress;
224410e230b6Smaya};
224510e230b6Smaya
224610e230b6Smayastatic inline void
224710e230b6SmayaGEN5_3DSTATE_STENCIL_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
224810e230b6Smaya                                 __attribute__((unused)) void * restrict dst,
224910e230b6Smaya                                 __attribute__((unused)) const struct GEN5_3DSTATE_STENCIL_BUFFER * restrict values)
225010e230b6Smaya{
225110e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
225210e230b6Smaya
225310e230b6Smaya   dw[0] =
225410e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
225510e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
225610e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
225710e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
225810e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
225910e230b6Smaya
226010e230b6Smaya   dw[1] =
226110e230b6Smaya      __gen_uint(values->SurfacePitch, 0, 16);
226210e230b6Smaya
226310e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->SurfaceBaseAddress, 0);
226410e230b6Smaya}
226510e230b6Smaya
226610e230b6Smaya#define GEN5_3DSTATE_VERTEX_BUFFERS_length_bias      2
226710e230b6Smaya#define GEN5_3DSTATE_VERTEX_BUFFERS_header      \
226810e230b6Smaya   .DWordLength                         =      3,  \
226910e230b6Smaya   ._3DCommandSubOpcode                 =      8,  \
227010e230b6Smaya   ._3DCommandOpcode                    =      0,  \
227110e230b6Smaya   .CommandSubType                      =      3,  \
227210e230b6Smaya   .CommandType                         =      3
227310e230b6Smaya
227410e230b6Smayastruct GEN5_3DSTATE_VERTEX_BUFFERS {
227510e230b6Smaya   uint32_t                             DWordLength;
227610e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
227710e230b6Smaya   uint32_t                             _3DCommandOpcode;
227810e230b6Smaya   uint32_t                             CommandSubType;
227910e230b6Smaya   uint32_t                             CommandType;
228010e230b6Smaya   /* variable length fields follow */
228110e230b6Smaya};
228210e230b6Smaya
228310e230b6Smayastatic inline void
228410e230b6SmayaGEN5_3DSTATE_VERTEX_BUFFERS_pack(__attribute__((unused)) __gen_user_data *data,
228510e230b6Smaya                                 __attribute__((unused)) void * restrict dst,
228610e230b6Smaya                                 __attribute__((unused)) const struct GEN5_3DSTATE_VERTEX_BUFFERS * restrict values)
228710e230b6Smaya{
228810e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
228910e230b6Smaya
229010e230b6Smaya   dw[0] =
229110e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
229210e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
229310e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
229410e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
229510e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
229610e230b6Smaya}
229710e230b6Smaya
229810e230b6Smaya#define GEN5_3DSTATE_VERTEX_ELEMENTS_length_bias      2
229910e230b6Smaya#define GEN5_3DSTATE_VERTEX_ELEMENTS_header     \
230010e230b6Smaya   .DWordLength                         =      1,  \
230110e230b6Smaya   ._3DCommandSubOpcode                 =      9,  \
230210e230b6Smaya   ._3DCommandOpcode                    =      0,  \
230310e230b6Smaya   .CommandSubType                      =      3,  \
230410e230b6Smaya   .CommandType                         =      3
230510e230b6Smaya
230610e230b6Smayastruct GEN5_3DSTATE_VERTEX_ELEMENTS {
230710e230b6Smaya   uint32_t                             DWordLength;
230810e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
230910e230b6Smaya   uint32_t                             _3DCommandOpcode;
231010e230b6Smaya   uint32_t                             CommandSubType;
231110e230b6Smaya   uint32_t                             CommandType;
231210e230b6Smaya   /* variable length fields follow */
231310e230b6Smaya};
231410e230b6Smaya
231510e230b6Smayastatic inline void
231610e230b6SmayaGEN5_3DSTATE_VERTEX_ELEMENTS_pack(__attribute__((unused)) __gen_user_data *data,
231710e230b6Smaya                                  __attribute__((unused)) void * restrict dst,
231810e230b6Smaya                                  __attribute__((unused)) const struct GEN5_3DSTATE_VERTEX_ELEMENTS * restrict values)
231910e230b6Smaya{
232010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
232110e230b6Smaya
232210e230b6Smaya   dw[0] =
232310e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
232410e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
232510e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
232610e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
232710e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
232810e230b6Smaya}
232910e230b6Smaya
233010e230b6Smaya#define GEN5_3DSTATE_VF_STATISTICS_length      1
233110e230b6Smaya#define GEN5_3DSTATE_VF_STATISTICS_length_bias      1
233210e230b6Smaya#define GEN5_3DSTATE_VF_STATISTICS_header       \
233310e230b6Smaya   ._3DCommandSubOpcode                 =     11,  \
233410e230b6Smaya   ._3DCommandOpcode                    =      0,  \
233510e230b6Smaya   .CommandSubType                      =      1,  \
233610e230b6Smaya   .CommandType                         =      3
233710e230b6Smaya
233810e230b6Smayastruct GEN5_3DSTATE_VF_STATISTICS {
233910e230b6Smaya   bool                                 StatisticsEnable;
234010e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
234110e230b6Smaya   uint32_t                             _3DCommandOpcode;
234210e230b6Smaya   uint32_t                             CommandSubType;
234310e230b6Smaya   uint32_t                             CommandType;
234410e230b6Smaya};
234510e230b6Smaya
234610e230b6Smayastatic inline void
234710e230b6SmayaGEN5_3DSTATE_VF_STATISTICS_pack(__attribute__((unused)) __gen_user_data *data,
234810e230b6Smaya                                __attribute__((unused)) void * restrict dst,
234910e230b6Smaya                                __attribute__((unused)) const struct GEN5_3DSTATE_VF_STATISTICS * restrict values)
235010e230b6Smaya{
235110e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
235210e230b6Smaya
235310e230b6Smaya   dw[0] =
235410e230b6Smaya      __gen_uint(values->StatisticsEnable, 0, 0) |
235510e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
235610e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
235710e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
235810e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
235910e230b6Smaya}
236010e230b6Smaya
236110e230b6Smaya#define GEN5_CONSTANT_BUFFER_length            2
236210e230b6Smaya#define GEN5_CONSTANT_BUFFER_length_bias       2
236310e230b6Smaya#define GEN5_CONSTANT_BUFFER_header             \
236410e230b6Smaya   .DWordLength                         =      0,  \
236510e230b6Smaya   ._3DCommandSubOpcode                 =      2,  \
236610e230b6Smaya   ._3DCommandOpcode                    =      0,  \
236710e230b6Smaya   .CommandSubType                      =      0,  \
236810e230b6Smaya   .CommandType                         =      3
236910e230b6Smaya
237010e230b6Smayastruct GEN5_CONSTANT_BUFFER {
237110e230b6Smaya   uint32_t                             DWordLength;
237210e230b6Smaya   bool                                 Valid;
237310e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
237410e230b6Smaya   uint32_t                             _3DCommandOpcode;
237510e230b6Smaya   uint32_t                             CommandSubType;
237610e230b6Smaya   uint32_t                             CommandType;
237710e230b6Smaya   uint32_t                             BufferLength;
237810e230b6Smaya   __gen_address_type                   BufferStartingAddress;
237910e230b6Smaya};
238010e230b6Smaya
238110e230b6Smayastatic inline void
238210e230b6SmayaGEN5_CONSTANT_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
238310e230b6Smaya                          __attribute__((unused)) void * restrict dst,
238410e230b6Smaya                          __attribute__((unused)) const struct GEN5_CONSTANT_BUFFER * restrict values)
238510e230b6Smaya{
238610e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
238710e230b6Smaya
238810e230b6Smaya   dw[0] =
238910e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
239010e230b6Smaya      __gen_uint(values->Valid, 8, 8) |
239110e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
239210e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
239310e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
239410e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
239510e230b6Smaya
239610e230b6Smaya   const uint32_t v1 =
239710e230b6Smaya      __gen_uint(values->BufferLength, 0, 5);
239810e230b6Smaya   dw[1] = __gen_combine_address(data, &dw[1], values->BufferStartingAddress, v1);
239910e230b6Smaya}
240010e230b6Smaya
240110e230b6Smaya#define GEN5_CS_URB_STATE_length               2
240210e230b6Smaya#define GEN5_CS_URB_STATE_length_bias          2
240310e230b6Smaya#define GEN5_CS_URB_STATE_header                \
240410e230b6Smaya   .DWordLength                         =      0,  \
240510e230b6Smaya   ._3DCommandSubOpcode                 =      1,  \
240610e230b6Smaya   ._3DCommandOpcode                    =      0,  \
240710e230b6Smaya   .CommandSubType                      =      0,  \
240810e230b6Smaya   .CommandType                         =      3
240910e230b6Smaya
241010e230b6Smayastruct GEN5_CS_URB_STATE {
241110e230b6Smaya   uint32_t                             DWordLength;
241210e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
241310e230b6Smaya   uint32_t                             _3DCommandOpcode;
241410e230b6Smaya   uint32_t                             CommandSubType;
241510e230b6Smaya   uint32_t                             CommandType;
241610e230b6Smaya   uint32_t                             NumberofURBEntries;
241710e230b6Smaya   uint32_t                             URBEntryAllocationSize;
241810e230b6Smaya};
241910e230b6Smaya
242010e230b6Smayastatic inline void
242110e230b6SmayaGEN5_CS_URB_STATE_pack(__attribute__((unused)) __gen_user_data *data,
242210e230b6Smaya                       __attribute__((unused)) void * restrict dst,
242310e230b6Smaya                       __attribute__((unused)) const struct GEN5_CS_URB_STATE * restrict values)
242410e230b6Smaya{
242510e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
242610e230b6Smaya
242710e230b6Smaya   dw[0] =
242810e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
242910e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
243010e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
243110e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
243210e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
243310e230b6Smaya
243410e230b6Smaya   dw[1] =
243510e230b6Smaya      __gen_uint(values->NumberofURBEntries, 0, 2) |
243610e230b6Smaya      __gen_uint(values->URBEntryAllocationSize, 4, 8);
243710e230b6Smaya}
243810e230b6Smaya
243910e230b6Smaya#define GEN5_MI_FLUSH_length                   1
244010e230b6Smaya#define GEN5_MI_FLUSH_length_bias              1
244110e230b6Smaya#define GEN5_MI_FLUSH_header                    \
244210e230b6Smaya   .MICommandOpcode                     =      4,  \
244310e230b6Smaya   .CommandType                         =      0
244410e230b6Smaya
244510e230b6Smayastruct GEN5_MI_FLUSH {
244610e230b6Smaya   uint32_t                             StateInstructionCacheInvalidate;
244710e230b6Smaya#define DontInvalidate                           0
244810e230b6Smaya#define Invalidate                               1
244910e230b6Smaya   uint32_t                             RenderCacheFlushInhibit;
245010e230b6Smaya#define Flush                                    0
245110e230b6Smaya#define DontFlush                                1
245210e230b6Smaya   uint32_t                             GlobalSnapshotCountReset;
245310e230b6Smaya#define DontReset                                0
245410e230b6Smaya#define Reset                                    1
245510e230b6Smaya   bool                                 GenericMediaStateClear;
245610e230b6Smaya   bool                                 IndirectStatePointersDisable;
245710e230b6Smaya   bool                                 ProtectedMemoryEnable;
245810e230b6Smaya   uint32_t                             MICommandOpcode;
245910e230b6Smaya   uint32_t                             CommandType;
246010e230b6Smaya};
246110e230b6Smaya
246210e230b6Smayastatic inline void
246310e230b6SmayaGEN5_MI_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
246410e230b6Smaya                   __attribute__((unused)) void * restrict dst,
246510e230b6Smaya                   __attribute__((unused)) const struct GEN5_MI_FLUSH * restrict values)
246610e230b6Smaya{
246710e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
246810e230b6Smaya
246910e230b6Smaya   dw[0] =
247010e230b6Smaya      __gen_uint(values->StateInstructionCacheInvalidate, 1, 1) |
247110e230b6Smaya      __gen_uint(values->RenderCacheFlushInhibit, 2, 2) |
247210e230b6Smaya      __gen_uint(values->GlobalSnapshotCountReset, 3, 3) |
247310e230b6Smaya      __gen_uint(values->GenericMediaStateClear, 4, 4) |
247410e230b6Smaya      __gen_uint(values->IndirectStatePointersDisable, 5, 5) |
247510e230b6Smaya      __gen_uint(values->ProtectedMemoryEnable, 6, 6) |
247610e230b6Smaya      __gen_uint(values->MICommandOpcode, 23, 28) |
247710e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
247810e230b6Smaya}
247910e230b6Smaya
248010e230b6Smaya#define GEN5_MI_LOAD_REGISTER_IMM_length       3
248110e230b6Smaya#define GEN5_MI_LOAD_REGISTER_IMM_length_bias      2
248210e230b6Smaya#define GEN5_MI_LOAD_REGISTER_IMM_header        \
248310e230b6Smaya   .DWordLength                         =      1,  \
248410e230b6Smaya   .MICommandOpcode                     =     34,  \
248510e230b6Smaya   .CommandType                         =      0
248610e230b6Smaya
248710e230b6Smayastruct GEN5_MI_LOAD_REGISTER_IMM {
248810e230b6Smaya   uint32_t                             DWordLength;
248910e230b6Smaya   uint32_t                             ByteWriteDisables;
249010e230b6Smaya   uint32_t                             MICommandOpcode;
249110e230b6Smaya   uint32_t                             CommandType;
249210e230b6Smaya   uint64_t                             RegisterOffset;
249310e230b6Smaya   uint32_t                             DataDWord;
249410e230b6Smaya   /* variable length fields follow */
249510e230b6Smaya};
249610e230b6Smaya
249710e230b6Smayastatic inline void
249810e230b6SmayaGEN5_MI_LOAD_REGISTER_IMM_pack(__attribute__((unused)) __gen_user_data *data,
249910e230b6Smaya                               __attribute__((unused)) void * restrict dst,
250010e230b6Smaya                               __attribute__((unused)) const struct GEN5_MI_LOAD_REGISTER_IMM * restrict values)
250110e230b6Smaya{
250210e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
250310e230b6Smaya
250410e230b6Smaya   dw[0] =
250510e230b6Smaya      __gen_uint(values->DWordLength, 0, 5) |
250610e230b6Smaya      __gen_uint(values->ByteWriteDisables, 8, 11) |
250710e230b6Smaya      __gen_uint(values->MICommandOpcode, 23, 28) |
250810e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
250910e230b6Smaya
251010e230b6Smaya   dw[1] =
251110e230b6Smaya      __gen_offset(values->RegisterOffset, 2, 31);
251210e230b6Smaya
251310e230b6Smaya   dw[2] =
251410e230b6Smaya      __gen_uint(values->DataDWord, 0, 31);
251510e230b6Smaya}
251610e230b6Smaya
251710e230b6Smaya#define GEN5_MI_STORE_DATA_IMM_length          5
251810e230b6Smaya#define GEN5_MI_STORE_DATA_IMM_length_bias      2
251910e230b6Smaya#define GEN5_MI_STORE_DATA_IMM_header           \
252010e230b6Smaya   .DWordLength                         =      2,  \
252110e230b6Smaya   .MICommandOpcode                     =     32,  \
252210e230b6Smaya   .CommandType                         =      0
252310e230b6Smaya
252410e230b6Smayastruct GEN5_MI_STORE_DATA_IMM {
252510e230b6Smaya   uint32_t                             DWordLength;
252610e230b6Smaya   bool                                 MemoryAddressType;
252710e230b6Smaya   uint32_t                             MICommandOpcode;
252810e230b6Smaya   uint32_t                             CommandType;
252910e230b6Smaya   __gen_address_type                   PhysicalStartAddressExtension;
253010e230b6Smaya   __gen_address_type                   Address;
253110e230b6Smaya   uint32_t                             DataDWord0;
253210e230b6Smaya   uint32_t                             DataDWord1;
253310e230b6Smaya};
253410e230b6Smaya
253510e230b6Smayastatic inline void
253610e230b6SmayaGEN5_MI_STORE_DATA_IMM_pack(__attribute__((unused)) __gen_user_data *data,
253710e230b6Smaya                            __attribute__((unused)) void * restrict dst,
253810e230b6Smaya                            __attribute__((unused)) const struct GEN5_MI_STORE_DATA_IMM * restrict values)
253910e230b6Smaya{
254010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
254110e230b6Smaya
254210e230b6Smaya   dw[0] =
254310e230b6Smaya      __gen_uint(values->DWordLength, 0, 5) |
254410e230b6Smaya      __gen_uint(values->MemoryAddressType, 22, 22) |
254510e230b6Smaya      __gen_uint(values->MICommandOpcode, 23, 28) |
254610e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
254710e230b6Smaya
254810e230b6Smaya   dw[1] = __gen_combine_address(data, &dw[1], values->PhysicalStartAddressExtension, 0);
254910e230b6Smaya
255010e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->Address, 0);
255110e230b6Smaya
255210e230b6Smaya   dw[3] =
255310e230b6Smaya      __gen_uint(values->DataDWord0, 0, 31);
255410e230b6Smaya
255510e230b6Smaya   dw[4] =
255610e230b6Smaya      __gen_uint(values->DataDWord1, 0, 31);
255710e230b6Smaya}
255810e230b6Smaya
255910e230b6Smaya#define GEN5_MI_STORE_REGISTER_MEM_length      3
256010e230b6Smaya#define GEN5_MI_STORE_REGISTER_MEM_length_bias      2
256110e230b6Smaya#define GEN5_MI_STORE_REGISTER_MEM_header       \
256210e230b6Smaya   .DWordLength                         =      1,  \
256310e230b6Smaya   .MICommandOpcode                     =     36,  \
256410e230b6Smaya   .CommandType                         =      0
256510e230b6Smaya
256610e230b6Smayastruct GEN5_MI_STORE_REGISTER_MEM {
256710e230b6Smaya   uint32_t                             DWordLength;
256810e230b6Smaya   bool                                 UseGlobalGTT;
256910e230b6Smaya   uint32_t                             MICommandOpcode;
257010e230b6Smaya   uint32_t                             CommandType;
257110e230b6Smaya   uint64_t                             RegisterAddress;
257210e230b6Smaya   __gen_address_type                   MemoryAddress;
257310e230b6Smaya};
257410e230b6Smaya
257510e230b6Smayastatic inline void
257610e230b6SmayaGEN5_MI_STORE_REGISTER_MEM_pack(__attribute__((unused)) __gen_user_data *data,
257710e230b6Smaya                                __attribute__((unused)) void * restrict dst,
257810e230b6Smaya                                __attribute__((unused)) const struct GEN5_MI_STORE_REGISTER_MEM * restrict values)
257910e230b6Smaya{
258010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
258110e230b6Smaya
258210e230b6Smaya   dw[0] =
258310e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
258410e230b6Smaya      __gen_uint(values->UseGlobalGTT, 22, 22) |
258510e230b6Smaya      __gen_uint(values->MICommandOpcode, 23, 28) |
258610e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
258710e230b6Smaya
258810e230b6Smaya   dw[1] =
258910e230b6Smaya      __gen_offset(values->RegisterAddress, 2, 25);
259010e230b6Smaya
259110e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->MemoryAddress, 0);
259210e230b6Smaya}
259310e230b6Smaya
259410e230b6Smaya#define GEN5_PIPELINE_SELECT_length            1
259510e230b6Smaya#define GEN5_PIPELINE_SELECT_length_bias       1
259610e230b6Smaya#define GEN5_PIPELINE_SELECT_header             \
259710e230b6Smaya   ._3DCommandSubOpcode                 =      4,  \
259810e230b6Smaya   ._3DCommandOpcode                    =      1,  \
259910e230b6Smaya   .CommandSubType                      =      1,  \
260010e230b6Smaya   .CommandType                         =      3
260110e230b6Smaya
260210e230b6Smayastruct GEN5_PIPELINE_SELECT {
260310e230b6Smaya   uint32_t                             PipelineSelection;
260410e230b6Smaya#define _3D                                      0
260510e230b6Smaya#define Media                                    1
260610e230b6Smaya#define GPGPU                                    2
260710e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
260810e230b6Smaya   uint32_t                             _3DCommandOpcode;
260910e230b6Smaya   uint32_t                             CommandSubType;
261010e230b6Smaya   uint32_t                             CommandType;
261110e230b6Smaya};
261210e230b6Smaya
261310e230b6Smayastatic inline void
261410e230b6SmayaGEN5_PIPELINE_SELECT_pack(__attribute__((unused)) __gen_user_data *data,
261510e230b6Smaya                          __attribute__((unused)) void * restrict dst,
261610e230b6Smaya                          __attribute__((unused)) const struct GEN5_PIPELINE_SELECT * restrict values)
261710e230b6Smaya{
261810e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
261910e230b6Smaya
262010e230b6Smaya   dw[0] =
262110e230b6Smaya      __gen_uint(values->PipelineSelection, 0, 1) |
262210e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
262310e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
262410e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
262510e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
262610e230b6Smaya}
262710e230b6Smaya
262810e230b6Smaya#define GEN5_PIPE_CONTROL_length               4
262910e230b6Smaya#define GEN5_PIPE_CONTROL_length_bias          2
263010e230b6Smaya#define GEN5_PIPE_CONTROL_header                \
263110e230b6Smaya   .DWordLength                         =      2,  \
263210e230b6Smaya   ._3DCommandSubOpcode                 =      0,  \
263310e230b6Smaya   ._3DCommandOpcode                    =      2,  \
263410e230b6Smaya   .CommandSubType                      =      3,  \
263510e230b6Smaya   .CommandType                         =      3
263610e230b6Smaya
263710e230b6Smayastruct GEN5_PIPE_CONTROL {
263810e230b6Smaya   uint32_t                             DWordLength;
263910e230b6Smaya   bool                                 NotifyEnable;
264010e230b6Smaya   bool                                 IndirectStatePointersDisable;
264110e230b6Smaya   bool                                 TextureCacheFlushEnable;
264210e230b6Smaya   bool                                 InstructionCacheInvalidateEnable;
264310e230b6Smaya   bool                                 WriteCacheFlush;
264410e230b6Smaya   bool                                 DepthStallEnable;
264510e230b6Smaya   uint32_t                             PostSyncOperation;
264610e230b6Smaya#define NoWrite                                  0
264710e230b6Smaya#define WriteImmediateData                       1
264810e230b6Smaya#define WritePSDepthCount                        2
264910e230b6Smaya#define WriteTimestamp                           3
265010e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
265110e230b6Smaya   uint32_t                             _3DCommandOpcode;
265210e230b6Smaya   uint32_t                             CommandSubType;
265310e230b6Smaya   uint32_t                             CommandType;
265410e230b6Smaya   uint32_t                             DepthCacheFlushInhibit;
265510e230b6Smaya#define Flushed                                  0
265610e230b6Smaya#define NotFlushed                               1
265710e230b6Smaya   bool                                 StallAtPixelScoreboard;
265810e230b6Smaya   uint32_t                             DestinationAddressType;
265910e230b6Smaya#define DAT_PGTT                                 0
266010e230b6Smaya#define DAT_GGTT                                 1
266110e230b6Smaya   __gen_address_type                   Address;
266210e230b6Smaya   uint64_t                             ImmediateData;
266310e230b6Smaya};
266410e230b6Smaya
266510e230b6Smayastatic inline void
266610e230b6SmayaGEN5_PIPE_CONTROL_pack(__attribute__((unused)) __gen_user_data *data,
266710e230b6Smaya                       __attribute__((unused)) void * restrict dst,
266810e230b6Smaya                       __attribute__((unused)) const struct GEN5_PIPE_CONTROL * restrict values)
266910e230b6Smaya{
267010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
267110e230b6Smaya
267210e230b6Smaya   dw[0] =
267310e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
267410e230b6Smaya      __gen_uint(values->NotifyEnable, 8, 8) |
267510e230b6Smaya      __gen_uint(values->IndirectStatePointersDisable, 9, 9) |
267610e230b6Smaya      __gen_uint(values->TextureCacheFlushEnable, 10, 10) |
267710e230b6Smaya      __gen_uint(values->InstructionCacheInvalidateEnable, 11, 11) |
267810e230b6Smaya      __gen_uint(values->WriteCacheFlush, 12, 12) |
267910e230b6Smaya      __gen_uint(values->DepthStallEnable, 13, 13) |
268010e230b6Smaya      __gen_uint(values->PostSyncOperation, 14, 15) |
268110e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
268210e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
268310e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
268410e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
268510e230b6Smaya
268610e230b6Smaya   const uint32_t v1 =
268710e230b6Smaya      __gen_uint(values->DepthCacheFlushInhibit, 0, 0) |
268810e230b6Smaya      __gen_uint(values->StallAtPixelScoreboard, 1, 1) |
268910e230b6Smaya      __gen_uint(values->DestinationAddressType, 2, 2);
269010e230b6Smaya   dw[1] = __gen_combine_address(data, &dw[1], values->Address, v1);
269110e230b6Smaya
269210e230b6Smaya   const uint64_t v2 =
269310e230b6Smaya      __gen_uint(values->ImmediateData, 0, 63);
269410e230b6Smaya   dw[2] = v2;
269510e230b6Smaya   dw[3] = v2 >> 32;
269610e230b6Smaya}
269710e230b6Smaya
269810e230b6Smaya#define GEN5_STATE_BASE_ADDRESS_length         8
269910e230b6Smaya#define GEN5_STATE_BASE_ADDRESS_length_bias      2
270010e230b6Smaya#define GEN5_STATE_BASE_ADDRESS_header          \
270110e230b6Smaya   .DWordLength                         =      6,  \
270210e230b6Smaya   ._3DCommandSubOpcode                 =      1,  \
270310e230b6Smaya   ._3DCommandOpcode                    =      1,  \
270410e230b6Smaya   .CommandSubType                      =      0,  \
270510e230b6Smaya   .CommandType                         =      3
270610e230b6Smaya
270710e230b6Smayastruct GEN5_STATE_BASE_ADDRESS {
270810e230b6Smaya   uint32_t                             DWordLength;
270910e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
271010e230b6Smaya   uint32_t                             _3DCommandOpcode;
271110e230b6Smaya   uint32_t                             CommandSubType;
271210e230b6Smaya   uint32_t                             CommandType;
271310e230b6Smaya   bool                                 GeneralStateBaseAddressModifyEnable;
271410e230b6Smaya   __gen_address_type                   GeneralStateBaseAddress;
271510e230b6Smaya   bool                                 SurfaceStateBaseAddressModifyEnable;
271610e230b6Smaya   __gen_address_type                   SurfaceStateBaseAddress;
271710e230b6Smaya   bool                                 IndirectObjectBaseAddressModifyEnable;
271810e230b6Smaya   __gen_address_type                   IndirectObjectBaseAddress;
271910e230b6Smaya   bool                                 InstructionBaseAddressModifyEnable;
272010e230b6Smaya   __gen_address_type                   InstructionBaseAddress;
272110e230b6Smaya   bool                                 GeneralStateAccessUpperBoundModifyEnable;
272210e230b6Smaya   __gen_address_type                   GeneralStateAccessUpperBound;
272310e230b6Smaya   bool                                 IndirectObjectAccessUpperBoundModifyEnable;
272410e230b6Smaya   __gen_address_type                   IndirectObjectAccessUpperBound;
272510e230b6Smaya   bool                                 InstructionAccessUpperBoundModifyEnable;
272610e230b6Smaya   __gen_address_type                   InstructionAccessUpperBound;
272710e230b6Smaya};
272810e230b6Smaya
272910e230b6Smayastatic inline void
273010e230b6SmayaGEN5_STATE_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data,
273110e230b6Smaya                             __attribute__((unused)) void * restrict dst,
273210e230b6Smaya                             __attribute__((unused)) const struct GEN5_STATE_BASE_ADDRESS * restrict values)
273310e230b6Smaya{
273410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
273510e230b6Smaya
273610e230b6Smaya   dw[0] =
273710e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
273810e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
273910e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
274010e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
274110e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
274210e230b6Smaya
274310e230b6Smaya   const uint32_t v1 =
274410e230b6Smaya      __gen_uint(values->GeneralStateBaseAddressModifyEnable, 0, 0);
274510e230b6Smaya   dw[1] = __gen_combine_address(data, &dw[1], values->GeneralStateBaseAddress, v1);
274610e230b6Smaya
274710e230b6Smaya   const uint32_t v2 =
274810e230b6Smaya      __gen_uint(values->SurfaceStateBaseAddressModifyEnable, 0, 0);
274910e230b6Smaya   dw[2] = __gen_combine_address(data, &dw[2], values->SurfaceStateBaseAddress, v2);
275010e230b6Smaya
275110e230b6Smaya   const uint32_t v3 =
275210e230b6Smaya      __gen_uint(values->IndirectObjectBaseAddressModifyEnable, 0, 0);
275310e230b6Smaya   dw[3] = __gen_combine_address(data, &dw[3], values->IndirectObjectBaseAddress, v3);
275410e230b6Smaya
275510e230b6Smaya   const uint32_t v4 =
275610e230b6Smaya      __gen_uint(values->InstructionBaseAddressModifyEnable, 0, 0);
275710e230b6Smaya   dw[4] = __gen_combine_address(data, &dw[4], values->InstructionBaseAddress, v4);
275810e230b6Smaya
275910e230b6Smaya   const uint32_t v5 =
276010e230b6Smaya      __gen_uint(values->GeneralStateAccessUpperBoundModifyEnable, 0, 0);
276110e230b6Smaya   dw[5] = __gen_combine_address(data, &dw[5], values->GeneralStateAccessUpperBound, v5);
276210e230b6Smaya
276310e230b6Smaya   const uint32_t v6 =
276410e230b6Smaya      __gen_uint(values->IndirectObjectAccessUpperBoundModifyEnable, 0, 0);
276510e230b6Smaya   dw[6] = __gen_combine_address(data, &dw[6], values->IndirectObjectAccessUpperBound, v6);
276610e230b6Smaya
276710e230b6Smaya   const uint32_t v7 =
276810e230b6Smaya      __gen_uint(values->InstructionAccessUpperBoundModifyEnable, 0, 0);
276910e230b6Smaya   dw[7] = __gen_combine_address(data, &dw[7], values->InstructionAccessUpperBound, v7);
277010e230b6Smaya}
277110e230b6Smaya
277210e230b6Smaya#define GEN5_STATE_SIP_length                  2
277310e230b6Smaya#define GEN5_STATE_SIP_length_bias             2
277410e230b6Smaya#define GEN5_STATE_SIP_header                   \
277510e230b6Smaya   .DWordLength                         =      0,  \
277610e230b6Smaya   ._3DCommandSubOpcode                 =      2,  \
277710e230b6Smaya   ._3DCommandOpcode                    =      1,  \
277810e230b6Smaya   .CommandSubType                      =      0,  \
277910e230b6Smaya   .CommandType                         =      3
278010e230b6Smaya
278110e230b6Smayastruct GEN5_STATE_SIP {
278210e230b6Smaya   uint32_t                             DWordLength;
278310e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
278410e230b6Smaya   uint32_t                             _3DCommandOpcode;
278510e230b6Smaya   uint32_t                             CommandSubType;
278610e230b6Smaya   uint32_t                             CommandType;
278710e230b6Smaya   uint64_t                             SystemInstructionPointer;
278810e230b6Smaya};
278910e230b6Smaya
279010e230b6Smayastatic inline void
279110e230b6SmayaGEN5_STATE_SIP_pack(__attribute__((unused)) __gen_user_data *data,
279210e230b6Smaya                    __attribute__((unused)) void * restrict dst,
279310e230b6Smaya                    __attribute__((unused)) const struct GEN5_STATE_SIP * restrict values)
279410e230b6Smaya{
279510e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
279610e230b6Smaya
279710e230b6Smaya   dw[0] =
279810e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
279910e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
280010e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
280110e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
280210e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
280310e230b6Smaya
280410e230b6Smaya   dw[1] =
280510e230b6Smaya      __gen_offset(values->SystemInstructionPointer, 4, 31);
280610e230b6Smaya}
280710e230b6Smaya
280810e230b6Smaya#define GEN5_URB_FENCE_length                  3
280910e230b6Smaya#define GEN5_URB_FENCE_length_bias             2
281010e230b6Smaya#define GEN5_URB_FENCE_header                   \
281110e230b6Smaya   .DWordLength                         =      1,  \
281210e230b6Smaya   ._3DCommandSubOpcode                 =      0,  \
281310e230b6Smaya   ._3DCommandOpcode                    =      0,  \
281410e230b6Smaya   .CommandSubType                      =      0,  \
281510e230b6Smaya   .CommandType                         =      3
281610e230b6Smaya
281710e230b6Smayastruct GEN5_URB_FENCE {
281810e230b6Smaya   uint32_t                             DWordLength;
281910e230b6Smaya   bool                                 VSUnitURBReallocationRequest;
282010e230b6Smaya   bool                                 GSUnitURBReallocationRequest;
282110e230b6Smaya   bool                                 CLIPUnitURBReallocationRequest;
282210e230b6Smaya   bool                                 SFUnitURBReallocationRequest;
282310e230b6Smaya   bool                                 VFEUnitURBReallocationRequest;
282410e230b6Smaya   bool                                 CSUnitURBReallocationRequest;
282510e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
282610e230b6Smaya   uint32_t                             _3DCommandOpcode;
282710e230b6Smaya   uint32_t                             CommandSubType;
282810e230b6Smaya   uint32_t                             CommandType;
282910e230b6Smaya   uint32_t                             VSFence;
283010e230b6Smaya   uint32_t                             GSFence;
283110e230b6Smaya   uint32_t                             CLIPFence;
283210e230b6Smaya   uint32_t                             SFFence;
283310e230b6Smaya   uint32_t                             VFEFence;
283410e230b6Smaya   uint32_t                             CSFence;
283510e230b6Smaya};
283610e230b6Smaya
283710e230b6Smayastatic inline void
283810e230b6SmayaGEN5_URB_FENCE_pack(__attribute__((unused)) __gen_user_data *data,
283910e230b6Smaya                    __attribute__((unused)) void * restrict dst,
284010e230b6Smaya                    __attribute__((unused)) const struct GEN5_URB_FENCE * restrict values)
284110e230b6Smaya{
284210e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
284310e230b6Smaya
284410e230b6Smaya   dw[0] =
284510e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
284610e230b6Smaya      __gen_uint(values->VSUnitURBReallocationRequest, 8, 8) |
284710e230b6Smaya      __gen_uint(values->GSUnitURBReallocationRequest, 9, 9) |
284810e230b6Smaya      __gen_uint(values->CLIPUnitURBReallocationRequest, 10, 10) |
284910e230b6Smaya      __gen_uint(values->SFUnitURBReallocationRequest, 11, 11) |
285010e230b6Smaya      __gen_uint(values->VFEUnitURBReallocationRequest, 12, 12) |
285110e230b6Smaya      __gen_uint(values->CSUnitURBReallocationRequest, 13, 13) |
285210e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
285310e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
285410e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
285510e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
285610e230b6Smaya
285710e230b6Smaya   dw[1] =
285810e230b6Smaya      __gen_uint(values->VSFence, 0, 9) |
285910e230b6Smaya      __gen_uint(values->GSFence, 10, 19) |
286010e230b6Smaya      __gen_uint(values->CLIPFence, 20, 29);
286110e230b6Smaya
286210e230b6Smaya   dw[2] =
286310e230b6Smaya      __gen_uint(values->SFFence, 0, 9) |
286410e230b6Smaya      __gen_uint(values->VFEFence, 10, 19) |
286510e230b6Smaya      __gen_uint(values->CSFence, 20, 30);
286610e230b6Smaya}
286710e230b6Smaya
286810e230b6Smaya#endif /* GEN5_PACK_H */
2869