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