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