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
3096c5ddc4Srjs#ifndef GFX5_PACK_H
3196c5ddc4Srjs#define GFX5_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
4396c5ddc4Srjs#ifndef __intel_field_functions
4496c5ddc4Srjs#define __intel_field_functions
4510e230b6Smaya
4610e230b6Smaya#ifdef NDEBUG
4710e230b6Smaya#define NDEBUG_UNUSED __attribute__((unused))
4810e230b6Smaya#else
4910e230b6Smaya#define NDEBUG_UNUSED
5010e230b6Smaya#endif
5110e230b6Smaya
5296c5ddc4Srjsunion __intel_value {
5310e230b6Smaya   float f;
5410e230b6Smaya   uint32_t dw;
5510e230b6Smaya};
5610e230b6Smaya
5796c5ddc4Srjsstatic inline __attribute__((always_inline)) uint64_t
5810e230b6Smaya__gen_mbo(uint32_t start, uint32_t end)
5910e230b6Smaya{
6010e230b6Smaya   return (~0ull >> (64 - (end - start + 1))) << start;
6110e230b6Smaya}
6210e230b6Smaya
6396c5ddc4Srjsstatic inline __attribute__((always_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
7996c5ddc4Srjsstatic inline __attribute__((always_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
9996c5ddc4Srjsstatic inline __attribute__((always_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
11296c5ddc4Srjsstatic inline __attribute__((always_inline)) uint64_t
11396c5ddc4Srjs__gen_address(__gen_user_data *data, void *location,
11496c5ddc4Srjs              __gen_address_type address, uint32_t delta,
11596c5ddc4Srjs              __attribute__((unused)) uint32_t start, uint32_t end)
11696c5ddc4Srjs{
11796c5ddc4Srjs   uint64_t addr_u64 = __gen_combine_address(data, location, address, delta);
11896c5ddc4Srjs   if (end == 31) {
11996c5ddc4Srjs      return addr_u64;
12096c5ddc4Srjs   } else if (end < 63) {
12196c5ddc4Srjs      const unsigned shift = 63 - end;
12296c5ddc4Srjs      return (addr_u64 << shift) >> shift;
12396c5ddc4Srjs   } else {
12496c5ddc4Srjs      return addr_u64;
12596c5ddc4Srjs   }
12696c5ddc4Srjs}
12796c5ddc4Srjs
12896c5ddc4Srjsstatic inline __attribute__((always_inline)) uint32_t
12910e230b6Smaya__gen_float(float v)
13010e230b6Smaya{
13110e230b6Smaya   __gen_validate_value(v);
13296c5ddc4Srjs   return ((union __intel_value) { .f = (v) }).dw;
13310e230b6Smaya}
13410e230b6Smaya
13596c5ddc4Srjsstatic inline __attribute__((always_inline)) uint64_t
13610e230b6Smaya__gen_sfixed(float v, uint32_t start, uint32_t end, uint32_t fract_bits)
13710e230b6Smaya{
13810e230b6Smaya   __gen_validate_value(v);
13910e230b6Smaya
14010e230b6Smaya   const float factor = (1 << fract_bits);
14110e230b6Smaya
14210e230b6Smaya#ifndef NDEBUG
14310e230b6Smaya   const float max = ((1 << (end - start)) - 1) / factor;
14410e230b6Smaya   const float min = -(1 << (end - start)) / factor;
14510e230b6Smaya   assert(min <= v && v <= max);
14610e230b6Smaya#endif
14710e230b6Smaya
14810e230b6Smaya   const int64_t int_val = llroundf(v * factor);
14910e230b6Smaya   const uint64_t mask = ~0ull >> (64 - (end - start + 1));
15010e230b6Smaya
15110e230b6Smaya   return (int_val & mask) << start;
15210e230b6Smaya}
15310e230b6Smaya
15496c5ddc4Srjsstatic inline __attribute__((always_inline)) uint64_t
15510e230b6Smaya__gen_ufixed(float v, uint32_t start, NDEBUG_UNUSED uint32_t end, uint32_t fract_bits)
15610e230b6Smaya{
15710e230b6Smaya   __gen_validate_value(v);
15810e230b6Smaya
15910e230b6Smaya   const float factor = (1 << fract_bits);
16010e230b6Smaya
16110e230b6Smaya#ifndef NDEBUG
16210e230b6Smaya   const float max = ((1 << (end - start + 1)) - 1) / factor;
16310e230b6Smaya   const float min = 0.0f;
16410e230b6Smaya   assert(min <= v && v <= max);
16510e230b6Smaya#endif
16610e230b6Smaya
16710e230b6Smaya   const uint64_t uint_val = llroundf(v * factor);
16810e230b6Smaya
16910e230b6Smaya   return uint_val << start;
17010e230b6Smaya}
17110e230b6Smaya
17210e230b6Smaya#ifndef __gen_address_type
17310e230b6Smaya#error #define __gen_address_type before including this file
17410e230b6Smaya#endif
17510e230b6Smaya
17610e230b6Smaya#ifndef __gen_user_data
17710e230b6Smaya#error #define __gen_combine_address before including this file
17810e230b6Smaya#endif
17910e230b6Smaya
18010e230b6Smaya#undef NDEBUG_UNUSED
18110e230b6Smaya
18210e230b6Smaya#endif
18310e230b6Smaya
18410e230b6Smaya
18596c5ddc4Srjsenum GFX5_3D_Color_Buffer_Blend_Factor {
18610e230b6Smaya   BLENDFACTOR_ONE                      =      1,
18710e230b6Smaya   BLENDFACTOR_SRC_COLOR                =      2,
18810e230b6Smaya   BLENDFACTOR_SRC_ALPHA                =      3,
18910e230b6Smaya   BLENDFACTOR_DST_ALPHA                =      4,
19010e230b6Smaya   BLENDFACTOR_DST_COLOR                =      5,
19110e230b6Smaya   BLENDFACTOR_SRC_ALPHA_SATURATE       =      6,
19210e230b6Smaya   BLENDFACTOR_CONST_COLOR              =      7,
19310e230b6Smaya   BLENDFACTOR_CONST_ALPHA              =      8,
19410e230b6Smaya   BLENDFACTOR_SRC1_COLOR               =      9,
19510e230b6Smaya   BLENDFACTOR_SRC1_ALPHA               =     10,
19610e230b6Smaya   BLENDFACTOR_ZERO                     =     17,
19710e230b6Smaya   BLENDFACTOR_INV_SRC_COLOR            =     18,
19810e230b6Smaya   BLENDFACTOR_INV_SRC_ALPHA            =     19,
19910e230b6Smaya   BLENDFACTOR_INV_DST_ALPHA            =     20,
20010e230b6Smaya   BLENDFACTOR_INV_DST_COLOR            =     21,
20110e230b6Smaya   BLENDFACTOR_INV_CONST_COLOR          =     23,
20210e230b6Smaya   BLENDFACTOR_INV_CONST_ALPHA          =     24,
20310e230b6Smaya   BLENDFACTOR_INV_SRC1_COLOR           =     25,
20410e230b6Smaya   BLENDFACTOR_INV_SRC1_ALPHA           =     26,
20510e230b6Smaya};
20610e230b6Smaya
20796c5ddc4Srjsenum GFX5_3D_Color_Buffer_Blend_Function {
20810e230b6Smaya   BLENDFUNCTION_ADD                    =      0,
20910e230b6Smaya   BLENDFUNCTION_SUBTRACT               =      1,
21010e230b6Smaya   BLENDFUNCTION_REVERSE_SUBTRACT       =      2,
21110e230b6Smaya   BLENDFUNCTION_MIN                    =      3,
21210e230b6Smaya   BLENDFUNCTION_MAX                    =      4,
21310e230b6Smaya};
21410e230b6Smaya
21596c5ddc4Srjsenum GFX5_3D_Compare_Function {
21610e230b6Smaya   COMPAREFUNCTION_ALWAYS               =      0,
21710e230b6Smaya   COMPAREFUNCTION_NEVER                =      1,
21810e230b6Smaya   COMPAREFUNCTION_LESS                 =      2,
21910e230b6Smaya   COMPAREFUNCTION_EQUAL                =      3,
22010e230b6Smaya   COMPAREFUNCTION_LEQUAL               =      4,
22110e230b6Smaya   COMPAREFUNCTION_GREATER              =      5,
22210e230b6Smaya   COMPAREFUNCTION_NOTEQUAL             =      6,
22310e230b6Smaya   COMPAREFUNCTION_GEQUAL               =      7,
22410e230b6Smaya};
22510e230b6Smaya
22696c5ddc4Srjsenum GFX5_3D_Logic_Op_Function {
22710e230b6Smaya   LOGICOP_CLEAR                        =      0,
22810e230b6Smaya   LOGICOP_NOR                          =      1,
22910e230b6Smaya   LOGICOP_AND_INVERTED                 =      2,
23010e230b6Smaya   LOGICOP_COPY_INVERTED                =      3,
23110e230b6Smaya   LOGICOP_AND_REVERSE                  =      4,
23210e230b6Smaya   LOGICOP_INVERT                       =      5,
23310e230b6Smaya   LOGICOP_XOR                          =      6,
23410e230b6Smaya   LOGICOP_NAND                         =      7,
23510e230b6Smaya   LOGICOP_AND                          =      8,
23610e230b6Smaya   LOGICOP_EQUIV                        =      9,
23710e230b6Smaya   LOGICOP_NOOP                         =     10,
23810e230b6Smaya   LOGICOP_OR_INVERTED                  =     11,
23910e230b6Smaya   LOGICOP_COPY                         =     12,
24010e230b6Smaya   LOGICOP_OR_REVERSE                   =     13,
24110e230b6Smaya   LOGICOP_OR                           =     14,
24210e230b6Smaya   LOGICOP_SET                          =     15,
24310e230b6Smaya};
24410e230b6Smaya
24596c5ddc4Srjsenum GFX5_3D_Prim_Topo_Type {
24610e230b6Smaya   _3DPRIM_POINTLIST                    =      1,
24710e230b6Smaya   _3DPRIM_LINELIST                     =      2,
24810e230b6Smaya   _3DPRIM_LINESTRIP                    =      3,
24910e230b6Smaya   _3DPRIM_TRILIST                      =      4,
25010e230b6Smaya   _3DPRIM_TRISTRIP                     =      5,
25110e230b6Smaya   _3DPRIM_TRIFAN                       =      6,
25210e230b6Smaya   _3DPRIM_QUADLIST                     =      7,
25310e230b6Smaya   _3DPRIM_QUADSTRIP                    =      8,
25410e230b6Smaya   _3DPRIM_LINELIST_ADJ                 =      9,
25510e230b6Smaya   _3DPRIM_LINESTRIP_ADJ                =     10,
25610e230b6Smaya   _3DPRIM_TRILIST_ADJ                  =     11,
25710e230b6Smaya   _3DPRIM_TRISTRIP_ADJ                 =     12,
25810e230b6Smaya   _3DPRIM_TRISTRIP_REVERSE             =     13,
25910e230b6Smaya   _3DPRIM_POLYGON                      =     14,
26010e230b6Smaya   _3DPRIM_RECTLIST                     =     15,
26110e230b6Smaya   _3DPRIM_LINELOOP                     =     16,
26210e230b6Smaya   _3DPRIM_POINTLIST_BF                 =     17,
26310e230b6Smaya   _3DPRIM_LINESTRIP_CONT               =     18,
26410e230b6Smaya   _3DPRIM_LINESTRIP_BF                 =     19,
26510e230b6Smaya   _3DPRIM_LINESTRIP_CONT_BF            =     20,
26610e230b6Smaya   _3DPRIM_TRIFAN_NOSTIPPLE             =     22,
26710e230b6Smaya};
26810e230b6Smaya
26996c5ddc4Srjsenum GFX5_3D_Stencil_Operation {
27010e230b6Smaya   STENCILOP_KEEP                       =      0,
27110e230b6Smaya   STENCILOP_ZERO                       =      1,
27210e230b6Smaya   STENCILOP_REPLACE                    =      2,
27310e230b6Smaya   STENCILOP_INCRSAT                    =      3,
27410e230b6Smaya   STENCILOP_DECRSAT                    =      4,
27510e230b6Smaya   STENCILOP_INCR                       =      5,
27610e230b6Smaya   STENCILOP_DECR                       =      6,
27710e230b6Smaya   STENCILOP_INVERT                     =      7,
27810e230b6Smaya};
27910e230b6Smaya
28096c5ddc4Srjsenum GFX5_3D_Vertex_Component_Control {
28110e230b6Smaya   VFCOMP_NOSTORE                       =      0,
28210e230b6Smaya   VFCOMP_STORE_SRC                     =      1,
28310e230b6Smaya   VFCOMP_STORE_0                       =      2,
28410e230b6Smaya   VFCOMP_STORE_1_FP                    =      3,
28510e230b6Smaya   VFCOMP_STORE_1_INT                   =      4,
28610e230b6Smaya   VFCOMP_STORE_VID                     =      5,
28710e230b6Smaya   VFCOMP_STORE_IID                     =      6,
28810e230b6Smaya   VFCOMP_STORE_PID                     =      7,
28910e230b6Smaya};
29010e230b6Smaya
29196c5ddc4Srjsenum GFX5_Texture_Coordinate_Mode {
29210e230b6Smaya   TCM_WRAP                             =      0,
29310e230b6Smaya   TCM_MIRROR                           =      1,
29410e230b6Smaya   TCM_CLAMP                            =      2,
29510e230b6Smaya   TCM_CUBE                             =      3,
29610e230b6Smaya   TCM_CLAMP_BORDER                     =      4,
29710e230b6Smaya   TCM_MIRROR_ONCE                      =      5,
29810e230b6Smaya};
29910e230b6Smaya
30096c5ddc4Srjs#define GFX5_CC_VIEWPORT_length                2
30196c5ddc4Srjsstruct GFX5_CC_VIEWPORT {
30210e230b6Smaya   float                                MinimumDepth;
30310e230b6Smaya   float                                MaximumDepth;
30410e230b6Smaya};
30510e230b6Smaya
30696c5ddc4Srjsstatic inline __attribute__((always_inline)) void
30796c5ddc4SrjsGFX5_CC_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
30810e230b6Smaya                      __attribute__((unused)) void * restrict dst,
30996c5ddc4Srjs                      __attribute__((unused)) const struct GFX5_CC_VIEWPORT * restrict values)
31010e230b6Smaya{
31110e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
31210e230b6Smaya
31310e230b6Smaya   dw[0] =
31410e230b6Smaya      __gen_float(values->MinimumDepth);
31510e230b6Smaya
31610e230b6Smaya   dw[1] =
31710e230b6Smaya      __gen_float(values->MaximumDepth);
31810e230b6Smaya}
31910e230b6Smaya
32096c5ddc4Srjs#define GFX5_CLIP_STATE_length                11
32196c5ddc4Srjsstruct GFX5_CLIP_STATE {
32210e230b6Smaya   uint32_t                             GRFRegisterCount;
32310e230b6Smaya   uint64_t                             KernelStartPointer;
32410e230b6Smaya   bool                                 SoftwareExceptionEnable;
32510e230b6Smaya   bool                                 MaskStackExceptionEnable;
32610e230b6Smaya   bool                                 IllegalOpcodeExceptionEnable;
32710e230b6Smaya   uint32_t                             FloatingPointMode;
32810e230b6Smaya#define FLOATING_POINT_MODE_IEEE754              0
32910e230b6Smaya#define FLOATING_POINT_MODE_Alternate            1
33010e230b6Smaya   uint32_t                             ThreadPriority;
33110e230b6Smaya#define NormalPriority                           0
33210e230b6Smaya#define HighPriority                             1
33310e230b6Smaya   uint32_t                             BindingTableEntryCount;
33410e230b6Smaya   bool                                 SingleProgramFlow;
33510e230b6Smaya   uint32_t                             PerThreadScratchSpace;
33610e230b6Smaya   __gen_address_type                   ScratchSpaceBasePointer;
33710e230b6Smaya   uint32_t                             DispatchGRFStartRegisterForURBData;
33810e230b6Smaya   uint32_t                             VertexURBEntryReadOffset;
33910e230b6Smaya   uint32_t                             VertexURBEntryReadLength;
34010e230b6Smaya   uint32_t                             ConstantURBEntryReadOffset;
34110e230b6Smaya   uint32_t                             ConstantURBEntryReadLength;
34210e230b6Smaya   uint32_t                             NumberofURBEntries;
34310e230b6Smaya   uint32_t                             URBEntryAllocationSize;
34410e230b6Smaya   uint32_t                             MaximumNumberofThreads;
34510e230b6Smaya   uint32_t                             ClipMode;
34610e230b6Smaya#define CLIPMODE_NORMAL                          0
34710e230b6Smaya#define CLIPMODE_ALL                             1
34810e230b6Smaya#define CLIPMODE_CLIP_NON_REJECTED               2
34910e230b6Smaya#define CLIPMODE_REJECT_ALL                      3
35010e230b6Smaya#define CLIPMODE_ACCEPT_ALL                      4
35110e230b6Smaya   uint32_t                             UserClipDistanceClipTestEnableBitmask;
35210e230b6Smaya   bool                                 UserClipFlagsMustClipEnable;
35310e230b6Smaya   bool                                 NegativeWClipTestEnable;
35410e230b6Smaya   bool                                 GuardbandClipTestEnable;
35510e230b6Smaya   bool                                 ViewportZClipTestEnable;
35610e230b6Smaya   bool                                 ViewportXYClipTestEnable;
35710e230b6Smaya   uint32_t                             VertexPositionSpace;
35810e230b6Smaya#define VPOS_NDCSPACE                            0
35910e230b6Smaya#define VPOS_SCREENSPACE                         1
36010e230b6Smaya   uint32_t                             APIMode;
36110e230b6Smaya#define APIMODE_OGL                              0
36210e230b6Smaya#define APIMODE_D3D                              1
36310e230b6Smaya   __gen_address_type                   ClipperViewportStatePointer;
36410e230b6Smaya   float                                ScreenSpaceViewportXMin;
36510e230b6Smaya   float                                ScreenSpaceViewportXMax;
36610e230b6Smaya   float                                ScreenSpaceViewportYMin;
36710e230b6Smaya   float                                ScreenSpaceViewportYMax;
36810e230b6Smaya};
36910e230b6Smaya
37096c5ddc4Srjsstatic inline __attribute__((always_inline)) void
37196c5ddc4SrjsGFX5_CLIP_STATE_pack(__attribute__((unused)) __gen_user_data *data,
37210e230b6Smaya                     __attribute__((unused)) void * restrict dst,
37396c5ddc4Srjs                     __attribute__((unused)) const struct GFX5_CLIP_STATE * restrict values)
37410e230b6Smaya{
37510e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
37610e230b6Smaya
37710e230b6Smaya   dw[0] =
37810e230b6Smaya      __gen_uint(values->GRFRegisterCount, 1, 3) |
37910e230b6Smaya      __gen_offset(values->KernelStartPointer, 6, 31);
38010e230b6Smaya
38110e230b6Smaya   dw[1] =
38210e230b6Smaya      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
38310e230b6Smaya      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
38410e230b6Smaya      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
38510e230b6Smaya      __gen_uint(values->FloatingPointMode, 16, 16) |
38610e230b6Smaya      __gen_uint(values->ThreadPriority, 17, 17) |
38710e230b6Smaya      __gen_uint(values->BindingTableEntryCount, 18, 25) |
38810e230b6Smaya      __gen_uint(values->SingleProgramFlow, 31, 31);
38910e230b6Smaya
39010e230b6Smaya   const uint32_t v2 =
39110e230b6Smaya      __gen_uint(values->PerThreadScratchSpace, 0, 3);
39296c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31);
39310e230b6Smaya
39410e230b6Smaya   dw[3] =
39510e230b6Smaya      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
39610e230b6Smaya      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
39710e230b6Smaya      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
39810e230b6Smaya      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
39910e230b6Smaya      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
40010e230b6Smaya
40110e230b6Smaya   dw[4] =
40210e230b6Smaya      __gen_uint(values->NumberofURBEntries, 11, 18) |
40310e230b6Smaya      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
40410e230b6Smaya      __gen_uint(values->MaximumNumberofThreads, 25, 30);
40510e230b6Smaya
40610e230b6Smaya   dw[5] =
40710e230b6Smaya      __gen_uint(values->ClipMode, 13, 15) |
40810e230b6Smaya      __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 16, 23) |
40910e230b6Smaya      __gen_uint(values->UserClipFlagsMustClipEnable, 24, 24) |
41010e230b6Smaya      __gen_uint(values->NegativeWClipTestEnable, 25, 25) |
41110e230b6Smaya      __gen_uint(values->GuardbandClipTestEnable, 26, 26) |
41210e230b6Smaya      __gen_uint(values->ViewportZClipTestEnable, 27, 27) |
41310e230b6Smaya      __gen_uint(values->ViewportXYClipTestEnable, 28, 28) |
41410e230b6Smaya      __gen_uint(values->VertexPositionSpace, 29, 29) |
41510e230b6Smaya      __gen_uint(values->APIMode, 30, 30);
41610e230b6Smaya
41796c5ddc4Srjs   dw[6] = __gen_address(data, &dw[6], values->ClipperViewportStatePointer, 0, 5, 31);
41810e230b6Smaya
41910e230b6Smaya   dw[7] =
42010e230b6Smaya      __gen_float(values->ScreenSpaceViewportXMin);
42110e230b6Smaya
42210e230b6Smaya   dw[8] =
42310e230b6Smaya      __gen_float(values->ScreenSpaceViewportXMax);
42410e230b6Smaya
42510e230b6Smaya   dw[9] =
42610e230b6Smaya      __gen_float(values->ScreenSpaceViewportYMin);
42710e230b6Smaya
42810e230b6Smaya   dw[10] =
42910e230b6Smaya      __gen_float(values->ScreenSpaceViewportYMax);
43010e230b6Smaya}
43110e230b6Smaya
43296c5ddc4Srjs#define GFX5_CLIP_VIEWPORT_length              4
43396c5ddc4Srjsstruct GFX5_CLIP_VIEWPORT {
43410e230b6Smaya   float                                XMinClipGuardband;
43510e230b6Smaya   float                                XMaxClipGuardband;
43610e230b6Smaya   float                                YMinClipGuardband;
43710e230b6Smaya   float                                YMaxClipGuardband;
43810e230b6Smaya};
43910e230b6Smaya
44096c5ddc4Srjsstatic inline __attribute__((always_inline)) void
44196c5ddc4SrjsGFX5_CLIP_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
44210e230b6Smaya                        __attribute__((unused)) void * restrict dst,
44396c5ddc4Srjs                        __attribute__((unused)) const struct GFX5_CLIP_VIEWPORT * restrict values)
44410e230b6Smaya{
44510e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
44610e230b6Smaya
44710e230b6Smaya   dw[0] =
44810e230b6Smaya      __gen_float(values->XMinClipGuardband);
44910e230b6Smaya
45010e230b6Smaya   dw[1] =
45110e230b6Smaya      __gen_float(values->XMaxClipGuardband);
45210e230b6Smaya
45310e230b6Smaya   dw[2] =
45410e230b6Smaya      __gen_float(values->YMinClipGuardband);
45510e230b6Smaya
45610e230b6Smaya   dw[3] =
45710e230b6Smaya      __gen_float(values->YMaxClipGuardband);
45810e230b6Smaya}
45910e230b6Smaya
46096c5ddc4Srjs#define GFX5_COLOR_CALC_STATE_length           8
46196c5ddc4Srjsstruct GFX5_COLOR_CALC_STATE {
46296c5ddc4Srjs   enum GFX5_3D_Stencil_Operation       BackfaceStencilPassDepthPassOp;
46396c5ddc4Srjs   enum GFX5_3D_Stencil_Operation       BackfaceStencilPassDepthFailOp;
46496c5ddc4Srjs   enum GFX5_3D_Stencil_Operation       BackfaceStencilFailOp;
46596c5ddc4Srjs   enum GFX5_3D_Compare_Function        BackfaceStencilTestFunction;
46610e230b6Smaya   bool                                 DoubleSidedStencilEnable;
46710e230b6Smaya   bool                                 StencilBufferWriteEnable;
46896c5ddc4Srjs   enum GFX5_3D_Stencil_Operation       StencilPassDepthPassOp;
46996c5ddc4Srjs   enum GFX5_3D_Stencil_Operation       StencilPassDepthFailOp;
47096c5ddc4Srjs   enum GFX5_3D_Stencil_Operation       StencilFailOp;
47196c5ddc4Srjs   enum GFX5_3D_Compare_Function        StencilTestFunction;
47210e230b6Smaya   bool                                 StencilTestEnable;
47310e230b6Smaya   uint32_t                             BackfaceStencilReferenceValue;
47410e230b6Smaya   uint32_t                             StencilWriteMask;
47510e230b6Smaya   uint32_t                             StencilTestMask;
47610e230b6Smaya   uint32_t                             StencilReferenceValue;
47710e230b6Smaya   bool                                 LogicOpEnable;
47810e230b6Smaya   bool                                 DepthBufferWriteEnable;
47996c5ddc4Srjs   enum GFX5_3D_Compare_Function        DepthTestFunction;
48010e230b6Smaya   bool                                 DepthTestEnable;
48110e230b6Smaya   uint32_t                             BackfaceStencilWriteMask;
48210e230b6Smaya   uint32_t                             BackfaceStencilTestMask;
48396c5ddc4Srjs   enum GFX5_3D_Compare_Function        AlphaTestFunction;
48410e230b6Smaya   bool                                 AlphaTestEnable;
48510e230b6Smaya   bool                                 ColorBufferBlendEnable;
48610e230b6Smaya   bool                                 IndependentAlphaBlendEnable;
48710e230b6Smaya   uint32_t                             AlphaTestFormat;
48810e230b6Smaya#define ALPHATEST_UNORM8                         0
48910e230b6Smaya#define ALPHATEST_FLOAT32                        1
49010e230b6Smaya   __gen_address_type                   CCViewportStatePointer;
49196c5ddc4Srjs   enum GFX5_3D_Color_Buffer_Blend_Factor DestinationAlphaBlendFactor;
49296c5ddc4Srjs   enum GFX5_3D_Color_Buffer_Blend_Factor SourceAlphaBlendFactor;
49396c5ddc4Srjs   enum GFX5_3D_Color_Buffer_Blend_Function AlphaBlendFunction;
49410e230b6Smaya   bool                                 StatisticsEnable;
49596c5ddc4Srjs   enum GFX5_3D_Logic_Op_Function       LogicOpFunction;
49610e230b6Smaya   bool                                 RoundDisableFunctionDisable;
49710e230b6Smaya   bool                                 ColorDitherEnable;
49810e230b6Smaya   bool                                 PostBlendColorClampEnable;
49910e230b6Smaya   bool                                 PreBlendColorClampEnable;
50010e230b6Smaya   uint32_t                             ColorClampRange;
50110e230b6Smaya#define COLORCLAMP_UNORM                         0
50210e230b6Smaya#define COLORCLAMP_SNORM                         1
50310e230b6Smaya#define COLORCLAMP_RTFORMAT                      2
50410e230b6Smaya   uint32_t                             YDitherOffset;
50510e230b6Smaya   uint32_t                             XDitherOffset;
50696c5ddc4Srjs   enum GFX5_3D_Color_Buffer_Blend_Factor DestinationBlendFactor;
50796c5ddc4Srjs   enum GFX5_3D_Color_Buffer_Blend_Factor SourceBlendFactor;
50896c5ddc4Srjs   enum GFX5_3D_Color_Buffer_Blend_Function ColorBlendFunction;
50910e230b6Smaya   uint32_t                             AlphaReferenceValueAsUNORM8;
51010e230b6Smaya   float                                AlphaReferenceValueAsFLOAT32;
51110e230b6Smaya};
51210e230b6Smaya
51396c5ddc4Srjsstatic inline __attribute__((always_inline)) void
51496c5ddc4SrjsGFX5_COLOR_CALC_STATE_pack(__attribute__((unused)) __gen_user_data *data,
51510e230b6Smaya                           __attribute__((unused)) void * restrict dst,
51696c5ddc4Srjs                           __attribute__((unused)) const struct GFX5_COLOR_CALC_STATE * restrict values)
51710e230b6Smaya{
51810e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
51910e230b6Smaya
52010e230b6Smaya   dw[0] =
52110e230b6Smaya      __gen_uint(values->BackfaceStencilPassDepthPassOp, 3, 5) |
52210e230b6Smaya      __gen_uint(values->BackfaceStencilPassDepthFailOp, 6, 8) |
52310e230b6Smaya      __gen_uint(values->BackfaceStencilFailOp, 9, 11) |
52410e230b6Smaya      __gen_uint(values->BackfaceStencilTestFunction, 12, 14) |
52510e230b6Smaya      __gen_uint(values->DoubleSidedStencilEnable, 15, 15) |
52610e230b6Smaya      __gen_uint(values->StencilBufferWriteEnable, 18, 18) |
52710e230b6Smaya      __gen_uint(values->StencilPassDepthPassOp, 19, 21) |
52810e230b6Smaya      __gen_uint(values->StencilPassDepthFailOp, 22, 24) |
52910e230b6Smaya      __gen_uint(values->StencilFailOp, 25, 27) |
53010e230b6Smaya      __gen_uint(values->StencilTestFunction, 28, 30) |
53110e230b6Smaya      __gen_uint(values->StencilTestEnable, 31, 31);
53210e230b6Smaya
53310e230b6Smaya   dw[1] =
53410e230b6Smaya      __gen_uint(values->BackfaceStencilReferenceValue, 0, 7) |
53510e230b6Smaya      __gen_uint(values->StencilWriteMask, 8, 15) |
53610e230b6Smaya      __gen_uint(values->StencilTestMask, 16, 23) |
53710e230b6Smaya      __gen_uint(values->StencilReferenceValue, 24, 31);
53810e230b6Smaya
53910e230b6Smaya   dw[2] =
54010e230b6Smaya      __gen_uint(values->LogicOpEnable, 0, 0) |
54110e230b6Smaya      __gen_uint(values->DepthBufferWriteEnable, 11, 11) |
54210e230b6Smaya      __gen_uint(values->DepthTestFunction, 12, 14) |
54310e230b6Smaya      __gen_uint(values->DepthTestEnable, 15, 15) |
54410e230b6Smaya      __gen_uint(values->BackfaceStencilWriteMask, 16, 23) |
54510e230b6Smaya      __gen_uint(values->BackfaceStencilTestMask, 24, 31);
54610e230b6Smaya
54710e230b6Smaya   dw[3] =
54810e230b6Smaya      __gen_uint(values->AlphaTestFunction, 8, 10) |
54910e230b6Smaya      __gen_uint(values->AlphaTestEnable, 11, 11) |
55010e230b6Smaya      __gen_uint(values->ColorBufferBlendEnable, 12, 12) |
55110e230b6Smaya      __gen_uint(values->IndependentAlphaBlendEnable, 13, 13) |
55210e230b6Smaya      __gen_uint(values->AlphaTestFormat, 15, 15);
55310e230b6Smaya
55496c5ddc4Srjs   dw[4] = __gen_address(data, &dw[4], values->CCViewportStatePointer, 0, 5, 31);
55510e230b6Smaya
55610e230b6Smaya   dw[5] =
55710e230b6Smaya      __gen_uint(values->DestinationAlphaBlendFactor, 2, 6) |
55810e230b6Smaya      __gen_uint(values->SourceAlphaBlendFactor, 7, 11) |
55910e230b6Smaya      __gen_uint(values->AlphaBlendFunction, 12, 14) |
56010e230b6Smaya      __gen_uint(values->StatisticsEnable, 15, 15) |
56110e230b6Smaya      __gen_uint(values->LogicOpFunction, 16, 19) |
56210e230b6Smaya      __gen_uint(values->RoundDisableFunctionDisable, 30, 30) |
56310e230b6Smaya      __gen_uint(values->ColorDitherEnable, 31, 31);
56410e230b6Smaya
56510e230b6Smaya   dw[6] =
56610e230b6Smaya      __gen_uint(values->PostBlendColorClampEnable, 0, 0) |
56710e230b6Smaya      __gen_uint(values->PreBlendColorClampEnable, 1, 1) |
56810e230b6Smaya      __gen_uint(values->ColorClampRange, 2, 3) |
56910e230b6Smaya      __gen_uint(values->YDitherOffset, 15, 16) |
57010e230b6Smaya      __gen_uint(values->XDitherOffset, 17, 18) |
57110e230b6Smaya      __gen_uint(values->DestinationBlendFactor, 19, 23) |
57210e230b6Smaya      __gen_uint(values->SourceBlendFactor, 24, 28) |
57310e230b6Smaya      __gen_uint(values->ColorBlendFunction, 29, 31);
57410e230b6Smaya
57510e230b6Smaya   dw[7] =
57610e230b6Smaya      __gen_uint(values->AlphaReferenceValueAsUNORM8, 0, 31) |
57710e230b6Smaya      __gen_float(values->AlphaReferenceValueAsFLOAT32);
57810e230b6Smaya}
57910e230b6Smaya
58096c5ddc4Srjs#define GFX5_GS_STATE_length                   7
58196c5ddc4Srjsstruct GFX5_GS_STATE {
58210e230b6Smaya   uint32_t                             GRFRegisterCount;
58310e230b6Smaya   uint64_t                             KernelStartPointer;
58410e230b6Smaya   bool                                 SoftwareExceptionEnable;
58510e230b6Smaya   bool                                 MaskStackExceptionEnable;
58610e230b6Smaya   bool                                 IllegalOpcodeExceptionEnable;
58710e230b6Smaya   uint32_t                             FloatingPointMode;
58810e230b6Smaya#define FLOATING_POINT_MODE_IEEE754              0
58910e230b6Smaya#define FLOATING_POINT_MODE_Alternate            1
59010e230b6Smaya   uint32_t                             BindingTableEntryCount;
59110e230b6Smaya   bool                                 SingleProgramFlow;
59210e230b6Smaya   uint32_t                             PerThreadScratchSpace;
59310e230b6Smaya   __gen_address_type                   ScratchSpaceBasePointer;
59410e230b6Smaya   uint32_t                             DispatchGRFStartRegisterForURBData;
59510e230b6Smaya   uint32_t                             VertexURBEntryReadOffset;
59610e230b6Smaya   uint32_t                             VertexURBEntryReadLength;
59710e230b6Smaya   uint32_t                             ConstantURBEntryReadOffset;
59810e230b6Smaya   uint32_t                             ConstantURBEntryReadLength;
59910e230b6Smaya   bool                                 RenderingEnabled;
60010e230b6Smaya   bool                                 SOStatisticsEnable;
60110e230b6Smaya   bool                                 GSStatisticsEnable;
60210e230b6Smaya   uint32_t                             NumberofURBEntries;
60310e230b6Smaya   uint32_t                             URBEntryAllocationSize;
60410e230b6Smaya   uint32_t                             MaximumNumberofThreads;
60510e230b6Smaya   uint32_t                             SamplerCount;
60610e230b6Smaya   __gen_address_type                   SamplerStatePointer;
60710e230b6Smaya   uint32_t                             MaximumVPIndex;
60810e230b6Smaya   bool                                 ReorderEnable;
60910e230b6Smaya};
61010e230b6Smaya
61196c5ddc4Srjsstatic inline __attribute__((always_inline)) void
61296c5ddc4SrjsGFX5_GS_STATE_pack(__attribute__((unused)) __gen_user_data *data,
61310e230b6Smaya                   __attribute__((unused)) void * restrict dst,
61496c5ddc4Srjs                   __attribute__((unused)) const struct GFX5_GS_STATE * restrict values)
61510e230b6Smaya{
61610e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
61710e230b6Smaya
61810e230b6Smaya   dw[0] =
61910e230b6Smaya      __gen_uint(values->GRFRegisterCount, 1, 3) |
62010e230b6Smaya      __gen_offset(values->KernelStartPointer, 6, 31);
62110e230b6Smaya
62210e230b6Smaya   dw[1] =
62310e230b6Smaya      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
62410e230b6Smaya      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
62510e230b6Smaya      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
62610e230b6Smaya      __gen_uint(values->FloatingPointMode, 16, 16) |
62710e230b6Smaya      __gen_uint(values->BindingTableEntryCount, 18, 25) |
62810e230b6Smaya      __gen_uint(values->SingleProgramFlow, 31, 31);
62910e230b6Smaya
63010e230b6Smaya   const uint32_t v2 =
63110e230b6Smaya      __gen_uint(values->PerThreadScratchSpace, 0, 3);
63296c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31);
63310e230b6Smaya
63410e230b6Smaya   dw[3] =
63510e230b6Smaya      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
63610e230b6Smaya      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
63710e230b6Smaya      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
63810e230b6Smaya      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
63910e230b6Smaya      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
64010e230b6Smaya
64110e230b6Smaya   dw[4] =
64210e230b6Smaya      __gen_uint(values->RenderingEnabled, 8, 8) |
64310e230b6Smaya      __gen_uint(values->SOStatisticsEnable, 9, 9) |
64410e230b6Smaya      __gen_uint(values->GSStatisticsEnable, 10, 10) |
64510e230b6Smaya      __gen_uint(values->NumberofURBEntries, 11, 18) |
64610e230b6Smaya      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
64710e230b6Smaya      __gen_uint(values->MaximumNumberofThreads, 25, 30);
64810e230b6Smaya
64910e230b6Smaya   const uint32_t v5 =
65010e230b6Smaya      __gen_uint(values->SamplerCount, 0, 2);
65196c5ddc4Srjs   dw[5] = __gen_address(data, &dw[5], values->SamplerStatePointer, v5, 5, 31);
65210e230b6Smaya
65310e230b6Smaya   dw[6] =
65410e230b6Smaya      __gen_uint(values->MaximumVPIndex, 0, 3) |
65510e230b6Smaya      __gen_uint(values->ReorderEnable, 30, 30);
65610e230b6Smaya}
65710e230b6Smaya
65896c5ddc4Srjs#define GFX5_MEMORY_OBJECT_CONTROL_STATE_length      1
65996c5ddc4Srjsstruct GFX5_MEMORY_OBJECT_CONTROL_STATE {
66010e230b6Smaya   uint32_t                             CacheabilityControl;
66110e230b6Smaya   uint32_t                             GraphicsDataTypeGFDT;
66210e230b6Smaya   bool                                 EncryptedData;
66310e230b6Smaya};
66410e230b6Smaya
66596c5ddc4Srjsstatic inline __attribute__((always_inline)) void
66696c5ddc4SrjsGFX5_MEMORY_OBJECT_CONTROL_STATE_pack(__attribute__((unused)) __gen_user_data *data,
66710e230b6Smaya                                      __attribute__((unused)) void * restrict dst,
66896c5ddc4Srjs                                      __attribute__((unused)) const struct GFX5_MEMORY_OBJECT_CONTROL_STATE * restrict values)
66910e230b6Smaya{
67010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
67110e230b6Smaya
67210e230b6Smaya   dw[0] =
67310e230b6Smaya      __gen_uint(values->CacheabilityControl, 0, 1) |
67410e230b6Smaya      __gen_uint(values->GraphicsDataTypeGFDT, 2, 2) |
67510e230b6Smaya      __gen_uint(values->EncryptedData, 3, 3);
67610e230b6Smaya}
67710e230b6Smaya
67896c5ddc4Srjs#define GFX5_RENDER_SURFACE_STATE_length       6
67996c5ddc4Srjsstruct GFX5_RENDER_SURFACE_STATE {
68010e230b6Smaya   bool                                 CubeFaceEnablePositiveZ;
68110e230b6Smaya   bool                                 CubeFaceEnableNegativeZ;
68210e230b6Smaya   bool                                 CubeFaceEnablePositiveY;
68310e230b6Smaya   bool                                 CubeFaceEnableNegativeY;
68410e230b6Smaya   bool                                 CubeFaceEnablePositiveX;
68510e230b6Smaya   bool                                 CubeFaceEnableNegativeX;
68610e230b6Smaya   uint32_t                             MediaBoundaryPixelMode;
68710e230b6Smaya#define NORMAL_MODE                              0
68810e230b6Smaya   uint32_t                             RenderCacheReadWriteMode;
68910e230b6Smaya#define WRITE_ONLY                               0
69010e230b6Smaya#define READ_WRITE                               1
69110e230b6Smaya   uint32_t                             CubeMapCornerMode;
69210e230b6Smaya#define CUBE_REPLICATE                           0
69310e230b6Smaya#define CUBE_AVERAGE                             1
69410e230b6Smaya   uint32_t                             MIPMapLayoutMode;
69510e230b6Smaya#define MIPLAYOUT_BELOW                          0
69610e230b6Smaya#define MIPLAYOUT_RIGHT                          1
69710e230b6Smaya   uint32_t                             VerticalLineStrideOffset;
69810e230b6Smaya   uint32_t                             VerticalLineStride;
69910e230b6Smaya   bool                                 ColorBlendEnable;
70010e230b6Smaya   uint32_t                             ColorBufferComponentWriteDisables;
70110e230b6Smaya#define WRITEDISABLE_ALPHA                       8
70210e230b6Smaya#define WRITEDISABLE_RED                         4
70310e230b6Smaya#define WRITEDISABLE_GREEN                       2
70410e230b6Smaya#define WRITEDISABLE_BLUE                        1
70510e230b6Smaya   uint32_t                             SurfaceFormat;
70610e230b6Smaya   uint32_t                             DataReturnFormat;
70710e230b6Smaya#define DATA_RETURN_FLOAT32                      0
70810e230b6Smaya#define DATA_RETURN_S114                         1
70910e230b6Smaya   uint32_t                             SurfaceType;
71010e230b6Smaya#define SURFTYPE_1D                              0
71110e230b6Smaya#define SURFTYPE_2D                              1
71210e230b6Smaya#define SURFTYPE_3D                              2
71310e230b6Smaya#define SURFTYPE_CUBE                            3
71410e230b6Smaya#define SURFTYPE_BUFFER                          4
71510e230b6Smaya#define SURFTYPE_NULL                            7
71610e230b6Smaya   __gen_address_type                   SurfaceBaseAddress;
71710e230b6Smaya   uint32_t                             RenderTargetRotation;
71810e230b6Smaya#define RTROTATE_0DEG                            0
71910e230b6Smaya#define RTROTATE_90DEG                           1
72010e230b6Smaya#define RTROTATE_270DEG                          3
72110e230b6Smaya   uint32_t                             MIPCountLOD;
72210e230b6Smaya   uint32_t                             Width;
72310e230b6Smaya   uint32_t                             Height;
72410e230b6Smaya   uint32_t                             TileWalk;
72510e230b6Smaya#define TILEWALK_XMAJOR                          0
72610e230b6Smaya#define TILEWALK_YMAJOR                          1
72710e230b6Smaya   uint32_t                             TiledSurface;
72810e230b6Smaya   uint32_t                             SurfacePitch;
72910e230b6Smaya   uint32_t                             Depth;
73010e230b6Smaya   uint32_t                             RenderTargetViewExtent;
73110e230b6Smaya   uint32_t                             MinimumArrayElement;
73210e230b6Smaya   uint32_t                             SurfaceMinLOD;
73310e230b6Smaya   uint32_t                             YOffset;
73410e230b6Smaya   uint32_t                             XOffset;
73510e230b6Smaya};
73610e230b6Smaya
73796c5ddc4Srjsstatic inline __attribute__((always_inline)) void
73896c5ddc4SrjsGFX5_RENDER_SURFACE_STATE_pack(__attribute__((unused)) __gen_user_data *data,
73910e230b6Smaya                               __attribute__((unused)) void * restrict dst,
74096c5ddc4Srjs                               __attribute__((unused)) const struct GFX5_RENDER_SURFACE_STATE * restrict values)
74110e230b6Smaya{
74210e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
74310e230b6Smaya
74410e230b6Smaya   dw[0] =
74510e230b6Smaya      __gen_uint(values->CubeFaceEnablePositiveZ, 0, 0) |
74610e230b6Smaya      __gen_uint(values->CubeFaceEnableNegativeZ, 1, 1) |
74710e230b6Smaya      __gen_uint(values->CubeFaceEnablePositiveY, 2, 2) |
74810e230b6Smaya      __gen_uint(values->CubeFaceEnableNegativeY, 3, 3) |
74910e230b6Smaya      __gen_uint(values->CubeFaceEnablePositiveX, 4, 4) |
75010e230b6Smaya      __gen_uint(values->CubeFaceEnableNegativeX, 5, 5) |
75110e230b6Smaya      __gen_uint(values->MediaBoundaryPixelMode, 6, 7) |
75210e230b6Smaya      __gen_uint(values->RenderCacheReadWriteMode, 8, 8) |
75310e230b6Smaya      __gen_uint(values->CubeMapCornerMode, 9, 9) |
75410e230b6Smaya      __gen_uint(values->MIPMapLayoutMode, 10, 10) |
75510e230b6Smaya      __gen_uint(values->VerticalLineStrideOffset, 11, 11) |
75610e230b6Smaya      __gen_uint(values->VerticalLineStride, 12, 12) |
75710e230b6Smaya      __gen_uint(values->ColorBlendEnable, 13, 13) |
75810e230b6Smaya      __gen_uint(values->ColorBufferComponentWriteDisables, 14, 17) |
75910e230b6Smaya      __gen_uint(values->SurfaceFormat, 18, 26) |
76010e230b6Smaya      __gen_uint(values->DataReturnFormat, 27, 27) |
76110e230b6Smaya      __gen_uint(values->SurfaceType, 29, 31);
76210e230b6Smaya
76396c5ddc4Srjs   dw[1] = __gen_address(data, &dw[1], values->SurfaceBaseAddress, 0, 0, 31);
76410e230b6Smaya
76510e230b6Smaya   dw[2] =
76610e230b6Smaya      __gen_uint(values->RenderTargetRotation, 0, 1) |
76710e230b6Smaya      __gen_uint(values->MIPCountLOD, 2, 5) |
76810e230b6Smaya      __gen_uint(values->Width, 6, 18) |
76910e230b6Smaya      __gen_uint(values->Height, 19, 31);
77010e230b6Smaya
77110e230b6Smaya   dw[3] =
77210e230b6Smaya      __gen_uint(values->TileWalk, 0, 0) |
77310e230b6Smaya      __gen_uint(values->TiledSurface, 1, 1) |
77410e230b6Smaya      __gen_uint(values->SurfacePitch, 3, 19) |
77510e230b6Smaya      __gen_uint(values->Depth, 21, 31);
77610e230b6Smaya
77710e230b6Smaya   dw[4] =
77810e230b6Smaya      __gen_uint(values->RenderTargetViewExtent, 8, 16) |
77910e230b6Smaya      __gen_uint(values->MinimumArrayElement, 17, 27) |
78010e230b6Smaya      __gen_uint(values->SurfaceMinLOD, 28, 31);
78110e230b6Smaya
78210e230b6Smaya   dw[5] =
78310e230b6Smaya      __gen_uint(values->YOffset, 20, 23) |
78410e230b6Smaya      __gen_uint(values->XOffset, 25, 31);
78510e230b6Smaya}
78610e230b6Smaya
78796c5ddc4Srjs#define GFX5_SAMPLER_BORDER_COLOR_STATE_length     12
78896c5ddc4Srjsstruct GFX5_SAMPLER_BORDER_COLOR_STATE {
78910e230b6Smaya   uint32_t                             BorderColorUnormRed;
79010e230b6Smaya   uint32_t                             BorderColorUnormGreen;
79110e230b6Smaya   uint32_t                             BorderColorUnormBlue;
79210e230b6Smaya   uint32_t                             BorderColorUnormAlpha;
79310e230b6Smaya   float                                BorderColorFloatRed;
79410e230b6Smaya   float                                BorderColorFloatGreen;
79510e230b6Smaya   float                                BorderColorFloatBlue;
79610e230b6Smaya   float                                BorderColorFloatAlpha;
79710e230b6Smaya   uint32_t                             BorderColorFloat16Red;
79810e230b6Smaya   uint32_t                             BorderColorFloat16Green;
79910e230b6Smaya   uint32_t                             BorderColorFloat16Blue;
80010e230b6Smaya   uint32_t                             BorderColorFloat16Alpha;
80110e230b6Smaya   uint32_t                             BorderColorUnorm16Red;
80210e230b6Smaya   uint32_t                             BorderColorUnorm16Green;
80310e230b6Smaya   uint32_t                             BorderColorUnorm16Blue;
80410e230b6Smaya   uint32_t                             BorderColorUnorm16Alpha;
80510e230b6Smaya   int32_t                              BorderColorSnorm16Red;
80610e230b6Smaya   int32_t                              BorderColorSnorm16Green;
80710e230b6Smaya   int32_t                              BorderColorSnorm16Blue;
80810e230b6Smaya   int32_t                              BorderColorSnorm16Alpha;
80910e230b6Smaya   int32_t                              BorderColorSnorm8Red;
81010e230b6Smaya   int32_t                              BorderColorSnorm8Green;
81110e230b6Smaya   int32_t                              BorderColorSnorm8Blue;
81210e230b6Smaya   int32_t                              BorderColorSnorm8Alpha;
81310e230b6Smaya};
81410e230b6Smaya
81596c5ddc4Srjsstatic inline __attribute__((always_inline)) void
81696c5ddc4SrjsGFX5_SAMPLER_BORDER_COLOR_STATE_pack(__attribute__((unused)) __gen_user_data *data,
81710e230b6Smaya                                     __attribute__((unused)) void * restrict dst,
81896c5ddc4Srjs                                     __attribute__((unused)) const struct GFX5_SAMPLER_BORDER_COLOR_STATE * restrict values)
81910e230b6Smaya{
82010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
82110e230b6Smaya
82210e230b6Smaya   dw[0] =
82310e230b6Smaya      __gen_uint(values->BorderColorUnormRed, 0, 7) |
82410e230b6Smaya      __gen_uint(values->BorderColorUnormGreen, 8, 15) |
82510e230b6Smaya      __gen_uint(values->BorderColorUnormBlue, 16, 23) |
82610e230b6Smaya      __gen_uint(values->BorderColorUnormAlpha, 24, 31);
82710e230b6Smaya
82810e230b6Smaya   dw[1] =
82910e230b6Smaya      __gen_float(values->BorderColorFloatRed);
83010e230b6Smaya
83110e230b6Smaya   dw[2] =
83210e230b6Smaya      __gen_float(values->BorderColorFloatGreen);
83310e230b6Smaya
83410e230b6Smaya   dw[3] =
83510e230b6Smaya      __gen_float(values->BorderColorFloatBlue);
83610e230b6Smaya
83710e230b6Smaya   dw[4] =
83810e230b6Smaya      __gen_float(values->BorderColorFloatAlpha);
83910e230b6Smaya
84010e230b6Smaya   dw[5] =
84110e230b6Smaya      __gen_uint(values->BorderColorFloat16Red, 0, 15) |
84210e230b6Smaya      __gen_uint(values->BorderColorFloat16Green, 16, 31);
84310e230b6Smaya
84410e230b6Smaya   dw[6] =
84510e230b6Smaya      __gen_uint(values->BorderColorFloat16Blue, 0, 15) |
84610e230b6Smaya      __gen_uint(values->BorderColorFloat16Alpha, 16, 31);
84710e230b6Smaya
84810e230b6Smaya   dw[7] =
84910e230b6Smaya      __gen_uint(values->BorderColorUnorm16Red, 0, 15) |
85010e230b6Smaya      __gen_uint(values->BorderColorUnorm16Green, 16, 31);
85110e230b6Smaya
85210e230b6Smaya   dw[8] =
85310e230b6Smaya      __gen_uint(values->BorderColorUnorm16Blue, 0, 15) |
85410e230b6Smaya      __gen_uint(values->BorderColorUnorm16Alpha, 16, 31);
85510e230b6Smaya
85610e230b6Smaya   dw[9] =
85710e230b6Smaya      __gen_sint(values->BorderColorSnorm16Red, 0, 15) |
85810e230b6Smaya      __gen_sint(values->BorderColorSnorm16Green, 16, 31);
85910e230b6Smaya
86010e230b6Smaya   dw[10] =
86110e230b6Smaya      __gen_sint(values->BorderColorSnorm16Blue, 0, 15) |
86210e230b6Smaya      __gen_sint(values->BorderColorSnorm16Alpha, 16, 31);
86310e230b6Smaya
86410e230b6Smaya   dw[11] =
86510e230b6Smaya      __gen_sint(values->BorderColorSnorm8Red, 0, 7) |
86610e230b6Smaya      __gen_sint(values->BorderColorSnorm8Green, 8, 15) |
86710e230b6Smaya      __gen_sint(values->BorderColorSnorm8Blue, 16, 23) |
86810e230b6Smaya      __gen_sint(values->BorderColorSnorm8Alpha, 24, 31);
86910e230b6Smaya}
87010e230b6Smaya
87196c5ddc4Srjs#define GFX5_SAMPLER_STATE_length              4
87296c5ddc4Srjsstruct GFX5_SAMPLER_STATE {
87310e230b6Smaya   uint32_t                             ShadowFunction;
87410e230b6Smaya#define PREFILTEROP_ALWAYS                       0
87510e230b6Smaya#define PREFILTEROP_NEVER                        1
87610e230b6Smaya#define PREFILTEROP_LESS                         2
87710e230b6Smaya#define PREFILTEROP_EQUAL                        3
87810e230b6Smaya#define PREFILTEROP_LEQUAL                       4
87910e230b6Smaya#define PREFILTEROP_GREATER                      5
88010e230b6Smaya#define PREFILTEROP_NOTEQUAL                     6
88110e230b6Smaya#define PREFILTEROP_GEQUAL                       7
88210e230b6Smaya   float                                TextureLODBias;
88310e230b6Smaya   uint32_t                             MinModeFilter;
88410e230b6Smaya   uint32_t                             MagModeFilter;
88510e230b6Smaya#define MAPFILTER_NEAREST                        0
88610e230b6Smaya#define MAPFILTER_LINEAR                         1
88710e230b6Smaya#define MAPFILTER_ANISOTROPIC                    2
88810e230b6Smaya#define MAPFILTER_MONO                           6
88910e230b6Smaya   uint32_t                             MipModeFilter;
89010e230b6Smaya#define MIPFILTER_NONE                           0
89110e230b6Smaya#define MIPFILTER_NEAREST                        1
89210e230b6Smaya#define MIPFILTER_LINEAR                         3
89310e230b6Smaya   float                                BaseMipLevel;
89410e230b6Smaya   bool                                 LODPreClampEnable;
89510e230b6Smaya   bool                                 SamplerDisable;
89696c5ddc4Srjs   enum GFX5_Texture_Coordinate_Mode    TCZAddressControlMode;
89796c5ddc4Srjs   enum GFX5_Texture_Coordinate_Mode    TCYAddressControlMode;
89896c5ddc4Srjs   enum GFX5_Texture_Coordinate_Mode    TCXAddressControlMode;
89910e230b6Smaya   uint32_t                             CubeSurfaceControlMode;
90010e230b6Smaya#define CUBECTRLMODE_PROGRAMMED                  0
90110e230b6Smaya#define CUBECTRLMODE_OVERRIDE                    1
90210e230b6Smaya   float                                MaxLOD;
90310e230b6Smaya   float                                MinLOD;
90410e230b6Smaya   __gen_address_type                   BorderColorPointer;
90510e230b6Smaya   bool                                 RAddressMinFilterRoundingEnable;
90610e230b6Smaya   bool                                 RAddressMagFilterRoundingEnable;
90710e230b6Smaya   bool                                 VAddressMinFilterRoundingEnable;
90810e230b6Smaya   bool                                 VAddressMagFilterRoundingEnable;
90910e230b6Smaya   bool                                 UAddressMinFilterRoundingEnable;
91010e230b6Smaya   bool                                 UAddressMagFilterRoundingEnable;
91110e230b6Smaya   uint32_t                             MaximumAnisotropy;
91210e230b6Smaya#define RATIO21                                  0
91310e230b6Smaya#define RATIO41                                  1
91410e230b6Smaya#define RATIO61                                  2
91510e230b6Smaya#define RATIO81                                  3
91610e230b6Smaya#define RATIO101                                 4
91710e230b6Smaya#define RATIO121                                 5
91810e230b6Smaya#define RATIO141                                 6
91910e230b6Smaya#define RATIO161                                 7
92010e230b6Smaya   uint32_t                             ChromaKeyMode;
92110e230b6Smaya#define KEYFILTER_KILL_ON_ANY_MATCH              0
92210e230b6Smaya#define KEYFILTER_REPLACE_BLACK                  1
92310e230b6Smaya   uint32_t                             ChromaKeyIndex;
92410e230b6Smaya   bool                                 ChromaKeyEnable;
92510e230b6Smaya   uint32_t                             MonochromeFilterWidth;
92610e230b6Smaya   uint32_t                             MonochromeFilterHeight;
92710e230b6Smaya};
92810e230b6Smaya
92996c5ddc4Srjsstatic inline __attribute__((always_inline)) void
93096c5ddc4SrjsGFX5_SAMPLER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
93110e230b6Smaya                        __attribute__((unused)) void * restrict dst,
93296c5ddc4Srjs                        __attribute__((unused)) const struct GFX5_SAMPLER_STATE * restrict values)
93310e230b6Smaya{
93410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
93510e230b6Smaya
93610e230b6Smaya   dw[0] =
93710e230b6Smaya      __gen_uint(values->ShadowFunction, 0, 2) |
93810e230b6Smaya      __gen_sfixed(values->TextureLODBias, 3, 13, 6) |
93910e230b6Smaya      __gen_uint(values->MinModeFilter, 14, 16) |
94010e230b6Smaya      __gen_uint(values->MagModeFilter, 17, 19) |
94110e230b6Smaya      __gen_uint(values->MipModeFilter, 20, 21) |
94210e230b6Smaya      __gen_ufixed(values->BaseMipLevel, 22, 26, 1) |
94310e230b6Smaya      __gen_uint(values->LODPreClampEnable, 28, 28) |
94410e230b6Smaya      __gen_uint(values->SamplerDisable, 31, 31);
94510e230b6Smaya
94610e230b6Smaya   dw[1] =
94710e230b6Smaya      __gen_uint(values->TCZAddressControlMode, 0, 2) |
94810e230b6Smaya      __gen_uint(values->TCYAddressControlMode, 3, 5) |
94910e230b6Smaya      __gen_uint(values->TCXAddressControlMode, 6, 8) |
95010e230b6Smaya      __gen_uint(values->CubeSurfaceControlMode, 9, 9) |
95110e230b6Smaya      __gen_ufixed(values->MaxLOD, 12, 21, 6) |
95210e230b6Smaya      __gen_ufixed(values->MinLOD, 22, 31, 6);
95310e230b6Smaya
95496c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->BorderColorPointer, 0, 5, 31);
95510e230b6Smaya
95610e230b6Smaya   dw[3] =
95710e230b6Smaya      __gen_uint(values->RAddressMinFilterRoundingEnable, 13, 13) |
95810e230b6Smaya      __gen_uint(values->RAddressMagFilterRoundingEnable, 14, 14) |
95910e230b6Smaya      __gen_uint(values->VAddressMinFilterRoundingEnable, 15, 15) |
96010e230b6Smaya      __gen_uint(values->VAddressMagFilterRoundingEnable, 16, 16) |
96110e230b6Smaya      __gen_uint(values->UAddressMinFilterRoundingEnable, 17, 17) |
96210e230b6Smaya      __gen_uint(values->UAddressMagFilterRoundingEnable, 18, 18) |
96310e230b6Smaya      __gen_uint(values->MaximumAnisotropy, 19, 21) |
96410e230b6Smaya      __gen_uint(values->ChromaKeyMode, 22, 22) |
96510e230b6Smaya      __gen_uint(values->ChromaKeyIndex, 23, 24) |
96610e230b6Smaya      __gen_uint(values->ChromaKeyEnable, 25, 25) |
96710e230b6Smaya      __gen_uint(values->MonochromeFilterWidth, 26, 28) |
96810e230b6Smaya      __gen_uint(values->MonochromeFilterHeight, 29, 31);
96910e230b6Smaya}
97010e230b6Smaya
97196c5ddc4Srjs#define GFX5_SCISSOR_RECT_length               2
97296c5ddc4Srjsstruct GFX5_SCISSOR_RECT {
97310e230b6Smaya   uint32_t                             ScissorRectangleXMin;
97410e230b6Smaya   uint32_t                             ScissorRectangleYMin;
97510e230b6Smaya   uint32_t                             ScissorRectangleXMax;
97610e230b6Smaya   uint32_t                             ScissorRectangleYMax;
97710e230b6Smaya};
97810e230b6Smaya
97996c5ddc4Srjsstatic inline __attribute__((always_inline)) void
98096c5ddc4SrjsGFX5_SCISSOR_RECT_pack(__attribute__((unused)) __gen_user_data *data,
98110e230b6Smaya                       __attribute__((unused)) void * restrict dst,
98296c5ddc4Srjs                       __attribute__((unused)) const struct GFX5_SCISSOR_RECT * restrict values)
98310e230b6Smaya{
98410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
98510e230b6Smaya
98610e230b6Smaya   dw[0] =
98710e230b6Smaya      __gen_uint(values->ScissorRectangleXMin, 0, 15) |
98810e230b6Smaya      __gen_uint(values->ScissorRectangleYMin, 16, 31);
98910e230b6Smaya
99010e230b6Smaya   dw[1] =
99110e230b6Smaya      __gen_uint(values->ScissorRectangleXMax, 0, 15) |
99210e230b6Smaya      __gen_uint(values->ScissorRectangleYMax, 16, 31);
99310e230b6Smaya}
99410e230b6Smaya
99596c5ddc4Srjs#define GFX5_SF_STATE_length                   8
99696c5ddc4Srjsstruct GFX5_SF_STATE {
99710e230b6Smaya   uint32_t                             GRFRegisterCount;
99810e230b6Smaya   uint64_t                             KernelStartPointer;
99910e230b6Smaya   bool                                 SoftwareExceptionEnable;
100010e230b6Smaya   bool                                 MaskStackExceptionEnable;
100110e230b6Smaya   bool                                 IllegalOpcodeExceptionEnable;
100210e230b6Smaya   uint32_t                             FloatingPointMode;
100310e230b6Smaya#define FLOATING_POINT_MODE_IEEE754              0
100410e230b6Smaya#define FLOATING_POINT_MODE_Alternate            1
100510e230b6Smaya   uint32_t                             ThreadPriority;
100610e230b6Smaya#define NormalPriority                           0
100710e230b6Smaya#define HighPriority                             1
100810e230b6Smaya   uint32_t                             BindingTableEntryCount;
100910e230b6Smaya   bool                                 SingleProgramFlow;
101010e230b6Smaya   uint32_t                             PerThreadScratchSpace;
101110e230b6Smaya   __gen_address_type                   ScratchSpaceBasePointer;
101210e230b6Smaya   uint32_t                             DispatchGRFStartRegisterForURBData;
101310e230b6Smaya   uint32_t                             VertexURBEntryReadOffset;
101410e230b6Smaya   uint32_t                             VertexURBEntryReadLength;
101510e230b6Smaya   uint32_t                             ConstantURBEntryReadOffset;
101610e230b6Smaya   uint32_t                             ConstantURBEntryReadLength;
101710e230b6Smaya   uint32_t                             NumberofURBEntries;
101810e230b6Smaya   uint32_t                             URBEntryAllocationSize;
101910e230b6Smaya   uint32_t                             MaximumNumberofThreads;
102010e230b6Smaya   uint32_t                             FrontWinding;
102110e230b6Smaya#define FRONTWINDING_CW                          0
102210e230b6Smaya#define FRONTWINDING_CCW                         1
102310e230b6Smaya   bool                                 ViewportTransformEnable;
102410e230b6Smaya   __gen_address_type                   SetupViewportStateOffset;
102510e230b6Smaya   float                                DestinationOriginVerticalBias;
102610e230b6Smaya   float                                DestinationOriginHorizontalBias;
102710e230b6Smaya   bool                                 ScissorRectangleEnable;
102810e230b6Smaya   bool                                 _2x2PixelTriangleFilterDisable;
102910e230b6Smaya   bool                                 ZeroPixelTriangleFilterDisable;
103010e230b6Smaya   uint32_t                             PointRasterizationRule;
103110e230b6Smaya#define RASTRULE_UPPER_LEFT                      0
103210e230b6Smaya#define RASTRULE_UPPER_RIGHT                     1
103310e230b6Smaya   uint32_t                             LineEndCapAntialiasingRegionWidth;
103410e230b6Smaya#define _05pixels                                0
103510e230b6Smaya#define _10pixels                                1
103610e230b6Smaya#define _20pixels                                2
103710e230b6Smaya#define _40pixels                                3
103810e230b6Smaya   float                                LineWidth;
103910e230b6Smaya   bool                                 FastScissorClipDisable;
104010e230b6Smaya   uint32_t                             CullMode;
104110e230b6Smaya#define CULLMODE_BOTH                            0
104210e230b6Smaya#define CULLMODE_NONE                            1
104310e230b6Smaya#define CULLMODE_FRONT                           2
104410e230b6Smaya#define CULLMODE_BACK                            3
104596c5ddc4Srjs   bool                                 AntialiasingEnable;
104610e230b6Smaya   float                                PointWidth;
104710e230b6Smaya   uint32_t                             PointWidthSource;
104810e230b6Smaya#define Vertex                                   0
104910e230b6Smaya#define State                                    1
105010e230b6Smaya   uint32_t                             VertexSubPixelPrecisionSelect;
105110e230b6Smaya#define _8SubPixelPrecisionBits                  0
105210e230b6Smaya#define _4SubPixelPrecisionBits                  1
105310e230b6Smaya   bool                                 SpritePointEnable;
105410e230b6Smaya   uint32_t                             AALineDistanceMode;
105510e230b6Smaya#define AALINEDISTANCE_MANHATTAN                 0
105610e230b6Smaya#define AALINEDISTANCE_TRUE                      1
105710e230b6Smaya   uint32_t                             TriangleFanProvokingVertexSelect;
105810e230b6Smaya#define Vertex0                                  0
105910e230b6Smaya#define Vertex1                                  1
106010e230b6Smaya#define Vertex2                                  2
106110e230b6Smaya   uint32_t                             LineStripListProvokingVertexSelect;
106210e230b6Smaya#define Vertex0                                  0
106310e230b6Smaya#define Vertex1                                  1
106410e230b6Smaya   uint32_t                             TriangleStripListProvokingVertexSelect;
106510e230b6Smaya#define Vertex0                                  0
106610e230b6Smaya#define Vertex1                                  1
106710e230b6Smaya#define Vertex2                                  2
106810e230b6Smaya   bool                                 LastPixelEnable;
106910e230b6Smaya};
107010e230b6Smaya
107196c5ddc4Srjsstatic inline __attribute__((always_inline)) void
107296c5ddc4SrjsGFX5_SF_STATE_pack(__attribute__((unused)) __gen_user_data *data,
107310e230b6Smaya                   __attribute__((unused)) void * restrict dst,
107496c5ddc4Srjs                   __attribute__((unused)) const struct GFX5_SF_STATE * restrict values)
107510e230b6Smaya{
107610e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
107710e230b6Smaya
107810e230b6Smaya   dw[0] =
107910e230b6Smaya      __gen_uint(values->GRFRegisterCount, 1, 3) |
108010e230b6Smaya      __gen_offset(values->KernelStartPointer, 6, 31);
108110e230b6Smaya
108210e230b6Smaya   dw[1] =
108310e230b6Smaya      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
108410e230b6Smaya      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
108510e230b6Smaya      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
108610e230b6Smaya      __gen_uint(values->FloatingPointMode, 16, 16) |
108710e230b6Smaya      __gen_uint(values->ThreadPriority, 17, 17) |
108810e230b6Smaya      __gen_uint(values->BindingTableEntryCount, 18, 25) |
108910e230b6Smaya      __gen_uint(values->SingleProgramFlow, 31, 31);
109010e230b6Smaya
109110e230b6Smaya   const uint32_t v2 =
109210e230b6Smaya      __gen_uint(values->PerThreadScratchSpace, 0, 3);
109396c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31);
109410e230b6Smaya
109510e230b6Smaya   dw[3] =
109610e230b6Smaya      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
109710e230b6Smaya      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
109810e230b6Smaya      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
109910e230b6Smaya      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
110010e230b6Smaya      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
110110e230b6Smaya
110210e230b6Smaya   dw[4] =
110310e230b6Smaya      __gen_uint(values->NumberofURBEntries, 11, 18) |
110410e230b6Smaya      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
110510e230b6Smaya      __gen_uint(values->MaximumNumberofThreads, 25, 30);
110610e230b6Smaya
110710e230b6Smaya   const uint32_t v5 =
110810e230b6Smaya      __gen_uint(values->FrontWinding, 0, 0) |
110910e230b6Smaya      __gen_uint(values->ViewportTransformEnable, 1, 1);
111096c5ddc4Srjs   dw[5] = __gen_address(data, &dw[5], values->SetupViewportStateOffset, v5, 5, 31);
111110e230b6Smaya
111210e230b6Smaya   dw[6] =
111310e230b6Smaya      __gen_ufixed(values->DestinationOriginVerticalBias, 9, 12, 4) |
111410e230b6Smaya      __gen_ufixed(values->DestinationOriginHorizontalBias, 13, 16, 4) |
111510e230b6Smaya      __gen_uint(values->ScissorRectangleEnable, 17, 17) |
111610e230b6Smaya      __gen_uint(values->_2x2PixelTriangleFilterDisable, 18, 18) |
111710e230b6Smaya      __gen_uint(values->ZeroPixelTriangleFilterDisable, 19, 19) |
111810e230b6Smaya      __gen_uint(values->PointRasterizationRule, 20, 21) |
111910e230b6Smaya      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 22, 23) |
112010e230b6Smaya      __gen_ufixed(values->LineWidth, 24, 27, 1) |
112110e230b6Smaya      __gen_uint(values->FastScissorClipDisable, 28, 28) |
112210e230b6Smaya      __gen_uint(values->CullMode, 29, 30) |
112396c5ddc4Srjs      __gen_uint(values->AntialiasingEnable, 31, 31);
112410e230b6Smaya
112510e230b6Smaya   dw[7] =
112610e230b6Smaya      __gen_ufixed(values->PointWidth, 0, 10, 3) |
112710e230b6Smaya      __gen_uint(values->PointWidthSource, 11, 11) |
112810e230b6Smaya      __gen_uint(values->VertexSubPixelPrecisionSelect, 12, 12) |
112910e230b6Smaya      __gen_uint(values->SpritePointEnable, 13, 13) |
113010e230b6Smaya      __gen_uint(values->AALineDistanceMode, 14, 14) |
113110e230b6Smaya      __gen_uint(values->TriangleFanProvokingVertexSelect, 25, 26) |
113210e230b6Smaya      __gen_uint(values->LineStripListProvokingVertexSelect, 27, 28) |
113310e230b6Smaya      __gen_uint(values->TriangleStripListProvokingVertexSelect, 29, 30) |
113410e230b6Smaya      __gen_uint(values->LastPixelEnable, 31, 31);
113510e230b6Smaya}
113610e230b6Smaya
113796c5ddc4Srjs#define GFX5_SF_VIEWPORT_length                8
113896c5ddc4Srjsstruct GFX5_SF_VIEWPORT {
113910e230b6Smaya   float                                ViewportMatrixElementm00;
114010e230b6Smaya   float                                ViewportMatrixElementm11;
114110e230b6Smaya   float                                ViewportMatrixElementm22;
114210e230b6Smaya   float                                ViewportMatrixElementm30;
114310e230b6Smaya   float                                ViewportMatrixElementm31;
114410e230b6Smaya   float                                ViewportMatrixElementm32;
114596c5ddc4Srjs   struct GFX5_SCISSOR_RECT             ScissorRectangle;
114610e230b6Smaya};
114710e230b6Smaya
114896c5ddc4Srjsstatic inline __attribute__((always_inline)) void
114996c5ddc4SrjsGFX5_SF_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data,
115010e230b6Smaya                      __attribute__((unused)) void * restrict dst,
115196c5ddc4Srjs                      __attribute__((unused)) const struct GFX5_SF_VIEWPORT * restrict values)
115210e230b6Smaya{
115310e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
115410e230b6Smaya
115510e230b6Smaya   dw[0] =
115610e230b6Smaya      __gen_float(values->ViewportMatrixElementm00);
115710e230b6Smaya
115810e230b6Smaya   dw[1] =
115910e230b6Smaya      __gen_float(values->ViewportMatrixElementm11);
116010e230b6Smaya
116110e230b6Smaya   dw[2] =
116210e230b6Smaya      __gen_float(values->ViewportMatrixElementm22);
116310e230b6Smaya
116410e230b6Smaya   dw[3] =
116510e230b6Smaya      __gen_float(values->ViewportMatrixElementm30);
116610e230b6Smaya
116710e230b6Smaya   dw[4] =
116810e230b6Smaya      __gen_float(values->ViewportMatrixElementm31);
116910e230b6Smaya
117010e230b6Smaya   dw[5] =
117110e230b6Smaya      __gen_float(values->ViewportMatrixElementm32);
117210e230b6Smaya
117396c5ddc4Srjs   GFX5_SCISSOR_RECT_pack(data, &dw[6], &values->ScissorRectangle);
117410e230b6Smaya}
117510e230b6Smaya
117696c5ddc4Srjs#define GFX5_VERTEX_BUFFER_STATE_length        4
117796c5ddc4Srjsstruct GFX5_VERTEX_BUFFER_STATE {
117810e230b6Smaya   uint32_t                             BufferPitch;
117910e230b6Smaya   bool                                 NullVertexBuffer;
118010e230b6Smaya   uint32_t                             BufferAccessType;
118110e230b6Smaya#define VERTEXDATA                               0
118210e230b6Smaya#define INSTANCEDATA                             1
118310e230b6Smaya   uint32_t                             VertexBufferIndex;
118410e230b6Smaya   __gen_address_type                   BufferStartingAddress;
118510e230b6Smaya   __gen_address_type                   EndAddress;
118610e230b6Smaya   uint32_t                             InstanceDataStepRate;
118710e230b6Smaya};
118810e230b6Smaya
118996c5ddc4Srjsstatic inline __attribute__((always_inline)) void
119096c5ddc4SrjsGFX5_VERTEX_BUFFER_STATE_pack(__attribute__((unused)) __gen_user_data *data,
119110e230b6Smaya                              __attribute__((unused)) void * restrict dst,
119296c5ddc4Srjs                              __attribute__((unused)) const struct GFX5_VERTEX_BUFFER_STATE * restrict values)
119310e230b6Smaya{
119410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
119510e230b6Smaya
119610e230b6Smaya   dw[0] =
119710e230b6Smaya      __gen_uint(values->BufferPitch, 0, 11) |
119810e230b6Smaya      __gen_uint(values->NullVertexBuffer, 13, 13) |
119910e230b6Smaya      __gen_uint(values->BufferAccessType, 26, 26) |
120010e230b6Smaya      __gen_uint(values->VertexBufferIndex, 27, 31);
120110e230b6Smaya
120296c5ddc4Srjs   dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, 0, 0, 31);
120310e230b6Smaya
120496c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->EndAddress, 0, 0, 31);
120510e230b6Smaya
120610e230b6Smaya   dw[3] =
120710e230b6Smaya      __gen_uint(values->InstanceDataStepRate, 0, 31);
120810e230b6Smaya}
120910e230b6Smaya
121096c5ddc4Srjs#define GFX5_VERTEX_ELEMENT_STATE_length       2
121196c5ddc4Srjsstruct GFX5_VERTEX_ELEMENT_STATE {
121210e230b6Smaya   uint32_t                             SourceElementOffset;
121310e230b6Smaya   uint32_t                             SourceElementFormat;
121410e230b6Smaya   bool                                 Valid;
121510e230b6Smaya   uint32_t                             VertexBufferIndex;
121610e230b6Smaya   uint32_t                             DestinationElementOffset;
121796c5ddc4Srjs   enum GFX5_3D_Vertex_Component_Control Component3Control;
121896c5ddc4Srjs   enum GFX5_3D_Vertex_Component_Control Component2Control;
121996c5ddc4Srjs   enum GFX5_3D_Vertex_Component_Control Component1Control;
122096c5ddc4Srjs   enum GFX5_3D_Vertex_Component_Control Component0Control;
122110e230b6Smaya};
122210e230b6Smaya
122396c5ddc4Srjsstatic inline __attribute__((always_inline)) void
122496c5ddc4SrjsGFX5_VERTEX_ELEMENT_STATE_pack(__attribute__((unused)) __gen_user_data *data,
122510e230b6Smaya                               __attribute__((unused)) void * restrict dst,
122696c5ddc4Srjs                               __attribute__((unused)) const struct GFX5_VERTEX_ELEMENT_STATE * restrict values)
122710e230b6Smaya{
122810e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
122910e230b6Smaya
123010e230b6Smaya   dw[0] =
123110e230b6Smaya      __gen_uint(values->SourceElementOffset, 0, 10) |
123210e230b6Smaya      __gen_uint(values->SourceElementFormat, 16, 24) |
123310e230b6Smaya      __gen_uint(values->Valid, 26, 26) |
123410e230b6Smaya      __gen_uint(values->VertexBufferIndex, 27, 31);
123510e230b6Smaya
123610e230b6Smaya   dw[1] =
123710e230b6Smaya      __gen_uint(values->DestinationElementOffset, 0, 7) |
123810e230b6Smaya      __gen_uint(values->Component3Control, 16, 18) |
123910e230b6Smaya      __gen_uint(values->Component2Control, 20, 22) |
124010e230b6Smaya      __gen_uint(values->Component1Control, 24, 26) |
124110e230b6Smaya      __gen_uint(values->Component0Control, 28, 30);
124210e230b6Smaya}
124310e230b6Smaya
124496c5ddc4Srjs#define GFX5_VS_STATE_length                   7
124596c5ddc4Srjsstruct GFX5_VS_STATE {
124610e230b6Smaya   uint32_t                             GRFRegisterCount;
124710e230b6Smaya   uint64_t                             KernelStartPointer;
124810e230b6Smaya   bool                                 SoftwareExceptionEnable;
124910e230b6Smaya   bool                                 MaskStackExceptionEnable;
125010e230b6Smaya   bool                                 IllegalOpcodeExceptionEnable;
125110e230b6Smaya   uint32_t                             FloatingPointMode;
125210e230b6Smaya#define FLOATING_POINT_MODE_IEEE754              0
125310e230b6Smaya#define FLOATING_POINT_MODE_Alternate            1
125410e230b6Smaya   uint32_t                             ThreadPriority;
125510e230b6Smaya#define NormalPriority                           0
125610e230b6Smaya#define HighPriority                             1
125710e230b6Smaya   uint32_t                             BindingTableEntryCount;
125810e230b6Smaya   bool                                 SingleProgramFlow;
125910e230b6Smaya   uint32_t                             PerThreadScratchSpace;
126010e230b6Smaya   __gen_address_type                   ScratchSpaceBasePointer;
126110e230b6Smaya   uint32_t                             DispatchGRFStartRegisterForURBData;
126210e230b6Smaya   uint32_t                             VertexURBEntryReadOffset;
126310e230b6Smaya   uint32_t                             VertexURBEntryReadLength;
126410e230b6Smaya   uint32_t                             ConstantURBEntryReadOffset;
126510e230b6Smaya   uint32_t                             ConstantURBEntryReadLength;
126610e230b6Smaya   bool                                 StatisticsEnable;
126710e230b6Smaya   uint32_t                             NumberofURBEntries;
126810e230b6Smaya   uint32_t                             URBEntryAllocationSize;
126910e230b6Smaya   uint32_t                             MaximumNumberofThreads;
127010e230b6Smaya   uint32_t                             SamplerCount;
127110e230b6Smaya   __gen_address_type                   SamplerStatePointer;
127210e230b6Smaya   bool                                 Enable;
127310e230b6Smaya   bool                                 VertexCacheDisable;
127410e230b6Smaya};
127510e230b6Smaya
127696c5ddc4Srjsstatic inline __attribute__((always_inline)) void
127796c5ddc4SrjsGFX5_VS_STATE_pack(__attribute__((unused)) __gen_user_data *data,
127810e230b6Smaya                   __attribute__((unused)) void * restrict dst,
127996c5ddc4Srjs                   __attribute__((unused)) const struct GFX5_VS_STATE * restrict values)
128010e230b6Smaya{
128110e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
128210e230b6Smaya
128310e230b6Smaya   dw[0] =
128410e230b6Smaya      __gen_uint(values->GRFRegisterCount, 1, 3) |
128510e230b6Smaya      __gen_offset(values->KernelStartPointer, 6, 31);
128610e230b6Smaya
128710e230b6Smaya   dw[1] =
128810e230b6Smaya      __gen_uint(values->SoftwareExceptionEnable, 7, 7) |
128910e230b6Smaya      __gen_uint(values->MaskStackExceptionEnable, 11, 11) |
129010e230b6Smaya      __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) |
129110e230b6Smaya      __gen_uint(values->FloatingPointMode, 16, 16) |
129210e230b6Smaya      __gen_uint(values->ThreadPriority, 17, 17) |
129310e230b6Smaya      __gen_uint(values->BindingTableEntryCount, 18, 25) |
129410e230b6Smaya      __gen_uint(values->SingleProgramFlow, 31, 31);
129510e230b6Smaya
129610e230b6Smaya   const uint32_t v2 =
129710e230b6Smaya      __gen_uint(values->PerThreadScratchSpace, 0, 3);
129896c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31);
129910e230b6Smaya
130010e230b6Smaya   dw[3] =
130110e230b6Smaya      __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) |
130210e230b6Smaya      __gen_uint(values->VertexURBEntryReadOffset, 4, 9) |
130310e230b6Smaya      __gen_uint(values->VertexURBEntryReadLength, 11, 16) |
130410e230b6Smaya      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
130510e230b6Smaya      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
130610e230b6Smaya
130710e230b6Smaya   dw[4] =
130810e230b6Smaya      __gen_uint(values->StatisticsEnable, 10, 10) |
130910e230b6Smaya      __gen_uint(values->NumberofURBEntries, 11, 18) |
131010e230b6Smaya      __gen_uint(values->URBEntryAllocationSize, 19, 23) |
131110e230b6Smaya      __gen_uint(values->MaximumNumberofThreads, 25, 30);
131210e230b6Smaya
131310e230b6Smaya   const uint32_t v5 =
131410e230b6Smaya      __gen_uint(values->SamplerCount, 0, 2);
131596c5ddc4Srjs   dw[5] = __gen_address(data, &dw[5], values->SamplerStatePointer, v5, 5, 31);
131610e230b6Smaya
131710e230b6Smaya   dw[6] =
131810e230b6Smaya      __gen_uint(values->Enable, 0, 0) |
131910e230b6Smaya      __gen_uint(values->VertexCacheDisable, 1, 1);
132010e230b6Smaya}
132110e230b6Smaya
132296c5ddc4Srjs#define GFX5_WM_STATE_length                  11
132396c5ddc4Srjsstruct GFX5_WM_STATE {
132410e230b6Smaya   uint32_t                             GRFRegisterCount0;
132510e230b6Smaya   uint64_t                             KernelStartPointer0;
132610e230b6Smaya   bool                                 SoftwareExceptionEnable;
132710e230b6Smaya   bool                                 MaskStackExceptionEnable;
132810e230b6Smaya   bool                                 IllegalOpcodeExceptionEnable;
132910e230b6Smaya   uint32_t                             DepthCoefficientURBReadOffset;
133010e230b6Smaya   uint32_t                             FloatingPointMode;
133110e230b6Smaya#define FLOATING_POINT_MODE_IEEE754              0
133210e230b6Smaya#define FLOATING_POINT_MODE_Alternate            1
133310e230b6Smaya   uint32_t                             ThreadPriority;
133410e230b6Smaya#define High                                     1
133510e230b6Smaya   uint32_t                             BindingTableEntryCount;
133610e230b6Smaya   bool                                 SingleProgramFlow;
133710e230b6Smaya   uint32_t                             PerThreadScratchSpace;
133810e230b6Smaya   __gen_address_type                   ScratchSpaceBasePointer;
133910e230b6Smaya   uint32_t                             DispatchGRFStartRegisterForConstantSetupData0;
134010e230b6Smaya   uint32_t                             SetupURBEntryReadOffset;
134110e230b6Smaya   uint32_t                             SetupURBEntryReadLength;
134210e230b6Smaya   uint32_t                             ConstantURBEntryReadOffset;
134310e230b6Smaya   uint32_t                             ConstantURBEntryReadLength;
134410e230b6Smaya   bool                                 StatisticsEnable;
134510e230b6Smaya   uint32_t                             SamplerCount;
134610e230b6Smaya   __gen_address_type                   SamplerStatePointer;
134710e230b6Smaya   bool                                 _8PixelDispatchEnable;
134810e230b6Smaya   bool                                 _16PixelDispatchEnable;
134910e230b6Smaya   bool                                 _32PixelDispatchEnable;
135010e230b6Smaya   bool                                 Contiguous32PixelDispatchEnable;
135110e230b6Smaya   bool                                 Contiguous64PixelDispatchEnable;
135210e230b6Smaya   bool                                 FastSpanCoverageEnable;
135310e230b6Smaya   bool                                 DepthBufferClear;
135410e230b6Smaya   bool                                 DepthBufferResolveEnable;
135510e230b6Smaya   bool                                 HierarchicalDepthBufferResolveEnable;
135610e230b6Smaya   bool                                 LegacyGlobalDepthBiasEnable;
135710e230b6Smaya   bool                                 LineStippleEnable;
135810e230b6Smaya   bool                                 GlobalDepthOffsetEnable;
135910e230b6Smaya   bool                                 PolygonStippleEnable;
136010e230b6Smaya   uint32_t                             LineAntialiasingRegionWidth;
136110e230b6Smaya#define _05pixels                                0
136210e230b6Smaya#define _10pixels                                1
136310e230b6Smaya#define _20pixels                                2
136410e230b6Smaya#define _40pixels                                3
136510e230b6Smaya   uint32_t                             LineEndCapAntialiasingRegionWidth;
136610e230b6Smaya#define _05pixels                                0
136710e230b6Smaya#define _10pixels                                1
136810e230b6Smaya#define _20pixels                                2
136910e230b6Smaya#define _40pixels                                3
137010e230b6Smaya   bool                                 EarlyDepthTestEnable;
137110e230b6Smaya   bool                                 ThreadDispatchEnable;
137210e230b6Smaya   bool                                 PixelShaderUsesSourceDepth;
137310e230b6Smaya   bool                                 PixelShaderComputedDepth;
137410e230b6Smaya   bool                                 PixelShaderKillsPixel;
137510e230b6Smaya   bool                                 LegacyDiamondLineRasterization;
137610e230b6Smaya   uint32_t                             MaximumNumberofThreads;
137710e230b6Smaya   float                                GlobalDepthOffsetConstant;
137810e230b6Smaya   float                                GlobalDepthOffsetScale;
137910e230b6Smaya   uint32_t                             GRFRegisterCount1;
138010e230b6Smaya   uint64_t                             KernelStartPointer1;
138110e230b6Smaya   uint32_t                             GRFRegisterCount2;
138210e230b6Smaya   uint64_t                             KernelStartPointer2;
138310e230b6Smaya   uint32_t                             GRFRegisterCount3;
138410e230b6Smaya   uint64_t                             KernelStartPointer3;
138510e230b6Smaya};
138610e230b6Smaya
138796c5ddc4Srjsstatic inline __attribute__((always_inline)) void
138896c5ddc4SrjsGFX5_WM_STATE_pack(__attribute__((unused)) __gen_user_data *data,
138910e230b6Smaya                   __attribute__((unused)) void * restrict dst,
139096c5ddc4Srjs                   __attribute__((unused)) const struct GFX5_WM_STATE * restrict values)
139110e230b6Smaya{
139210e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
139310e230b6Smaya
139410e230b6Smaya   dw[0] =
139510e230b6Smaya      __gen_uint(values->GRFRegisterCount0, 1, 3) |
139610e230b6Smaya      __gen_offset(values->KernelStartPointer0, 6, 31);
139710e230b6Smaya
139810e230b6Smaya   dw[1] =
139910e230b6Smaya      __gen_uint(values->SoftwareExceptionEnable, 1, 1) |
140010e230b6Smaya      __gen_uint(values->MaskStackExceptionEnable, 2, 2) |
140110e230b6Smaya      __gen_uint(values->IllegalOpcodeExceptionEnable, 4, 4) |
140210e230b6Smaya      __gen_uint(values->DepthCoefficientURBReadOffset, 8, 13) |
140310e230b6Smaya      __gen_uint(values->FloatingPointMode, 16, 16) |
140410e230b6Smaya      __gen_uint(values->ThreadPriority, 17, 17) |
140510e230b6Smaya      __gen_uint(values->BindingTableEntryCount, 18, 25) |
140610e230b6Smaya      __gen_uint(values->SingleProgramFlow, 31, 31);
140710e230b6Smaya
140810e230b6Smaya   const uint32_t v2 =
140910e230b6Smaya      __gen_uint(values->PerThreadScratchSpace, 0, 3);
141096c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31);
141110e230b6Smaya
141210e230b6Smaya   dw[3] =
141310e230b6Smaya      __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData0, 0, 3) |
141410e230b6Smaya      __gen_uint(values->SetupURBEntryReadOffset, 4, 9) |
141510e230b6Smaya      __gen_uint(values->SetupURBEntryReadLength, 11, 16) |
141610e230b6Smaya      __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) |
141710e230b6Smaya      __gen_uint(values->ConstantURBEntryReadLength, 25, 30);
141810e230b6Smaya
141910e230b6Smaya   const uint32_t v4 =
142010e230b6Smaya      __gen_uint(values->StatisticsEnable, 0, 0) |
142110e230b6Smaya      __gen_uint(values->SamplerCount, 2, 4);
142296c5ddc4Srjs   dw[4] = __gen_address(data, &dw[4], values->SamplerStatePointer, v4, 5, 31);
142310e230b6Smaya
142410e230b6Smaya   dw[5] =
142510e230b6Smaya      __gen_uint(values->_8PixelDispatchEnable, 0, 0) |
142610e230b6Smaya      __gen_uint(values->_16PixelDispatchEnable, 1, 1) |
142710e230b6Smaya      __gen_uint(values->_32PixelDispatchEnable, 2, 2) |
142810e230b6Smaya      __gen_uint(values->Contiguous32PixelDispatchEnable, 3, 3) |
142910e230b6Smaya      __gen_uint(values->Contiguous64PixelDispatchEnable, 4, 4) |
143010e230b6Smaya      __gen_uint(values->FastSpanCoverageEnable, 6, 6) |
143110e230b6Smaya      __gen_uint(values->DepthBufferClear, 7, 7) |
143210e230b6Smaya      __gen_uint(values->DepthBufferResolveEnable, 8, 8) |
143310e230b6Smaya      __gen_uint(values->HierarchicalDepthBufferResolveEnable, 9, 9) |
143410e230b6Smaya      __gen_uint(values->LegacyGlobalDepthBiasEnable, 10, 10) |
143510e230b6Smaya      __gen_uint(values->LineStippleEnable, 11, 11) |
143610e230b6Smaya      __gen_uint(values->GlobalDepthOffsetEnable, 12, 12) |
143710e230b6Smaya      __gen_uint(values->PolygonStippleEnable, 13, 13) |
143810e230b6Smaya      __gen_uint(values->LineAntialiasingRegionWidth, 14, 15) |
143910e230b6Smaya      __gen_uint(values->LineEndCapAntialiasingRegionWidth, 16, 17) |
144010e230b6Smaya      __gen_uint(values->EarlyDepthTestEnable, 18, 18) |
144110e230b6Smaya      __gen_uint(values->ThreadDispatchEnable, 19, 19) |
144210e230b6Smaya      __gen_uint(values->PixelShaderUsesSourceDepth, 20, 20) |
144310e230b6Smaya      __gen_uint(values->PixelShaderComputedDepth, 21, 21) |
144410e230b6Smaya      __gen_uint(values->PixelShaderKillsPixel, 22, 22) |
144510e230b6Smaya      __gen_uint(values->LegacyDiamondLineRasterization, 23, 23) |
144610e230b6Smaya      __gen_uint(values->MaximumNumberofThreads, 25, 31);
144710e230b6Smaya
144810e230b6Smaya   dw[6] =
144910e230b6Smaya      __gen_float(values->GlobalDepthOffsetConstant);
145010e230b6Smaya
145110e230b6Smaya   dw[7] =
145210e230b6Smaya      __gen_float(values->GlobalDepthOffsetScale);
145310e230b6Smaya
145410e230b6Smaya   dw[8] =
145510e230b6Smaya      __gen_uint(values->GRFRegisterCount1, 1, 3) |
145610e230b6Smaya      __gen_offset(values->KernelStartPointer1, 6, 31);
145710e230b6Smaya
145810e230b6Smaya   dw[9] =
145910e230b6Smaya      __gen_uint(values->GRFRegisterCount2, 1, 3) |
146010e230b6Smaya      __gen_offset(values->KernelStartPointer2, 6, 31);
146110e230b6Smaya
146210e230b6Smaya   dw[10] =
146310e230b6Smaya      __gen_uint(values->GRFRegisterCount3, 1, 3) |
146410e230b6Smaya      __gen_offset(values->KernelStartPointer3, 6, 31);
146510e230b6Smaya}
146610e230b6Smaya
146796c5ddc4Srjs#define GFX5_3DPRIMITIVE_length                6
146896c5ddc4Srjs#define GFX5_3DPRIMITIVE_length_bias           2
146996c5ddc4Srjs#define GFX5_3DPRIMITIVE_header                 \
147010e230b6Smaya   .DWordLength                         =      4,  \
147110e230b6Smaya   ._3DCommandSubOpcode                 =      0,  \
147210e230b6Smaya   ._3DCommandOpcode                    =      3,  \
147310e230b6Smaya   .CommandSubType                      =      3,  \
147410e230b6Smaya   .CommandType                         =      3
147510e230b6Smaya
147696c5ddc4Srjsstruct GFX5_3DPRIMITIVE {
147710e230b6Smaya   uint32_t                             DWordLength;
147810e230b6Smaya   uint32_t                             IndirectVertexCount;
147996c5ddc4Srjs   enum GFX5_3D_Prim_Topo_Type          PrimitiveTopologyType;
148010e230b6Smaya   uint32_t                             VertexAccessType;
148110e230b6Smaya#define SEQUENTIAL                               0
148210e230b6Smaya#define RANDOM                                   1
148310e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
148410e230b6Smaya   uint32_t                             _3DCommandOpcode;
148510e230b6Smaya   uint32_t                             CommandSubType;
148610e230b6Smaya   uint32_t                             CommandType;
148710e230b6Smaya   uint32_t                             VertexCountPerInstance;
148810e230b6Smaya   uint32_t                             StartVertexLocation;
148910e230b6Smaya   uint32_t                             InstanceCount;
149010e230b6Smaya   uint32_t                             StartInstanceLocation;
149110e230b6Smaya   int32_t                              BaseVertexLocation;
149210e230b6Smaya};
149310e230b6Smaya
149496c5ddc4Srjsstatic inline __attribute__((always_inline)) void
149596c5ddc4SrjsGFX5_3DPRIMITIVE_pack(__attribute__((unused)) __gen_user_data *data,
149610e230b6Smaya                      __attribute__((unused)) void * restrict dst,
149796c5ddc4Srjs                      __attribute__((unused)) const struct GFX5_3DPRIMITIVE * restrict values)
149810e230b6Smaya{
149910e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
150010e230b6Smaya
150110e230b6Smaya   dw[0] =
150210e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
150310e230b6Smaya      __gen_uint(values->IndirectVertexCount, 9, 9) |
150410e230b6Smaya      __gen_uint(values->PrimitiveTopologyType, 10, 14) |
150510e230b6Smaya      __gen_uint(values->VertexAccessType, 15, 15) |
150610e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
150710e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
150810e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
150910e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
151010e230b6Smaya
151110e230b6Smaya   dw[1] =
151210e230b6Smaya      __gen_uint(values->VertexCountPerInstance, 0, 31);
151310e230b6Smaya
151410e230b6Smaya   dw[2] =
151510e230b6Smaya      __gen_uint(values->StartVertexLocation, 0, 31);
151610e230b6Smaya
151710e230b6Smaya   dw[3] =
151810e230b6Smaya      __gen_uint(values->InstanceCount, 0, 31);
151910e230b6Smaya
152010e230b6Smaya   dw[4] =
152110e230b6Smaya      __gen_uint(values->StartInstanceLocation, 0, 31);
152210e230b6Smaya
152310e230b6Smaya   dw[5] =
152410e230b6Smaya      __gen_sint(values->BaseVertexLocation, 0, 31);
152510e230b6Smaya}
152610e230b6Smaya
152796c5ddc4Srjs#define GFX5_3DSTATE_AA_LINE_PARAMETERS_length      3
152896c5ddc4Srjs#define GFX5_3DSTATE_AA_LINE_PARAMETERS_length_bias      2
152996c5ddc4Srjs#define GFX5_3DSTATE_AA_LINE_PARAMETERS_header  \
153010e230b6Smaya   .DWordLength                         =      1,  \
153110e230b6Smaya   ._3DCommandSubOpcode                 =     10,  \
153210e230b6Smaya   ._3DCommandOpcode                    =      1,  \
153310e230b6Smaya   .CommandSubType                      =      3,  \
153410e230b6Smaya   .CommandType                         =      3
153510e230b6Smaya
153696c5ddc4Srjsstruct GFX5_3DSTATE_AA_LINE_PARAMETERS {
153710e230b6Smaya   uint32_t                             DWordLength;
153810e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
153910e230b6Smaya   uint32_t                             _3DCommandOpcode;
154010e230b6Smaya   uint32_t                             CommandSubType;
154110e230b6Smaya   uint32_t                             CommandType;
154210e230b6Smaya   float                                AACoverageSlope;
154310e230b6Smaya   float                                AACoverageBias;
154410e230b6Smaya   float                                AACoverageEndCapSlope;
154510e230b6Smaya   float                                AACoverageEndCapBias;
154610e230b6Smaya};
154710e230b6Smaya
154896c5ddc4Srjsstatic inline __attribute__((always_inline)) void
154996c5ddc4SrjsGFX5_3DSTATE_AA_LINE_PARAMETERS_pack(__attribute__((unused)) __gen_user_data *data,
155010e230b6Smaya                                     __attribute__((unused)) void * restrict dst,
155196c5ddc4Srjs                                     __attribute__((unused)) const struct GFX5_3DSTATE_AA_LINE_PARAMETERS * restrict values)
155210e230b6Smaya{
155310e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
155410e230b6Smaya
155510e230b6Smaya   dw[0] =
155610e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
155710e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
155810e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
155910e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
156010e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
156110e230b6Smaya
156210e230b6Smaya   dw[1] =
156310e230b6Smaya      __gen_ufixed(values->AACoverageSlope, 0, 7, 8) |
156410e230b6Smaya      __gen_ufixed(values->AACoverageBias, 16, 23, 8);
156510e230b6Smaya
156610e230b6Smaya   dw[2] =
156710e230b6Smaya      __gen_ufixed(values->AACoverageEndCapSlope, 0, 7, 8) |
156810e230b6Smaya      __gen_ufixed(values->AACoverageEndCapBias, 16, 23, 8);
156910e230b6Smaya}
157010e230b6Smaya
157196c5ddc4Srjs#define GFX5_3DSTATE_BINDING_TABLE_POINTERS_length      6
157296c5ddc4Srjs#define GFX5_3DSTATE_BINDING_TABLE_POINTERS_length_bias      2
157396c5ddc4Srjs#define GFX5_3DSTATE_BINDING_TABLE_POINTERS_header\
157410e230b6Smaya   .DWordLength                         =      4,  \
157510e230b6Smaya   ._3DCommandSubOpcode                 =      1,  \
157610e230b6Smaya   ._3DCommandOpcode                    =      0,  \
157710e230b6Smaya   .CommandSubType                      =      3,  \
157810e230b6Smaya   .CommandType                         =      3
157910e230b6Smaya
158096c5ddc4Srjsstruct GFX5_3DSTATE_BINDING_TABLE_POINTERS {
158110e230b6Smaya   uint32_t                             DWordLength;
158210e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
158310e230b6Smaya   uint32_t                             _3DCommandOpcode;
158410e230b6Smaya   uint32_t                             CommandSubType;
158510e230b6Smaya   uint32_t                             CommandType;
158610e230b6Smaya   uint64_t                             PointertoVSBindingTable;
158710e230b6Smaya   uint64_t                             PointertoGSBindingTable;
158810e230b6Smaya   uint64_t                             PointertoCLIPBindingTable;
158910e230b6Smaya   uint64_t                             PointertoSFBindingTable;
159010e230b6Smaya   uint64_t                             PointertoPSBindingTable;
159110e230b6Smaya};
159210e230b6Smaya
159396c5ddc4Srjsstatic inline __attribute__((always_inline)) void
159496c5ddc4SrjsGFX5_3DSTATE_BINDING_TABLE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
159510e230b6Smaya                                         __attribute__((unused)) void * restrict dst,
159696c5ddc4Srjs                                         __attribute__((unused)) const struct GFX5_3DSTATE_BINDING_TABLE_POINTERS * restrict values)
159710e230b6Smaya{
159810e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
159910e230b6Smaya
160010e230b6Smaya   dw[0] =
160110e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
160210e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
160310e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
160410e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
160510e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
160610e230b6Smaya
160710e230b6Smaya   dw[1] =
160810e230b6Smaya      __gen_offset(values->PointertoVSBindingTable, 5, 31);
160910e230b6Smaya
161010e230b6Smaya   dw[2] =
161110e230b6Smaya      __gen_offset(values->PointertoGSBindingTable, 5, 31);
161210e230b6Smaya
161310e230b6Smaya   dw[3] =
161410e230b6Smaya      __gen_offset(values->PointertoCLIPBindingTable, 5, 31);
161510e230b6Smaya
161610e230b6Smaya   dw[4] =
161710e230b6Smaya      __gen_offset(values->PointertoSFBindingTable, 5, 31);
161810e230b6Smaya
161910e230b6Smaya   dw[5] =
162010e230b6Smaya      __gen_offset(values->PointertoPSBindingTable, 5, 31);
162110e230b6Smaya}
162210e230b6Smaya
162396c5ddc4Srjs#define GFX5_3DSTATE_CLEAR_PARAMS_length       2
162496c5ddc4Srjs#define GFX5_3DSTATE_CLEAR_PARAMS_length_bias      2
162596c5ddc4Srjs#define GFX5_3DSTATE_CLEAR_PARAMS_header        \
162610e230b6Smaya   .DWordLength                         =      0,  \
162710e230b6Smaya   ._3DCommandSubOpcode                 =     16,  \
162810e230b6Smaya   ._3DCommandOpcode                    =      1,  \
162910e230b6Smaya   .CommandSubType                      =      3,  \
163010e230b6Smaya   .CommandType                         =      3
163110e230b6Smaya
163296c5ddc4Srjsstruct GFX5_3DSTATE_CLEAR_PARAMS {
163310e230b6Smaya   uint32_t                             DWordLength;
163410e230b6Smaya   bool                                 DepthClearValueValid;
163510e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
163610e230b6Smaya   uint32_t                             _3DCommandOpcode;
163710e230b6Smaya   uint32_t                             CommandSubType;
163810e230b6Smaya   uint32_t                             CommandType;
163910e230b6Smaya   uint32_t                             DepthClearValue;
164010e230b6Smaya};
164110e230b6Smaya
164296c5ddc4Srjsstatic inline __attribute__((always_inline)) void
164396c5ddc4SrjsGFX5_3DSTATE_CLEAR_PARAMS_pack(__attribute__((unused)) __gen_user_data *data,
164410e230b6Smaya                               __attribute__((unused)) void * restrict dst,
164596c5ddc4Srjs                               __attribute__((unused)) const struct GFX5_3DSTATE_CLEAR_PARAMS * restrict values)
164610e230b6Smaya{
164710e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
164810e230b6Smaya
164910e230b6Smaya   dw[0] =
165010e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
165110e230b6Smaya      __gen_uint(values->DepthClearValueValid, 15, 15) |
165210e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
165310e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
165410e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
165510e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
165610e230b6Smaya
165710e230b6Smaya   dw[1] =
165810e230b6Smaya      __gen_uint(values->DepthClearValue, 0, 31);
165910e230b6Smaya}
166010e230b6Smaya
166196c5ddc4Srjs#define GFX5_3DSTATE_CONSTANT_COLOR_length      5
166296c5ddc4Srjs#define GFX5_3DSTATE_CONSTANT_COLOR_length_bias      2
166396c5ddc4Srjs#define GFX5_3DSTATE_CONSTANT_COLOR_header      \
166410e230b6Smaya   .DWordLength                         =      3,  \
166510e230b6Smaya   ._3DCommandSubOpcode                 =      1,  \
166610e230b6Smaya   ._3DCommandOpcode                    =      1,  \
166710e230b6Smaya   .CommandSubType                      =      3,  \
166810e230b6Smaya   .CommandType                         =      3
166910e230b6Smaya
167096c5ddc4Srjsstruct GFX5_3DSTATE_CONSTANT_COLOR {
167110e230b6Smaya   uint32_t                             DWordLength;
167210e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
167310e230b6Smaya   uint32_t                             _3DCommandOpcode;
167410e230b6Smaya   uint32_t                             CommandSubType;
167510e230b6Smaya   uint32_t                             CommandType;
167610e230b6Smaya   float                                BlendConstantColorRed;
167710e230b6Smaya   float                                BlendConstantColorGreen;
167810e230b6Smaya   float                                BlendConstantColorBlue;
167910e230b6Smaya   float                                BlendConstantColorAlpha;
168010e230b6Smaya};
168110e230b6Smaya
168296c5ddc4Srjsstatic inline __attribute__((always_inline)) void
168396c5ddc4SrjsGFX5_3DSTATE_CONSTANT_COLOR_pack(__attribute__((unused)) __gen_user_data *data,
168410e230b6Smaya                                 __attribute__((unused)) void * restrict dst,
168596c5ddc4Srjs                                 __attribute__((unused)) const struct GFX5_3DSTATE_CONSTANT_COLOR * restrict values)
168610e230b6Smaya{
168710e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
168810e230b6Smaya
168910e230b6Smaya   dw[0] =
169010e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
169110e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
169210e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
169310e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
169410e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
169510e230b6Smaya
169610e230b6Smaya   dw[1] =
169710e230b6Smaya      __gen_float(values->BlendConstantColorRed);
169810e230b6Smaya
169910e230b6Smaya   dw[2] =
170010e230b6Smaya      __gen_float(values->BlendConstantColorGreen);
170110e230b6Smaya
170210e230b6Smaya   dw[3] =
170310e230b6Smaya      __gen_float(values->BlendConstantColorBlue);
170410e230b6Smaya
170510e230b6Smaya   dw[4] =
170610e230b6Smaya      __gen_float(values->BlendConstantColorAlpha);
170710e230b6Smaya}
170810e230b6Smaya
170996c5ddc4Srjs#define GFX5_3DSTATE_DEPTH_BUFFER_length       6
171096c5ddc4Srjs#define GFX5_3DSTATE_DEPTH_BUFFER_length_bias      2
171196c5ddc4Srjs#define GFX5_3DSTATE_DEPTH_BUFFER_header        \
171210e230b6Smaya   .DWordLength                         =      4,  \
171310e230b6Smaya   ._3DCommandSubOpcode                 =      5,  \
171410e230b6Smaya   ._3DCommandOpcode                    =      1,  \
171510e230b6Smaya   .CommandSubType                      =      3,  \
171610e230b6Smaya   .CommandType                         =      3
171710e230b6Smaya
171896c5ddc4Srjsstruct GFX5_3DSTATE_DEPTH_BUFFER {
171910e230b6Smaya   uint32_t                             DWordLength;
172010e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
172110e230b6Smaya   uint32_t                             _3DCommandOpcode;
172210e230b6Smaya   uint32_t                             CommandSubType;
172310e230b6Smaya   uint32_t                             CommandType;
172410e230b6Smaya   uint32_t                             SurfacePitch;
172510e230b6Smaya   uint32_t                             SurfaceFormat;
172610e230b6Smaya#define D32_FLOAT_S8X24_UINT                     0
172710e230b6Smaya#define D32_FLOAT                                1
172810e230b6Smaya#define D24_UNORM_S8_UINT                        2
172910e230b6Smaya#define D24_UNORM_X8_UINT                        3
173010e230b6Smaya#define D16_UNORM                                5
173110e230b6Smaya   bool                                 SeparateStencilBufferEnable;
173210e230b6Smaya   bool                                 HierarchicalDepthBufferEnable;
173310e230b6Smaya   uint32_t                             SoftwareTiledRenderingMode;
173410e230b6Smaya#define NORMAL                                   0
173510e230b6Smaya#define STR1                                     1
173610e230b6Smaya#define STR2                                     3
173710e230b6Smaya   uint32_t                             TileWalk;
173810e230b6Smaya#define TILEWALK_YMAJOR                          1
173910e230b6Smaya   bool                                 TiledSurface;
174010e230b6Smaya   uint32_t                             SurfaceType;
174110e230b6Smaya#define SURFTYPE_1D                              0
174210e230b6Smaya#define SURFTYPE_2D                              1
174310e230b6Smaya#define SURFTYPE_3D                              2
174410e230b6Smaya#define SURFTYPE_CUBE                            3
174510e230b6Smaya#define SURFTYPE_NULL                            7
174610e230b6Smaya   __gen_address_type                   SurfaceBaseAddress;
174710e230b6Smaya   uint32_t                             MIPMapLayoutMode;
174810e230b6Smaya#define MIPLAYOUT_BELOW                          0
174910e230b6Smaya#define MIPLAYOUT_RIGHT                          1
175010e230b6Smaya   uint32_t                             LOD;
175110e230b6Smaya   uint32_t                             Width;
175210e230b6Smaya   uint32_t                             Height;
175310e230b6Smaya   uint32_t                             RenderTargetViewExtent;
175410e230b6Smaya   uint32_t                             MinimumArrayElement;
175510e230b6Smaya   uint32_t                             Depth;
175610e230b6Smaya   int32_t                              DepthCoordinateOffsetX;
175710e230b6Smaya   int32_t                              DepthCoordinateOffsetY;
175810e230b6Smaya};
175910e230b6Smaya
176096c5ddc4Srjsstatic inline __attribute__((always_inline)) void
176196c5ddc4SrjsGFX5_3DSTATE_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
176210e230b6Smaya                               __attribute__((unused)) void * restrict dst,
176396c5ddc4Srjs                               __attribute__((unused)) const struct GFX5_3DSTATE_DEPTH_BUFFER * restrict values)
176410e230b6Smaya{
176510e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
176610e230b6Smaya
176710e230b6Smaya   dw[0] =
176810e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
176910e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
177010e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
177110e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
177210e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
177310e230b6Smaya
177410e230b6Smaya   dw[1] =
177510e230b6Smaya      __gen_uint(values->SurfacePitch, 0, 16) |
177610e230b6Smaya      __gen_uint(values->SurfaceFormat, 18, 20) |
177710e230b6Smaya      __gen_uint(values->SeparateStencilBufferEnable, 21, 21) |
177810e230b6Smaya      __gen_uint(values->HierarchicalDepthBufferEnable, 22, 22) |
177910e230b6Smaya      __gen_uint(values->SoftwareTiledRenderingMode, 23, 24) |
178010e230b6Smaya      __gen_uint(values->TileWalk, 26, 26) |
178110e230b6Smaya      __gen_uint(values->TiledSurface, 27, 27) |
178210e230b6Smaya      __gen_uint(values->SurfaceType, 29, 31);
178310e230b6Smaya
178496c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
178510e230b6Smaya
178610e230b6Smaya   dw[3] =
178710e230b6Smaya      __gen_uint(values->MIPMapLayoutMode, 1, 1) |
178810e230b6Smaya      __gen_uint(values->LOD, 2, 5) |
178910e230b6Smaya      __gen_uint(values->Width, 6, 18) |
179010e230b6Smaya      __gen_uint(values->Height, 19, 31);
179110e230b6Smaya
179210e230b6Smaya   dw[4] =
179310e230b6Smaya      __gen_uint(values->RenderTargetViewExtent, 1, 9) |
179410e230b6Smaya      __gen_uint(values->MinimumArrayElement, 10, 20) |
179510e230b6Smaya      __gen_uint(values->Depth, 21, 31);
179610e230b6Smaya
179710e230b6Smaya   dw[5] =
179810e230b6Smaya      __gen_sint(values->DepthCoordinateOffsetX, 0, 15) |
179910e230b6Smaya      __gen_sint(values->DepthCoordinateOffsetY, 16, 31);
180010e230b6Smaya}
180110e230b6Smaya
180296c5ddc4Srjs#define GFX5_3DSTATE_DRAWING_RECTANGLE_length      4
180396c5ddc4Srjs#define GFX5_3DSTATE_DRAWING_RECTANGLE_length_bias      2
180496c5ddc4Srjs#define GFX5_3DSTATE_DRAWING_RECTANGLE_header   \
180510e230b6Smaya   .DWordLength                         =      2,  \
180610e230b6Smaya   ._3DCommandSubOpcode                 =      0,  \
180710e230b6Smaya   ._3DCommandOpcode                    =      1,  \
180810e230b6Smaya   .CommandSubType                      =      3,  \
180910e230b6Smaya   .CommandType                         =      3
181010e230b6Smaya
181196c5ddc4Srjsstruct GFX5_3DSTATE_DRAWING_RECTANGLE {
181210e230b6Smaya   uint32_t                             DWordLength;
181310e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
181410e230b6Smaya   uint32_t                             _3DCommandOpcode;
181510e230b6Smaya   uint32_t                             CommandSubType;
181610e230b6Smaya   uint32_t                             CommandType;
181710e230b6Smaya   uint32_t                             ClippedDrawingRectangleXMin;
181810e230b6Smaya   uint32_t                             ClippedDrawingRectangleYMin;
181910e230b6Smaya   uint32_t                             ClippedDrawingRectangleXMax;
182010e230b6Smaya   uint32_t                             ClippedDrawingRectangleYMax;
182110e230b6Smaya   int32_t                              DrawingRectangleOriginX;
182210e230b6Smaya   int32_t                              DrawingRectangleOriginY;
182310e230b6Smaya};
182410e230b6Smaya
182596c5ddc4Srjsstatic inline __attribute__((always_inline)) void
182696c5ddc4SrjsGFX5_3DSTATE_DRAWING_RECTANGLE_pack(__attribute__((unused)) __gen_user_data *data,
182710e230b6Smaya                                    __attribute__((unused)) void * restrict dst,
182896c5ddc4Srjs                                    __attribute__((unused)) const struct GFX5_3DSTATE_DRAWING_RECTANGLE * restrict values)
182910e230b6Smaya{
183010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
183110e230b6Smaya
183210e230b6Smaya   dw[0] =
183310e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
183410e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
183510e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
183610e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
183710e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
183810e230b6Smaya
183910e230b6Smaya   dw[1] =
184010e230b6Smaya      __gen_uint(values->ClippedDrawingRectangleXMin, 0, 15) |
184110e230b6Smaya      __gen_uint(values->ClippedDrawingRectangleYMin, 16, 31);
184210e230b6Smaya
184310e230b6Smaya   dw[2] =
184410e230b6Smaya      __gen_uint(values->ClippedDrawingRectangleXMax, 0, 15) |
184510e230b6Smaya      __gen_uint(values->ClippedDrawingRectangleYMax, 16, 31);
184610e230b6Smaya
184710e230b6Smaya   dw[3] =
184810e230b6Smaya      __gen_sint(values->DrawingRectangleOriginX, 0, 15) |
184910e230b6Smaya      __gen_sint(values->DrawingRectangleOriginY, 16, 31);
185010e230b6Smaya}
185110e230b6Smaya
185296c5ddc4Srjs#define GFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length      2
185396c5ddc4Srjs#define GFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length_bias      2
185496c5ddc4Srjs#define GFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_header\
185510e230b6Smaya   .DWordLength                         =      0,  \
185610e230b6Smaya   ._3DCommandSubOpcode                 =      9,  \
185710e230b6Smaya   ._3DCommandOpcode                    =      1,  \
185810e230b6Smaya   .CommandSubType                      =      3,  \
185910e230b6Smaya   .CommandType                         =      3
186010e230b6Smaya
186196c5ddc4Srjsstruct GFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP {
186210e230b6Smaya   uint32_t                             DWordLength;
186310e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
186410e230b6Smaya   uint32_t                             _3DCommandOpcode;
186510e230b6Smaya   uint32_t                             CommandSubType;
186610e230b6Smaya   uint32_t                             CommandType;
186710e230b6Smaya   float                                GlobalDepthOffsetClamp;
186810e230b6Smaya};
186910e230b6Smaya
187096c5ddc4Srjsstatic inline __attribute__((always_inline)) void
187196c5ddc4SrjsGFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_pack(__attribute__((unused)) __gen_user_data *data,
187210e230b6Smaya                                            __attribute__((unused)) void * restrict dst,
187396c5ddc4Srjs                                            __attribute__((unused)) const struct GFX5_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP * restrict values)
187410e230b6Smaya{
187510e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
187610e230b6Smaya
187710e230b6Smaya   dw[0] =
187810e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
187910e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
188010e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
188110e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
188210e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
188310e230b6Smaya
188410e230b6Smaya   dw[1] =
188510e230b6Smaya      __gen_float(values->GlobalDepthOffsetClamp);
188610e230b6Smaya}
188710e230b6Smaya
188896c5ddc4Srjs#define GFX5_3DSTATE_HIER_DEPTH_BUFFER_length      3
188996c5ddc4Srjs#define GFX5_3DSTATE_HIER_DEPTH_BUFFER_length_bias      2
189096c5ddc4Srjs#define GFX5_3DSTATE_HIER_DEPTH_BUFFER_header   \
189110e230b6Smaya   .DWordLength                         =      1,  \
189210e230b6Smaya   ._3DCommandSubOpcode                 =     15,  \
189310e230b6Smaya   ._3DCommandOpcode                    =      1,  \
189410e230b6Smaya   .CommandSubType                      =      3,  \
189510e230b6Smaya   .CommandType                         =      3
189610e230b6Smaya
189796c5ddc4Srjsstruct GFX5_3DSTATE_HIER_DEPTH_BUFFER {
189810e230b6Smaya   uint32_t                             DWordLength;
189910e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
190010e230b6Smaya   uint32_t                             _3DCommandOpcode;
190110e230b6Smaya   uint32_t                             CommandSubType;
190210e230b6Smaya   uint32_t                             CommandType;
190310e230b6Smaya   uint32_t                             SurfacePitch;
190410e230b6Smaya   __gen_address_type                   SurfaceBaseAddress;
190510e230b6Smaya};
190610e230b6Smaya
190796c5ddc4Srjsstatic inline __attribute__((always_inline)) void
190896c5ddc4SrjsGFX5_3DSTATE_HIER_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
190910e230b6Smaya                                    __attribute__((unused)) void * restrict dst,
191096c5ddc4Srjs                                    __attribute__((unused)) const struct GFX5_3DSTATE_HIER_DEPTH_BUFFER * restrict values)
191110e230b6Smaya{
191210e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
191310e230b6Smaya
191410e230b6Smaya   dw[0] =
191510e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
191610e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
191710e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
191810e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
191910e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
192010e230b6Smaya
192110e230b6Smaya   dw[1] =
192210e230b6Smaya      __gen_uint(values->SurfacePitch, 0, 16);
192310e230b6Smaya
192496c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
192510e230b6Smaya}
192610e230b6Smaya
192796c5ddc4Srjs#define GFX5_3DSTATE_INDEX_BUFFER_length       3
192896c5ddc4Srjs#define GFX5_3DSTATE_INDEX_BUFFER_length_bias      2
192996c5ddc4Srjs#define GFX5_3DSTATE_INDEX_BUFFER_header        \
193010e230b6Smaya   .DWordLength                         =      1,  \
193110e230b6Smaya   ._3DCommandSubOpcode                 =     10,  \
193210e230b6Smaya   ._3DCommandOpcode                    =      0,  \
193310e230b6Smaya   .CommandSubType                      =      3,  \
193410e230b6Smaya   .CommandType                         =      3
193510e230b6Smaya
193696c5ddc4Srjsstruct GFX5_3DSTATE_INDEX_BUFFER {
193710e230b6Smaya   uint32_t                             DWordLength;
193810e230b6Smaya   uint32_t                             IndexFormat;
193910e230b6Smaya#define INDEX_BYTE                               0
194010e230b6Smaya#define INDEX_WORD                               1
194110e230b6Smaya#define INDEX_DWORD                              2
194210e230b6Smaya   bool                                 CutIndexEnable;
194310e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
194410e230b6Smaya   uint32_t                             _3DCommandOpcode;
194510e230b6Smaya   uint32_t                             CommandSubType;
194610e230b6Smaya   uint32_t                             CommandType;
194710e230b6Smaya   __gen_address_type                   BufferStartingAddress;
194810e230b6Smaya   __gen_address_type                   BufferEndingAddress;
194910e230b6Smaya};
195010e230b6Smaya
195196c5ddc4Srjsstatic inline __attribute__((always_inline)) void
195296c5ddc4SrjsGFX5_3DSTATE_INDEX_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
195310e230b6Smaya                               __attribute__((unused)) void * restrict dst,
195496c5ddc4Srjs                               __attribute__((unused)) const struct GFX5_3DSTATE_INDEX_BUFFER * restrict values)
195510e230b6Smaya{
195610e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
195710e230b6Smaya
195810e230b6Smaya   dw[0] =
195910e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
196010e230b6Smaya      __gen_uint(values->IndexFormat, 8, 9) |
196110e230b6Smaya      __gen_uint(values->CutIndexEnable, 10, 10) |
196210e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
196310e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
196410e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
196510e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
196610e230b6Smaya
196796c5ddc4Srjs   dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, 0, 0, 31);
196810e230b6Smaya
196996c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->BufferEndingAddress, 0, 0, 31);
197010e230b6Smaya}
197110e230b6Smaya
197296c5ddc4Srjs#define GFX5_3DSTATE_LINE_STIPPLE_length       3
197396c5ddc4Srjs#define GFX5_3DSTATE_LINE_STIPPLE_length_bias      2
197496c5ddc4Srjs#define GFX5_3DSTATE_LINE_STIPPLE_header        \
197510e230b6Smaya   .DWordLength                         =      1,  \
197610e230b6Smaya   ._3DCommandSubOpcode                 =      8,  \
197710e230b6Smaya   ._3DCommandOpcode                    =      1,  \
197810e230b6Smaya   .CommandSubType                      =      3,  \
197910e230b6Smaya   .CommandType                         =      3
198010e230b6Smaya
198196c5ddc4Srjsstruct GFX5_3DSTATE_LINE_STIPPLE {
198210e230b6Smaya   uint32_t                             DWordLength;
198310e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
198410e230b6Smaya   uint32_t                             _3DCommandOpcode;
198510e230b6Smaya   uint32_t                             CommandSubType;
198610e230b6Smaya   uint32_t                             CommandType;
198710e230b6Smaya   uint32_t                             LineStipplePattern;
198810e230b6Smaya   uint32_t                             CurrentStippleIndex;
198910e230b6Smaya   uint32_t                             CurrentRepeatCounter;
199010e230b6Smaya   bool                                 ModifyEnable;
199110e230b6Smaya   uint32_t                             LineStippleRepeatCount;
199210e230b6Smaya   float                                LineStippleInverseRepeatCount;
199310e230b6Smaya};
199410e230b6Smaya
199596c5ddc4Srjsstatic inline __attribute__((always_inline)) void
199696c5ddc4SrjsGFX5_3DSTATE_LINE_STIPPLE_pack(__attribute__((unused)) __gen_user_data *data,
199710e230b6Smaya                               __attribute__((unused)) void * restrict dst,
199896c5ddc4Srjs                               __attribute__((unused)) const struct GFX5_3DSTATE_LINE_STIPPLE * restrict values)
199910e230b6Smaya{
200010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
200110e230b6Smaya
200210e230b6Smaya   dw[0] =
200310e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
200410e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
200510e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
200610e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
200710e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
200810e230b6Smaya
200910e230b6Smaya   dw[1] =
201010e230b6Smaya      __gen_uint(values->LineStipplePattern, 0, 15) |
201110e230b6Smaya      __gen_uint(values->CurrentStippleIndex, 16, 19) |
201210e230b6Smaya      __gen_uint(values->CurrentRepeatCounter, 21, 29) |
201310e230b6Smaya      __gen_uint(values->ModifyEnable, 31, 31);
201410e230b6Smaya
201510e230b6Smaya   dw[2] =
201610e230b6Smaya      __gen_uint(values->LineStippleRepeatCount, 0, 8) |
201710e230b6Smaya      __gen_ufixed(values->LineStippleInverseRepeatCount, 16, 31, 13);
201810e230b6Smaya}
201910e230b6Smaya
202096c5ddc4Srjs#define GFX5_3DSTATE_PIPELINED_POINTERS_length      7
202196c5ddc4Srjs#define GFX5_3DSTATE_PIPELINED_POINTERS_length_bias      2
202296c5ddc4Srjs#define GFX5_3DSTATE_PIPELINED_POINTERS_header  \
202310e230b6Smaya   .DWordLength                         =      5,  \
202410e230b6Smaya   ._3DCommandSubOpcode                 =      0,  \
202510e230b6Smaya   ._3DCommandOpcode                    =      0,  \
202610e230b6Smaya   .CommandSubType                      =      3,  \
202710e230b6Smaya   .CommandType                         =      3
202810e230b6Smaya
202996c5ddc4Srjsstruct GFX5_3DSTATE_PIPELINED_POINTERS {
203010e230b6Smaya   uint32_t                             DWordLength;
203110e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
203210e230b6Smaya   uint32_t                             _3DCommandOpcode;
203310e230b6Smaya   uint32_t                             CommandSubType;
203410e230b6Smaya   uint32_t                             CommandType;
203510e230b6Smaya   __gen_address_type                   PointertoVSState;
203610e230b6Smaya   bool                                 GSEnable;
203710e230b6Smaya   __gen_address_type                   PointertoGSState;
203810e230b6Smaya   bool                                 ClipEnable;
203910e230b6Smaya   __gen_address_type                   PointertoCLIPState;
204010e230b6Smaya   __gen_address_type                   PointertoSFState;
204110e230b6Smaya   __gen_address_type                   PointertoWMState;
204210e230b6Smaya   __gen_address_type                   PointertoColorCalcState;
204310e230b6Smaya};
204410e230b6Smaya
204596c5ddc4Srjsstatic inline __attribute__((always_inline)) void
204696c5ddc4SrjsGFX5_3DSTATE_PIPELINED_POINTERS_pack(__attribute__((unused)) __gen_user_data *data,
204710e230b6Smaya                                     __attribute__((unused)) void * restrict dst,
204896c5ddc4Srjs                                     __attribute__((unused)) const struct GFX5_3DSTATE_PIPELINED_POINTERS * restrict values)
204910e230b6Smaya{
205010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
205110e230b6Smaya
205210e230b6Smaya   dw[0] =
205310e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
205410e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
205510e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
205610e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
205710e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
205810e230b6Smaya
205996c5ddc4Srjs   dw[1] = __gen_address(data, &dw[1], values->PointertoVSState, 0, 5, 31);
206010e230b6Smaya
206110e230b6Smaya   const uint32_t v2 =
206210e230b6Smaya      __gen_uint(values->GSEnable, 0, 0);
206396c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->PointertoGSState, v2, 5, 31);
206410e230b6Smaya
206510e230b6Smaya   const uint32_t v3 =
206610e230b6Smaya      __gen_uint(values->ClipEnable, 0, 0);
206796c5ddc4Srjs   dw[3] = __gen_address(data, &dw[3], values->PointertoCLIPState, v3, 5, 31);
206810e230b6Smaya
206996c5ddc4Srjs   dw[4] = __gen_address(data, &dw[4], values->PointertoSFState, 0, 5, 31);
207010e230b6Smaya
207196c5ddc4Srjs   dw[5] = __gen_address(data, &dw[5], values->PointertoWMState, 0, 5, 31);
207210e230b6Smaya
207396c5ddc4Srjs   dw[6] = __gen_address(data, &dw[6], values->PointertoColorCalcState, 0, 5, 31);
207410e230b6Smaya}
207510e230b6Smaya
207696c5ddc4Srjs#define GFX5_3DSTATE_POLY_STIPPLE_OFFSET_length      2
207796c5ddc4Srjs#define GFX5_3DSTATE_POLY_STIPPLE_OFFSET_length_bias      2
207896c5ddc4Srjs#define GFX5_3DSTATE_POLY_STIPPLE_OFFSET_header \
207910e230b6Smaya   .DWordLength                         =      0,  \
208010e230b6Smaya   ._3DCommandSubOpcode                 =      6,  \
208110e230b6Smaya   ._3DCommandOpcode                    =      1,  \
208210e230b6Smaya   .CommandSubType                      =      3,  \
208310e230b6Smaya   .CommandType                         =      3
208410e230b6Smaya
208596c5ddc4Srjsstruct GFX5_3DSTATE_POLY_STIPPLE_OFFSET {
208610e230b6Smaya   uint32_t                             DWordLength;
208710e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
208810e230b6Smaya   uint32_t                             _3DCommandOpcode;
208910e230b6Smaya   uint32_t                             CommandSubType;
209010e230b6Smaya   uint32_t                             CommandType;
209110e230b6Smaya   uint32_t                             PolygonStippleYOffset;
209210e230b6Smaya   uint32_t                             PolygonStippleXOffset;
209310e230b6Smaya};
209410e230b6Smaya
209596c5ddc4Srjsstatic inline __attribute__((always_inline)) void
209696c5ddc4SrjsGFX5_3DSTATE_POLY_STIPPLE_OFFSET_pack(__attribute__((unused)) __gen_user_data *data,
209710e230b6Smaya                                      __attribute__((unused)) void * restrict dst,
209896c5ddc4Srjs                                      __attribute__((unused)) const struct GFX5_3DSTATE_POLY_STIPPLE_OFFSET * restrict values)
209910e230b6Smaya{
210010e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
210110e230b6Smaya
210210e230b6Smaya   dw[0] =
210310e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
210410e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
210510e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
210610e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
210710e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
210810e230b6Smaya
210910e230b6Smaya   dw[1] =
211010e230b6Smaya      __gen_uint(values->PolygonStippleYOffset, 0, 4) |
211110e230b6Smaya      __gen_uint(values->PolygonStippleXOffset, 8, 12);
211210e230b6Smaya}
211310e230b6Smaya
211496c5ddc4Srjs#define GFX5_3DSTATE_POLY_STIPPLE_PATTERN_length     33
211596c5ddc4Srjs#define GFX5_3DSTATE_POLY_STIPPLE_PATTERN_length_bias      2
211696c5ddc4Srjs#define GFX5_3DSTATE_POLY_STIPPLE_PATTERN_header\
211710e230b6Smaya   .DWordLength                         =     31,  \
211810e230b6Smaya   ._3DCommandSubOpcode                 =      7,  \
211910e230b6Smaya   ._3DCommandOpcode                    =      1,  \
212010e230b6Smaya   .CommandSubType                      =      3,  \
212110e230b6Smaya   .CommandType                         =      3
212210e230b6Smaya
212396c5ddc4Srjsstruct GFX5_3DSTATE_POLY_STIPPLE_PATTERN {
212410e230b6Smaya   uint32_t                             DWordLength;
212510e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
212610e230b6Smaya   uint32_t                             _3DCommandOpcode;
212710e230b6Smaya   uint32_t                             CommandSubType;
212810e230b6Smaya   uint32_t                             CommandType;
212910e230b6Smaya   uint32_t                             PatternRow[32];
213010e230b6Smaya};
213110e230b6Smaya
213296c5ddc4Srjsstatic inline __attribute__((always_inline)) void
213396c5ddc4SrjsGFX5_3DSTATE_POLY_STIPPLE_PATTERN_pack(__attribute__((unused)) __gen_user_data *data,
213410e230b6Smaya                                       __attribute__((unused)) void * restrict dst,
213596c5ddc4Srjs                                       __attribute__((unused)) const struct GFX5_3DSTATE_POLY_STIPPLE_PATTERN * restrict values)
213610e230b6Smaya{
213710e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
213810e230b6Smaya
213910e230b6Smaya   dw[0] =
214010e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
214110e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
214210e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
214310e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
214410e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
214510e230b6Smaya
214610e230b6Smaya   dw[1] =
214710e230b6Smaya      __gen_uint(values->PatternRow[0], 0, 31);
214810e230b6Smaya
214910e230b6Smaya   dw[2] =
215010e230b6Smaya      __gen_uint(values->PatternRow[1], 0, 31);
215110e230b6Smaya
215210e230b6Smaya   dw[3] =
215310e230b6Smaya      __gen_uint(values->PatternRow[2], 0, 31);
215410e230b6Smaya
215510e230b6Smaya   dw[4] =
215610e230b6Smaya      __gen_uint(values->PatternRow[3], 0, 31);
215710e230b6Smaya
215810e230b6Smaya   dw[5] =
215910e230b6Smaya      __gen_uint(values->PatternRow[4], 0, 31);
216010e230b6Smaya
216110e230b6Smaya   dw[6] =
216210e230b6Smaya      __gen_uint(values->PatternRow[5], 0, 31);
216310e230b6Smaya
216410e230b6Smaya   dw[7] =
216510e230b6Smaya      __gen_uint(values->PatternRow[6], 0, 31);
216610e230b6Smaya
216710e230b6Smaya   dw[8] =
216810e230b6Smaya      __gen_uint(values->PatternRow[7], 0, 31);
216910e230b6Smaya
217010e230b6Smaya   dw[9] =
217110e230b6Smaya      __gen_uint(values->PatternRow[8], 0, 31);
217210e230b6Smaya
217310e230b6Smaya   dw[10] =
217410e230b6Smaya      __gen_uint(values->PatternRow[9], 0, 31);
217510e230b6Smaya
217610e230b6Smaya   dw[11] =
217710e230b6Smaya      __gen_uint(values->PatternRow[10], 0, 31);
217810e230b6Smaya
217910e230b6Smaya   dw[12] =
218010e230b6Smaya      __gen_uint(values->PatternRow[11], 0, 31);
218110e230b6Smaya
218210e230b6Smaya   dw[13] =
218310e230b6Smaya      __gen_uint(values->PatternRow[12], 0, 31);
218410e230b6Smaya
218510e230b6Smaya   dw[14] =
218610e230b6Smaya      __gen_uint(values->PatternRow[13], 0, 31);
218710e230b6Smaya
218810e230b6Smaya   dw[15] =
218910e230b6Smaya      __gen_uint(values->PatternRow[14], 0, 31);
219010e230b6Smaya
219110e230b6Smaya   dw[16] =
219210e230b6Smaya      __gen_uint(values->PatternRow[15], 0, 31);
219310e230b6Smaya
219410e230b6Smaya   dw[17] =
219510e230b6Smaya      __gen_uint(values->PatternRow[16], 0, 31);
219610e230b6Smaya
219710e230b6Smaya   dw[18] =
219810e230b6Smaya      __gen_uint(values->PatternRow[17], 0, 31);
219910e230b6Smaya
220010e230b6Smaya   dw[19] =
220110e230b6Smaya      __gen_uint(values->PatternRow[18], 0, 31);
220210e230b6Smaya
220310e230b6Smaya   dw[20] =
220410e230b6Smaya      __gen_uint(values->PatternRow[19], 0, 31);
220510e230b6Smaya
220610e230b6Smaya   dw[21] =
220710e230b6Smaya      __gen_uint(values->PatternRow[20], 0, 31);
220810e230b6Smaya
220910e230b6Smaya   dw[22] =
221010e230b6Smaya      __gen_uint(values->PatternRow[21], 0, 31);
221110e230b6Smaya
221210e230b6Smaya   dw[23] =
221310e230b6Smaya      __gen_uint(values->PatternRow[22], 0, 31);
221410e230b6Smaya
221510e230b6Smaya   dw[24] =
221610e230b6Smaya      __gen_uint(values->PatternRow[23], 0, 31);
221710e230b6Smaya
221810e230b6Smaya   dw[25] =
221910e230b6Smaya      __gen_uint(values->PatternRow[24], 0, 31);
222010e230b6Smaya
222110e230b6Smaya   dw[26] =
222210e230b6Smaya      __gen_uint(values->PatternRow[25], 0, 31);
222310e230b6Smaya
222410e230b6Smaya   dw[27] =
222510e230b6Smaya      __gen_uint(values->PatternRow[26], 0, 31);
222610e230b6Smaya
222710e230b6Smaya   dw[28] =
222810e230b6Smaya      __gen_uint(values->PatternRow[27], 0, 31);
222910e230b6Smaya
223010e230b6Smaya   dw[29] =
223110e230b6Smaya      __gen_uint(values->PatternRow[28], 0, 31);
223210e230b6Smaya
223310e230b6Smaya   dw[30] =
223410e230b6Smaya      __gen_uint(values->PatternRow[29], 0, 31);
223510e230b6Smaya
223610e230b6Smaya   dw[31] =
223710e230b6Smaya      __gen_uint(values->PatternRow[30], 0, 31);
223810e230b6Smaya
223910e230b6Smaya   dw[32] =
224010e230b6Smaya      __gen_uint(values->PatternRow[31], 0, 31);
224110e230b6Smaya}
224210e230b6Smaya
224396c5ddc4Srjs#define GFX5_3DSTATE_STENCIL_BUFFER_length      3
224496c5ddc4Srjs#define GFX5_3DSTATE_STENCIL_BUFFER_length_bias      2
224596c5ddc4Srjs#define GFX5_3DSTATE_STENCIL_BUFFER_header      \
224610e230b6Smaya   .DWordLength                         =      1,  \
224710e230b6Smaya   ._3DCommandSubOpcode                 =     14,  \
224810e230b6Smaya   ._3DCommandOpcode                    =      1,  \
224910e230b6Smaya   .CommandSubType                      =      3,  \
225010e230b6Smaya   .CommandType                         =      3
225110e230b6Smaya
225296c5ddc4Srjsstruct GFX5_3DSTATE_STENCIL_BUFFER {
225310e230b6Smaya   uint32_t                             DWordLength;
225410e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
225510e230b6Smaya   uint32_t                             _3DCommandOpcode;
225610e230b6Smaya   uint32_t                             CommandSubType;
225710e230b6Smaya   uint32_t                             CommandType;
225810e230b6Smaya   uint32_t                             SurfacePitch;
225910e230b6Smaya   __gen_address_type                   SurfaceBaseAddress;
226010e230b6Smaya};
226110e230b6Smaya
226296c5ddc4Srjsstatic inline __attribute__((always_inline)) void
226396c5ddc4SrjsGFX5_3DSTATE_STENCIL_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
226410e230b6Smaya                                 __attribute__((unused)) void * restrict dst,
226596c5ddc4Srjs                                 __attribute__((unused)) const struct GFX5_3DSTATE_STENCIL_BUFFER * restrict values)
226610e230b6Smaya{
226710e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
226810e230b6Smaya
226910e230b6Smaya   dw[0] =
227010e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
227110e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
227210e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
227310e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
227410e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
227510e230b6Smaya
227610e230b6Smaya   dw[1] =
227710e230b6Smaya      __gen_uint(values->SurfacePitch, 0, 16);
227810e230b6Smaya
227996c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31);
228010e230b6Smaya}
228110e230b6Smaya
228296c5ddc4Srjs#define GFX5_3DSTATE_VERTEX_BUFFERS_length_bias      2
228396c5ddc4Srjs#define GFX5_3DSTATE_VERTEX_BUFFERS_header      \
228410e230b6Smaya   .DWordLength                         =      3,  \
228510e230b6Smaya   ._3DCommandSubOpcode                 =      8,  \
228610e230b6Smaya   ._3DCommandOpcode                    =      0,  \
228710e230b6Smaya   .CommandSubType                      =      3,  \
228810e230b6Smaya   .CommandType                         =      3
228910e230b6Smaya
229096c5ddc4Srjsstruct GFX5_3DSTATE_VERTEX_BUFFERS {
229110e230b6Smaya   uint32_t                             DWordLength;
229210e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
229310e230b6Smaya   uint32_t                             _3DCommandOpcode;
229410e230b6Smaya   uint32_t                             CommandSubType;
229510e230b6Smaya   uint32_t                             CommandType;
229610e230b6Smaya   /* variable length fields follow */
229710e230b6Smaya};
229810e230b6Smaya
229996c5ddc4Srjsstatic inline __attribute__((always_inline)) void
230096c5ddc4SrjsGFX5_3DSTATE_VERTEX_BUFFERS_pack(__attribute__((unused)) __gen_user_data *data,
230110e230b6Smaya                                 __attribute__((unused)) void * restrict dst,
230296c5ddc4Srjs                                 __attribute__((unused)) const struct GFX5_3DSTATE_VERTEX_BUFFERS * restrict values)
230310e230b6Smaya{
230410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
230510e230b6Smaya
230610e230b6Smaya   dw[0] =
230710e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
230810e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
230910e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
231010e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
231110e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
231210e230b6Smaya}
231310e230b6Smaya
231496c5ddc4Srjs#define GFX5_3DSTATE_VERTEX_ELEMENTS_length_bias      2
231596c5ddc4Srjs#define GFX5_3DSTATE_VERTEX_ELEMENTS_header     \
231610e230b6Smaya   .DWordLength                         =      1,  \
231710e230b6Smaya   ._3DCommandSubOpcode                 =      9,  \
231810e230b6Smaya   ._3DCommandOpcode                    =      0,  \
231910e230b6Smaya   .CommandSubType                      =      3,  \
232010e230b6Smaya   .CommandType                         =      3
232110e230b6Smaya
232296c5ddc4Srjsstruct GFX5_3DSTATE_VERTEX_ELEMENTS {
232310e230b6Smaya   uint32_t                             DWordLength;
232410e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
232510e230b6Smaya   uint32_t                             _3DCommandOpcode;
232610e230b6Smaya   uint32_t                             CommandSubType;
232710e230b6Smaya   uint32_t                             CommandType;
232810e230b6Smaya   /* variable length fields follow */
232910e230b6Smaya};
233010e230b6Smaya
233196c5ddc4Srjsstatic inline __attribute__((always_inline)) void
233296c5ddc4SrjsGFX5_3DSTATE_VERTEX_ELEMENTS_pack(__attribute__((unused)) __gen_user_data *data,
233310e230b6Smaya                                  __attribute__((unused)) void * restrict dst,
233496c5ddc4Srjs                                  __attribute__((unused)) const struct GFX5_3DSTATE_VERTEX_ELEMENTS * restrict values)
233510e230b6Smaya{
233610e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
233710e230b6Smaya
233810e230b6Smaya   dw[0] =
233910e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
234010e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
234110e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
234210e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
234310e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
234410e230b6Smaya}
234510e230b6Smaya
234696c5ddc4Srjs#define GFX5_3DSTATE_VF_STATISTICS_length      1
234796c5ddc4Srjs#define GFX5_3DSTATE_VF_STATISTICS_length_bias      1
234896c5ddc4Srjs#define GFX5_3DSTATE_VF_STATISTICS_header       \
234910e230b6Smaya   ._3DCommandSubOpcode                 =     11,  \
235010e230b6Smaya   ._3DCommandOpcode                    =      0,  \
235110e230b6Smaya   .CommandSubType                      =      1,  \
235210e230b6Smaya   .CommandType                         =      3
235310e230b6Smaya
235496c5ddc4Srjsstruct GFX5_3DSTATE_VF_STATISTICS {
235510e230b6Smaya   bool                                 StatisticsEnable;
235610e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
235710e230b6Smaya   uint32_t                             _3DCommandOpcode;
235810e230b6Smaya   uint32_t                             CommandSubType;
235910e230b6Smaya   uint32_t                             CommandType;
236010e230b6Smaya};
236110e230b6Smaya
236296c5ddc4Srjsstatic inline __attribute__((always_inline)) void
236396c5ddc4SrjsGFX5_3DSTATE_VF_STATISTICS_pack(__attribute__((unused)) __gen_user_data *data,
236410e230b6Smaya                                __attribute__((unused)) void * restrict dst,
236596c5ddc4Srjs                                __attribute__((unused)) const struct GFX5_3DSTATE_VF_STATISTICS * restrict values)
236610e230b6Smaya{
236710e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
236810e230b6Smaya
236910e230b6Smaya   dw[0] =
237010e230b6Smaya      __gen_uint(values->StatisticsEnable, 0, 0) |
237110e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
237210e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
237310e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
237410e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
237510e230b6Smaya}
237610e230b6Smaya
237796c5ddc4Srjs#define GFX5_CONSTANT_BUFFER_length            2
237896c5ddc4Srjs#define GFX5_CONSTANT_BUFFER_length_bias       2
237996c5ddc4Srjs#define GFX5_CONSTANT_BUFFER_header             \
238010e230b6Smaya   .DWordLength                         =      0,  \
238110e230b6Smaya   ._3DCommandSubOpcode                 =      2,  \
238210e230b6Smaya   ._3DCommandOpcode                    =      0,  \
238310e230b6Smaya   .CommandSubType                      =      0,  \
238410e230b6Smaya   .CommandType                         =      3
238510e230b6Smaya
238696c5ddc4Srjsstruct GFX5_CONSTANT_BUFFER {
238710e230b6Smaya   uint32_t                             DWordLength;
238810e230b6Smaya   bool                                 Valid;
238910e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
239010e230b6Smaya   uint32_t                             _3DCommandOpcode;
239110e230b6Smaya   uint32_t                             CommandSubType;
239210e230b6Smaya   uint32_t                             CommandType;
239310e230b6Smaya   uint32_t                             BufferLength;
239410e230b6Smaya   __gen_address_type                   BufferStartingAddress;
239510e230b6Smaya};
239610e230b6Smaya
239796c5ddc4Srjsstatic inline __attribute__((always_inline)) void
239896c5ddc4SrjsGFX5_CONSTANT_BUFFER_pack(__attribute__((unused)) __gen_user_data *data,
239910e230b6Smaya                          __attribute__((unused)) void * restrict dst,
240096c5ddc4Srjs                          __attribute__((unused)) const struct GFX5_CONSTANT_BUFFER * restrict values)
240110e230b6Smaya{
240210e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
240310e230b6Smaya
240410e230b6Smaya   dw[0] =
240510e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
240610e230b6Smaya      __gen_uint(values->Valid, 8, 8) |
240710e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
240810e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
240910e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
241010e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
241110e230b6Smaya
241210e230b6Smaya   const uint32_t v1 =
241310e230b6Smaya      __gen_uint(values->BufferLength, 0, 5);
241496c5ddc4Srjs   dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, v1, 6, 31);
241510e230b6Smaya}
241610e230b6Smaya
241796c5ddc4Srjs#define GFX5_CS_URB_STATE_length               2
241896c5ddc4Srjs#define GFX5_CS_URB_STATE_length_bias          2
241996c5ddc4Srjs#define GFX5_CS_URB_STATE_header                \
242010e230b6Smaya   .DWordLength                         =      0,  \
242110e230b6Smaya   ._3DCommandSubOpcode                 =      1,  \
242210e230b6Smaya   ._3DCommandOpcode                    =      0,  \
242310e230b6Smaya   .CommandSubType                      =      0,  \
242410e230b6Smaya   .CommandType                         =      3
242510e230b6Smaya
242696c5ddc4Srjsstruct GFX5_CS_URB_STATE {
242710e230b6Smaya   uint32_t                             DWordLength;
242810e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
242910e230b6Smaya   uint32_t                             _3DCommandOpcode;
243010e230b6Smaya   uint32_t                             CommandSubType;
243110e230b6Smaya   uint32_t                             CommandType;
243210e230b6Smaya   uint32_t                             NumberofURBEntries;
243310e230b6Smaya   uint32_t                             URBEntryAllocationSize;
243410e230b6Smaya};
243510e230b6Smaya
243696c5ddc4Srjsstatic inline __attribute__((always_inline)) void
243796c5ddc4SrjsGFX5_CS_URB_STATE_pack(__attribute__((unused)) __gen_user_data *data,
243810e230b6Smaya                       __attribute__((unused)) void * restrict dst,
243996c5ddc4Srjs                       __attribute__((unused)) const struct GFX5_CS_URB_STATE * restrict values)
244010e230b6Smaya{
244110e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
244210e230b6Smaya
244310e230b6Smaya   dw[0] =
244410e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
244510e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
244610e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
244710e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
244810e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
244910e230b6Smaya
245010e230b6Smaya   dw[1] =
245110e230b6Smaya      __gen_uint(values->NumberofURBEntries, 0, 2) |
245210e230b6Smaya      __gen_uint(values->URBEntryAllocationSize, 4, 8);
245310e230b6Smaya}
245410e230b6Smaya
245596c5ddc4Srjs#define GFX5_MI_FLUSH_length                   1
245696c5ddc4Srjs#define GFX5_MI_FLUSH_length_bias              1
245796c5ddc4Srjs#define GFX5_MI_FLUSH_header                    \
245810e230b6Smaya   .MICommandOpcode                     =      4,  \
245910e230b6Smaya   .CommandType                         =      0
246010e230b6Smaya
246196c5ddc4Srjsstruct GFX5_MI_FLUSH {
246210e230b6Smaya   uint32_t                             StateInstructionCacheInvalidate;
246310e230b6Smaya#define DontInvalidate                           0
246410e230b6Smaya#define Invalidate                               1
246510e230b6Smaya   uint32_t                             RenderCacheFlushInhibit;
246610e230b6Smaya#define Flush                                    0
246710e230b6Smaya#define DontFlush                                1
246810e230b6Smaya   uint32_t                             GlobalSnapshotCountReset;
246910e230b6Smaya#define DontReset                                0
247010e230b6Smaya#define Reset                                    1
247110e230b6Smaya   bool                                 GenericMediaStateClear;
247210e230b6Smaya   bool                                 IndirectStatePointersDisable;
247310e230b6Smaya   bool                                 ProtectedMemoryEnable;
247410e230b6Smaya   uint32_t                             MICommandOpcode;
247510e230b6Smaya   uint32_t                             CommandType;
247610e230b6Smaya};
247710e230b6Smaya
247896c5ddc4Srjsstatic inline __attribute__((always_inline)) void
247996c5ddc4SrjsGFX5_MI_FLUSH_pack(__attribute__((unused)) __gen_user_data *data,
248010e230b6Smaya                   __attribute__((unused)) void * restrict dst,
248196c5ddc4Srjs                   __attribute__((unused)) const struct GFX5_MI_FLUSH * restrict values)
248210e230b6Smaya{
248310e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
248410e230b6Smaya
248510e230b6Smaya   dw[0] =
248610e230b6Smaya      __gen_uint(values->StateInstructionCacheInvalidate, 1, 1) |
248710e230b6Smaya      __gen_uint(values->RenderCacheFlushInhibit, 2, 2) |
248810e230b6Smaya      __gen_uint(values->GlobalSnapshotCountReset, 3, 3) |
248910e230b6Smaya      __gen_uint(values->GenericMediaStateClear, 4, 4) |
249010e230b6Smaya      __gen_uint(values->IndirectStatePointersDisable, 5, 5) |
249110e230b6Smaya      __gen_uint(values->ProtectedMemoryEnable, 6, 6) |
249210e230b6Smaya      __gen_uint(values->MICommandOpcode, 23, 28) |
249310e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
249410e230b6Smaya}
249510e230b6Smaya
249696c5ddc4Srjs#define GFX5_MI_LOAD_REGISTER_IMM_length       3
249796c5ddc4Srjs#define GFX5_MI_LOAD_REGISTER_IMM_length_bias      2
249896c5ddc4Srjs#define GFX5_MI_LOAD_REGISTER_IMM_header        \
249910e230b6Smaya   .DWordLength                         =      1,  \
250010e230b6Smaya   .MICommandOpcode                     =     34,  \
250110e230b6Smaya   .CommandType                         =      0
250210e230b6Smaya
250396c5ddc4Srjsstruct GFX5_MI_LOAD_REGISTER_IMM {
250410e230b6Smaya   uint32_t                             DWordLength;
250510e230b6Smaya   uint32_t                             ByteWriteDisables;
250610e230b6Smaya   uint32_t                             MICommandOpcode;
250710e230b6Smaya   uint32_t                             CommandType;
250810e230b6Smaya   uint64_t                             RegisterOffset;
250910e230b6Smaya   uint32_t                             DataDWord;
251010e230b6Smaya   /* variable length fields follow */
251110e230b6Smaya};
251210e230b6Smaya
251396c5ddc4Srjsstatic inline __attribute__((always_inline)) void
251496c5ddc4SrjsGFX5_MI_LOAD_REGISTER_IMM_pack(__attribute__((unused)) __gen_user_data *data,
251510e230b6Smaya                               __attribute__((unused)) void * restrict dst,
251696c5ddc4Srjs                               __attribute__((unused)) const struct GFX5_MI_LOAD_REGISTER_IMM * restrict values)
251710e230b6Smaya{
251810e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
251910e230b6Smaya
252010e230b6Smaya   dw[0] =
252110e230b6Smaya      __gen_uint(values->DWordLength, 0, 5) |
252210e230b6Smaya      __gen_uint(values->ByteWriteDisables, 8, 11) |
252310e230b6Smaya      __gen_uint(values->MICommandOpcode, 23, 28) |
252410e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
252510e230b6Smaya
252610e230b6Smaya   dw[1] =
252710e230b6Smaya      __gen_offset(values->RegisterOffset, 2, 31);
252810e230b6Smaya
252910e230b6Smaya   dw[2] =
253010e230b6Smaya      __gen_uint(values->DataDWord, 0, 31);
253110e230b6Smaya}
253210e230b6Smaya
253396c5ddc4Srjs#define GFX5_MI_STORE_DATA_IMM_length          5
253496c5ddc4Srjs#define GFX5_MI_STORE_DATA_IMM_length_bias      2
253596c5ddc4Srjs#define GFX5_MI_STORE_DATA_IMM_header           \
253610e230b6Smaya   .DWordLength                         =      2,  \
253710e230b6Smaya   .MICommandOpcode                     =     32,  \
253810e230b6Smaya   .CommandType                         =      0
253910e230b6Smaya
254096c5ddc4Srjsstruct GFX5_MI_STORE_DATA_IMM {
254110e230b6Smaya   uint32_t                             DWordLength;
254210e230b6Smaya   bool                                 MemoryAddressType;
254310e230b6Smaya   uint32_t                             MICommandOpcode;
254410e230b6Smaya   uint32_t                             CommandType;
254510e230b6Smaya   __gen_address_type                   PhysicalStartAddressExtension;
254610e230b6Smaya   __gen_address_type                   Address;
254796c5ddc4Srjs   uint64_t                             ImmediateData;
254810e230b6Smaya};
254910e230b6Smaya
255096c5ddc4Srjsstatic inline __attribute__((always_inline)) void
255196c5ddc4SrjsGFX5_MI_STORE_DATA_IMM_pack(__attribute__((unused)) __gen_user_data *data,
255210e230b6Smaya                            __attribute__((unused)) void * restrict dst,
255396c5ddc4Srjs                            __attribute__((unused)) const struct GFX5_MI_STORE_DATA_IMM * restrict values)
255410e230b6Smaya{
255510e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
255610e230b6Smaya
255710e230b6Smaya   dw[0] =
255810e230b6Smaya      __gen_uint(values->DWordLength, 0, 5) |
255910e230b6Smaya      __gen_uint(values->MemoryAddressType, 22, 22) |
256010e230b6Smaya      __gen_uint(values->MICommandOpcode, 23, 28) |
256110e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
256210e230b6Smaya
256396c5ddc4Srjs   dw[1] = __gen_address(data, &dw[1], values->PhysicalStartAddressExtension, 0, 0, 3);
256410e230b6Smaya
256596c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->Address, 0, 2, 31);
256610e230b6Smaya
256796c5ddc4Srjs   const uint64_t v3 =
256896c5ddc4Srjs      __gen_uint(values->ImmediateData, 0, 63);
256996c5ddc4Srjs   dw[3] = v3;
257096c5ddc4Srjs   dw[4] = v3 >> 32;
257110e230b6Smaya}
257210e230b6Smaya
257396c5ddc4Srjs#define GFX5_MI_STORE_REGISTER_MEM_length      3
257496c5ddc4Srjs#define GFX5_MI_STORE_REGISTER_MEM_length_bias      2
257596c5ddc4Srjs#define GFX5_MI_STORE_REGISTER_MEM_header       \
257610e230b6Smaya   .DWordLength                         =      1,  \
257710e230b6Smaya   .MICommandOpcode                     =     36,  \
257810e230b6Smaya   .CommandType                         =      0
257910e230b6Smaya
258096c5ddc4Srjsstruct GFX5_MI_STORE_REGISTER_MEM {
258110e230b6Smaya   uint32_t                             DWordLength;
258210e230b6Smaya   bool                                 UseGlobalGTT;
258310e230b6Smaya   uint32_t                             MICommandOpcode;
258410e230b6Smaya   uint32_t                             CommandType;
258510e230b6Smaya   uint64_t                             RegisterAddress;
258610e230b6Smaya   __gen_address_type                   MemoryAddress;
258710e230b6Smaya};
258810e230b6Smaya
258996c5ddc4Srjsstatic inline __attribute__((always_inline)) void
259096c5ddc4SrjsGFX5_MI_STORE_REGISTER_MEM_pack(__attribute__((unused)) __gen_user_data *data,
259110e230b6Smaya                                __attribute__((unused)) void * restrict dst,
259296c5ddc4Srjs                                __attribute__((unused)) const struct GFX5_MI_STORE_REGISTER_MEM * restrict values)
259310e230b6Smaya{
259410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
259510e230b6Smaya
259610e230b6Smaya   dw[0] =
259710e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
259810e230b6Smaya      __gen_uint(values->UseGlobalGTT, 22, 22) |
259910e230b6Smaya      __gen_uint(values->MICommandOpcode, 23, 28) |
260010e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
260110e230b6Smaya
260210e230b6Smaya   dw[1] =
260310e230b6Smaya      __gen_offset(values->RegisterAddress, 2, 25);
260410e230b6Smaya
260596c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->MemoryAddress, 0, 2, 31);
260610e230b6Smaya}
260710e230b6Smaya
260896c5ddc4Srjs#define GFX5_PIPELINE_SELECT_length            1
260996c5ddc4Srjs#define GFX5_PIPELINE_SELECT_length_bias       1
261096c5ddc4Srjs#define GFX5_PIPELINE_SELECT_header             \
261110e230b6Smaya   ._3DCommandSubOpcode                 =      4,  \
261210e230b6Smaya   ._3DCommandOpcode                    =      1,  \
261310e230b6Smaya   .CommandSubType                      =      1,  \
261410e230b6Smaya   .CommandType                         =      3
261510e230b6Smaya
261696c5ddc4Srjsstruct GFX5_PIPELINE_SELECT {
261710e230b6Smaya   uint32_t                             PipelineSelection;
261810e230b6Smaya#define _3D                                      0
261910e230b6Smaya#define Media                                    1
262010e230b6Smaya#define GPGPU                                    2
262110e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
262210e230b6Smaya   uint32_t                             _3DCommandOpcode;
262310e230b6Smaya   uint32_t                             CommandSubType;
262410e230b6Smaya   uint32_t                             CommandType;
262510e230b6Smaya};
262610e230b6Smaya
262796c5ddc4Srjsstatic inline __attribute__((always_inline)) void
262896c5ddc4SrjsGFX5_PIPELINE_SELECT_pack(__attribute__((unused)) __gen_user_data *data,
262910e230b6Smaya                          __attribute__((unused)) void * restrict dst,
263096c5ddc4Srjs                          __attribute__((unused)) const struct GFX5_PIPELINE_SELECT * restrict values)
263110e230b6Smaya{
263210e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
263310e230b6Smaya
263410e230b6Smaya   dw[0] =
263510e230b6Smaya      __gen_uint(values->PipelineSelection, 0, 1) |
263610e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
263710e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
263810e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
263910e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
264010e230b6Smaya}
264110e230b6Smaya
264296c5ddc4Srjs#define GFX5_PIPE_CONTROL_length               4
264396c5ddc4Srjs#define GFX5_PIPE_CONTROL_length_bias          2
264496c5ddc4Srjs#define GFX5_PIPE_CONTROL_header                \
264510e230b6Smaya   .DWordLength                         =      2,  \
264610e230b6Smaya   ._3DCommandSubOpcode                 =      0,  \
264710e230b6Smaya   ._3DCommandOpcode                    =      2,  \
264810e230b6Smaya   .CommandSubType                      =      3,  \
264910e230b6Smaya   .CommandType                         =      3
265010e230b6Smaya
265196c5ddc4Srjsstruct GFX5_PIPE_CONTROL {
265210e230b6Smaya   uint32_t                             DWordLength;
265310e230b6Smaya   bool                                 NotifyEnable;
265410e230b6Smaya   bool                                 IndirectStatePointersDisable;
265510e230b6Smaya   bool                                 TextureCacheFlushEnable;
265610e230b6Smaya   bool                                 InstructionCacheInvalidateEnable;
265710e230b6Smaya   bool                                 WriteCacheFlush;
265810e230b6Smaya   bool                                 DepthStallEnable;
265910e230b6Smaya   uint32_t                             PostSyncOperation;
266010e230b6Smaya#define NoWrite                                  0
266110e230b6Smaya#define WriteImmediateData                       1
266210e230b6Smaya#define WritePSDepthCount                        2
266310e230b6Smaya#define WriteTimestamp                           3
266410e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
266510e230b6Smaya   uint32_t                             _3DCommandOpcode;
266610e230b6Smaya   uint32_t                             CommandSubType;
266710e230b6Smaya   uint32_t                             CommandType;
266810e230b6Smaya   uint32_t                             DepthCacheFlushInhibit;
266910e230b6Smaya#define Flushed                                  0
267010e230b6Smaya#define NotFlushed                               1
267110e230b6Smaya   bool                                 StallAtPixelScoreboard;
267210e230b6Smaya   uint32_t                             DestinationAddressType;
267310e230b6Smaya#define DAT_PGTT                                 0
267410e230b6Smaya#define DAT_GGTT                                 1
267510e230b6Smaya   __gen_address_type                   Address;
267610e230b6Smaya   uint64_t                             ImmediateData;
267710e230b6Smaya};
267810e230b6Smaya
267996c5ddc4Srjsstatic inline __attribute__((always_inline)) void
268096c5ddc4SrjsGFX5_PIPE_CONTROL_pack(__attribute__((unused)) __gen_user_data *data,
268110e230b6Smaya                       __attribute__((unused)) void * restrict dst,
268296c5ddc4Srjs                       __attribute__((unused)) const struct GFX5_PIPE_CONTROL * restrict values)
268310e230b6Smaya{
268410e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
268510e230b6Smaya
268610e230b6Smaya   dw[0] =
268710e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
268810e230b6Smaya      __gen_uint(values->NotifyEnable, 8, 8) |
268910e230b6Smaya      __gen_uint(values->IndirectStatePointersDisable, 9, 9) |
269010e230b6Smaya      __gen_uint(values->TextureCacheFlushEnable, 10, 10) |
269110e230b6Smaya      __gen_uint(values->InstructionCacheInvalidateEnable, 11, 11) |
269210e230b6Smaya      __gen_uint(values->WriteCacheFlush, 12, 12) |
269310e230b6Smaya      __gen_uint(values->DepthStallEnable, 13, 13) |
269410e230b6Smaya      __gen_uint(values->PostSyncOperation, 14, 15) |
269510e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
269610e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
269710e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
269810e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
269910e230b6Smaya
270010e230b6Smaya   const uint32_t v1 =
270110e230b6Smaya      __gen_uint(values->DepthCacheFlushInhibit, 0, 0) |
270210e230b6Smaya      __gen_uint(values->StallAtPixelScoreboard, 1, 1) |
270310e230b6Smaya      __gen_uint(values->DestinationAddressType, 2, 2);
270496c5ddc4Srjs   dw[1] = __gen_address(data, &dw[1], values->Address, v1, 3, 31);
270510e230b6Smaya
270610e230b6Smaya   const uint64_t v2 =
270710e230b6Smaya      __gen_uint(values->ImmediateData, 0, 63);
270810e230b6Smaya   dw[2] = v2;
270910e230b6Smaya   dw[3] = v2 >> 32;
271010e230b6Smaya}
271110e230b6Smaya
271296c5ddc4Srjs#define GFX5_STATE_BASE_ADDRESS_length         8
271396c5ddc4Srjs#define GFX5_STATE_BASE_ADDRESS_length_bias      2
271496c5ddc4Srjs#define GFX5_STATE_BASE_ADDRESS_header          \
271510e230b6Smaya   .DWordLength                         =      6,  \
271610e230b6Smaya   ._3DCommandSubOpcode                 =      1,  \
271710e230b6Smaya   ._3DCommandOpcode                    =      1,  \
271810e230b6Smaya   .CommandSubType                      =      0,  \
271910e230b6Smaya   .CommandType                         =      3
272010e230b6Smaya
272196c5ddc4Srjsstruct GFX5_STATE_BASE_ADDRESS {
272210e230b6Smaya   uint32_t                             DWordLength;
272310e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
272410e230b6Smaya   uint32_t                             _3DCommandOpcode;
272510e230b6Smaya   uint32_t                             CommandSubType;
272610e230b6Smaya   uint32_t                             CommandType;
272710e230b6Smaya   bool                                 GeneralStateBaseAddressModifyEnable;
272810e230b6Smaya   __gen_address_type                   GeneralStateBaseAddress;
272910e230b6Smaya   bool                                 SurfaceStateBaseAddressModifyEnable;
273010e230b6Smaya   __gen_address_type                   SurfaceStateBaseAddress;
273110e230b6Smaya   bool                                 IndirectObjectBaseAddressModifyEnable;
273210e230b6Smaya   __gen_address_type                   IndirectObjectBaseAddress;
273310e230b6Smaya   bool                                 InstructionBaseAddressModifyEnable;
273410e230b6Smaya   __gen_address_type                   InstructionBaseAddress;
273510e230b6Smaya   bool                                 GeneralStateAccessUpperBoundModifyEnable;
273610e230b6Smaya   __gen_address_type                   GeneralStateAccessUpperBound;
273710e230b6Smaya   bool                                 IndirectObjectAccessUpperBoundModifyEnable;
273810e230b6Smaya   __gen_address_type                   IndirectObjectAccessUpperBound;
273910e230b6Smaya   bool                                 InstructionAccessUpperBoundModifyEnable;
274010e230b6Smaya   __gen_address_type                   InstructionAccessUpperBound;
274110e230b6Smaya};
274210e230b6Smaya
274396c5ddc4Srjsstatic inline __attribute__((always_inline)) void
274496c5ddc4SrjsGFX5_STATE_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data,
274510e230b6Smaya                             __attribute__((unused)) void * restrict dst,
274696c5ddc4Srjs                             __attribute__((unused)) const struct GFX5_STATE_BASE_ADDRESS * restrict values)
274710e230b6Smaya{
274810e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
274910e230b6Smaya
275010e230b6Smaya   dw[0] =
275110e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
275210e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
275310e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
275410e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
275510e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
275610e230b6Smaya
275710e230b6Smaya   const uint32_t v1 =
275810e230b6Smaya      __gen_uint(values->GeneralStateBaseAddressModifyEnable, 0, 0);
275996c5ddc4Srjs   dw[1] = __gen_address(data, &dw[1], values->GeneralStateBaseAddress, v1, 12, 31);
276010e230b6Smaya
276110e230b6Smaya   const uint32_t v2 =
276210e230b6Smaya      __gen_uint(values->SurfaceStateBaseAddressModifyEnable, 0, 0);
276396c5ddc4Srjs   dw[2] = __gen_address(data, &dw[2], values->SurfaceStateBaseAddress, v2, 12, 31);
276410e230b6Smaya
276510e230b6Smaya   const uint32_t v3 =
276610e230b6Smaya      __gen_uint(values->IndirectObjectBaseAddressModifyEnable, 0, 0);
276796c5ddc4Srjs   dw[3] = __gen_address(data, &dw[3], values->IndirectObjectBaseAddress, v3, 12, 31);
276810e230b6Smaya
276910e230b6Smaya   const uint32_t v4 =
277010e230b6Smaya      __gen_uint(values->InstructionBaseAddressModifyEnable, 0, 0);
277196c5ddc4Srjs   dw[4] = __gen_address(data, &dw[4], values->InstructionBaseAddress, v4, 12, 31);
277210e230b6Smaya
277310e230b6Smaya   const uint32_t v5 =
277410e230b6Smaya      __gen_uint(values->GeneralStateAccessUpperBoundModifyEnable, 0, 0);
277596c5ddc4Srjs   dw[5] = __gen_address(data, &dw[5], values->GeneralStateAccessUpperBound, v5, 12, 31);
277610e230b6Smaya
277710e230b6Smaya   const uint32_t v6 =
277810e230b6Smaya      __gen_uint(values->IndirectObjectAccessUpperBoundModifyEnable, 0, 0);
277996c5ddc4Srjs   dw[6] = __gen_address(data, &dw[6], values->IndirectObjectAccessUpperBound, v6, 12, 31);
278010e230b6Smaya
278110e230b6Smaya   const uint32_t v7 =
278210e230b6Smaya      __gen_uint(values->InstructionAccessUpperBoundModifyEnable, 0, 0);
278396c5ddc4Srjs   dw[7] = __gen_address(data, &dw[7], values->InstructionAccessUpperBound, v7, 12, 31);
278410e230b6Smaya}
278510e230b6Smaya
278696c5ddc4Srjs#define GFX5_STATE_SIP_length                  2
278796c5ddc4Srjs#define GFX5_STATE_SIP_length_bias             2
278896c5ddc4Srjs#define GFX5_STATE_SIP_header                   \
278910e230b6Smaya   .DWordLength                         =      0,  \
279010e230b6Smaya   ._3DCommandSubOpcode                 =      2,  \
279110e230b6Smaya   ._3DCommandOpcode                    =      1,  \
279210e230b6Smaya   .CommandSubType                      =      0,  \
279310e230b6Smaya   .CommandType                         =      3
279410e230b6Smaya
279596c5ddc4Srjsstruct GFX5_STATE_SIP {
279610e230b6Smaya   uint32_t                             DWordLength;
279710e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
279810e230b6Smaya   uint32_t                             _3DCommandOpcode;
279910e230b6Smaya   uint32_t                             CommandSubType;
280010e230b6Smaya   uint32_t                             CommandType;
280110e230b6Smaya   uint64_t                             SystemInstructionPointer;
280210e230b6Smaya};
280310e230b6Smaya
280496c5ddc4Srjsstatic inline __attribute__((always_inline)) void
280596c5ddc4SrjsGFX5_STATE_SIP_pack(__attribute__((unused)) __gen_user_data *data,
280610e230b6Smaya                    __attribute__((unused)) void * restrict dst,
280796c5ddc4Srjs                    __attribute__((unused)) const struct GFX5_STATE_SIP * restrict values)
280810e230b6Smaya{
280910e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
281010e230b6Smaya
281110e230b6Smaya   dw[0] =
281210e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
281310e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
281410e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
281510e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
281610e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
281710e230b6Smaya
281810e230b6Smaya   dw[1] =
281910e230b6Smaya      __gen_offset(values->SystemInstructionPointer, 4, 31);
282010e230b6Smaya}
282110e230b6Smaya
282296c5ddc4Srjs#define GFX5_URB_FENCE_length                  3
282396c5ddc4Srjs#define GFX5_URB_FENCE_length_bias             2
282496c5ddc4Srjs#define GFX5_URB_FENCE_header                   \
282510e230b6Smaya   .DWordLength                         =      1,  \
282610e230b6Smaya   ._3DCommandSubOpcode                 =      0,  \
282710e230b6Smaya   ._3DCommandOpcode                    =      0,  \
282810e230b6Smaya   .CommandSubType                      =      0,  \
282910e230b6Smaya   .CommandType                         =      3
283010e230b6Smaya
283196c5ddc4Srjsstruct GFX5_URB_FENCE {
283210e230b6Smaya   uint32_t                             DWordLength;
283310e230b6Smaya   bool                                 VSUnitURBReallocationRequest;
283410e230b6Smaya   bool                                 GSUnitURBReallocationRequest;
283510e230b6Smaya   bool                                 CLIPUnitURBReallocationRequest;
283610e230b6Smaya   bool                                 SFUnitURBReallocationRequest;
283710e230b6Smaya   bool                                 VFEUnitURBReallocationRequest;
283810e230b6Smaya   bool                                 CSUnitURBReallocationRequest;
283910e230b6Smaya   uint32_t                             _3DCommandSubOpcode;
284010e230b6Smaya   uint32_t                             _3DCommandOpcode;
284110e230b6Smaya   uint32_t                             CommandSubType;
284210e230b6Smaya   uint32_t                             CommandType;
284310e230b6Smaya   uint32_t                             VSFence;
284410e230b6Smaya   uint32_t                             GSFence;
284510e230b6Smaya   uint32_t                             CLIPFence;
284610e230b6Smaya   uint32_t                             SFFence;
284710e230b6Smaya   uint32_t                             VFEFence;
284810e230b6Smaya   uint32_t                             CSFence;
284910e230b6Smaya};
285010e230b6Smaya
285196c5ddc4Srjsstatic inline __attribute__((always_inline)) void
285296c5ddc4SrjsGFX5_URB_FENCE_pack(__attribute__((unused)) __gen_user_data *data,
285310e230b6Smaya                    __attribute__((unused)) void * restrict dst,
285496c5ddc4Srjs                    __attribute__((unused)) const struct GFX5_URB_FENCE * restrict values)
285510e230b6Smaya{
285610e230b6Smaya   uint32_t * restrict dw = (uint32_t * restrict) dst;
285710e230b6Smaya
285810e230b6Smaya   dw[0] =
285910e230b6Smaya      __gen_uint(values->DWordLength, 0, 7) |
286010e230b6Smaya      __gen_uint(values->VSUnitURBReallocationRequest, 8, 8) |
286110e230b6Smaya      __gen_uint(values->GSUnitURBReallocationRequest, 9, 9) |
286210e230b6Smaya      __gen_uint(values->CLIPUnitURBReallocationRequest, 10, 10) |
286310e230b6Smaya      __gen_uint(values->SFUnitURBReallocationRequest, 11, 11) |
286410e230b6Smaya      __gen_uint(values->VFEUnitURBReallocationRequest, 12, 12) |
286510e230b6Smaya      __gen_uint(values->CSUnitURBReallocationRequest, 13, 13) |
286610e230b6Smaya      __gen_uint(values->_3DCommandSubOpcode, 16, 23) |
286710e230b6Smaya      __gen_uint(values->_3DCommandOpcode, 24, 26) |
286810e230b6Smaya      __gen_uint(values->CommandSubType, 27, 28) |
286910e230b6Smaya      __gen_uint(values->CommandType, 29, 31);
287010e230b6Smaya
287110e230b6Smaya   dw[1] =
287210e230b6Smaya      __gen_uint(values->VSFence, 0, 9) |
287310e230b6Smaya      __gen_uint(values->GSFence, 10, 19) |
287410e230b6Smaya      __gen_uint(values->CLIPFence, 20, 29);
287510e230b6Smaya
287610e230b6Smaya   dw[2] =
287710e230b6Smaya      __gen_uint(values->SFFence, 0, 9) |
287810e230b6Smaya      __gen_uint(values->VFEFence, 10, 19) |
287910e230b6Smaya      __gen_uint(values->CSFence, 20, 30);
288010e230b6Smaya}
288110e230b6Smaya
288296c5ddc4Srjs#define GFX5_XY_COLOR_BLT_length               6
288396c5ddc4Srjs#define GFX5_XY_COLOR_BLT_length_bias          2
288496c5ddc4Srjs#define GFX5_XY_COLOR_BLT_header                \
288596c5ddc4Srjs   .DWordLength                         =      4,  \
288696c5ddc4Srjs   ._2DCommandOpcode                    =     80,  \
288796c5ddc4Srjs   .CommandType                         =      2
288896c5ddc4Srjs
288996c5ddc4Srjsstruct GFX5_XY_COLOR_BLT {
289096c5ddc4Srjs   uint32_t                             DWordLength;
289196c5ddc4Srjs   bool                                 TilingEnable;
289296c5ddc4Srjs   uint32_t                             _32bppByteMask;
289396c5ddc4Srjs   uint32_t                             _2DCommandOpcode;
289496c5ddc4Srjs   uint32_t                             CommandType;
289596c5ddc4Srjs   int32_t                              DestinationPitch;
289696c5ddc4Srjs   uint32_t                             RasterOperation;
289796c5ddc4Srjs   uint32_t                             ColorDepth;
289896c5ddc4Srjs#define COLOR_DEPTH__8bit                        0
289996c5ddc4Srjs#define COLOR_DEPTH__565                         1
290096c5ddc4Srjs#define COLOR_DEPTH__1555                        2
290196c5ddc4Srjs#define COLOR_DEPTH__32bit                       3
290296c5ddc4Srjs   bool                                 ClippingEnabled;
290396c5ddc4Srjs   int32_t                              DestinationX1Coordinate;
290496c5ddc4Srjs   int32_t                              DestinationY1Coordinate;
290596c5ddc4Srjs   int32_t                              DestinationX2Coordinate;
290696c5ddc4Srjs   int32_t                              DestinationY2Coordinate;
290796c5ddc4Srjs   __gen_address_type                   DestinationBaseAddress;
290896c5ddc4Srjs   int32_t                              SolidPatternColor;
290996c5ddc4Srjs};
291096c5ddc4Srjs
291196c5ddc4Srjsstatic inline __attribute__((always_inline)) void
291296c5ddc4SrjsGFX5_XY_COLOR_BLT_pack(__attribute__((unused)) __gen_user_data *data,
291396c5ddc4Srjs                       __attribute__((unused)) void * restrict dst,
291496c5ddc4Srjs                       __attribute__((unused)) const struct GFX5_XY_COLOR_BLT * restrict values)
291596c5ddc4Srjs{
291696c5ddc4Srjs   uint32_t * restrict dw = (uint32_t * restrict) dst;
291796c5ddc4Srjs
291896c5ddc4Srjs   dw[0] =
291996c5ddc4Srjs      __gen_uint(values->DWordLength, 0, 7) |
292096c5ddc4Srjs      __gen_uint(values->TilingEnable, 11, 11) |
292196c5ddc4Srjs      __gen_uint(values->_32bppByteMask, 20, 21) |
292296c5ddc4Srjs      __gen_uint(values->_2DCommandOpcode, 22, 28) |
292396c5ddc4Srjs      __gen_uint(values->CommandType, 29, 31);
292496c5ddc4Srjs
292596c5ddc4Srjs   dw[1] =
292696c5ddc4Srjs      __gen_sint(values->DestinationPitch, 0, 15) |
292796c5ddc4Srjs      __gen_uint(values->RasterOperation, 16, 23) |
292896c5ddc4Srjs      __gen_uint(values->ColorDepth, 24, 26) |
292996c5ddc4Srjs      __gen_uint(values->ClippingEnabled, 30, 30);
293096c5ddc4Srjs
293196c5ddc4Srjs   dw[2] =
293296c5ddc4Srjs      __gen_sint(values->DestinationX1Coordinate, 0, 15) |
293396c5ddc4Srjs      __gen_sint(values->DestinationY1Coordinate, 16, 31);
293496c5ddc4Srjs
293596c5ddc4Srjs   dw[3] =
293696c5ddc4Srjs      __gen_sint(values->DestinationX2Coordinate, 0, 15) |
293796c5ddc4Srjs      __gen_sint(values->DestinationY2Coordinate, 16, 31);
293896c5ddc4Srjs
293996c5ddc4Srjs   dw[4] = __gen_address(data, &dw[4], values->DestinationBaseAddress, 0, 0, 31);
294096c5ddc4Srjs
294196c5ddc4Srjs   dw[5] =
294296c5ddc4Srjs      __gen_sint(values->SolidPatternColor, 0, 31);
294396c5ddc4Srjs}
294496c5ddc4Srjs
294596c5ddc4Srjs#define GFX5_XY_SRC_COPY_BLT_length            8
294696c5ddc4Srjs#define GFX5_XY_SRC_COPY_BLT_length_bias       2
294796c5ddc4Srjs#define GFX5_XY_SRC_COPY_BLT_header             \
294896c5ddc4Srjs   .DWordLength                         =      6,  \
294996c5ddc4Srjs   ._2DCommandOpcode                    =     83,  \
295096c5ddc4Srjs   .CommandType                         =      2
295196c5ddc4Srjs
295296c5ddc4Srjsstruct GFX5_XY_SRC_COPY_BLT {
295396c5ddc4Srjs   uint32_t                             DWordLength;
295496c5ddc4Srjs   bool                                 DestinationTilingEnable;
295596c5ddc4Srjs   bool                                 SourceTilingEnable;
295696c5ddc4Srjs   uint32_t                             _32bppByteMask;
295796c5ddc4Srjs   uint32_t                             _2DCommandOpcode;
295896c5ddc4Srjs   uint32_t                             CommandType;
295996c5ddc4Srjs   int32_t                              DestinationPitch;
296096c5ddc4Srjs   uint32_t                             RasterOperation;
296196c5ddc4Srjs   uint32_t                             ColorDepth;
296296c5ddc4Srjs#define COLOR_DEPTH__8bit                        0
296396c5ddc4Srjs#define COLOR_DEPTH__565                         1
296496c5ddc4Srjs#define COLOR_DEPTH__1555                        2
296596c5ddc4Srjs#define COLOR_DEPTH__32bit                       3
296696c5ddc4Srjs   bool                                 ClippingEnabled;
296796c5ddc4Srjs   int32_t                              DestinationX1Coordinate;
296896c5ddc4Srjs   int32_t                              DestinationY1Coordinate;
296996c5ddc4Srjs   int32_t                              DestinationX2Coordinate;
297096c5ddc4Srjs   int32_t                              DestinationY2Coordinate;
297196c5ddc4Srjs   __gen_address_type                   DestinationBaseAddress;
297296c5ddc4Srjs   int32_t                              SourceX1Coordinate;
297396c5ddc4Srjs   int32_t                              SourceY1Coordinate;
297496c5ddc4Srjs   int32_t                              SourcePitch;
297596c5ddc4Srjs   __gen_address_type                   SourceBaseAddress;
297696c5ddc4Srjs};
297796c5ddc4Srjs
297896c5ddc4Srjsstatic inline __attribute__((always_inline)) void
297996c5ddc4SrjsGFX5_XY_SRC_COPY_BLT_pack(__attribute__((unused)) __gen_user_data *data,
298096c5ddc4Srjs                          __attribute__((unused)) void * restrict dst,
298196c5ddc4Srjs                          __attribute__((unused)) const struct GFX5_XY_SRC_COPY_BLT * restrict values)
298296c5ddc4Srjs{
298396c5ddc4Srjs   uint32_t * restrict dw = (uint32_t * restrict) dst;
298496c5ddc4Srjs
298596c5ddc4Srjs   dw[0] =
298696c5ddc4Srjs      __gen_uint(values->DWordLength, 0, 7) |
298796c5ddc4Srjs      __gen_uint(values->DestinationTilingEnable, 11, 11) |
298896c5ddc4Srjs      __gen_uint(values->SourceTilingEnable, 15, 15) |
298996c5ddc4Srjs      __gen_uint(values->_32bppByteMask, 20, 21) |
299096c5ddc4Srjs      __gen_uint(values->_2DCommandOpcode, 22, 28) |
299196c5ddc4Srjs      __gen_uint(values->CommandType, 29, 31);
299296c5ddc4Srjs
299396c5ddc4Srjs   dw[1] =
299496c5ddc4Srjs      __gen_sint(values->DestinationPitch, 0, 15) |
299596c5ddc4Srjs      __gen_uint(values->RasterOperation, 16, 23) |
299696c5ddc4Srjs      __gen_uint(values->ColorDepth, 24, 26) |
299796c5ddc4Srjs      __gen_uint(values->ClippingEnabled, 30, 30);
299896c5ddc4Srjs
299996c5ddc4Srjs   dw[2] =
300096c5ddc4Srjs      __gen_sint(values->DestinationX1Coordinate, 0, 15) |
300196c5ddc4Srjs      __gen_sint(values->DestinationY1Coordinate, 16, 31);
300296c5ddc4Srjs
300396c5ddc4Srjs   dw[3] =
300496c5ddc4Srjs      __gen_sint(values->DestinationX2Coordinate, 0, 15) |
300596c5ddc4Srjs      __gen_sint(values->DestinationY2Coordinate, 16, 31);
300696c5ddc4Srjs
300796c5ddc4Srjs   dw[4] = __gen_address(data, &dw[4], values->DestinationBaseAddress, 0, 0, 31);
300896c5ddc4Srjs
300996c5ddc4Srjs   dw[5] =
301096c5ddc4Srjs      __gen_sint(values->SourceX1Coordinate, 0, 15) |
301196c5ddc4Srjs      __gen_sint(values->SourceY1Coordinate, 16, 31);
301296c5ddc4Srjs
301396c5ddc4Srjs   dw[6] =
301496c5ddc4Srjs      __gen_sint(values->SourcePitch, 0, 15);
301596c5ddc4Srjs
301696c5ddc4Srjs   dw[7] = __gen_address(data, &dw[7], values->SourceBaseAddress, 0, 0, 31);
301796c5ddc4Srjs}
301896c5ddc4Srjs
301996c5ddc4Srjs#define GFX5_XY_TEXT_IMMEDIATE_BLT_length      3
302096c5ddc4Srjs#define GFX5_XY_TEXT_IMMEDIATE_BLT_length_bias      2
302196c5ddc4Srjs#define GFX5_XY_TEXT_IMMEDIATE_BLT_header       \
302296c5ddc4Srjs   .DWordLength                         =      1,  \
302396c5ddc4Srjs   ._2DCommandOpcode                    =     49,  \
302496c5ddc4Srjs   .CommandType                         =      2
302596c5ddc4Srjs
302696c5ddc4Srjsstruct GFX5_XY_TEXT_IMMEDIATE_BLT {
302796c5ddc4Srjs   uint32_t                             DWordLength;
302896c5ddc4Srjs   bool                                 TilingEnable;
302996c5ddc4Srjs   uint32_t                             Packing;
303096c5ddc4Srjs#define BitPacked                                0
303196c5ddc4Srjs#define BytePacked                               1
303296c5ddc4Srjs   uint32_t                             _32bppByteMask;
303396c5ddc4Srjs   uint32_t                             _2DCommandOpcode;
303496c5ddc4Srjs   uint32_t                             CommandType;
303596c5ddc4Srjs   int32_t                              DestinationPitch;
303696c5ddc4Srjs   int32_t                              DestinationX1Coordinate;
303796c5ddc4Srjs   int32_t                              DestinationY1Coordinate;
303896c5ddc4Srjs   int32_t                              DestinationX2Coordinate;
303996c5ddc4Srjs   int32_t                              DestinationY2Coordinate;
304096c5ddc4Srjs};
304196c5ddc4Srjs
304296c5ddc4Srjsstatic inline __attribute__((always_inline)) void
304396c5ddc4SrjsGFX5_XY_TEXT_IMMEDIATE_BLT_pack(__attribute__((unused)) __gen_user_data *data,
304496c5ddc4Srjs                                __attribute__((unused)) void * restrict dst,
304596c5ddc4Srjs                                __attribute__((unused)) const struct GFX5_XY_TEXT_IMMEDIATE_BLT * restrict values)
304696c5ddc4Srjs{
304796c5ddc4Srjs   uint32_t * restrict dw = (uint32_t * restrict) dst;
304896c5ddc4Srjs
304996c5ddc4Srjs   dw[0] =
305096c5ddc4Srjs      __gen_uint(values->DWordLength, 0, 7) |
305196c5ddc4Srjs      __gen_uint(values->TilingEnable, 11, 11) |
305296c5ddc4Srjs      __gen_uint(values->Packing, 16, 16) |
305396c5ddc4Srjs      __gen_uint(values->_32bppByteMask, 20, 21) |
305496c5ddc4Srjs      __gen_uint(values->_2DCommandOpcode, 22, 28) |
305596c5ddc4Srjs      __gen_uint(values->CommandType, 29, 31);
305696c5ddc4Srjs
305796c5ddc4Srjs   dw[1] =
305896c5ddc4Srjs      __gen_sint(values->DestinationPitch, 0, 15) |
305996c5ddc4Srjs      __gen_sint(values->DestinationX1Coordinate, 0, 15) |
306096c5ddc4Srjs      __gen_sint(values->DestinationY1Coordinate, 16, 31);
306196c5ddc4Srjs
306296c5ddc4Srjs   dw[2] =
306396c5ddc4Srjs      __gen_sint(values->DestinationX2Coordinate, 0, 15) |
306496c5ddc4Srjs      __gen_sint(values->DestinationY2Coordinate, 16, 31);
306596c5ddc4Srjs}
306696c5ddc4Srjs
306796c5ddc4Srjs#endif /* GFX5_PACK_H */
3068