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 GFX4_PACK_H 31#define GFX4_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 __intel_field_functions 44#define __intel_field_functions 45 46#ifdef NDEBUG 47#define NDEBUG_UNUSED __attribute__((unused)) 48#else 49#define NDEBUG_UNUSED 50#endif 51 52union __intel_value { 53 float f; 54 uint32_t dw; 55}; 56 57static inline __attribute__((always_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 __attribute__((always_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 __attribute__((always_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 __attribute__((always_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 __attribute__((always_inline)) uint64_t 113__gen_address(__gen_user_data *data, void *location, 114 __gen_address_type address, uint32_t delta, 115 __attribute__((unused)) uint32_t start, uint32_t end) 116{ 117 uint64_t addr_u64 = __gen_combine_address(data, location, address, delta); 118 if (end == 31) { 119 return addr_u64; 120 } else if (end < 63) { 121 const unsigned shift = 63 - end; 122 return (addr_u64 << shift) >> shift; 123 } else { 124 return addr_u64; 125 } 126} 127 128static inline __attribute__((always_inline)) uint32_t 129__gen_float(float v) 130{ 131 __gen_validate_value(v); 132 return ((union __intel_value) { .f = (v) }).dw; 133} 134 135static inline __attribute__((always_inline)) uint64_t 136__gen_sfixed(float v, uint32_t start, uint32_t end, uint32_t fract_bits) 137{ 138 __gen_validate_value(v); 139 140 const float factor = (1 << fract_bits); 141 142#ifndef NDEBUG 143 const float max = ((1 << (end - start)) - 1) / factor; 144 const float min = -(1 << (end - start)) / factor; 145 assert(min <= v && v <= max); 146#endif 147 148 const int64_t int_val = llroundf(v * factor); 149 const uint64_t mask = ~0ull >> (64 - (end - start + 1)); 150 151 return (int_val & mask) << start; 152} 153 154static inline __attribute__((always_inline)) uint64_t 155__gen_ufixed(float v, uint32_t start, NDEBUG_UNUSED uint32_t end, uint32_t fract_bits) 156{ 157 __gen_validate_value(v); 158 159 const float factor = (1 << fract_bits); 160 161#ifndef NDEBUG 162 const float max = ((1 << (end - start + 1)) - 1) / factor; 163 const float min = 0.0f; 164 assert(min <= v && v <= max); 165#endif 166 167 const uint64_t uint_val = llroundf(v * factor); 168 169 return uint_val << start; 170} 171 172#ifndef __gen_address_type 173#error #define __gen_address_type before including this file 174#endif 175 176#ifndef __gen_user_data 177#error #define __gen_combine_address before including this file 178#endif 179 180#undef NDEBUG_UNUSED 181 182#endif 183 184 185enum GFX4_3D_Color_Buffer_Blend_Factor { 186 BLENDFACTOR_ONE = 1, 187 BLENDFACTOR_SRC_COLOR = 2, 188 BLENDFACTOR_SRC_ALPHA = 3, 189 BLENDFACTOR_DST_ALPHA = 4, 190 BLENDFACTOR_DST_COLOR = 5, 191 BLENDFACTOR_SRC_ALPHA_SATURATE = 6, 192 BLENDFACTOR_CONST_COLOR = 7, 193 BLENDFACTOR_CONST_ALPHA = 8, 194 BLENDFACTOR_SRC1_COLOR = 9, 195 BLENDFACTOR_SRC1_ALPHA = 10, 196 BLENDFACTOR_ZERO = 17, 197 BLENDFACTOR_INV_SRC_COLOR = 18, 198 BLENDFACTOR_INV_SRC_ALPHA = 19, 199 BLENDFACTOR_INV_DST_ALPHA = 20, 200 BLENDFACTOR_INV_DST_COLOR = 21, 201 BLENDFACTOR_INV_CONST_COLOR = 23, 202 BLENDFACTOR_INV_CONST_ALPHA = 24, 203 BLENDFACTOR_INV_SRC1_COLOR = 25, 204 BLENDFACTOR_INV_SRC1_ALPHA = 26, 205}; 206 207enum GFX4_3D_Color_Buffer_Blend_Function { 208 BLENDFUNCTION_ADD = 0, 209 BLENDFUNCTION_SUBTRACT = 1, 210 BLENDFUNCTION_REVERSE_SUBTRACT = 2, 211 BLENDFUNCTION_MIN = 3, 212 BLENDFUNCTION_MAX = 4, 213}; 214 215enum GFX4_3D_Compare_Function { 216 COMPAREFUNCTION_ALWAYS = 0, 217 COMPAREFUNCTION_NEVER = 1, 218 COMPAREFUNCTION_LESS = 2, 219 COMPAREFUNCTION_EQUAL = 3, 220 COMPAREFUNCTION_LEQUAL = 4, 221 COMPAREFUNCTION_GREATER = 5, 222 COMPAREFUNCTION_NOTEQUAL = 6, 223 COMPAREFUNCTION_GEQUAL = 7, 224}; 225 226enum GFX4_3D_Logic_Op_Function { 227 LOGICOP_CLEAR = 0, 228 LOGICOP_NOR = 1, 229 LOGICOP_AND_INVERTED = 2, 230 LOGICOP_COPY_INVERTED = 3, 231 LOGICOP_AND_REVERSE = 4, 232 LOGICOP_INVERT = 5, 233 LOGICOP_XOR = 6, 234 LOGICOP_NAND = 7, 235 LOGICOP_AND = 8, 236 LOGICOP_EQUIV = 9, 237 LOGICOP_NOOP = 10, 238 LOGICOP_OR_INVERTED = 11, 239 LOGICOP_COPY = 12, 240 LOGICOP_OR_REVERSE = 13, 241 LOGICOP_OR = 14, 242 LOGICOP_SET = 15, 243}; 244 245enum GFX4_3D_Prim_Topo_Type { 246 _3DPRIM_POINTLIST = 1, 247 _3DPRIM_LINELIST = 2, 248 _3DPRIM_LINESTRIP = 3, 249 _3DPRIM_TRILIST = 4, 250 _3DPRIM_TRISTRIP = 5, 251 _3DPRIM_TRIFAN = 6, 252 _3DPRIM_QUADLIST = 7, 253 _3DPRIM_QUADSTRIP = 8, 254 _3DPRIM_LINELIST_ADJ = 9, 255 _3DPRIM_LINESTRIP_ADJ = 10, 256 _3DPRIM_TRILIST_ADJ = 11, 257 _3DPRIM_TRISTRIP_ADJ = 12, 258 _3DPRIM_TRISTRIP_REVERSE = 13, 259 _3DPRIM_POLYGON = 14, 260 _3DPRIM_RECTLIST = 15, 261 _3DPRIM_LINELOOP = 16, 262 _3DPRIM_POINTLIST_BF = 17, 263 _3DPRIM_LINESTRIP_CONT = 18, 264 _3DPRIM_LINESTRIP_BF = 19, 265 _3DPRIM_LINESTRIP_CONT_BF = 20, 266 _3DPRIM_TRIFAN_NOSTIPPLE = 22, 267}; 268 269enum GFX4_3D_Stencil_Operation { 270 STENCILOP_KEEP = 0, 271 STENCILOP_ZERO = 1, 272 STENCILOP_REPLACE = 2, 273 STENCILOP_INCRSAT = 3, 274 STENCILOP_DECRSAT = 4, 275 STENCILOP_INCR = 5, 276 STENCILOP_DECR = 6, 277 STENCILOP_INVERT = 7, 278}; 279 280enum GFX4_3D_Vertex_Component_Control { 281 VFCOMP_NOSTORE = 0, 282 VFCOMP_STORE_SRC = 1, 283 VFCOMP_STORE_0 = 2, 284 VFCOMP_STORE_1_FP = 3, 285 VFCOMP_STORE_1_INT = 4, 286 VFCOMP_STORE_VID = 5, 287 VFCOMP_STORE_IID = 6, 288 VFCOMP_STORE_PID = 7, 289}; 290 291enum GFX4_Texture_Coordinate_Mode { 292 TCM_WRAP = 0, 293 TCM_MIRROR = 1, 294 TCM_CLAMP = 2, 295 TCM_CUBE = 3, 296 TCM_CLAMP_BORDER = 4, 297 TCM_MIRROR_ONCE = 5, 298}; 299 300#define GFX4_CC_VIEWPORT_length 2 301struct GFX4_CC_VIEWPORT { 302 float MinimumDepth; 303 float MaximumDepth; 304}; 305 306static inline __attribute__((always_inline)) void 307GFX4_CC_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data, 308 __attribute__((unused)) void * restrict dst, 309 __attribute__((unused)) const struct GFX4_CC_VIEWPORT * restrict values) 310{ 311 uint32_t * restrict dw = (uint32_t * restrict) dst; 312 313 dw[0] = 314 __gen_float(values->MinimumDepth); 315 316 dw[1] = 317 __gen_float(values->MaximumDepth); 318} 319 320#define GFX4_CLIP_STATE_length 11 321struct GFX4_CLIP_STATE { 322 uint32_t GRFRegisterCount; 323 __gen_address_type KernelStartPointer; 324 bool SoftwareExceptionEnable; 325 bool MaskStackExceptionEnable; 326 bool IllegalOpcodeExceptionEnable; 327 uint32_t FloatingPointMode; 328#define FLOATING_POINT_MODE_IEEE754 0 329#define FLOATING_POINT_MODE_Alternate 1 330 uint32_t ThreadPriority; 331#define NormalPriority 0 332#define HighPriority 1 333 uint32_t BindingTableEntryCount; 334 bool SingleProgramFlow; 335 uint32_t PerThreadScratchSpace; 336 __gen_address_type ScratchSpaceBasePointer; 337 uint32_t DispatchGRFStartRegisterForURBData; 338 uint32_t VertexURBEntryReadOffset; 339 uint32_t VertexURBEntryReadLength; 340 uint32_t ConstantURBEntryReadOffset; 341 uint32_t ConstantURBEntryReadLength; 342 bool ClipperStatisticsEnable; 343 bool GSOutputObjectStatisticsEnable; 344 uint32_t NumberofURBEntries; 345 uint32_t URBEntryAllocationSize; 346 uint32_t MaximumNumberofThreads; 347 uint32_t ClipMode; 348#define CLIPMODE_NORMAL 0 349#define CLIPMODE_ALL 1 350#define CLIPMODE_CLIP_NON_REJECTED 2 351#define CLIPMODE_REJECT_ALL 3 352#define CLIPMODE_ACCEPT_ALL 4 353 uint32_t UserClipDistanceClipTestEnableBitmask; 354 bool UserClipFlagsMustClipEnable; 355 bool GuardbandClipTestEnable; 356 bool ViewportZClipTestEnable; 357 bool ViewportXYClipTestEnable; 358 uint32_t VertexPositionSpace; 359#define VPOS_NDCSPACE 0 360#define VPOS_SCREENSPACE 1 361 uint32_t APIMode; 362#define APIMODE_OGL 0 363#define APIMODE_D3D 1 364 __gen_address_type ClipperViewportStatePointer; 365 float ScreenSpaceViewportXMin; 366 float ScreenSpaceViewportXMax; 367 float ScreenSpaceViewportYMin; 368 float ScreenSpaceViewportYMax; 369}; 370 371static inline __attribute__((always_inline)) void 372GFX4_CLIP_STATE_pack(__attribute__((unused)) __gen_user_data *data, 373 __attribute__((unused)) void * restrict dst, 374 __attribute__((unused)) const struct GFX4_CLIP_STATE * restrict values) 375{ 376 uint32_t * restrict dw = (uint32_t * restrict) dst; 377 378 const uint32_t v0 = 379 __gen_uint(values->GRFRegisterCount, 1, 3); 380 dw[0] = __gen_address(data, &dw[0], values->KernelStartPointer, v0, 6, 31); 381 382 dw[1] = 383 __gen_uint(values->SoftwareExceptionEnable, 7, 7) | 384 __gen_uint(values->MaskStackExceptionEnable, 11, 11) | 385 __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) | 386 __gen_uint(values->FloatingPointMode, 16, 16) | 387 __gen_uint(values->ThreadPriority, 17, 17) | 388 __gen_uint(values->BindingTableEntryCount, 18, 25) | 389 __gen_uint(values->SingleProgramFlow, 31, 31); 390 391 const uint32_t v2 = 392 __gen_uint(values->PerThreadScratchSpace, 0, 3); 393 dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31); 394 395 dw[3] = 396 __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) | 397 __gen_uint(values->VertexURBEntryReadOffset, 4, 9) | 398 __gen_uint(values->VertexURBEntryReadLength, 11, 16) | 399 __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) | 400 __gen_uint(values->ConstantURBEntryReadLength, 25, 30); 401 402 dw[4] = 403 __gen_uint(values->ClipperStatisticsEnable, 10, 10) | 404 __gen_uint(values->GSOutputObjectStatisticsEnable, 10, 10) | 405 __gen_uint(values->NumberofURBEntries, 11, 18) | 406 __gen_uint(values->URBEntryAllocationSize, 19, 23) | 407 __gen_uint(values->MaximumNumberofThreads, 25, 30); 408 409 dw[5] = 410 __gen_uint(values->ClipMode, 13, 15) | 411 __gen_uint(values->UserClipDistanceClipTestEnableBitmask, 16, 23) | 412 __gen_uint(values->UserClipFlagsMustClipEnable, 24, 24) | 413 __gen_uint(values->GuardbandClipTestEnable, 26, 26) | 414 __gen_uint(values->ViewportZClipTestEnable, 27, 27) | 415 __gen_uint(values->ViewportXYClipTestEnable, 28, 28) | 416 __gen_uint(values->VertexPositionSpace, 29, 29) | 417 __gen_uint(values->APIMode, 30, 30); 418 419 dw[6] = __gen_address(data, &dw[6], values->ClipperViewportStatePointer, 0, 5, 31); 420 421 dw[7] = 422 __gen_float(values->ScreenSpaceViewportXMin); 423 424 dw[8] = 425 __gen_float(values->ScreenSpaceViewportXMax); 426 427 dw[9] = 428 __gen_float(values->ScreenSpaceViewportYMin); 429 430 dw[10] = 431 __gen_float(values->ScreenSpaceViewportYMax); 432} 433 434#define GFX4_CLIP_VIEWPORT_length 4 435struct GFX4_CLIP_VIEWPORT { 436 float XMinClipGuardband; 437 float XMaxClipGuardband; 438 float YMinClipGuardband; 439 float YMaxClipGuardband; 440}; 441 442static inline __attribute__((always_inline)) void 443GFX4_CLIP_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data, 444 __attribute__((unused)) void * restrict dst, 445 __attribute__((unused)) const struct GFX4_CLIP_VIEWPORT * restrict values) 446{ 447 uint32_t * restrict dw = (uint32_t * restrict) dst; 448 449 dw[0] = 450 __gen_float(values->XMinClipGuardband); 451 452 dw[1] = 453 __gen_float(values->XMaxClipGuardband); 454 455 dw[2] = 456 __gen_float(values->YMinClipGuardband); 457 458 dw[3] = 459 __gen_float(values->YMaxClipGuardband); 460} 461 462#define GFX4_COLOR_CALC_STATE_length 8 463struct GFX4_COLOR_CALC_STATE { 464 enum GFX4_3D_Stencil_Operation BackfaceStencilPassDepthPassOp; 465 enum GFX4_3D_Stencil_Operation BackfaceStencilPassDepthFailOp; 466 enum GFX4_3D_Stencil_Operation BackfaceStencilFailOp; 467 enum GFX4_3D_Compare_Function BackfaceStencilTestFunction; 468 bool DoubleSidedStencilEnable; 469 bool StencilBufferWriteEnable; 470 enum GFX4_3D_Stencil_Operation StencilPassDepthPassOp; 471 enum GFX4_3D_Stencil_Operation StencilPassDepthFailOp; 472 enum GFX4_3D_Stencil_Operation StencilFailOp; 473 enum GFX4_3D_Compare_Function StencilTestFunction; 474 bool StencilTestEnable; 475 uint32_t BackfaceStencilReferenceValue; 476 uint32_t StencilWriteMask; 477 uint32_t StencilTestMask; 478 uint32_t StencilReferenceValue; 479 bool LogicOpEnable; 480 bool DepthBufferWriteEnable; 481 enum GFX4_3D_Compare_Function DepthTestFunction; 482 bool DepthTestEnable; 483 uint32_t BackfaceStencilWriteMask; 484 uint32_t BackfaceStencilTestMask; 485 enum GFX4_3D_Compare_Function AlphaTestFunction; 486 bool AlphaTestEnable; 487 bool ColorBufferBlendEnable; 488 bool IndependentAlphaBlendEnable; 489 uint32_t AlphaTestFormat; 490#define ALPHATEST_UNORM8 0 491#define ALPHATEST_FLOAT32 1 492 __gen_address_type CCViewportStatePointer; 493 enum GFX4_3D_Color_Buffer_Blend_Factor DestinationAlphaBlendFactor; 494 enum GFX4_3D_Color_Buffer_Blend_Factor SourceAlphaBlendFactor; 495 enum GFX4_3D_Color_Buffer_Blend_Function AlphaBlendFunction; 496 bool StatisticsEnable; 497 enum GFX4_3D_Logic_Op_Function LogicOpFunction; 498 bool RoundDisableFunctionDisable; 499 bool ColorDitherEnable; 500 bool PostBlendColorClampEnable; 501 bool PreBlendColorClampEnable; 502 uint32_t ColorClampRange; 503#define COLORCLAMP_UNORM 0 504#define COLORCLAMP_SNORM 1 505#define COLORCLAMP_RTFORMAT 2 506 uint32_t YDitherOffset; 507 uint32_t XDitherOffset; 508 enum GFX4_3D_Color_Buffer_Blend_Factor DestinationBlendFactor; 509 enum GFX4_3D_Color_Buffer_Blend_Factor SourceBlendFactor; 510 enum GFX4_3D_Color_Buffer_Blend_Function ColorBlendFunction; 511 uint32_t AlphaReferenceValueAsUNORM8; 512 float AlphaReferenceValueAsFLOAT32; 513}; 514 515static inline __attribute__((always_inline)) void 516GFX4_COLOR_CALC_STATE_pack(__attribute__((unused)) __gen_user_data *data, 517 __attribute__((unused)) void * restrict dst, 518 __attribute__((unused)) const struct GFX4_COLOR_CALC_STATE * restrict values) 519{ 520 uint32_t * restrict dw = (uint32_t * restrict) dst; 521 522 dw[0] = 523 __gen_uint(values->BackfaceStencilPassDepthPassOp, 3, 5) | 524 __gen_uint(values->BackfaceStencilPassDepthFailOp, 6, 8) | 525 __gen_uint(values->BackfaceStencilFailOp, 9, 11) | 526 __gen_uint(values->BackfaceStencilTestFunction, 12, 14) | 527 __gen_uint(values->DoubleSidedStencilEnable, 15, 15) | 528 __gen_uint(values->StencilBufferWriteEnable, 18, 18) | 529 __gen_uint(values->StencilPassDepthPassOp, 19, 21) | 530 __gen_uint(values->StencilPassDepthFailOp, 22, 24) | 531 __gen_uint(values->StencilFailOp, 25, 27) | 532 __gen_uint(values->StencilTestFunction, 28, 30) | 533 __gen_uint(values->StencilTestEnable, 31, 31); 534 535 dw[1] = 536 __gen_uint(values->BackfaceStencilReferenceValue, 0, 7) | 537 __gen_uint(values->StencilWriteMask, 8, 15) | 538 __gen_uint(values->StencilTestMask, 16, 23) | 539 __gen_uint(values->StencilReferenceValue, 24, 31); 540 541 dw[2] = 542 __gen_uint(values->LogicOpEnable, 0, 0) | 543 __gen_uint(values->DepthBufferWriteEnable, 11, 11) | 544 __gen_uint(values->DepthTestFunction, 12, 14) | 545 __gen_uint(values->DepthTestEnable, 15, 15) | 546 __gen_uint(values->BackfaceStencilWriteMask, 16, 23) | 547 __gen_uint(values->BackfaceStencilTestMask, 24, 31); 548 549 dw[3] = 550 __gen_uint(values->AlphaTestFunction, 8, 10) | 551 __gen_uint(values->AlphaTestEnable, 11, 11) | 552 __gen_uint(values->ColorBufferBlendEnable, 12, 12) | 553 __gen_uint(values->IndependentAlphaBlendEnable, 13, 13) | 554 __gen_uint(values->AlphaTestFormat, 15, 15); 555 556 dw[4] = __gen_address(data, &dw[4], values->CCViewportStatePointer, 0, 5, 31); 557 558 dw[5] = 559 __gen_uint(values->DestinationAlphaBlendFactor, 2, 6) | 560 __gen_uint(values->SourceAlphaBlendFactor, 7, 11) | 561 __gen_uint(values->AlphaBlendFunction, 12, 14) | 562 __gen_uint(values->StatisticsEnable, 15, 15) | 563 __gen_uint(values->LogicOpFunction, 16, 19) | 564 __gen_uint(values->RoundDisableFunctionDisable, 30, 30) | 565 __gen_uint(values->ColorDitherEnable, 31, 31); 566 567 dw[6] = 568 __gen_uint(values->PostBlendColorClampEnable, 0, 0) | 569 __gen_uint(values->PreBlendColorClampEnable, 1, 1) | 570 __gen_uint(values->ColorClampRange, 2, 3) | 571 __gen_uint(values->YDitherOffset, 15, 16) | 572 __gen_uint(values->XDitherOffset, 17, 18) | 573 __gen_uint(values->DestinationBlendFactor, 19, 23) | 574 __gen_uint(values->SourceBlendFactor, 24, 28) | 575 __gen_uint(values->ColorBlendFunction, 29, 31); 576 577 dw[7] = 578 __gen_uint(values->AlphaReferenceValueAsUNORM8, 0, 31) | 579 __gen_float(values->AlphaReferenceValueAsFLOAT32); 580} 581 582#define GFX4_GS_STATE_length 7 583struct GFX4_GS_STATE { 584 uint32_t GRFRegisterCount; 585 __gen_address_type KernelStartPointer; 586 bool SoftwareExceptionEnable; 587 bool MaskStackExceptionEnable; 588 bool IllegalOpcodeExceptionEnable; 589 uint32_t FloatingPointMode; 590#define FLOATING_POINT_MODE_IEEE754 0 591#define FLOATING_POINT_MODE_Alternate 1 592 uint32_t BindingTableEntryCount; 593 bool SingleProgramFlow; 594 uint32_t PerThreadScratchSpace; 595 __gen_address_type ScratchSpaceBasePointer; 596 uint32_t DispatchGRFStartRegisterForURBData; 597 uint32_t VertexURBEntryReadOffset; 598 uint32_t VertexURBEntryReadLength; 599 uint32_t ConstantURBEntryReadOffset; 600 uint32_t ConstantURBEntryReadLength; 601 uint32_t NumberofURBEntries; 602 uint32_t URBEntryAllocationSize; 603 uint32_t MaximumNumberofThreads; 604 uint32_t SamplerCount; 605 __gen_address_type SamplerStatePointer; 606 uint32_t MaximumVPIndex; 607 bool DiscardAdjacency; 608 bool ReorderEnable; 609}; 610 611static inline __attribute__((always_inline)) void 612GFX4_GS_STATE_pack(__attribute__((unused)) __gen_user_data *data, 613 __attribute__((unused)) void * restrict dst, 614 __attribute__((unused)) const struct GFX4_GS_STATE * restrict values) 615{ 616 uint32_t * restrict dw = (uint32_t * restrict) dst; 617 618 const uint32_t v0 = 619 __gen_uint(values->GRFRegisterCount, 1, 3); 620 dw[0] = __gen_address(data, &dw[0], values->KernelStartPointer, v0, 6, 31); 621 622 dw[1] = 623 __gen_uint(values->SoftwareExceptionEnable, 7, 7) | 624 __gen_uint(values->MaskStackExceptionEnable, 11, 11) | 625 __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) | 626 __gen_uint(values->FloatingPointMode, 16, 16) | 627 __gen_uint(values->BindingTableEntryCount, 18, 25) | 628 __gen_uint(values->SingleProgramFlow, 31, 31); 629 630 const uint32_t v2 = 631 __gen_uint(values->PerThreadScratchSpace, 0, 3); 632 dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31); 633 634 dw[3] = 635 __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) | 636 __gen_uint(values->VertexURBEntryReadOffset, 4, 9) | 637 __gen_uint(values->VertexURBEntryReadLength, 11, 16) | 638 __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) | 639 __gen_uint(values->ConstantURBEntryReadLength, 25, 30); 640 641 dw[4] = 642 __gen_uint(values->NumberofURBEntries, 11, 18) | 643 __gen_uint(values->URBEntryAllocationSize, 19, 23) | 644 __gen_uint(values->MaximumNumberofThreads, 25, 30); 645 646 const uint32_t v5 = 647 __gen_uint(values->SamplerCount, 0, 2); 648 dw[5] = __gen_address(data, &dw[5], values->SamplerStatePointer, v5, 5, 31); 649 650 dw[6] = 651 __gen_uint(values->MaximumVPIndex, 0, 3) | 652 __gen_uint(values->DiscardAdjacency, 29, 29) | 653 __gen_uint(values->ReorderEnable, 30, 30); 654} 655 656#define GFX4_RENDER_SURFACE_STATE_length 5 657struct GFX4_RENDER_SURFACE_STATE { 658 bool CubeFaceEnablePositiveZ; 659 bool CubeFaceEnableNegativeZ; 660 bool CubeFaceEnablePositiveY; 661 bool CubeFaceEnableNegativeY; 662 bool CubeFaceEnablePositiveX; 663 bool CubeFaceEnableNegativeX; 664 uint32_t MediaBoundaryPixelMode; 665#define NORMAL_MODE 0 666 uint32_t RenderCacheReadWriteMode; 667#define WRITE_ONLY 0 668#define READ_WRITE 1 669 uint32_t MIPMapLayoutMode; 670#define MIPLAYOUT_BELOW 0 671#define MIPLAYOUT_RIGHT 1 672 uint32_t VerticalLineStrideOffset; 673 uint32_t VerticalLineStride; 674 bool ColorBlendEnable; 675 uint32_t ColorBufferComponentWriteDisables; 676#define WRITEDISABLE_ALPHA 8 677#define WRITEDISABLE_RED 4 678#define WRITEDISABLE_GREEN 2 679#define WRITEDISABLE_BLUE 1 680 uint32_t SurfaceFormat; 681 uint32_t DataReturnFormat; 682#define DATA_RETURN_FLOAT32 0 683#define DATA_RETURN_S114 1 684 uint32_t SurfaceType; 685#define SURFTYPE_1D 0 686#define SURFTYPE_2D 1 687#define SURFTYPE_3D 2 688#define SURFTYPE_CUBE 3 689#define SURFTYPE_BUFFER 4 690#define SURFTYPE_NULL 7 691 __gen_address_type SurfaceBaseAddress; 692 uint32_t MIPCountLOD; 693 uint32_t Width; 694 uint32_t Height; 695 uint32_t TileWalk; 696#define TILEWALK_XMAJOR 0 697#define TILEWALK_YMAJOR 1 698 uint32_t TiledSurface; 699 uint32_t SurfacePitch; 700 uint32_t Depth; 701 uint32_t RenderTargetViewExtent; 702 uint32_t MinimumArrayElement; 703 uint32_t SurfaceMinLOD; 704}; 705 706static inline __attribute__((always_inline)) void 707GFX4_RENDER_SURFACE_STATE_pack(__attribute__((unused)) __gen_user_data *data, 708 __attribute__((unused)) void * restrict dst, 709 __attribute__((unused)) const struct GFX4_RENDER_SURFACE_STATE * restrict values) 710{ 711 uint32_t * restrict dw = (uint32_t * restrict) dst; 712 713 dw[0] = 714 __gen_uint(values->CubeFaceEnablePositiveZ, 0, 0) | 715 __gen_uint(values->CubeFaceEnableNegativeZ, 1, 1) | 716 __gen_uint(values->CubeFaceEnablePositiveY, 2, 2) | 717 __gen_uint(values->CubeFaceEnableNegativeY, 3, 3) | 718 __gen_uint(values->CubeFaceEnablePositiveX, 4, 4) | 719 __gen_uint(values->CubeFaceEnableNegativeX, 5, 5) | 720 __gen_uint(values->MediaBoundaryPixelMode, 6, 7) | 721 __gen_uint(values->RenderCacheReadWriteMode, 8, 8) | 722 __gen_uint(values->MIPMapLayoutMode, 10, 10) | 723 __gen_uint(values->VerticalLineStrideOffset, 11, 11) | 724 __gen_uint(values->VerticalLineStride, 12, 12) | 725 __gen_uint(values->ColorBlendEnable, 13, 13) | 726 __gen_uint(values->ColorBufferComponentWriteDisables, 14, 17) | 727 __gen_uint(values->SurfaceFormat, 18, 26) | 728 __gen_uint(values->DataReturnFormat, 27, 27) | 729 __gen_uint(values->SurfaceType, 29, 31); 730 731 dw[1] = __gen_address(data, &dw[1], values->SurfaceBaseAddress, 0, 0, 31); 732 733 dw[2] = 734 __gen_uint(values->MIPCountLOD, 2, 5) | 735 __gen_uint(values->Width, 6, 18) | 736 __gen_uint(values->Height, 19, 31); 737 738 dw[3] = 739 __gen_uint(values->TileWalk, 0, 0) | 740 __gen_uint(values->TiledSurface, 1, 1) | 741 __gen_uint(values->SurfacePitch, 3, 19) | 742 __gen_uint(values->Depth, 21, 31); 743 744 dw[4] = 745 __gen_uint(values->RenderTargetViewExtent, 8, 16) | 746 __gen_uint(values->MinimumArrayElement, 17, 27) | 747 __gen_uint(values->SurfaceMinLOD, 28, 31); 748} 749 750#define GFX4_SAMPLER_BORDER_COLOR_STATE_length 12 751struct GFX4_SAMPLER_BORDER_COLOR_STATE { 752 float BorderColorRed; 753 float BorderColorGreen; 754 float BorderColorBlue; 755 float BorderColorAlpha; 756}; 757 758static inline __attribute__((always_inline)) void 759GFX4_SAMPLER_BORDER_COLOR_STATE_pack(__attribute__((unused)) __gen_user_data *data, 760 __attribute__((unused)) void * restrict dst, 761 __attribute__((unused)) const struct GFX4_SAMPLER_BORDER_COLOR_STATE * restrict values) 762{ 763 uint32_t * restrict dw = (uint32_t * restrict) dst; 764 765 dw[0] = 766 __gen_float(values->BorderColorRed); 767 768 dw[1] = 769 __gen_float(values->BorderColorGreen); 770 771 dw[2] = 772 __gen_float(values->BorderColorBlue); 773 774 dw[3] = 775 __gen_float(values->BorderColorAlpha); 776 777 dw[4] = 0; 778 779 dw[5] = 0; 780 781 dw[6] = 0; 782 783 dw[7] = 0; 784 785 dw[8] = 0; 786 787 dw[9] = 0; 788 789 dw[10] = 0; 790 791 dw[11] = 0; 792} 793 794#define GFX4_SAMPLER_STATE_length 4 795struct GFX4_SAMPLER_STATE { 796 uint32_t ShadowFunction; 797#define PREFILTEROP_ALWAYS 0 798#define PREFILTEROP_NEVER 1 799#define PREFILTEROP_LESS 2 800#define PREFILTEROP_EQUAL 3 801#define PREFILTEROP_LEQUAL 4 802#define PREFILTEROP_GREATER 5 803#define PREFILTEROP_NOTEQUAL 6 804#define PREFILTEROP_GEQUAL 7 805 float TextureLODBias; 806 uint32_t MinModeFilter; 807 uint32_t MagModeFilter; 808#define MAPFILTER_NEAREST 0 809#define MAPFILTER_LINEAR 1 810#define MAPFILTER_ANISOTROPIC 2 811#define MAPFILTER_MONO 6 812 uint32_t MipModeFilter; 813#define MIPFILTER_NONE 0 814#define MIPFILTER_NEAREST 1 815#define MIPFILTER_LINEAR 3 816 float BaseMipLevel; 817 bool LODPreClampEnable; 818 bool SamplerDisable; 819 enum GFX4_Texture_Coordinate_Mode TCZAddressControlMode; 820 enum GFX4_Texture_Coordinate_Mode TCYAddressControlMode; 821 enum GFX4_Texture_Coordinate_Mode TCXAddressControlMode; 822 uint32_t CubeSurfaceControlMode; 823#define CUBECTRLMODE_PROGRAMMED 0 824#define CUBECTRLMODE_OVERRIDE 1 825 float MaxLOD; 826 float MinLOD; 827 __gen_address_type BorderColorPointer; 828 bool RAddressMinFilterRoundingEnable; 829 bool RAddressMagFilterRoundingEnable; 830 bool VAddressMinFilterRoundingEnable; 831 bool VAddressMagFilterRoundingEnable; 832 bool UAddressMinFilterRoundingEnable; 833 bool UAddressMagFilterRoundingEnable; 834 uint32_t MaximumAnisotropy; 835#define RATIO21 0 836#define RATIO41 1 837#define RATIO61 2 838#define RATIO81 3 839#define RATIO101 4 840#define RATIO121 5 841#define RATIO141 6 842#define RATIO161 7 843 uint32_t ChromaKeyMode; 844#define KEYFILTER_KILL_ON_ANY_MATCH 0 845#define KEYFILTER_REPLACE_BLACK 1 846 uint32_t ChromaKeyIndex; 847 bool ChromaKeyEnable; 848}; 849 850static inline __attribute__((always_inline)) void 851GFX4_SAMPLER_STATE_pack(__attribute__((unused)) __gen_user_data *data, 852 __attribute__((unused)) void * restrict dst, 853 __attribute__((unused)) const struct GFX4_SAMPLER_STATE * restrict values) 854{ 855 uint32_t * restrict dw = (uint32_t * restrict) dst; 856 857 dw[0] = 858 __gen_uint(values->ShadowFunction, 0, 2) | 859 __gen_sfixed(values->TextureLODBias, 3, 13, 6) | 860 __gen_uint(values->MinModeFilter, 14, 16) | 861 __gen_uint(values->MagModeFilter, 17, 19) | 862 __gen_uint(values->MipModeFilter, 20, 21) | 863 __gen_ufixed(values->BaseMipLevel, 22, 26, 1) | 864 __gen_uint(values->LODPreClampEnable, 28, 28) | 865 __gen_uint(values->SamplerDisable, 31, 31); 866 867 dw[1] = 868 __gen_uint(values->TCZAddressControlMode, 0, 2) | 869 __gen_uint(values->TCYAddressControlMode, 3, 5) | 870 __gen_uint(values->TCXAddressControlMode, 6, 8) | 871 __gen_uint(values->CubeSurfaceControlMode, 9, 9) | 872 __gen_ufixed(values->MaxLOD, 12, 21, 6) | 873 __gen_ufixed(values->MinLOD, 22, 31, 6); 874 875 dw[2] = __gen_address(data, &dw[2], values->BorderColorPointer, 0, 5, 31); 876 877 dw[3] = 878 __gen_uint(values->RAddressMinFilterRoundingEnable, 13, 13) | 879 __gen_uint(values->RAddressMagFilterRoundingEnable, 14, 14) | 880 __gen_uint(values->VAddressMinFilterRoundingEnable, 15, 15) | 881 __gen_uint(values->VAddressMagFilterRoundingEnable, 16, 16) | 882 __gen_uint(values->UAddressMinFilterRoundingEnable, 17, 17) | 883 __gen_uint(values->UAddressMagFilterRoundingEnable, 18, 18) | 884 __gen_uint(values->MaximumAnisotropy, 19, 21) | 885 __gen_uint(values->ChromaKeyMode, 22, 22) | 886 __gen_uint(values->ChromaKeyIndex, 23, 24) | 887 __gen_uint(values->ChromaKeyEnable, 25, 25); 888} 889 890#define GFX4_SCISSOR_RECT_length 2 891struct GFX4_SCISSOR_RECT { 892 uint32_t ScissorRectangleXMin; 893 uint32_t ScissorRectangleYMin; 894 uint32_t ScissorRectangleXMax; 895 uint32_t ScissorRectangleYMax; 896}; 897 898static inline __attribute__((always_inline)) void 899GFX4_SCISSOR_RECT_pack(__attribute__((unused)) __gen_user_data *data, 900 __attribute__((unused)) void * restrict dst, 901 __attribute__((unused)) const struct GFX4_SCISSOR_RECT * restrict values) 902{ 903 uint32_t * restrict dw = (uint32_t * restrict) dst; 904 905 dw[0] = 906 __gen_uint(values->ScissorRectangleXMin, 0, 15) | 907 __gen_uint(values->ScissorRectangleYMin, 16, 31); 908 909 dw[1] = 910 __gen_uint(values->ScissorRectangleXMax, 0, 15) | 911 __gen_uint(values->ScissorRectangleYMax, 16, 31); 912} 913 914#define GFX4_SF_STATE_length 8 915struct GFX4_SF_STATE { 916 uint32_t GRFRegisterCount; 917 __gen_address_type KernelStartPointer; 918 bool SoftwareExceptionEnable; 919 bool MaskStackExceptionEnable; 920 bool IllegalOpcodeExceptionEnable; 921 uint32_t FloatingPointMode; 922#define FLOATING_POINT_MODE_IEEE754 0 923#define FLOATING_POINT_MODE_Alternate 1 924 uint32_t ThreadPriority; 925#define NormalPriority 0 926#define HighPriority 1 927 uint32_t BindingTableEntryCount; 928 bool SingleProgramFlow; 929 uint32_t PerThreadScratchSpace; 930 __gen_address_type ScratchSpaceBasePointer; 931 uint32_t DispatchGRFStartRegisterForURBData; 932 uint32_t VertexURBEntryReadOffset; 933 uint32_t VertexURBEntryReadLength; 934 uint32_t ConstantURBEntryReadOffset; 935 uint32_t ConstantURBEntryReadLength; 936 uint32_t NumberofURBEntries; 937 uint32_t URBEntryAllocationSize; 938 uint32_t MaximumNumberofThreads; 939 uint32_t FrontWinding; 940#define FRONTWINDING_CW 0 941#define FRONTWINDING_CCW 1 942 bool ViewportTransformEnable; 943 __gen_address_type SetupViewportStateOffset; 944 float DestinationOriginVerticalBias; 945 float DestinationOriginHorizontalBias; 946 bool ScissorRectangleEnable; 947 bool _2x2PixelTriangleFilterDisable; 948 bool ZeroPixelTriangleFilterDisable; 949 uint32_t PointRasterizationRule; 950#define RASTRULE_UPPER_LEFT 0 951#define RASTRULE_UPPER_RIGHT 1 952 uint32_t LineEndCapAntialiasingRegionWidth; 953#define _05pixels 0 954#define _10pixels 1 955#define _20pixels 2 956#define _40pixels 3 957 float LineWidth; 958 bool FastScissorClipDisable; 959 uint32_t CullMode; 960#define CULLMODE_BOTH 0 961#define CULLMODE_NONE 1 962#define CULLMODE_FRONT 2 963#define CULLMODE_BACK 3 964 bool AntialiasingEnable; 965 float PointWidth; 966 uint32_t PointWidthSource; 967#define Vertex 0 968#define State 1 969 uint32_t VertexSubPixelPrecisionSelect; 970#define _8SubPixelPrecisionBits 0 971#define _4SubPixelPrecisionBits 1 972 bool SpritePointEnable; 973 uint32_t TriangleFanProvokingVertexSelect; 974#define Vertex0 0 975#define Vertex1 1 976#define Vertex2 2 977 uint32_t LineStripListProvokingVertexSelect; 978#define Vertex0 0 979#define Vertex1 1 980 uint32_t TriangleStripListProvokingVertexSelect; 981#define Vertex0 0 982#define Vertex1 1 983#define Vertex2 2 984 bool LastPixelEnable; 985}; 986 987static inline __attribute__((always_inline)) void 988GFX4_SF_STATE_pack(__attribute__((unused)) __gen_user_data *data, 989 __attribute__((unused)) void * restrict dst, 990 __attribute__((unused)) const struct GFX4_SF_STATE * restrict values) 991{ 992 uint32_t * restrict dw = (uint32_t * restrict) dst; 993 994 const uint32_t v0 = 995 __gen_uint(values->GRFRegisterCount, 1, 3); 996 dw[0] = __gen_address(data, &dw[0], values->KernelStartPointer, v0, 6, 31); 997 998 dw[1] = 999 __gen_uint(values->SoftwareExceptionEnable, 7, 7) | 1000 __gen_uint(values->MaskStackExceptionEnable, 11, 11) | 1001 __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) | 1002 __gen_uint(values->FloatingPointMode, 16, 16) | 1003 __gen_uint(values->ThreadPriority, 17, 17) | 1004 __gen_uint(values->BindingTableEntryCount, 18, 25) | 1005 __gen_uint(values->SingleProgramFlow, 31, 31); 1006 1007 const uint32_t v2 = 1008 __gen_uint(values->PerThreadScratchSpace, 0, 3); 1009 dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31); 1010 1011 dw[3] = 1012 __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) | 1013 __gen_uint(values->VertexURBEntryReadOffset, 4, 9) | 1014 __gen_uint(values->VertexURBEntryReadLength, 11, 16) | 1015 __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) | 1016 __gen_uint(values->ConstantURBEntryReadLength, 25, 30); 1017 1018 dw[4] = 1019 __gen_uint(values->NumberofURBEntries, 11, 18) | 1020 __gen_uint(values->URBEntryAllocationSize, 19, 23) | 1021 __gen_uint(values->MaximumNumberofThreads, 25, 30); 1022 1023 const uint32_t v5 = 1024 __gen_uint(values->FrontWinding, 0, 0) | 1025 __gen_uint(values->ViewportTransformEnable, 1, 1); 1026 dw[5] = __gen_address(data, &dw[5], values->SetupViewportStateOffset, v5, 5, 31); 1027 1028 dw[6] = 1029 __gen_ufixed(values->DestinationOriginVerticalBias, 9, 12, 4) | 1030 __gen_ufixed(values->DestinationOriginHorizontalBias, 13, 16, 4) | 1031 __gen_uint(values->ScissorRectangleEnable, 17, 17) | 1032 __gen_uint(values->_2x2PixelTriangleFilterDisable, 18, 18) | 1033 __gen_uint(values->ZeroPixelTriangleFilterDisable, 19, 19) | 1034 __gen_uint(values->PointRasterizationRule, 20, 21) | 1035 __gen_uint(values->LineEndCapAntialiasingRegionWidth, 22, 23) | 1036 __gen_ufixed(values->LineWidth, 24, 27, 1) | 1037 __gen_uint(values->FastScissorClipDisable, 28, 28) | 1038 __gen_uint(values->CullMode, 29, 30) | 1039 __gen_uint(values->AntialiasingEnable, 31, 31); 1040 1041 dw[7] = 1042 __gen_ufixed(values->PointWidth, 0, 10, 3) | 1043 __gen_uint(values->PointWidthSource, 11, 11) | 1044 __gen_uint(values->VertexSubPixelPrecisionSelect, 12, 12) | 1045 __gen_uint(values->SpritePointEnable, 13, 13) | 1046 __gen_uint(values->TriangleFanProvokingVertexSelect, 25, 26) | 1047 __gen_uint(values->LineStripListProvokingVertexSelect, 27, 28) | 1048 __gen_uint(values->TriangleStripListProvokingVertexSelect, 29, 30) | 1049 __gen_uint(values->LastPixelEnable, 31, 31); 1050} 1051 1052#define GFX4_SF_VIEWPORT_length 8 1053struct GFX4_SF_VIEWPORT { 1054 float ViewportMatrixElementm00; 1055 float ViewportMatrixElementm11; 1056 float ViewportMatrixElementm22; 1057 float ViewportMatrixElementm30; 1058 float ViewportMatrixElementm31; 1059 float ViewportMatrixElementm32; 1060 struct GFX4_SCISSOR_RECT ScissorRectangle; 1061}; 1062 1063static inline __attribute__((always_inline)) void 1064GFX4_SF_VIEWPORT_pack(__attribute__((unused)) __gen_user_data *data, 1065 __attribute__((unused)) void * restrict dst, 1066 __attribute__((unused)) const struct GFX4_SF_VIEWPORT * restrict values) 1067{ 1068 uint32_t * restrict dw = (uint32_t * restrict) dst; 1069 1070 dw[0] = 1071 __gen_float(values->ViewportMatrixElementm00); 1072 1073 dw[1] = 1074 __gen_float(values->ViewportMatrixElementm11); 1075 1076 dw[2] = 1077 __gen_float(values->ViewportMatrixElementm22); 1078 1079 dw[3] = 1080 __gen_float(values->ViewportMatrixElementm30); 1081 1082 dw[4] = 1083 __gen_float(values->ViewportMatrixElementm31); 1084 1085 dw[5] = 1086 __gen_float(values->ViewportMatrixElementm32); 1087 1088 GFX4_SCISSOR_RECT_pack(data, &dw[6], &values->ScissorRectangle); 1089} 1090 1091#define GFX4_VERTEX_BUFFER_STATE_length 4 1092struct GFX4_VERTEX_BUFFER_STATE { 1093 uint32_t BufferPitch; 1094 uint32_t BufferAccessType; 1095#define VERTEXDATA 0 1096#define INSTANCEDATA 1 1097 uint32_t VertexBufferIndex; 1098 __gen_address_type BufferStartingAddress; 1099 uint32_t MaxIndex; 1100 uint32_t InstanceDataStepRate; 1101}; 1102 1103static inline __attribute__((always_inline)) void 1104GFX4_VERTEX_BUFFER_STATE_pack(__attribute__((unused)) __gen_user_data *data, 1105 __attribute__((unused)) void * restrict dst, 1106 __attribute__((unused)) const struct GFX4_VERTEX_BUFFER_STATE * restrict values) 1107{ 1108 uint32_t * restrict dw = (uint32_t * restrict) dst; 1109 1110 dw[0] = 1111 __gen_uint(values->BufferPitch, 0, 10) | 1112 __gen_uint(values->BufferAccessType, 26, 26) | 1113 __gen_uint(values->VertexBufferIndex, 27, 31); 1114 1115 dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, 0, 0, 31); 1116 1117 dw[2] = 1118 __gen_uint(values->MaxIndex, 0, 31); 1119 1120 dw[3] = 1121 __gen_uint(values->InstanceDataStepRate, 0, 31); 1122} 1123 1124#define GFX4_VERTEX_ELEMENT_STATE_length 2 1125struct GFX4_VERTEX_ELEMENT_STATE { 1126 uint32_t SourceElementOffset; 1127 uint32_t SourceElementFormat; 1128 bool Valid; 1129 uint32_t VertexBufferIndex; 1130 uint32_t DestinationElementOffset; 1131 enum GFX4_3D_Vertex_Component_Control Component3Control; 1132 enum GFX4_3D_Vertex_Component_Control Component2Control; 1133 enum GFX4_3D_Vertex_Component_Control Component1Control; 1134 enum GFX4_3D_Vertex_Component_Control Component0Control; 1135}; 1136 1137static inline __attribute__((always_inline)) void 1138GFX4_VERTEX_ELEMENT_STATE_pack(__attribute__((unused)) __gen_user_data *data, 1139 __attribute__((unused)) void * restrict dst, 1140 __attribute__((unused)) const struct GFX4_VERTEX_ELEMENT_STATE * restrict values) 1141{ 1142 uint32_t * restrict dw = (uint32_t * restrict) dst; 1143 1144 dw[0] = 1145 __gen_uint(values->SourceElementOffset, 0, 10) | 1146 __gen_uint(values->SourceElementFormat, 16, 24) | 1147 __gen_uint(values->Valid, 26, 26) | 1148 __gen_uint(values->VertexBufferIndex, 27, 31); 1149 1150 dw[1] = 1151 __gen_uint(values->DestinationElementOffset, 0, 7) | 1152 __gen_uint(values->Component3Control, 16, 18) | 1153 __gen_uint(values->Component2Control, 20, 22) | 1154 __gen_uint(values->Component1Control, 24, 26) | 1155 __gen_uint(values->Component0Control, 28, 30); 1156} 1157 1158#define GFX4_VS_STATE_length 7 1159struct GFX4_VS_STATE { 1160 uint32_t GRFRegisterCount; 1161 __gen_address_type KernelStartPointer; 1162 bool SoftwareExceptionEnable; 1163 bool MaskStackExceptionEnable; 1164 bool IllegalOpcodeExceptionEnable; 1165 uint32_t FloatingPointMode; 1166#define FLOATING_POINT_MODE_IEEE754 0 1167#define FLOATING_POINT_MODE_Alternate 1 1168 uint32_t ThreadPriority; 1169#define NormalPriority 0 1170#define HighPriority 1 1171 uint32_t BindingTableEntryCount; 1172 bool SingleProgramFlow; 1173 uint32_t PerThreadScratchSpace; 1174 __gen_address_type ScratchSpaceBasePointer; 1175 uint32_t DispatchGRFStartRegisterForURBData; 1176 uint32_t VertexURBEntryReadOffset; 1177 uint32_t VertexURBEntryReadLength; 1178 uint32_t ConstantURBEntryReadOffset; 1179 uint32_t ConstantURBEntryReadLength; 1180 bool StatisticsEnable; 1181 uint32_t NumberofURBEntries; 1182 uint32_t URBEntryAllocationSize; 1183 uint32_t MaximumNumberofThreads; 1184 uint32_t SamplerCount; 1185 __gen_address_type SamplerStatePointer; 1186 bool Enable; 1187 bool VertexCacheDisable; 1188}; 1189 1190static inline __attribute__((always_inline)) void 1191GFX4_VS_STATE_pack(__attribute__((unused)) __gen_user_data *data, 1192 __attribute__((unused)) void * restrict dst, 1193 __attribute__((unused)) const struct GFX4_VS_STATE * restrict values) 1194{ 1195 uint32_t * restrict dw = (uint32_t * restrict) dst; 1196 1197 const uint32_t v0 = 1198 __gen_uint(values->GRFRegisterCount, 1, 3); 1199 dw[0] = __gen_address(data, &dw[0], values->KernelStartPointer, v0, 6, 31); 1200 1201 dw[1] = 1202 __gen_uint(values->SoftwareExceptionEnable, 7, 7) | 1203 __gen_uint(values->MaskStackExceptionEnable, 11, 11) | 1204 __gen_uint(values->IllegalOpcodeExceptionEnable, 13, 13) | 1205 __gen_uint(values->FloatingPointMode, 16, 16) | 1206 __gen_uint(values->ThreadPriority, 17, 17) | 1207 __gen_uint(values->BindingTableEntryCount, 18, 25) | 1208 __gen_uint(values->SingleProgramFlow, 31, 31); 1209 1210 const uint32_t v2 = 1211 __gen_uint(values->PerThreadScratchSpace, 0, 3); 1212 dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31); 1213 1214 dw[3] = 1215 __gen_uint(values->DispatchGRFStartRegisterForURBData, 0, 3) | 1216 __gen_uint(values->VertexURBEntryReadOffset, 4, 9) | 1217 __gen_uint(values->VertexURBEntryReadLength, 11, 16) | 1218 __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) | 1219 __gen_uint(values->ConstantURBEntryReadLength, 25, 30); 1220 1221 dw[4] = 1222 __gen_uint(values->StatisticsEnable, 10, 10) | 1223 __gen_uint(values->NumberofURBEntries, 11, 18) | 1224 __gen_uint(values->URBEntryAllocationSize, 19, 23) | 1225 __gen_uint(values->MaximumNumberofThreads, 25, 30); 1226 1227 const uint32_t v5 = 1228 __gen_uint(values->SamplerCount, 0, 2); 1229 dw[5] = __gen_address(data, &dw[5], values->SamplerStatePointer, v5, 5, 31); 1230 1231 dw[6] = 1232 __gen_uint(values->Enable, 0, 0) | 1233 __gen_uint(values->VertexCacheDisable, 1, 1); 1234} 1235 1236#define GFX4_WM_STATE_length 8 1237struct GFX4_WM_STATE { 1238 uint32_t GRFRegisterCount0; 1239 __gen_address_type KernelStartPointer0; 1240 bool SoftwareExceptionEnable; 1241 bool MaskStackExceptionEnable; 1242 bool IllegalOpcodeExceptionEnable; 1243 uint32_t DepthCoefficientURBReadOffset; 1244 uint32_t FloatingPointMode; 1245#define FLOATING_POINT_MODE_IEEE754 0 1246#define FLOATING_POINT_MODE_Alternate 1 1247 uint32_t ThreadPriority; 1248#define High 1 1249 uint32_t BindingTableEntryCount; 1250 bool SingleProgramFlow; 1251 uint32_t PerThreadScratchSpace; 1252 __gen_address_type ScratchSpaceBasePointer; 1253 uint32_t DispatchGRFStartRegisterForConstantSetupData0; 1254 uint32_t SetupURBEntryReadOffset; 1255 uint32_t SetupURBEntryReadLength; 1256 uint32_t ConstantURBEntryReadOffset; 1257 uint32_t ConstantURBEntryReadLength; 1258 bool StatisticsEnable; 1259 uint32_t SamplerCount; 1260 __gen_address_type SamplerStatePointer; 1261 bool _8PixelDispatchEnable; 1262 bool _16PixelDispatchEnable; 1263 bool _32PixelDispatchEnable; 1264 bool LegacyGlobalDepthBiasEnable; 1265 bool LineStippleEnable; 1266 bool GlobalDepthOffsetEnable; 1267 bool PolygonStippleEnable; 1268 uint32_t LineAntialiasingRegionWidth; 1269#define _05pixels 0 1270#define _10pixels 1 1271#define _20pixels 2 1272#define _40pixels 3 1273 uint32_t LineEndCapAntialiasingRegionWidth; 1274#define _05pixels 0 1275#define _10pixels 1 1276#define _20pixels 2 1277#define _40pixels 3 1278 bool EarlyDepthTestEnable; 1279 bool ThreadDispatchEnable; 1280 bool PixelShaderUsesSourceDepth; 1281 bool PixelShaderComputedDepth; 1282 bool PixelShaderKillsPixel; 1283 bool LegacyDiamondLineRasterization; 1284 uint32_t MaximumNumberofThreads; 1285 float GlobalDepthOffsetConstant; 1286 float GlobalDepthOffsetScale; 1287}; 1288 1289static inline __attribute__((always_inline)) void 1290GFX4_WM_STATE_pack(__attribute__((unused)) __gen_user_data *data, 1291 __attribute__((unused)) void * restrict dst, 1292 __attribute__((unused)) const struct GFX4_WM_STATE * restrict values) 1293{ 1294 uint32_t * restrict dw = (uint32_t * restrict) dst; 1295 1296 const uint32_t v0 = 1297 __gen_uint(values->GRFRegisterCount0, 1, 3); 1298 dw[0] = __gen_address(data, &dw[0], values->KernelStartPointer0, v0, 6, 31); 1299 1300 dw[1] = 1301 __gen_uint(values->SoftwareExceptionEnable, 1, 1) | 1302 __gen_uint(values->MaskStackExceptionEnable, 2, 2) | 1303 __gen_uint(values->IllegalOpcodeExceptionEnable, 4, 4) | 1304 __gen_uint(values->DepthCoefficientURBReadOffset, 8, 13) | 1305 __gen_uint(values->FloatingPointMode, 16, 16) | 1306 __gen_uint(values->ThreadPriority, 17, 17) | 1307 __gen_uint(values->BindingTableEntryCount, 18, 25) | 1308 __gen_uint(values->SingleProgramFlow, 31, 31); 1309 1310 const uint32_t v2 = 1311 __gen_uint(values->PerThreadScratchSpace, 0, 3); 1312 dw[2] = __gen_address(data, &dw[2], values->ScratchSpaceBasePointer, v2, 10, 31); 1313 1314 dw[3] = 1315 __gen_uint(values->DispatchGRFStartRegisterForConstantSetupData0, 0, 3) | 1316 __gen_uint(values->SetupURBEntryReadOffset, 4, 9) | 1317 __gen_uint(values->SetupURBEntryReadLength, 11, 16) | 1318 __gen_uint(values->ConstantURBEntryReadOffset, 18, 23) | 1319 __gen_uint(values->ConstantURBEntryReadLength, 25, 30); 1320 1321 const uint32_t v4 = 1322 __gen_uint(values->StatisticsEnable, 0, 0) | 1323 __gen_uint(values->SamplerCount, 2, 4); 1324 dw[4] = __gen_address(data, &dw[4], values->SamplerStatePointer, v4, 5, 31); 1325 1326 dw[5] = 1327 __gen_uint(values->_8PixelDispatchEnable, 0, 0) | 1328 __gen_uint(values->_16PixelDispatchEnable, 1, 1) | 1329 __gen_uint(values->_32PixelDispatchEnable, 2, 2) | 1330 __gen_uint(values->LegacyGlobalDepthBiasEnable, 10, 10) | 1331 __gen_uint(values->LineStippleEnable, 11, 11) | 1332 __gen_uint(values->GlobalDepthOffsetEnable, 12, 12) | 1333 __gen_uint(values->PolygonStippleEnable, 13, 13) | 1334 __gen_uint(values->LineAntialiasingRegionWidth, 14, 15) | 1335 __gen_uint(values->LineEndCapAntialiasingRegionWidth, 16, 17) | 1336 __gen_uint(values->EarlyDepthTestEnable, 18, 18) | 1337 __gen_uint(values->ThreadDispatchEnable, 19, 19) | 1338 __gen_uint(values->PixelShaderUsesSourceDepth, 20, 20) | 1339 __gen_uint(values->PixelShaderComputedDepth, 21, 21) | 1340 __gen_uint(values->PixelShaderKillsPixel, 22, 22) | 1341 __gen_uint(values->LegacyDiamondLineRasterization, 23, 23) | 1342 __gen_uint(values->MaximumNumberofThreads, 25, 31); 1343 1344 dw[6] = 1345 __gen_float(values->GlobalDepthOffsetConstant); 1346 1347 dw[7] = 1348 __gen_float(values->GlobalDepthOffsetScale); 1349} 1350 1351#define GFX4_3DPRIMITIVE_length 6 1352#define GFX4_3DPRIMITIVE_length_bias 2 1353#define GFX4_3DPRIMITIVE_header \ 1354 .DWordLength = 4, \ 1355 ._3DCommandSubOpcode = 0, \ 1356 ._3DCommandOpcode = 3, \ 1357 .CommandSubType = 3, \ 1358 .CommandType = 3, \ 1359 .InstanceCount = 1 1360 1361struct GFX4_3DPRIMITIVE { 1362 uint32_t DWordLength; 1363 enum GFX4_3D_Prim_Topo_Type PrimitiveTopologyType; 1364 uint32_t VertexAccessType; 1365#define SEQUENTIAL 0 1366#define RANDOM 1 1367 uint32_t _3DCommandSubOpcode; 1368 uint32_t _3DCommandOpcode; 1369 uint32_t CommandSubType; 1370 uint32_t CommandType; 1371 uint32_t VertexCountPerInstance; 1372 uint32_t StartVertexLocation; 1373 uint32_t InstanceCount; 1374#define UNDEFINED 0 1375#define noninstancedoperation 1 1376 int32_t BaseVertexLocation; 1377}; 1378 1379static inline __attribute__((always_inline)) void 1380GFX4_3DPRIMITIVE_pack(__attribute__((unused)) __gen_user_data *data, 1381 __attribute__((unused)) void * restrict dst, 1382 __attribute__((unused)) const struct GFX4_3DPRIMITIVE * restrict values) 1383{ 1384 uint32_t * restrict dw = (uint32_t * restrict) dst; 1385 1386 dw[0] = 1387 __gen_uint(values->DWordLength, 0, 7) | 1388 __gen_uint(values->PrimitiveTopologyType, 10, 14) | 1389 __gen_uint(values->VertexAccessType, 15, 15) | 1390 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 1391 __gen_uint(values->_3DCommandOpcode, 24, 26) | 1392 __gen_uint(values->CommandSubType, 27, 28) | 1393 __gen_uint(values->CommandType, 29, 31); 1394 1395 dw[1] = 1396 __gen_uint(values->VertexCountPerInstance, 0, 31); 1397 1398 dw[2] = 1399 __gen_uint(values->StartVertexLocation, 0, 31); 1400 1401 dw[3] = 1402 __gen_uint(values->InstanceCount, 0, 31); 1403 1404 dw[4] = 0; 1405 1406 dw[5] = 1407 __gen_sint(values->BaseVertexLocation, 0, 31); 1408} 1409 1410#define GFX4_3DSTATE_BINDING_TABLE_POINTERS_length 6 1411#define GFX4_3DSTATE_BINDING_TABLE_POINTERS_length_bias 2 1412#define GFX4_3DSTATE_BINDING_TABLE_POINTERS_header\ 1413 .DWordLength = 4, \ 1414 ._3DCommandSubOpcode = 1, \ 1415 ._3DCommandOpcode = 0, \ 1416 .CommandSubType = 3, \ 1417 .CommandType = 3 1418 1419struct GFX4_3DSTATE_BINDING_TABLE_POINTERS { 1420 uint32_t DWordLength; 1421 uint32_t _3DCommandSubOpcode; 1422 uint32_t _3DCommandOpcode; 1423 uint32_t CommandSubType; 1424 uint32_t CommandType; 1425 uint64_t PointertoVSBindingTable; 1426 uint64_t PointertoGSBindingTable; 1427 uint64_t PointertoCLIPBindingTable; 1428 uint64_t PointertoSFBindingTable; 1429 uint64_t PointertoPSBindingTable; 1430}; 1431 1432static inline __attribute__((always_inline)) void 1433GFX4_3DSTATE_BINDING_TABLE_POINTERS_pack(__attribute__((unused)) __gen_user_data *data, 1434 __attribute__((unused)) void * restrict dst, 1435 __attribute__((unused)) const struct GFX4_3DSTATE_BINDING_TABLE_POINTERS * restrict values) 1436{ 1437 uint32_t * restrict dw = (uint32_t * restrict) dst; 1438 1439 dw[0] = 1440 __gen_uint(values->DWordLength, 0, 7) | 1441 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 1442 __gen_uint(values->_3DCommandOpcode, 24, 26) | 1443 __gen_uint(values->CommandSubType, 27, 28) | 1444 __gen_uint(values->CommandType, 29, 31); 1445 1446 dw[1] = 1447 __gen_offset(values->PointertoVSBindingTable, 5, 31); 1448 1449 dw[2] = 1450 __gen_offset(values->PointertoGSBindingTable, 5, 31); 1451 1452 dw[3] = 1453 __gen_offset(values->PointertoCLIPBindingTable, 5, 31); 1454 1455 dw[4] = 1456 __gen_offset(values->PointertoSFBindingTable, 5, 31); 1457 1458 dw[5] = 1459 __gen_offset(values->PointertoPSBindingTable, 5, 31); 1460} 1461 1462#define GFX4_3DSTATE_CONSTANT_COLOR_length 5 1463#define GFX4_3DSTATE_CONSTANT_COLOR_length_bias 2 1464#define GFX4_3DSTATE_CONSTANT_COLOR_header \ 1465 .DWordLength = 3, \ 1466 ._3DCommandSubOpcode = 1, \ 1467 ._3DCommandOpcode = 1, \ 1468 .CommandSubType = 3, \ 1469 .CommandType = 3 1470 1471struct GFX4_3DSTATE_CONSTANT_COLOR { 1472 uint32_t DWordLength; 1473 uint32_t _3DCommandSubOpcode; 1474 uint32_t _3DCommandOpcode; 1475 uint32_t CommandSubType; 1476 uint32_t CommandType; 1477 float BlendConstantColorRed; 1478 float BlendConstantColorGreen; 1479 float BlendConstantColorBlue; 1480 float BlendConstantColorAlpha; 1481}; 1482 1483static inline __attribute__((always_inline)) void 1484GFX4_3DSTATE_CONSTANT_COLOR_pack(__attribute__((unused)) __gen_user_data *data, 1485 __attribute__((unused)) void * restrict dst, 1486 __attribute__((unused)) const struct GFX4_3DSTATE_CONSTANT_COLOR * restrict values) 1487{ 1488 uint32_t * restrict dw = (uint32_t * restrict) dst; 1489 1490 dw[0] = 1491 __gen_uint(values->DWordLength, 0, 7) | 1492 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 1493 __gen_uint(values->_3DCommandOpcode, 24, 26) | 1494 __gen_uint(values->CommandSubType, 27, 28) | 1495 __gen_uint(values->CommandType, 29, 31); 1496 1497 dw[1] = 1498 __gen_float(values->BlendConstantColorRed); 1499 1500 dw[2] = 1501 __gen_float(values->BlendConstantColorGreen); 1502 1503 dw[3] = 1504 __gen_float(values->BlendConstantColorBlue); 1505 1506 dw[4] = 1507 __gen_float(values->BlendConstantColorAlpha); 1508} 1509 1510#define GFX4_3DSTATE_DEPTH_BUFFER_length 5 1511#define GFX4_3DSTATE_DEPTH_BUFFER_length_bias 2 1512#define GFX4_3DSTATE_DEPTH_BUFFER_header \ 1513 .DWordLength = 3, \ 1514 ._3DCommandSubOpcode = 5, \ 1515 ._3DCommandOpcode = 1, \ 1516 .CommandSubType = 3, \ 1517 .CommandType = 3 1518 1519struct GFX4_3DSTATE_DEPTH_BUFFER { 1520 uint32_t DWordLength; 1521 uint32_t _3DCommandSubOpcode; 1522 uint32_t _3DCommandOpcode; 1523 uint32_t CommandSubType; 1524 uint32_t CommandType; 1525 uint32_t SurfacePitch; 1526 uint32_t SurfaceFormat; 1527#define D32_FLOAT_S8X24_UINT 0 1528#define D32_FLOAT 1 1529#define D24_UNORM_S8_UINT 2 1530#define D24_UNORM_X8_UINT 3 1531#define D16_UNORM 5 1532 uint32_t SoftwareTiledRenderingMode; 1533#define NORMAL 0 1534#define STR1 1 1535#define STR2 3 1536 bool DepthBufferCoordinateOffsetDisable; 1537 uint32_t TileWalk; 1538#define TILEWALK_YMAJOR 1 1539 bool TiledSurface; 1540 uint32_t SurfaceType; 1541#define SURFTYPE_1D 0 1542#define SURFTYPE_2D 1 1543#define SURFTYPE_3D 2 1544#define SURFTYPE_CUBE 3 1545#define SURFTYPE_NULL 7 1546 __gen_address_type SurfaceBaseAddress; 1547 uint32_t MIPMapLayoutMode; 1548#define MIPLAYOUT_BELOW 0 1549#define MIPLAYOUT_RIGHT 1 1550 uint32_t LOD; 1551 uint32_t Width; 1552 uint32_t Height; 1553#define SURFTYPE_1Dmustbezero 0 1554 uint32_t RenderTargetViewExtent; 1555 uint32_t MinimumArrayElement; 1556 uint32_t Depth; 1557#define SURFTYPE_CUBEmustbezero 0 1558}; 1559 1560static inline __attribute__((always_inline)) void 1561GFX4_3DSTATE_DEPTH_BUFFER_pack(__attribute__((unused)) __gen_user_data *data, 1562 __attribute__((unused)) void * restrict dst, 1563 __attribute__((unused)) const struct GFX4_3DSTATE_DEPTH_BUFFER * restrict values) 1564{ 1565 uint32_t * restrict dw = (uint32_t * restrict) dst; 1566 1567 dw[0] = 1568 __gen_uint(values->DWordLength, 0, 7) | 1569 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 1570 __gen_uint(values->_3DCommandOpcode, 24, 26) | 1571 __gen_uint(values->CommandSubType, 27, 28) | 1572 __gen_uint(values->CommandType, 29, 31); 1573 1574 dw[1] = 1575 __gen_uint(values->SurfacePitch, 0, 16) | 1576 __gen_uint(values->SurfaceFormat, 18, 20) | 1577 __gen_uint(values->SoftwareTiledRenderingMode, 23, 24) | 1578 __gen_uint(values->DepthBufferCoordinateOffsetDisable, 25, 25) | 1579 __gen_uint(values->TileWalk, 26, 26) | 1580 __gen_uint(values->TiledSurface, 27, 27) | 1581 __gen_uint(values->SurfaceType, 29, 31); 1582 1583 dw[2] = __gen_address(data, &dw[2], values->SurfaceBaseAddress, 0, 0, 31); 1584 1585 dw[3] = 1586 __gen_uint(values->MIPMapLayoutMode, 1, 1) | 1587 __gen_uint(values->LOD, 2, 5) | 1588 __gen_uint(values->Width, 6, 18) | 1589 __gen_uint(values->Height, 19, 31); 1590 1591 dw[4] = 1592 __gen_uint(values->RenderTargetViewExtent, 1, 9) | 1593 __gen_uint(values->MinimumArrayElement, 10, 20) | 1594 __gen_uint(values->Depth, 21, 31); 1595} 1596 1597#define GFX4_3DSTATE_DRAWING_RECTANGLE_length 4 1598#define GFX4_3DSTATE_DRAWING_RECTANGLE_length_bias 2 1599#define GFX4_3DSTATE_DRAWING_RECTANGLE_header \ 1600 .DWordLength = 2, \ 1601 ._3DCommandSubOpcode = 0, \ 1602 ._3DCommandOpcode = 1, \ 1603 .CommandSubType = 3, \ 1604 .CommandType = 3 1605 1606struct GFX4_3DSTATE_DRAWING_RECTANGLE { 1607 uint32_t DWordLength; 1608 uint32_t _3DCommandSubOpcode; 1609 uint32_t _3DCommandOpcode; 1610 uint32_t CommandSubType; 1611 uint32_t CommandType; 1612 uint32_t ClippedDrawingRectangleXMin; 1613 uint32_t ClippedDrawingRectangleYMin; 1614 uint32_t ClippedDrawingRectangleXMax; 1615 uint32_t ClippedDrawingRectangleYMax; 1616 int32_t DrawingRectangleOriginX; 1617 int32_t DrawingRectangleOriginY; 1618}; 1619 1620static inline __attribute__((always_inline)) void 1621GFX4_3DSTATE_DRAWING_RECTANGLE_pack(__attribute__((unused)) __gen_user_data *data, 1622 __attribute__((unused)) void * restrict dst, 1623 __attribute__((unused)) const struct GFX4_3DSTATE_DRAWING_RECTANGLE * restrict values) 1624{ 1625 uint32_t * restrict dw = (uint32_t * restrict) dst; 1626 1627 dw[0] = 1628 __gen_uint(values->DWordLength, 0, 7) | 1629 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 1630 __gen_uint(values->_3DCommandOpcode, 24, 26) | 1631 __gen_uint(values->CommandSubType, 27, 28) | 1632 __gen_uint(values->CommandType, 29, 31); 1633 1634 dw[1] = 1635 __gen_uint(values->ClippedDrawingRectangleXMin, 0, 15) | 1636 __gen_uint(values->ClippedDrawingRectangleYMin, 16, 31); 1637 1638 dw[2] = 1639 __gen_uint(values->ClippedDrawingRectangleXMax, 0, 15) | 1640 __gen_uint(values->ClippedDrawingRectangleYMax, 16, 31); 1641 1642 dw[3] = 1643 __gen_sint(values->DrawingRectangleOriginX, 0, 15) | 1644 __gen_sint(values->DrawingRectangleOriginY, 16, 31); 1645} 1646 1647#define GFX4_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length 2 1648#define GFX4_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_length_bias 2 1649#define GFX4_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_header\ 1650 .DWordLength = 0, \ 1651 ._3DCommandSubOpcode = 9, \ 1652 ._3DCommandOpcode = 1, \ 1653 .CommandSubType = 3, \ 1654 .CommandType = 3 1655 1656struct GFX4_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP { 1657 uint32_t DWordLength; 1658 uint32_t _3DCommandSubOpcode; 1659 uint32_t _3DCommandOpcode; 1660 uint32_t CommandSubType; 1661 uint32_t CommandType; 1662 float GlobalDepthOffsetClamp; 1663}; 1664 1665static inline __attribute__((always_inline)) void 1666GFX4_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP_pack(__attribute__((unused)) __gen_user_data *data, 1667 __attribute__((unused)) void * restrict dst, 1668 __attribute__((unused)) const struct GFX4_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP * restrict values) 1669{ 1670 uint32_t * restrict dw = (uint32_t * restrict) dst; 1671 1672 dw[0] = 1673 __gen_uint(values->DWordLength, 0, 7) | 1674 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 1675 __gen_uint(values->_3DCommandOpcode, 24, 26) | 1676 __gen_uint(values->CommandSubType, 27, 28) | 1677 __gen_uint(values->CommandType, 29, 31); 1678 1679 dw[1] = 1680 __gen_float(values->GlobalDepthOffsetClamp); 1681} 1682 1683#define GFX4_3DSTATE_INDEX_BUFFER_length 3 1684#define GFX4_3DSTATE_INDEX_BUFFER_length_bias 2 1685#define GFX4_3DSTATE_INDEX_BUFFER_header \ 1686 .DWordLength = 1, \ 1687 ._3DCommandSubOpcode = 10, \ 1688 ._3DCommandOpcode = 0, \ 1689 .CommandSubType = 3, \ 1690 .CommandType = 3 1691 1692struct GFX4_3DSTATE_INDEX_BUFFER { 1693 uint32_t DWordLength; 1694 uint32_t IndexFormat; 1695#define INDEX_BYTE 0 1696#define INDEX_WORD 1 1697#define INDEX_DWORD 2 1698 bool CutIndexEnable; 1699 uint32_t _3DCommandSubOpcode; 1700 uint32_t _3DCommandOpcode; 1701 uint32_t CommandSubType; 1702 uint32_t CommandType; 1703 __gen_address_type BufferStartingAddress; 1704 __gen_address_type BufferEndingAddress; 1705}; 1706 1707static inline __attribute__((always_inline)) void 1708GFX4_3DSTATE_INDEX_BUFFER_pack(__attribute__((unused)) __gen_user_data *data, 1709 __attribute__((unused)) void * restrict dst, 1710 __attribute__((unused)) const struct GFX4_3DSTATE_INDEX_BUFFER * restrict values) 1711{ 1712 uint32_t * restrict dw = (uint32_t * restrict) dst; 1713 1714 dw[0] = 1715 __gen_uint(values->DWordLength, 0, 7) | 1716 __gen_uint(values->IndexFormat, 8, 9) | 1717 __gen_uint(values->CutIndexEnable, 10, 10) | 1718 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 1719 __gen_uint(values->_3DCommandOpcode, 24, 26) | 1720 __gen_uint(values->CommandSubType, 27, 28) | 1721 __gen_uint(values->CommandType, 29, 31); 1722 1723 dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, 0, 0, 31); 1724 1725 dw[2] = __gen_address(data, &dw[2], values->BufferEndingAddress, 0, 0, 31); 1726} 1727 1728#define GFX4_3DSTATE_LINE_STIPPLE_length 3 1729#define GFX4_3DSTATE_LINE_STIPPLE_length_bias 2 1730#define GFX4_3DSTATE_LINE_STIPPLE_header \ 1731 .DWordLength = 1, \ 1732 ._3DCommandSubOpcode = 8, \ 1733 ._3DCommandOpcode = 1, \ 1734 .CommandSubType = 3, \ 1735 .CommandType = 3 1736 1737struct GFX4_3DSTATE_LINE_STIPPLE { 1738 uint32_t DWordLength; 1739 uint32_t _3DCommandSubOpcode; 1740 uint32_t _3DCommandOpcode; 1741 uint32_t CommandSubType; 1742 uint32_t CommandType; 1743 uint32_t LineStipplePattern; 1744 uint32_t CurrentStippleIndex; 1745 uint32_t CurrentRepeatCounter; 1746 bool ModifyEnable; 1747 uint32_t LineStippleRepeatCount; 1748 float LineStippleInverseRepeatCount; 1749}; 1750 1751static inline __attribute__((always_inline)) void 1752GFX4_3DSTATE_LINE_STIPPLE_pack(__attribute__((unused)) __gen_user_data *data, 1753 __attribute__((unused)) void * restrict dst, 1754 __attribute__((unused)) const struct GFX4_3DSTATE_LINE_STIPPLE * restrict values) 1755{ 1756 uint32_t * restrict dw = (uint32_t * restrict) dst; 1757 1758 dw[0] = 1759 __gen_uint(values->DWordLength, 0, 7) | 1760 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 1761 __gen_uint(values->_3DCommandOpcode, 24, 26) | 1762 __gen_uint(values->CommandSubType, 27, 28) | 1763 __gen_uint(values->CommandType, 29, 31); 1764 1765 dw[1] = 1766 __gen_uint(values->LineStipplePattern, 0, 15) | 1767 __gen_uint(values->CurrentStippleIndex, 16, 19) | 1768 __gen_uint(values->CurrentRepeatCounter, 21, 29) | 1769 __gen_uint(values->ModifyEnable, 31, 31); 1770 1771 dw[2] = 1772 __gen_uint(values->LineStippleRepeatCount, 0, 8) | 1773 __gen_ufixed(values->LineStippleInverseRepeatCount, 16, 31, 13); 1774} 1775 1776#define GFX4_3DSTATE_PIPELINED_POINTERS_length 7 1777#define GFX4_3DSTATE_PIPELINED_POINTERS_length_bias 2 1778#define GFX4_3DSTATE_PIPELINED_POINTERS_header \ 1779 .DWordLength = 5, \ 1780 ._3DCommandSubOpcode = 0, \ 1781 ._3DCommandOpcode = 0, \ 1782 .CommandSubType = 3, \ 1783 .CommandType = 3 1784 1785struct GFX4_3DSTATE_PIPELINED_POINTERS { 1786 uint32_t DWordLength; 1787 uint32_t _3DCommandSubOpcode; 1788 uint32_t _3DCommandOpcode; 1789 uint32_t CommandSubType; 1790 uint32_t CommandType; 1791 __gen_address_type PointertoVSState; 1792 bool GSEnable; 1793 __gen_address_type PointertoGSState; 1794 bool ClipEnable; 1795 __gen_address_type PointertoCLIPState; 1796 __gen_address_type PointertoSFState; 1797 __gen_address_type PointertoWMState; 1798 __gen_address_type PointertoColorCalcState; 1799}; 1800 1801static inline __attribute__((always_inline)) void 1802GFX4_3DSTATE_PIPELINED_POINTERS_pack(__attribute__((unused)) __gen_user_data *data, 1803 __attribute__((unused)) void * restrict dst, 1804 __attribute__((unused)) const struct GFX4_3DSTATE_PIPELINED_POINTERS * restrict values) 1805{ 1806 uint32_t * restrict dw = (uint32_t * restrict) dst; 1807 1808 dw[0] = 1809 __gen_uint(values->DWordLength, 0, 7) | 1810 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 1811 __gen_uint(values->_3DCommandOpcode, 24, 26) | 1812 __gen_uint(values->CommandSubType, 27, 28) | 1813 __gen_uint(values->CommandType, 29, 31); 1814 1815 dw[1] = __gen_address(data, &dw[1], values->PointertoVSState, 0, 5, 31); 1816 1817 const uint32_t v2 = 1818 __gen_uint(values->GSEnable, 0, 0); 1819 dw[2] = __gen_address(data, &dw[2], values->PointertoGSState, v2, 5, 31); 1820 1821 const uint32_t v3 = 1822 __gen_uint(values->ClipEnable, 0, 0); 1823 dw[3] = __gen_address(data, &dw[3], values->PointertoCLIPState, v3, 5, 31); 1824 1825 dw[4] = __gen_address(data, &dw[4], values->PointertoSFState, 0, 5, 31); 1826 1827 dw[5] = __gen_address(data, &dw[5], values->PointertoWMState, 0, 5, 31); 1828 1829 dw[6] = __gen_address(data, &dw[6], values->PointertoColorCalcState, 0, 5, 31); 1830} 1831 1832#define GFX4_3DSTATE_POLY_STIPPLE_OFFSET_length 2 1833#define GFX4_3DSTATE_POLY_STIPPLE_OFFSET_length_bias 2 1834#define GFX4_3DSTATE_POLY_STIPPLE_OFFSET_header \ 1835 .DWordLength = 0, \ 1836 ._3DCommandSubOpcode = 6, \ 1837 ._3DCommandOpcode = 1, \ 1838 .CommandSubType = 3, \ 1839 .CommandType = 3 1840 1841struct GFX4_3DSTATE_POLY_STIPPLE_OFFSET { 1842 uint32_t DWordLength; 1843 uint32_t _3DCommandSubOpcode; 1844 uint32_t _3DCommandOpcode; 1845 uint32_t CommandSubType; 1846 uint32_t CommandType; 1847 uint32_t PolygonStippleYOffset; 1848 uint32_t PolygonStippleXOffset; 1849}; 1850 1851static inline __attribute__((always_inline)) void 1852GFX4_3DSTATE_POLY_STIPPLE_OFFSET_pack(__attribute__((unused)) __gen_user_data *data, 1853 __attribute__((unused)) void * restrict dst, 1854 __attribute__((unused)) const struct GFX4_3DSTATE_POLY_STIPPLE_OFFSET * restrict values) 1855{ 1856 uint32_t * restrict dw = (uint32_t * restrict) dst; 1857 1858 dw[0] = 1859 __gen_uint(values->DWordLength, 0, 7) | 1860 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 1861 __gen_uint(values->_3DCommandOpcode, 24, 26) | 1862 __gen_uint(values->CommandSubType, 27, 28) | 1863 __gen_uint(values->CommandType, 29, 31); 1864 1865 dw[1] = 1866 __gen_uint(values->PolygonStippleYOffset, 0, 4) | 1867 __gen_uint(values->PolygonStippleXOffset, 8, 12); 1868} 1869 1870#define GFX4_3DSTATE_POLY_STIPPLE_PATTERN_length 33 1871#define GFX4_3DSTATE_POLY_STIPPLE_PATTERN_length_bias 2 1872#define GFX4_3DSTATE_POLY_STIPPLE_PATTERN_header\ 1873 .DWordLength = 31, \ 1874 ._3DCommandSubOpcode = 7, \ 1875 ._3DCommandOpcode = 1, \ 1876 .CommandSubType = 3, \ 1877 .CommandType = 3 1878 1879struct GFX4_3DSTATE_POLY_STIPPLE_PATTERN { 1880 uint32_t DWordLength; 1881 uint32_t _3DCommandSubOpcode; 1882 uint32_t _3DCommandOpcode; 1883 uint32_t CommandSubType; 1884 uint32_t CommandType; 1885 uint32_t PatternRow[32]; 1886}; 1887 1888static inline __attribute__((always_inline)) void 1889GFX4_3DSTATE_POLY_STIPPLE_PATTERN_pack(__attribute__((unused)) __gen_user_data *data, 1890 __attribute__((unused)) void * restrict dst, 1891 __attribute__((unused)) const struct GFX4_3DSTATE_POLY_STIPPLE_PATTERN * restrict values) 1892{ 1893 uint32_t * restrict dw = (uint32_t * restrict) dst; 1894 1895 dw[0] = 1896 __gen_uint(values->DWordLength, 0, 7) | 1897 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 1898 __gen_uint(values->_3DCommandOpcode, 24, 26) | 1899 __gen_uint(values->CommandSubType, 27, 28) | 1900 __gen_uint(values->CommandType, 29, 31); 1901 1902 dw[1] = 1903 __gen_uint(values->PatternRow[0], 0, 31); 1904 1905 dw[2] = 1906 __gen_uint(values->PatternRow[1], 0, 31); 1907 1908 dw[3] = 1909 __gen_uint(values->PatternRow[2], 0, 31); 1910 1911 dw[4] = 1912 __gen_uint(values->PatternRow[3], 0, 31); 1913 1914 dw[5] = 1915 __gen_uint(values->PatternRow[4], 0, 31); 1916 1917 dw[6] = 1918 __gen_uint(values->PatternRow[5], 0, 31); 1919 1920 dw[7] = 1921 __gen_uint(values->PatternRow[6], 0, 31); 1922 1923 dw[8] = 1924 __gen_uint(values->PatternRow[7], 0, 31); 1925 1926 dw[9] = 1927 __gen_uint(values->PatternRow[8], 0, 31); 1928 1929 dw[10] = 1930 __gen_uint(values->PatternRow[9], 0, 31); 1931 1932 dw[11] = 1933 __gen_uint(values->PatternRow[10], 0, 31); 1934 1935 dw[12] = 1936 __gen_uint(values->PatternRow[11], 0, 31); 1937 1938 dw[13] = 1939 __gen_uint(values->PatternRow[12], 0, 31); 1940 1941 dw[14] = 1942 __gen_uint(values->PatternRow[13], 0, 31); 1943 1944 dw[15] = 1945 __gen_uint(values->PatternRow[14], 0, 31); 1946 1947 dw[16] = 1948 __gen_uint(values->PatternRow[15], 0, 31); 1949 1950 dw[17] = 1951 __gen_uint(values->PatternRow[16], 0, 31); 1952 1953 dw[18] = 1954 __gen_uint(values->PatternRow[17], 0, 31); 1955 1956 dw[19] = 1957 __gen_uint(values->PatternRow[18], 0, 31); 1958 1959 dw[20] = 1960 __gen_uint(values->PatternRow[19], 0, 31); 1961 1962 dw[21] = 1963 __gen_uint(values->PatternRow[20], 0, 31); 1964 1965 dw[22] = 1966 __gen_uint(values->PatternRow[21], 0, 31); 1967 1968 dw[23] = 1969 __gen_uint(values->PatternRow[22], 0, 31); 1970 1971 dw[24] = 1972 __gen_uint(values->PatternRow[23], 0, 31); 1973 1974 dw[25] = 1975 __gen_uint(values->PatternRow[24], 0, 31); 1976 1977 dw[26] = 1978 __gen_uint(values->PatternRow[25], 0, 31); 1979 1980 dw[27] = 1981 __gen_uint(values->PatternRow[26], 0, 31); 1982 1983 dw[28] = 1984 __gen_uint(values->PatternRow[27], 0, 31); 1985 1986 dw[29] = 1987 __gen_uint(values->PatternRow[28], 0, 31); 1988 1989 dw[30] = 1990 __gen_uint(values->PatternRow[29], 0, 31); 1991 1992 dw[31] = 1993 __gen_uint(values->PatternRow[30], 0, 31); 1994 1995 dw[32] = 1996 __gen_uint(values->PatternRow[31], 0, 31); 1997} 1998 1999#define GFX4_3DSTATE_VERTEX_BUFFERS_length_bias 2 2000#define GFX4_3DSTATE_VERTEX_BUFFERS_header \ 2001 .DWordLength = 3, \ 2002 ._3DCommandSubOpcode = 8, \ 2003 ._3DCommandOpcode = 0, \ 2004 .CommandSubType = 3, \ 2005 .CommandType = 3 2006 2007struct GFX4_3DSTATE_VERTEX_BUFFERS { 2008 uint32_t DWordLength; 2009 uint32_t _3DCommandSubOpcode; 2010 uint32_t _3DCommandOpcode; 2011 uint32_t CommandSubType; 2012 uint32_t CommandType; 2013 /* variable length fields follow */ 2014}; 2015 2016static inline __attribute__((always_inline)) void 2017GFX4_3DSTATE_VERTEX_BUFFERS_pack(__attribute__((unused)) __gen_user_data *data, 2018 __attribute__((unused)) void * restrict dst, 2019 __attribute__((unused)) const struct GFX4_3DSTATE_VERTEX_BUFFERS * restrict values) 2020{ 2021 uint32_t * restrict dw = (uint32_t * restrict) dst; 2022 2023 dw[0] = 2024 __gen_uint(values->DWordLength, 0, 7) | 2025 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 2026 __gen_uint(values->_3DCommandOpcode, 24, 26) | 2027 __gen_uint(values->CommandSubType, 27, 28) | 2028 __gen_uint(values->CommandType, 29, 31); 2029} 2030 2031#define GFX4_3DSTATE_VERTEX_ELEMENTS_length_bias 2 2032#define GFX4_3DSTATE_VERTEX_ELEMENTS_header \ 2033 .DWordLength = 1, \ 2034 ._3DCommandSubOpcode = 9, \ 2035 ._3DCommandOpcode = 0, \ 2036 .CommandSubType = 3, \ 2037 .CommandType = 3 2038 2039struct GFX4_3DSTATE_VERTEX_ELEMENTS { 2040 uint32_t DWordLength; 2041 uint32_t _3DCommandSubOpcode; 2042 uint32_t _3DCommandOpcode; 2043 uint32_t CommandSubType; 2044 uint32_t CommandType; 2045 /* variable length fields follow */ 2046}; 2047 2048static inline __attribute__((always_inline)) void 2049GFX4_3DSTATE_VERTEX_ELEMENTS_pack(__attribute__((unused)) __gen_user_data *data, 2050 __attribute__((unused)) void * restrict dst, 2051 __attribute__((unused)) const struct GFX4_3DSTATE_VERTEX_ELEMENTS * restrict values) 2052{ 2053 uint32_t * restrict dw = (uint32_t * restrict) dst; 2054 2055 dw[0] = 2056 __gen_uint(values->DWordLength, 0, 7) | 2057 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 2058 __gen_uint(values->_3DCommandOpcode, 24, 26) | 2059 __gen_uint(values->CommandSubType, 27, 28) | 2060 __gen_uint(values->CommandType, 29, 31); 2061} 2062 2063#define GFX4_3DSTATE_VF_STATISTICS_length 1 2064#define GFX4_3DSTATE_VF_STATISTICS_length_bias 1 2065#define GFX4_3DSTATE_VF_STATISTICS_header \ 2066 ._3DCommandSubOpcode = 11, \ 2067 ._3DCommandOpcode = 0, \ 2068 .CommandSubType = 3, \ 2069 .CommandType = 3 2070 2071struct GFX4_3DSTATE_VF_STATISTICS { 2072 bool StatisticsEnable; 2073 uint32_t _3DCommandSubOpcode; 2074 uint32_t _3DCommandOpcode; 2075 uint32_t CommandSubType; 2076 uint32_t CommandType; 2077}; 2078 2079static inline __attribute__((always_inline)) void 2080GFX4_3DSTATE_VF_STATISTICS_pack(__attribute__((unused)) __gen_user_data *data, 2081 __attribute__((unused)) void * restrict dst, 2082 __attribute__((unused)) const struct GFX4_3DSTATE_VF_STATISTICS * restrict values) 2083{ 2084 uint32_t * restrict dw = (uint32_t * restrict) dst; 2085 2086 dw[0] = 2087 __gen_uint(values->StatisticsEnable, 0, 0) | 2088 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 2089 __gen_uint(values->_3DCommandOpcode, 24, 26) | 2090 __gen_uint(values->CommandSubType, 27, 28) | 2091 __gen_uint(values->CommandType, 29, 31); 2092} 2093 2094#define GFX4_CONSTANT_BUFFER_length 2 2095#define GFX4_CONSTANT_BUFFER_length_bias 2 2096#define GFX4_CONSTANT_BUFFER_header \ 2097 .DWordLength = 0, \ 2098 .Valid = 0, \ 2099 ._3DCommandSubOpcode = 2, \ 2100 ._3DCommandOpcode = 0, \ 2101 .CommandSubType = 0, \ 2102 .CommandType = 3 2103 2104struct GFX4_CONSTANT_BUFFER { 2105 uint32_t DWordLength; 2106 bool Valid; 2107 uint32_t _3DCommandSubOpcode; 2108 uint32_t _3DCommandOpcode; 2109 uint32_t CommandSubType; 2110 uint32_t CommandType; 2111 uint32_t BufferLength; 2112 __gen_address_type BufferStartingAddress; 2113}; 2114 2115static inline __attribute__((always_inline)) void 2116GFX4_CONSTANT_BUFFER_pack(__attribute__((unused)) __gen_user_data *data, 2117 __attribute__((unused)) void * restrict dst, 2118 __attribute__((unused)) const struct GFX4_CONSTANT_BUFFER * restrict values) 2119{ 2120 uint32_t * restrict dw = (uint32_t * restrict) dst; 2121 2122 dw[0] = 2123 __gen_uint(values->DWordLength, 0, 7) | 2124 __gen_uint(values->Valid, 8, 8) | 2125 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 2126 __gen_uint(values->_3DCommandOpcode, 24, 26) | 2127 __gen_uint(values->CommandSubType, 27, 28) | 2128 __gen_uint(values->CommandType, 29, 31); 2129 2130 const uint32_t v1 = 2131 __gen_uint(values->BufferLength, 0, 5); 2132 dw[1] = __gen_address(data, &dw[1], values->BufferStartingAddress, v1, 6, 31); 2133} 2134 2135#define GFX4_CS_URB_STATE_length 2 2136#define GFX4_CS_URB_STATE_length_bias 2 2137#define GFX4_CS_URB_STATE_header \ 2138 .DWordLength = 0, \ 2139 ._3DCommandSubOpcode = 1, \ 2140 ._3DCommandOpcode = 0, \ 2141 .CommandSubType = 0, \ 2142 .CommandType = 3 2143 2144struct GFX4_CS_URB_STATE { 2145 uint32_t DWordLength; 2146 uint32_t _3DCommandSubOpcode; 2147 uint32_t _3DCommandOpcode; 2148 uint32_t CommandSubType; 2149 uint32_t CommandType; 2150 uint32_t NumberofURBEntries; 2151 uint32_t URBEntryAllocationSize; 2152}; 2153 2154static inline __attribute__((always_inline)) void 2155GFX4_CS_URB_STATE_pack(__attribute__((unused)) __gen_user_data *data, 2156 __attribute__((unused)) void * restrict dst, 2157 __attribute__((unused)) const struct GFX4_CS_URB_STATE * restrict values) 2158{ 2159 uint32_t * restrict dw = (uint32_t * restrict) dst; 2160 2161 dw[0] = 2162 __gen_uint(values->DWordLength, 0, 7) | 2163 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 2164 __gen_uint(values->_3DCommandOpcode, 24, 26) | 2165 __gen_uint(values->CommandSubType, 27, 28) | 2166 __gen_uint(values->CommandType, 29, 31); 2167 2168 dw[1] = 2169 __gen_uint(values->NumberofURBEntries, 0, 2) | 2170 __gen_uint(values->URBEntryAllocationSize, 4, 8); 2171} 2172 2173#define GFX4_MI_FLUSH_length 1 2174#define GFX4_MI_FLUSH_length_bias 1 2175#define GFX4_MI_FLUSH_header \ 2176 .MICommandOpcode = 4, \ 2177 .CommandType = 0 2178 2179struct GFX4_MI_FLUSH { 2180 uint32_t StateInstructionCacheInvalidate; 2181#define DontInvalidate 0 2182#define Invalidate 1 2183 uint32_t RenderCacheFlushInhibit; 2184#define Flush 0 2185#define DontFlush 1 2186 uint32_t GlobalSnapshotCountReset; 2187#define DontReset 0 2188#define Reset 1 2189 uint32_t MICommandOpcode; 2190 uint32_t CommandType; 2191}; 2192 2193static inline __attribute__((always_inline)) void 2194GFX4_MI_FLUSH_pack(__attribute__((unused)) __gen_user_data *data, 2195 __attribute__((unused)) void * restrict dst, 2196 __attribute__((unused)) const struct GFX4_MI_FLUSH * restrict values) 2197{ 2198 uint32_t * restrict dw = (uint32_t * restrict) dst; 2199 2200 dw[0] = 2201 __gen_uint(values->StateInstructionCacheInvalidate, 1, 1) | 2202 __gen_uint(values->RenderCacheFlushInhibit, 2, 2) | 2203 __gen_uint(values->GlobalSnapshotCountReset, 3, 3) | 2204 __gen_uint(values->MICommandOpcode, 23, 28) | 2205 __gen_uint(values->CommandType, 29, 31); 2206} 2207 2208#define GFX4_MI_LOAD_REGISTER_IMM_length 3 2209#define GFX4_MI_LOAD_REGISTER_IMM_length_bias 2 2210#define GFX4_MI_LOAD_REGISTER_IMM_header \ 2211 .DWordLength = 1, \ 2212 .MICommandOpcode = 34, \ 2213 .CommandType = 0 2214 2215struct GFX4_MI_LOAD_REGISTER_IMM { 2216 uint32_t DWordLength; 2217 uint32_t ByteWriteDisables; 2218 uint32_t MICommandOpcode; 2219 uint32_t CommandType; 2220 uint64_t RegisterOffset; 2221 uint32_t DataDWord; 2222 /* variable length fields follow */ 2223}; 2224 2225static inline __attribute__((always_inline)) void 2226GFX4_MI_LOAD_REGISTER_IMM_pack(__attribute__((unused)) __gen_user_data *data, 2227 __attribute__((unused)) void * restrict dst, 2228 __attribute__((unused)) const struct GFX4_MI_LOAD_REGISTER_IMM * restrict values) 2229{ 2230 uint32_t * restrict dw = (uint32_t * restrict) dst; 2231 2232 dw[0] = 2233 __gen_uint(values->DWordLength, 0, 5) | 2234 __gen_uint(values->ByteWriteDisables, 8, 11) | 2235 __gen_uint(values->MICommandOpcode, 23, 28) | 2236 __gen_uint(values->CommandType, 29, 31); 2237 2238 dw[1] = 2239 __gen_offset(values->RegisterOffset, 2, 31); 2240 2241 dw[2] = 2242 __gen_uint(values->DataDWord, 0, 31); 2243} 2244 2245#define GFX4_MI_STORE_DATA_IMM_length 5 2246#define GFX4_MI_STORE_DATA_IMM_length_bias 2 2247#define GFX4_MI_STORE_DATA_IMM_header \ 2248 .DWordLength = 2, \ 2249 .MICommandOpcode = 32, \ 2250 .CommandType = 0 2251 2252struct GFX4_MI_STORE_DATA_IMM { 2253 uint32_t DWordLength; 2254 uint32_t BitFieldName; 2255 bool MemoryAddressType; 2256 uint32_t MICommandOpcode; 2257 uint32_t CommandType; 2258 __gen_address_type PhysicalStartAddressExtension; 2259 __gen_address_type Address; 2260 uint64_t ImmediateData; 2261}; 2262 2263static inline __attribute__((always_inline)) void 2264GFX4_MI_STORE_DATA_IMM_pack(__attribute__((unused)) __gen_user_data *data, 2265 __attribute__((unused)) void * restrict dst, 2266 __attribute__((unused)) const struct GFX4_MI_STORE_DATA_IMM * restrict values) 2267{ 2268 uint32_t * restrict dw = (uint32_t * restrict) dst; 2269 2270 dw[0] = 2271 __gen_uint(values->DWordLength, 0, 5) | 2272 __gen_uint(values->BitFieldName, 21, 21) | 2273 __gen_uint(values->MemoryAddressType, 22, 22) | 2274 __gen_uint(values->MICommandOpcode, 23, 28) | 2275 __gen_uint(values->CommandType, 29, 31); 2276 2277 dw[1] = __gen_address(data, &dw[1], values->PhysicalStartAddressExtension, 0, 0, 3); 2278 2279 dw[2] = __gen_address(data, &dw[2], values->Address, 0, 2, 31); 2280 2281 const uint64_t v3 = 2282 __gen_uint(values->ImmediateData, 0, 63); 2283 dw[3] = v3; 2284 dw[4] = v3 >> 32; 2285} 2286 2287#define GFX4_MI_STORE_REGISTER_MEM_length 3 2288#define GFX4_MI_STORE_REGISTER_MEM_length_bias 2 2289#define GFX4_MI_STORE_REGISTER_MEM_header \ 2290 .DWordLength = 1, \ 2291 .MICommandOpcode = 36, \ 2292 .CommandType = 0 2293 2294struct GFX4_MI_STORE_REGISTER_MEM { 2295 uint32_t DWordLength; 2296 bool UseGlobalGTT; 2297 uint32_t MICommandOpcode; 2298 uint32_t CommandType; 2299 uint64_t RegisterAddress; 2300 __gen_address_type PhysicalStartAddressExtension; 2301 __gen_address_type MemoryAddress; 2302}; 2303 2304static inline __attribute__((always_inline)) void 2305GFX4_MI_STORE_REGISTER_MEM_pack(__attribute__((unused)) __gen_user_data *data, 2306 __attribute__((unused)) void * restrict dst, 2307 __attribute__((unused)) const struct GFX4_MI_STORE_REGISTER_MEM * restrict values) 2308{ 2309 uint32_t * restrict dw = (uint32_t * restrict) dst; 2310 2311 dw[0] = 2312 __gen_uint(values->DWordLength, 0, 7) | 2313 __gen_uint(values->UseGlobalGTT, 22, 22) | 2314 __gen_uint(values->MICommandOpcode, 23, 28) | 2315 __gen_uint(values->CommandType, 29, 31); 2316 2317 const uint32_t v1 = 2318 __gen_offset(values->RegisterAddress, 2, 22); 2319 dw[1] = __gen_address(data, &dw[1], values->PhysicalStartAddressExtension, v1, 28, 31); 2320 2321 dw[2] = __gen_address(data, &dw[2], values->MemoryAddress, 0, 2, 31); 2322} 2323 2324#define GFX4_PIPELINE_SELECT_length 1 2325#define GFX4_PIPELINE_SELECT_length_bias 1 2326#define GFX4_PIPELINE_SELECT_header \ 2327 ._3DCommandSubOpcode = 4, \ 2328 ._3DCommandOpcode = 1, \ 2329 .CommandSubType = 0, \ 2330 .CommandType = 3 2331 2332struct GFX4_PIPELINE_SELECT { 2333 uint32_t PipelineSelection; 2334#define _3D 0 2335#define Media 1 2336 uint32_t _3DCommandSubOpcode; 2337 uint32_t _3DCommandOpcode; 2338 uint32_t CommandSubType; 2339 uint32_t CommandType; 2340}; 2341 2342static inline __attribute__((always_inline)) void 2343GFX4_PIPELINE_SELECT_pack(__attribute__((unused)) __gen_user_data *data, 2344 __attribute__((unused)) void * restrict dst, 2345 __attribute__((unused)) const struct GFX4_PIPELINE_SELECT * restrict values) 2346{ 2347 uint32_t * restrict dw = (uint32_t * restrict) dst; 2348 2349 dw[0] = 2350 __gen_uint(values->PipelineSelection, 0, 0) | 2351 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 2352 __gen_uint(values->_3DCommandOpcode, 24, 26) | 2353 __gen_uint(values->CommandSubType, 27, 28) | 2354 __gen_uint(values->CommandType, 29, 31); 2355} 2356 2357#define GFX4_PIPE_CONTROL_length 4 2358#define GFX4_PIPE_CONTROL_length_bias 2 2359#define GFX4_PIPE_CONTROL_header \ 2360 .DWordLength = 2, \ 2361 ._3DCommandSubOpcode = 0, \ 2362 ._3DCommandOpcode = 2, \ 2363 .CommandSubType = 3, \ 2364 .CommandType = 3 2365 2366struct GFX4_PIPE_CONTROL { 2367 uint32_t DWordLength; 2368 bool NotifyEnable; 2369 bool InstructionCacheInvalidateEnable; 2370 bool WriteCacheFlush; 2371 bool DepthStallEnable; 2372 uint32_t PostSyncOperation; 2373#define NoWrite 0 2374#define WriteImmediateData 1 2375#define WritePSDepthCount 2 2376#define WriteTimestamp 3 2377 uint32_t _3DCommandSubOpcode; 2378 uint32_t _3DCommandOpcode; 2379 uint32_t CommandSubType; 2380 uint32_t CommandType; 2381 uint32_t DestinationAddressType; 2382#define DAT_GGTT 1 2383 __gen_address_type Address; 2384 uint64_t ImmediateData; 2385}; 2386 2387static inline __attribute__((always_inline)) void 2388GFX4_PIPE_CONTROL_pack(__attribute__((unused)) __gen_user_data *data, 2389 __attribute__((unused)) void * restrict dst, 2390 __attribute__((unused)) const struct GFX4_PIPE_CONTROL * restrict values) 2391{ 2392 uint32_t * restrict dw = (uint32_t * restrict) dst; 2393 2394 dw[0] = 2395 __gen_uint(values->DWordLength, 0, 7) | 2396 __gen_uint(values->NotifyEnable, 8, 8) | 2397 __gen_uint(values->InstructionCacheInvalidateEnable, 11, 11) | 2398 __gen_uint(values->WriteCacheFlush, 12, 12) | 2399 __gen_uint(values->DepthStallEnable, 13, 13) | 2400 __gen_uint(values->PostSyncOperation, 14, 15) | 2401 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 2402 __gen_uint(values->_3DCommandOpcode, 24, 26) | 2403 __gen_uint(values->CommandSubType, 27, 28) | 2404 __gen_uint(values->CommandType, 29, 31); 2405 2406 const uint32_t v1 = 2407 __gen_uint(values->DestinationAddressType, 2, 2); 2408 dw[1] = __gen_address(data, &dw[1], values->Address, v1, 3, 31); 2409 2410 const uint64_t v2 = 2411 __gen_uint(values->ImmediateData, 0, 63); 2412 dw[2] = v2; 2413 dw[3] = v2 >> 32; 2414} 2415 2416#define GFX4_STATE_BASE_ADDRESS_length 6 2417#define GFX4_STATE_BASE_ADDRESS_length_bias 2 2418#define GFX4_STATE_BASE_ADDRESS_header \ 2419 .DWordLength = 4, \ 2420 ._3DCommandSubOpcode = 1, \ 2421 ._3DCommandOpcode = 1, \ 2422 .CommandSubType = 0, \ 2423 .CommandType = 3 2424 2425struct GFX4_STATE_BASE_ADDRESS { 2426 uint32_t DWordLength; 2427 uint32_t _3DCommandSubOpcode; 2428 uint32_t _3DCommandOpcode; 2429 uint32_t CommandSubType; 2430 uint32_t CommandType; 2431 bool GeneralStateBaseAddressModifyEnable; 2432 __gen_address_type GeneralStateBaseAddress; 2433 bool SurfaceStateBaseAddressModifyEnable; 2434 __gen_address_type SurfaceStateBaseAddress; 2435 bool IndirectObjectBaseAddressModifyEnable; 2436 __gen_address_type IndirectObjectBaseAddress; 2437 bool GeneralStateAccessUpperBoundModifyEnable; 2438 __gen_address_type GeneralStateAccessUpperBound; 2439 bool InstructionAccessUpperBoundModifyEnable; 2440 __gen_address_type InstructionAccessUpperBound; 2441}; 2442 2443static inline __attribute__((always_inline)) void 2444GFX4_STATE_BASE_ADDRESS_pack(__attribute__((unused)) __gen_user_data *data, 2445 __attribute__((unused)) void * restrict dst, 2446 __attribute__((unused)) const struct GFX4_STATE_BASE_ADDRESS * restrict values) 2447{ 2448 uint32_t * restrict dw = (uint32_t * restrict) dst; 2449 2450 dw[0] = 2451 __gen_uint(values->DWordLength, 0, 7) | 2452 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 2453 __gen_uint(values->_3DCommandOpcode, 24, 26) | 2454 __gen_uint(values->CommandSubType, 27, 28) | 2455 __gen_uint(values->CommandType, 29, 31); 2456 2457 const uint32_t v1 = 2458 __gen_uint(values->GeneralStateBaseAddressModifyEnable, 0, 0); 2459 dw[1] = __gen_address(data, &dw[1], values->GeneralStateBaseAddress, v1, 12, 31); 2460 2461 const uint32_t v2 = 2462 __gen_uint(values->SurfaceStateBaseAddressModifyEnable, 0, 0); 2463 dw[2] = __gen_address(data, &dw[2], values->SurfaceStateBaseAddress, v2, 12, 31); 2464 2465 const uint32_t v3 = 2466 __gen_uint(values->IndirectObjectBaseAddressModifyEnable, 0, 0); 2467 dw[3] = __gen_address(data, &dw[3], values->IndirectObjectBaseAddress, v3, 12, 31); 2468 2469 const uint32_t v4 = 2470 __gen_uint(values->GeneralStateAccessUpperBoundModifyEnable, 0, 0); 2471 dw[4] = __gen_address(data, &dw[4], values->GeneralStateAccessUpperBound, v4, 12, 31); 2472 2473 const uint32_t v5 = 2474 __gen_uint(values->InstructionAccessUpperBoundModifyEnable, 0, 0); 2475 dw[5] = __gen_address(data, &dw[5], values->InstructionAccessUpperBound, v5, 12, 31); 2476} 2477 2478#define GFX4_STATE_SIP_length 2 2479#define GFX4_STATE_SIP_length_bias 2 2480#define GFX4_STATE_SIP_header \ 2481 .DWordLength = 0, \ 2482 ._3DCommandSubOpcode = 2, \ 2483 ._3DCommandOpcode = 1, \ 2484 .CommandSubType = 0, \ 2485 .CommandType = 3 2486 2487struct GFX4_STATE_SIP { 2488 uint32_t DWordLength; 2489 uint32_t _3DCommandSubOpcode; 2490 uint32_t _3DCommandOpcode; 2491 uint32_t CommandSubType; 2492 uint32_t CommandType; 2493 uint64_t SystemInstructionPointer; 2494}; 2495 2496static inline __attribute__((always_inline)) void 2497GFX4_STATE_SIP_pack(__attribute__((unused)) __gen_user_data *data, 2498 __attribute__((unused)) void * restrict dst, 2499 __attribute__((unused)) const struct GFX4_STATE_SIP * restrict values) 2500{ 2501 uint32_t * restrict dw = (uint32_t * restrict) dst; 2502 2503 dw[0] = 2504 __gen_uint(values->DWordLength, 0, 7) | 2505 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 2506 __gen_uint(values->_3DCommandOpcode, 24, 26) | 2507 __gen_uint(values->CommandSubType, 27, 28) | 2508 __gen_uint(values->CommandType, 29, 31); 2509 2510 dw[1] = 2511 __gen_offset(values->SystemInstructionPointer, 4, 31); 2512} 2513 2514#define GFX4_URB_FENCE_length 3 2515#define GFX4_URB_FENCE_length_bias 2 2516#define GFX4_URB_FENCE_header \ 2517 .DWordLength = 1, \ 2518 ._3DCommandSubOpcode = 0, \ 2519 ._3DCommandOpcode = 0, \ 2520 .CommandSubType = 0, \ 2521 .CommandType = 3 2522 2523struct GFX4_URB_FENCE { 2524 uint32_t DWordLength; 2525 bool VSUnitURBReallocationRequest; 2526 bool GSUnitURBReallocationRequest; 2527 bool CLIPUnitURBReallocationRequest; 2528 bool SFUnitURBReallocationRequest; 2529 bool VFEUnitURBReallocationRequest; 2530 bool CSUnitURBReallocationRequest; 2531 uint32_t _3DCommandSubOpcode; 2532 uint32_t _3DCommandOpcode; 2533 uint32_t CommandSubType; 2534 uint32_t CommandType; 2535 uint32_t VSFence; 2536 uint32_t GSFence; 2537 uint32_t CLIPFence; 2538 uint32_t SFFence; 2539 uint32_t VFEFence; 2540 uint32_t CSFence; 2541}; 2542 2543static inline __attribute__((always_inline)) void 2544GFX4_URB_FENCE_pack(__attribute__((unused)) __gen_user_data *data, 2545 __attribute__((unused)) void * restrict dst, 2546 __attribute__((unused)) const struct GFX4_URB_FENCE * restrict values) 2547{ 2548 uint32_t * restrict dw = (uint32_t * restrict) dst; 2549 2550 dw[0] = 2551 __gen_uint(values->DWordLength, 0, 7) | 2552 __gen_uint(values->VSUnitURBReallocationRequest, 8, 8) | 2553 __gen_uint(values->GSUnitURBReallocationRequest, 9, 9) | 2554 __gen_uint(values->CLIPUnitURBReallocationRequest, 10, 10) | 2555 __gen_uint(values->SFUnitURBReallocationRequest, 11, 11) | 2556 __gen_uint(values->VFEUnitURBReallocationRequest, 12, 12) | 2557 __gen_uint(values->CSUnitURBReallocationRequest, 13, 13) | 2558 __gen_uint(values->_3DCommandSubOpcode, 16, 23) | 2559 __gen_uint(values->_3DCommandOpcode, 24, 26) | 2560 __gen_uint(values->CommandSubType, 27, 28) | 2561 __gen_uint(values->CommandType, 29, 31); 2562 2563 dw[1] = 2564 __gen_uint(values->VSFence, 0, 9) | 2565 __gen_uint(values->GSFence, 10, 19) | 2566 __gen_uint(values->CLIPFence, 20, 29); 2567 2568 dw[2] = 2569 __gen_uint(values->SFFence, 0, 9) | 2570 __gen_uint(values->VFEFence, 10, 19) | 2571 __gen_uint(values->CSFence, 20, 30); 2572} 2573 2574#define GFX4_XY_COLOR_BLT_length 6 2575#define GFX4_XY_COLOR_BLT_length_bias 2 2576#define GFX4_XY_COLOR_BLT_header \ 2577 .DWordLength = 4, \ 2578 ._2DCommandOpcode = 80, \ 2579 .CommandType = 2 2580 2581struct GFX4_XY_COLOR_BLT { 2582 uint32_t DWordLength; 2583 bool TilingEnable; 2584 uint32_t _32bppByteMask; 2585 uint32_t _2DCommandOpcode; 2586 uint32_t CommandType; 2587 int32_t DestinationPitch; 2588 uint32_t RasterOperation; 2589 uint32_t ColorDepth; 2590#define COLOR_DEPTH__8bit 0 2591#define COLOR_DEPTH__565 1 2592#define COLOR_DEPTH__1555 2 2593#define COLOR_DEPTH__32bit 3 2594 bool ClippingEnabled; 2595 int32_t DestinationX1Coordinate; 2596 int32_t DestinationY1Coordinate; 2597 int32_t DestinationX2Coordinate; 2598 int32_t DestinationY2Coordinate; 2599 __gen_address_type DestinationBaseAddress; 2600 int32_t SolidPatternColor; 2601}; 2602 2603static inline __attribute__((always_inline)) void 2604GFX4_XY_COLOR_BLT_pack(__attribute__((unused)) __gen_user_data *data, 2605 __attribute__((unused)) void * restrict dst, 2606 __attribute__((unused)) const struct GFX4_XY_COLOR_BLT * restrict values) 2607{ 2608 uint32_t * restrict dw = (uint32_t * restrict) dst; 2609 2610 dw[0] = 2611 __gen_uint(values->DWordLength, 0, 7) | 2612 __gen_uint(values->TilingEnable, 11, 11) | 2613 __gen_uint(values->_32bppByteMask, 20, 21) | 2614 __gen_uint(values->_2DCommandOpcode, 22, 28) | 2615 __gen_uint(values->CommandType, 29, 31); 2616 2617 dw[1] = 2618 __gen_sint(values->DestinationPitch, 0, 15) | 2619 __gen_uint(values->RasterOperation, 16, 23) | 2620 __gen_uint(values->ColorDepth, 24, 25) | 2621 __gen_uint(values->ClippingEnabled, 30, 30); 2622 2623 dw[2] = 2624 __gen_sint(values->DestinationX1Coordinate, 0, 15) | 2625 __gen_sint(values->DestinationY1Coordinate, 16, 31); 2626 2627 dw[3] = 2628 __gen_sint(values->DestinationX2Coordinate, 0, 15) | 2629 __gen_sint(values->DestinationY2Coordinate, 16, 31); 2630 2631 dw[4] = __gen_address(data, &dw[4], values->DestinationBaseAddress, 0, 0, 31); 2632 2633 dw[5] = 2634 __gen_sint(values->SolidPatternColor, 0, 31); 2635} 2636 2637#define GFX4_XY_SETUP_BLT_length 8 2638#define GFX4_XY_SETUP_BLT_length_bias 2 2639#define GFX4_XY_SETUP_BLT_header \ 2640 .DWordLength = 6, \ 2641 ._2DCommandOpcode = 1, \ 2642 .CommandType = 2 2643 2644struct GFX4_XY_SETUP_BLT { 2645 uint32_t DWordLength; 2646 bool TilingEnable; 2647 uint32_t _32bppByteMask; 2648 uint32_t _2DCommandOpcode; 2649 uint32_t CommandType; 2650 int32_t DestinationPitch; 2651 uint32_t RasterOperation; 2652 uint32_t ColorDepth; 2653#define COLOR_DEPTH__8bit 0 2654#define COLOR_DEPTH__565 1 2655#define COLOR_DEPTH__1555 2 2656#define COLOR_DEPTH__32bit 3 2657 bool MonoSourceTransparencyMode; 2658 bool ClippingEnabled; 2659 int32_t ClipRectX1Coordinate; 2660 int32_t ClipRectY1Coordinate; 2661 int32_t ClipRectX2Coordinate; 2662 int32_t ClipRectY2Coordinate; 2663 __gen_address_type DestinationBaseAddress; 2664 uint32_t BackgroundColor; 2665 uint32_t ForegroundColor; 2666 uint32_t PatternBaseAddress; 2667}; 2668 2669static inline __attribute__((always_inline)) void 2670GFX4_XY_SETUP_BLT_pack(__attribute__((unused)) __gen_user_data *data, 2671 __attribute__((unused)) void * restrict dst, 2672 __attribute__((unused)) const struct GFX4_XY_SETUP_BLT * restrict values) 2673{ 2674 uint32_t * restrict dw = (uint32_t * restrict) dst; 2675 2676 dw[0] = 2677 __gen_uint(values->DWordLength, 0, 7) | 2678 __gen_uint(values->TilingEnable, 11, 11) | 2679 __gen_uint(values->_32bppByteMask, 20, 21) | 2680 __gen_uint(values->_2DCommandOpcode, 22, 28) | 2681 __gen_uint(values->CommandType, 29, 31); 2682 2683 dw[1] = 2684 __gen_sint(values->DestinationPitch, 0, 15) | 2685 __gen_uint(values->RasterOperation, 16, 23) | 2686 __gen_uint(values->ColorDepth, 24, 25) | 2687 __gen_uint(values->MonoSourceTransparencyMode, 29, 29) | 2688 __gen_uint(values->ClippingEnabled, 30, 30); 2689 2690 dw[2] = 2691 __gen_sint(values->ClipRectX1Coordinate, 0, 15) | 2692 __gen_sint(values->ClipRectY1Coordinate, 16, 31); 2693 2694 dw[3] = 2695 __gen_sint(values->ClipRectX2Coordinate, 0, 15) | 2696 __gen_sint(values->ClipRectY2Coordinate, 16, 31); 2697 2698 dw[4] = __gen_address(data, &dw[4], values->DestinationBaseAddress, 0, 0, 31); 2699 2700 dw[5] = 2701 __gen_uint(values->BackgroundColor, 0, 31); 2702 2703 dw[6] = 2704 __gen_uint(values->ForegroundColor, 0, 31); 2705 2706 dw[7] = 2707 __gen_uint(values->PatternBaseAddress, 0, 31); 2708} 2709 2710#define GFX4_XY_SRC_COPY_BLT_length 8 2711#define GFX4_XY_SRC_COPY_BLT_length_bias 2 2712#define GFX4_XY_SRC_COPY_BLT_header \ 2713 .DWordLength = 6, \ 2714 ._2DCommandOpcode = 83, \ 2715 .CommandType = 2 2716 2717struct GFX4_XY_SRC_COPY_BLT { 2718 uint32_t DWordLength; 2719 bool DestinationTilingEnable; 2720 bool SourceTilingEnable; 2721 uint32_t _32bppByteMask; 2722 uint32_t _2DCommandOpcode; 2723 uint32_t CommandType; 2724 int32_t DestinationPitch; 2725 uint32_t RasterOperation; 2726 uint32_t ColorDepth; 2727#define COLOR_DEPTH__8bit 0 2728#define COLOR_DEPTH__565 1 2729#define COLOR_DEPTH__1555 2 2730#define COLOR_DEPTH__32bit 3 2731 bool ClippingEnabled; 2732 int32_t DestinationX1Coordinate; 2733 int32_t DestinationY1Coordinate; 2734 int32_t DestinationX2Coordinate; 2735 int32_t DestinationY2Coordinate; 2736 __gen_address_type DestinationBaseAddress; 2737 int32_t SourceX1Coordinate; 2738 int32_t SourceY1Coordinate; 2739 int32_t SourcePitch; 2740 __gen_address_type SourceBaseAddress; 2741}; 2742 2743static inline __attribute__((always_inline)) void 2744GFX4_XY_SRC_COPY_BLT_pack(__attribute__((unused)) __gen_user_data *data, 2745 __attribute__((unused)) void * restrict dst, 2746 __attribute__((unused)) const struct GFX4_XY_SRC_COPY_BLT * restrict values) 2747{ 2748 uint32_t * restrict dw = (uint32_t * restrict) dst; 2749 2750 dw[0] = 2751 __gen_uint(values->DWordLength, 0, 7) | 2752 __gen_uint(values->DestinationTilingEnable, 11, 11) | 2753 __gen_uint(values->SourceTilingEnable, 15, 15) | 2754 __gen_uint(values->_32bppByteMask, 20, 21) | 2755 __gen_uint(values->_2DCommandOpcode, 22, 28) | 2756 __gen_uint(values->CommandType, 29, 31); 2757 2758 dw[1] = 2759 __gen_sint(values->DestinationPitch, 0, 15) | 2760 __gen_uint(values->RasterOperation, 16, 23) | 2761 __gen_uint(values->ColorDepth, 24, 25) | 2762 __gen_uint(values->ClippingEnabled, 30, 30); 2763 2764 dw[2] = 2765 __gen_sint(values->DestinationX1Coordinate, 0, 15) | 2766 __gen_sint(values->DestinationY1Coordinate, 16, 31); 2767 2768 dw[3] = 2769 __gen_sint(values->DestinationX2Coordinate, 0, 15) | 2770 __gen_sint(values->DestinationY2Coordinate, 16, 31); 2771 2772 dw[4] = __gen_address(data, &dw[4], values->DestinationBaseAddress, 0, 0, 31); 2773 2774 dw[5] = 2775 __gen_sint(values->SourceX1Coordinate, 0, 15) | 2776 __gen_sint(values->SourceY1Coordinate, 16, 31); 2777 2778 dw[6] = 2779 __gen_sint(values->SourcePitch, 0, 15); 2780 2781 dw[7] = __gen_address(data, &dw[7], values->SourceBaseAddress, 0, 0, 31); 2782} 2783 2784#define GFX4_XY_TEXT_IMMEDIATE_BLT_length 3 2785#define GFX4_XY_TEXT_IMMEDIATE_BLT_length_bias 2 2786#define GFX4_XY_TEXT_IMMEDIATE_BLT_header \ 2787 .DWordLength = 1, \ 2788 ._2DCommandOpcode = 49, \ 2789 .CommandType = 2 2790 2791struct GFX4_XY_TEXT_IMMEDIATE_BLT { 2792 uint32_t DWordLength; 2793 bool TilingEnable; 2794 uint32_t Packing; 2795#define BitPacked 0 2796#define BytePacked 1 2797 uint32_t _32bppByteMask; 2798 uint32_t _2DCommandOpcode; 2799 uint32_t CommandType; 2800 int32_t DestinationPitch; 2801 int32_t DestinationX1Coordinate; 2802 int32_t DestinationY1Coordinate; 2803 int32_t DestinationX2Coordinate; 2804 int32_t DestinationY2Coordinate; 2805}; 2806 2807static inline __attribute__((always_inline)) void 2808GFX4_XY_TEXT_IMMEDIATE_BLT_pack(__attribute__((unused)) __gen_user_data *data, 2809 __attribute__((unused)) void * restrict dst, 2810 __attribute__((unused)) const struct GFX4_XY_TEXT_IMMEDIATE_BLT * restrict values) 2811{ 2812 uint32_t * restrict dw = (uint32_t * restrict) dst; 2813 2814 dw[0] = 2815 __gen_uint(values->DWordLength, 0, 7) | 2816 __gen_uint(values->TilingEnable, 11, 11) | 2817 __gen_uint(values->Packing, 16, 16) | 2818 __gen_uint(values->_32bppByteMask, 20, 21) | 2819 __gen_uint(values->_2DCommandOpcode, 22, 28) | 2820 __gen_uint(values->CommandType, 29, 31); 2821 2822 dw[1] = 2823 __gen_sint(values->DestinationPitch, 0, 15) | 2824 __gen_sint(values->DestinationX1Coordinate, 0, 15) | 2825 __gen_sint(values->DestinationY1Coordinate, 16, 31); 2826 2827 dw[2] = 2828 __gen_sint(values->DestinationX2Coordinate, 0, 15) | 2829 __gen_sint(values->DestinationY2Coordinate, 16, 31); 2830} 2831 2832#endif /* GFX4_PACK_H */ 2833