1 2/* Generated code, see midgard.xml and gen_pack_header.py 3 * 4 * Packets, enums and structures for Panfrost. 5 * 6 * This file has been generated, do not hand edit. 7 */ 8 9#ifndef PAN_PACK_H 10#define PAN_PACK_H 11 12#include <stdio.h> 13#include <stdint.h> 14#include <stdbool.h> 15#include <assert.h> 16#include <math.h> 17#include <inttypes.h> 18#include "util/macros.h" 19#include "util/u_math.h" 20 21#define __gen_unpack_float(x, y, z) uif(__gen_unpack_uint(x, y, z)) 22 23static inline uint64_t 24__gen_uint(uint64_t v, uint32_t start, uint32_t end) 25{ 26#ifndef NDEBUG 27 const int width = end - start + 1; 28 if (width < 64) { 29 const uint64_t max = (1ull << width) - 1; 30 assert(v <= max); 31 } 32#endif 33 34 return v << start; 35} 36 37static inline uint32_t 38__gen_sint(int32_t v, uint32_t start, uint32_t end) 39{ 40#ifndef NDEBUG 41 const int width = end - start + 1; 42 if (width < 64) { 43 const int64_t max = (1ll << (width - 1)) - 1; 44 const int64_t min = -(1ll << (width - 1)); 45 assert(min <= v && v <= max); 46 } 47#endif 48 49 return (((uint32_t) v) << start) & ((2ll << end) - 1); 50} 51 52static inline uint32_t 53__gen_padded(uint32_t v, uint32_t start, uint32_t end) 54{ 55 unsigned shift = __builtin_ctz(v); 56 unsigned odd = v >> (shift + 1); 57 58#ifndef NDEBUG 59 assert((v >> shift) & 1); 60 assert(shift <= 31); 61 assert(odd <= 7); 62 assert((end - start + 1) == 8); 63#endif 64 65 return __gen_uint(shift | (odd << 5), start, end); 66} 67 68 69static inline uint64_t 70__gen_unpack_uint(const uint8_t *restrict cl, uint32_t start, uint32_t end) 71{ 72 uint64_t val = 0; 73 const int width = end - start + 1; 74 const uint64_t mask = (width == 64 ? ~0 : (1ull << width) - 1 ); 75 76 for (uint32_t byte = start / 8; byte <= end / 8; byte++) { 77 val |= ((uint64_t) cl[byte]) << ((byte - start / 8) * 8); 78 } 79 80 return (val >> (start % 8)) & mask; 81} 82 83static inline uint64_t 84__gen_unpack_sint(const uint8_t *restrict cl, uint32_t start, uint32_t end) 85{ 86 int size = end - start + 1; 87 int64_t val = __gen_unpack_uint(cl, start, end); 88 89 /* Get the sign bit extended. */ 90 return (val << (64 - size)) >> (64 - size); 91} 92 93static inline uint64_t 94__gen_unpack_padded(const uint8_t *restrict cl, uint32_t start, uint32_t end) 95{ 96 unsigned val = __gen_unpack_uint(cl, start, end); 97 unsigned shift = val & 0b11111; 98 unsigned odd = val >> 5; 99 100 return (2*odd + 1) << shift; 101} 102 103#define PREFIX1(A) MALI_ ## A 104#define PREFIX2(A, B) MALI_ ## A ## _ ## B 105#define PREFIX4(A, B, C, D) MALI_ ## A ## _ ## B ## _ ## C ## _ ## D 106 107#define pan_prepare(dst, T) \ 108 *(dst) = (struct PREFIX1(T)){ PREFIX2(T, header) } 109 110#define pan_pack(dst, T, name) \ 111 for (struct PREFIX1(T) name = { PREFIX2(T, header) }, \ 112 *_loop_terminate = (void *) (dst); \ 113 __builtin_expect(_loop_terminate != NULL, 1); \ 114 ({ PREFIX2(T, pack)((uint32_t *) (dst), &name); \ 115 _loop_terminate = NULL; })) 116 117#define pan_unpack(src, T, name) \ 118 struct PREFIX1(T) name; \ 119 PREFIX2(T, unpack)((uint8_t *)(src), &name) 120 121#define pan_print(fp, T, var, indent) \ 122 PREFIX2(T, print)(fp, &(var), indent) 123 124#define pan_size(T) PREFIX2(T, LENGTH) 125#define pan_alignment(T) PREFIX2(T, ALIGN) 126 127#define pan_section_offset(A, S) \ 128 PREFIX4(A, SECTION, S, OFFSET) 129 130#define pan_section_ptr(base, A, S) \ 131 ((void *)((uint8_t *)(base) + pan_section_offset(A, S))) 132 133#define pan_section_pack(dst, A, S, name) \ 134 for (PREFIX4(A, SECTION, S, TYPE) name = { PREFIX4(A, SECTION, S, header) }, \ 135 *_loop_terminate = (void *) (dst); \ 136 __builtin_expect(_loop_terminate != NULL, 1); \ 137 ({ PREFIX4(A, SECTION, S, pack) (pan_section_ptr(dst, A, S), &name); \ 138 _loop_terminate = NULL; })) 139 140#define pan_section_unpack(src, A, S, name) \ 141 PREFIX4(A, SECTION, S, TYPE) name; \ 142 PREFIX4(A, SECTION, S, unpack)(pan_section_ptr(src, A, S), &name) 143 144#define pan_section_print(fp, A, S, var, indent) \ 145 PREFIX4(A, SECTION, S, print)(fp, &(var), indent) 146 147#define pan_merge(packed1, packed2, type) do { for (unsigned i = 0; i < (PREFIX2(type, LENGTH) / 4); ++i) (packed1).opaque[i] |= (packed2).opaque[i]; } while(0) 148 149/* From presentations, 16x16 tiles externally. Use shift for fast computation 150 * of tile numbers. */ 151 152#define MALI_TILE_SHIFT 4 153#define MALI_TILE_LENGTH (1 << MALI_TILE_SHIFT) 154 155 156 157 158#define mali_pixel_format_print(fp, format) \ 159 fprintf(fp, "%*sFormat (v6): %s%s%s %s%s%s%s\n", indent, "", \ 160 mali_format_as_str((enum mali_format)((format >> 12) & 0xFF)), \ 161 (format & (1 << 20)) ? " sRGB" : "", \ 162 (format & (1 << 21)) ? " big-endian" : "", \ 163 mali_channel_as_str((enum mali_channel)((format >> 0) & 0x7)), \ 164 mali_channel_as_str((enum mali_channel)((format >> 3) & 0x7)), \ 165 mali_channel_as_str((enum mali_channel)((format >> 6) & 0x7)), \ 166 mali_channel_as_str((enum mali_channel)((format >> 9) & 0x7))); 167 168 169enum mali_attribute_type { 170 MALI_ATTRIBUTE_TYPE_1D = 1, 171 MALI_ATTRIBUTE_TYPE_1D_POT_DIVISOR = 2, 172 MALI_ATTRIBUTE_TYPE_1D_MODULUS = 3, 173 MALI_ATTRIBUTE_TYPE_1D_NPOT_DIVISOR = 4, 174 MALI_ATTRIBUTE_TYPE_3D_LINEAR = 5, 175 MALI_ATTRIBUTE_TYPE_3D_INTERLEAVED = 6, 176 MALI_ATTRIBUTE_TYPE_1D_PRIMITIVE_INDEX_BUFFER = 7, 177 MALI_ATTRIBUTE_TYPE_1D_POT_DIVISOR_WRITE_REDUCTION = 10, 178 MALI_ATTRIBUTE_TYPE_1D_MODULUS_WRITE_REDUCTION = 11, 179 MALI_ATTRIBUTE_TYPE_1D_NPOT_DIVISOR_WRITE_REDUCTION = 12, 180 MALI_ATTRIBUTE_TYPE_CONTINUATION = 32, 181}; 182 183static inline const char * 184mali_attribute_type_as_str(enum mali_attribute_type imm) 185{ 186 switch (imm) { 187 case MALI_ATTRIBUTE_TYPE_1D: return "1D"; 188 case MALI_ATTRIBUTE_TYPE_1D_POT_DIVISOR: return "1D POT Divisor"; 189 case MALI_ATTRIBUTE_TYPE_1D_MODULUS: return "1D Modulus"; 190 case MALI_ATTRIBUTE_TYPE_1D_NPOT_DIVISOR: return "1D NPOT Divisor"; 191 case MALI_ATTRIBUTE_TYPE_3D_LINEAR: return "3D Linear"; 192 case MALI_ATTRIBUTE_TYPE_3D_INTERLEAVED: return "3D Interleaved"; 193 case MALI_ATTRIBUTE_TYPE_1D_PRIMITIVE_INDEX_BUFFER: return "1D Primitive Index Buffer"; 194 case MALI_ATTRIBUTE_TYPE_1D_POT_DIVISOR_WRITE_REDUCTION: return "1D POT Divisor Write Reduction"; 195 case MALI_ATTRIBUTE_TYPE_1D_MODULUS_WRITE_REDUCTION: return "1D Modulus Write Reduction"; 196 case MALI_ATTRIBUTE_TYPE_1D_NPOT_DIVISOR_WRITE_REDUCTION: return "1D NPOT Divisor Write Reduction"; 197 case MALI_ATTRIBUTE_TYPE_CONTINUATION: return "Continuation"; 198 default: return "XXX: INVALID"; 199 } 200} 201 202enum mali_channel { 203 MALI_CHANNEL_R = 0, 204 MALI_CHANNEL_G = 1, 205 MALI_CHANNEL_B = 2, 206 MALI_CHANNEL_A = 3, 207 MALI_CHANNEL_0 = 4, 208 MALI_CHANNEL_1 = 5, 209}; 210 211static inline const char * 212mali_channel_as_str(enum mali_channel imm) 213{ 214 switch (imm) { 215 case MALI_CHANNEL_R: return "R"; 216 case MALI_CHANNEL_G: return "G"; 217 case MALI_CHANNEL_B: return "B"; 218 case MALI_CHANNEL_A: return "A"; 219 case MALI_CHANNEL_0: return "0"; 220 case MALI_CHANNEL_1: return "1"; 221 default: return "XXX: INVALID"; 222 } 223} 224 225enum mali_depth_source { 226 MALI_DEPTH_SOURCE_MINIMUM = 0, 227 MALI_DEPTH_SOURCE_MAXIMUM = 1, 228 MALI_DEPTH_SOURCE_FIXED_FUNCTION = 2, 229 MALI_DEPTH_SOURCE_SHADER = 3, 230}; 231 232static inline const char * 233mali_depth_source_as_str(enum mali_depth_source imm) 234{ 235 switch (imm) { 236 case MALI_DEPTH_SOURCE_MINIMUM: return "Minimum"; 237 case MALI_DEPTH_SOURCE_MAXIMUM: return "Maximum"; 238 case MALI_DEPTH_SOURCE_FIXED_FUNCTION: return "Fixed function"; 239 case MALI_DEPTH_SOURCE_SHADER: return "Shader"; 240 default: return "XXX: INVALID"; 241 } 242} 243 244enum mali_job_type { 245 MALI_JOB_TYPE_NOT_STARTED = 0, 246 MALI_JOB_TYPE_NULL = 1, 247 MALI_JOB_TYPE_WRITE_VALUE = 2, 248 MALI_JOB_TYPE_CACHE_FLUSH = 3, 249 MALI_JOB_TYPE_COMPUTE = 4, 250 MALI_JOB_TYPE_VERTEX = 5, 251 MALI_JOB_TYPE_GEOMETRY = 6, 252 MALI_JOB_TYPE_TILER = 7, 253 MALI_JOB_TYPE_FUSED = 8, 254 MALI_JOB_TYPE_FRAGMENT = 9, 255 MALI_JOB_TYPE_INDEXED_VERTEX = 10, 256}; 257 258static inline const char * 259mali_job_type_as_str(enum mali_job_type imm) 260{ 261 switch (imm) { 262 case MALI_JOB_TYPE_NOT_STARTED: return "Not started"; 263 case MALI_JOB_TYPE_NULL: return "Null"; 264 case MALI_JOB_TYPE_WRITE_VALUE: return "Write value"; 265 case MALI_JOB_TYPE_CACHE_FLUSH: return "Cache flush"; 266 case MALI_JOB_TYPE_COMPUTE: return "Compute"; 267 case MALI_JOB_TYPE_VERTEX: return "Vertex"; 268 case MALI_JOB_TYPE_GEOMETRY: return "Geometry"; 269 case MALI_JOB_TYPE_TILER: return "Tiler"; 270 case MALI_JOB_TYPE_FUSED: return "Fused"; 271 case MALI_JOB_TYPE_FRAGMENT: return "Fragment"; 272 case MALI_JOB_TYPE_INDEXED_VERTEX: return "Indexed Vertex"; 273 default: return "XXX: INVALID"; 274 } 275} 276 277enum mali_draw_mode { 278 MALI_DRAW_MODE_NONE = 0, 279 MALI_DRAW_MODE_POINTS = 1, 280 MALI_DRAW_MODE_LINES = 2, 281 MALI_DRAW_MODE_LINE_STRIP = 4, 282 MALI_DRAW_MODE_LINE_LOOP = 6, 283 MALI_DRAW_MODE_TRIANGLES = 8, 284 MALI_DRAW_MODE_TRIANGLE_STRIP = 10, 285 MALI_DRAW_MODE_TRIANGLE_FAN = 12, 286 MALI_DRAW_MODE_POLYGON = 13, 287 MALI_DRAW_MODE_QUADS = 14, 288 MALI_DRAW_MODE_QUAD_STRIP = 15, 289}; 290 291static inline const char * 292mali_draw_mode_as_str(enum mali_draw_mode imm) 293{ 294 switch (imm) { 295 case MALI_DRAW_MODE_NONE: return "None"; 296 case MALI_DRAW_MODE_POINTS: return "Points"; 297 case MALI_DRAW_MODE_LINES: return "Lines"; 298 case MALI_DRAW_MODE_LINE_STRIP: return "Line strip"; 299 case MALI_DRAW_MODE_LINE_LOOP: return "Line loop"; 300 case MALI_DRAW_MODE_TRIANGLES: return "Triangles"; 301 case MALI_DRAW_MODE_TRIANGLE_STRIP: return "Triangle strip"; 302 case MALI_DRAW_MODE_TRIANGLE_FAN: return "Triangle fan"; 303 case MALI_DRAW_MODE_POLYGON: return "Polygon"; 304 case MALI_DRAW_MODE_QUADS: return "Quads"; 305 case MALI_DRAW_MODE_QUAD_STRIP: return "Quad strip"; 306 default: return "XXX: INVALID"; 307 } 308} 309 310enum mali_exception_access { 311 MALI_EXCEPTION_ACCESS_NONE = 0, 312 MALI_EXCEPTION_ACCESS_EXECUTE = 2, 313 MALI_EXCEPTION_ACCESS_READ = 1, 314 MALI_EXCEPTION_ACCESS_WRITE = 3, 315}; 316 317static inline const char * 318mali_exception_access_as_str(enum mali_exception_access imm) 319{ 320 switch (imm) { 321 case MALI_EXCEPTION_ACCESS_NONE: return "None"; 322 case MALI_EXCEPTION_ACCESS_EXECUTE: return "Execute"; 323 case MALI_EXCEPTION_ACCESS_READ: return "Read"; 324 case MALI_EXCEPTION_ACCESS_WRITE: return "Write"; 325 default: return "XXX: INVALID"; 326 } 327} 328 329enum mali_func { 330 MALI_FUNC_NEVER = 0, 331 MALI_FUNC_LESS = 1, 332 MALI_FUNC_EQUAL = 2, 333 MALI_FUNC_LEQUAL = 3, 334 MALI_FUNC_GREATER = 4, 335 MALI_FUNC_NOT_EQUAL = 5, 336 MALI_FUNC_GEQUAL = 6, 337 MALI_FUNC_ALWAYS = 7, 338}; 339 340static inline const char * 341mali_func_as_str(enum mali_func imm) 342{ 343 switch (imm) { 344 case MALI_FUNC_NEVER: return "Never"; 345 case MALI_FUNC_LESS: return "Less"; 346 case MALI_FUNC_EQUAL: return "Equal"; 347 case MALI_FUNC_LEQUAL: return "Lequal"; 348 case MALI_FUNC_GREATER: return "Greater"; 349 case MALI_FUNC_NOT_EQUAL: return "Not Equal"; 350 case MALI_FUNC_GEQUAL: return "Gequal"; 351 case MALI_FUNC_ALWAYS: return "Always"; 352 default: return "XXX: INVALID"; 353 } 354} 355 356enum mali_format { 357 MALI_ETC2_RGB8 = 1, 358 MALI_ETC2_R11_UNORM = 2, 359 MALI_ETC2_RGBA8 = 3, 360 MALI_ETC2_RG11_UNORM = 4, 361 MALI_BC1_UNORM = 7, 362 MALI_BC2_UNORM = 8, 363 MALI_BC3_UNORM = 9, 364 MALI_BC4_UNORM = 10, 365 MALI_BC4_SNORM = 11, 366 MALI_BC5_UNORM = 12, 367 MALI_BC5_SNORM = 13, 368 MALI_BC6H_UF16 = 14, 369 MALI_BC6H_SF16 = 15, 370 MALI_BC7_UNORM = 16, 371 MALI_ETC2_R11_SNORM = 17, 372 MALI_ETC2_RG11_SNORM = 18, 373 MALI_ETC2_RGB8A1 = 19, 374 MALI_ASTC_3D_LDR = 20, 375 MALI_ASTC_3D_HDR = 21, 376 MALI_ASTC_2D_LDR = 22, 377 MALI_ASTC_2D_HDR = 23, 378 MALI_RGB565 = 64, 379 MALI_RGB5_A1_UNORM = 65, 380 MALI_A1_BGR5_UNORM = 66, 381 MALI_RGB10_A2_UNORM = 67, 382 MALI_A2_BGR10_UNORM = 68, 383 MALI_RGB10_A2_SNORM = 69, 384 MALI_A2_BGR10_SNORM = 70, 385 MALI_RGB10_A2UI = 71, 386 MALI_A2_BGR10UI = 72, 387 MALI_RGB10_A2I = 73, 388 MALI_A2_BGR10I = 74, 389 MALI_Z24X8_UNORM = 77, 390 MALI_X8Z24 = 78, 391 MALI_X32_S8X24 = 79, 392 MALI_X24S8_X32 = 80, 393 MALI_R32_FIXED = 81, 394 MALI_RG32_FIXED = 82, 395 MALI_RGB32_FIXED = 83, 396 MALI_RGBA32_FIXED = 84, 397 MALI_R11F_G11F_B10F = 89, 398 MALI_B10F_G11F_R11F = 90, 399 MALI_R9F_G9F_B9F_E5F = 91, 400 MALI_E5F_B9F_G9F_R9F = 92, 401 MALI_SNAP_2 = 93, 402 MALI_SNAP_4 = 94, 403 MALI_CONSTANT = 95, 404 MALI_R1_SNORM = 96, 405 MALI_R2_SNORM = 97, 406 MALI_R4_SNORM = 98, 407 MALI_R8_SNORM = 99, 408 MALI_R16_SNORM = 100, 409 MALI_R32_SNORM = 101, 410 MALI_R64_SNORM = 102, 411 MALI_RG1_SNORM = 104, 412 MALI_RG2_SNORM = 105, 413 MALI_RG4_SNORM = 106, 414 MALI_RG8_SNORM = 107, 415 MALI_RG16_SNORM = 108, 416 MALI_RG32_SNORM = 109, 417 MALI_RG64_SNORM = 110, 418 MALI_RGB1_SNORM = 112, 419 MALI_RGB2_SNORM = 113, 420 MALI_RGB4_SNORM = 114, 421 MALI_RGB8_SNORM = 115, 422 MALI_RGB16_SNORM = 116, 423 MALI_RGB32_SNORM = 117, 424 MALI_RGB64_SNORM = 118, 425 MALI_RGBA1_SNORM = 120, 426 MALI_RGBA2_SNORM = 121, 427 MALI_RGBA4_SNORM = 122, 428 MALI_RGBA8_SNORM = 123, 429 MALI_RGBA16_SNORM = 124, 430 MALI_RGBA32_SNORM = 125, 431 MALI_RGBA64_SNORM = 126, 432 MALI_R1UI = 128, 433 MALI_R2UI = 129, 434 MALI_R4UI = 130, 435 MALI_R8UI = 131, 436 MALI_R16UI = 132, 437 MALI_R32UI = 133, 438 MALI_R64UI = 134, 439 MALI_R64F = 135, 440 MALI_RG1UI = 136, 441 MALI_RG2UI = 137, 442 MALI_RG4UI = 138, 443 MALI_RG8UI = 139, 444 MALI_RG16UI = 140, 445 MALI_RG32UI = 141, 446 MALI_RG64UI = 142, 447 MALI_RG64F = 143, 448 MALI_RGB1UI = 144, 449 MALI_RGB2UI = 145, 450 MALI_RGB4UI = 146, 451 MALI_RGB8UI = 147, 452 MALI_RGB16UI = 148, 453 MALI_RGB32UI = 149, 454 MALI_RGB64UI = 150, 455 MALI_RGB64F = 151, 456 MALI_RGBA1UI = 152, 457 MALI_RGBA2UI = 153, 458 MALI_RGBA4UI = 154, 459 MALI_RGBA8UI = 155, 460 MALI_RGBA16UI = 156, 461 MALI_RGBA32UI = 157, 462 MALI_RGBA64UI = 158, 463 MALI_RGBA64F = 159, 464 MALI_R1_UNORM = 160, 465 MALI_R2_UNORM = 161, 466 MALI_R4_UNORM = 162, 467 MALI_R8_UNORM = 163, 468 MALI_R16_UNORM = 164, 469 MALI_R32_UNORM = 165, 470 MALI_R64_UNORM = 166, 471 MALI_R32F = 167, 472 MALI_RG1_UNORM = 168, 473 MALI_RG2_UNORM = 169, 474 MALI_RG4_UNORM = 170, 475 MALI_RG8_UNORM = 171, 476 MALI_RG16_UNORM = 172, 477 MALI_RG32_UNORM = 173, 478 MALI_RG64_UNORM = 174, 479 MALI_RG32F = 175, 480 MALI_RGB1_UNORM = 176, 481 MALI_RGB2_UNORM = 177, 482 MALI_RGB4_UNORM = 178, 483 MALI_RGB8_UNORM = 179, 484 MALI_RGB16_UNORM = 180, 485 MALI_RGB32_UNORM = 181, 486 MALI_RGB64_UNORM = 182, 487 MALI_RGB32F = 183, 488 MALI_RGBA1_UNORM = 184, 489 MALI_RGBA2_UNORM = 185, 490 MALI_RGBA4_UNORM = 186, 491 MALI_RGBA8_UNORM = 187, 492 MALI_RGBA16_UNORM = 188, 493 MALI_RGBA32_UNORM = 189, 494 MALI_RGBA64_UNORM = 190, 495 MALI_RGBA32F = 191, 496 MALI_R1I = 192, 497 MALI_R2I = 193, 498 MALI_R4I = 194, 499 MALI_R8I = 195, 500 MALI_R16I = 196, 501 MALI_R32I = 197, 502 MALI_R64I = 198, 503 MALI_R16F = 199, 504 MALI_RG1I = 200, 505 MALI_RG2I = 201, 506 MALI_RG4I = 202, 507 MALI_RG8I = 203, 508 MALI_RG16I = 204, 509 MALI_RG32I = 205, 510 MALI_RG64I = 206, 511 MALI_RG16F = 207, 512 MALI_RGB1I = 208, 513 MALI_RGB2I = 209, 514 MALI_RGB4I = 210, 515 MALI_RGB8I = 211, 516 MALI_RGB16I = 212, 517 MALI_RGB32I = 213, 518 MALI_RGB64I = 214, 519 MALI_RGB16F = 215, 520 MALI_RGBA1I = 216, 521 MALI_RGBA2I = 217, 522 MALI_RGBA4I = 218, 523 MALI_RGBA8I = 219, 524 MALI_RGBA16I = 220, 525 MALI_RGBA32I = 221, 526 MALI_RGBA64I = 222, 527 MALI_RGBA16F = 223, 528 MALI_RGB5_A1_AU = 224, 529 MALI_RGB5_A1_PU = 225, 530 MALI_R5G6B5_AU = 226, 531 MALI_R5G6B5_PU = 227, 532 MALI_SNAP4_V = 230, 533 MALI_RGBA4_AU = 232, 534 MALI_RGBA4_PU = 233, 535 MALI_RGBA8_TB = 237, 536 MALI_RGB10_A2_TB = 238, 537 MALI_TESS_VERTEX_PACK = 240, 538 MALI_RGB8_A2_AU = 241, 539 MALI_RGB8_A2_PU = 242, 540}; 541 542static inline const char * 543mali_format_as_str(enum mali_format imm) 544{ 545 switch (imm) { 546 case MALI_ETC2_RGB8: return "ETC2 RGB8"; 547 case MALI_ETC2_R11_UNORM: return "ETC2 R11 UNORM"; 548 case MALI_ETC2_RGBA8: return "ETC2 RGBA8"; 549 case MALI_ETC2_RG11_UNORM: return "ETC2 RG11 UNORM"; 550 case MALI_BC1_UNORM: return "BC1 UNORM"; 551 case MALI_BC2_UNORM: return "BC2 UNORM"; 552 case MALI_BC3_UNORM: return "BC3 UNORM"; 553 case MALI_BC4_UNORM: return "BC4 UNORM"; 554 case MALI_BC4_SNORM: return "BC4 SNORM"; 555 case MALI_BC5_UNORM: return "BC5 UNORM"; 556 case MALI_BC5_SNORM: return "BC5 SNORM"; 557 case MALI_BC6H_UF16: return "BC6H UF16"; 558 case MALI_BC6H_SF16: return "BC6H SF16"; 559 case MALI_BC7_UNORM: return "BC7 UNORM"; 560 case MALI_ETC2_R11_SNORM: return "ETC2 R11 SNORM"; 561 case MALI_ETC2_RG11_SNORM: return "ETC2 RG11 SNORM"; 562 case MALI_ETC2_RGB8A1: return "ETC2 RGB8A1"; 563 case MALI_ASTC_3D_LDR: return "ASTC 3D LDR"; 564 case MALI_ASTC_3D_HDR: return "ASTC 3D HDR"; 565 case MALI_ASTC_2D_LDR: return "ASTC 2D LDR"; 566 case MALI_ASTC_2D_HDR: return "ASTC 2D HDR"; 567 case MALI_RGB565: return "RGB565"; 568 case MALI_RGB5_A1_UNORM: return "RGB5 A1 UNORM"; 569 case MALI_A1_BGR5_UNORM: return "A1 BGR5 UNORM"; 570 case MALI_RGB10_A2_UNORM: return "RGB10 A2 UNORM"; 571 case MALI_A2_BGR10_UNORM: return "A2 BGR10 UNORM"; 572 case MALI_RGB10_A2_SNORM: return "RGB10 A2 SNORM"; 573 case MALI_A2_BGR10_SNORM: return "A2 BGR10 SNORM"; 574 case MALI_RGB10_A2UI: return "RGB10 A2UI"; 575 case MALI_A2_BGR10UI: return "A2 BGR10UI"; 576 case MALI_RGB10_A2I: return "RGB10 A2I"; 577 case MALI_A2_BGR10I: return "A2 BGR10I"; 578 case MALI_Z24X8_UNORM: return "Z24X8 UNORM"; 579 case MALI_X8Z24: return "X8Z24"; 580 case MALI_X32_S8X24: return "X32 S8X24"; 581 case MALI_X24S8_X32: return "X24S8 X32"; 582 case MALI_R32_FIXED: return "R32 FIXED"; 583 case MALI_RG32_FIXED: return "RG32 FIXED"; 584 case MALI_RGB32_FIXED: return "RGB32 FIXED"; 585 case MALI_RGBA32_FIXED: return "RGBA32 FIXED"; 586 case MALI_R11F_G11F_B10F: return "R11F G11F B10F"; 587 case MALI_B10F_G11F_R11F: return "B10F G11F R11F"; 588 case MALI_R9F_G9F_B9F_E5F: return "R9F G9F B9F E5F"; 589 case MALI_E5F_B9F_G9F_R9F: return "E5F B9F G9F R9F"; 590 case MALI_SNAP_2: return "Snap 2"; 591 case MALI_SNAP_4: return "Snap 4"; 592 case MALI_CONSTANT: return "Constant"; 593 case MALI_R1_SNORM: return "R1 SNORM"; 594 case MALI_R2_SNORM: return "R2 SNORM"; 595 case MALI_R4_SNORM: return "R4 SNORM"; 596 case MALI_R8_SNORM: return "R8 SNORM"; 597 case MALI_R16_SNORM: return "R16 SNORM"; 598 case MALI_R32_SNORM: return "R32 SNORM"; 599 case MALI_R64_SNORM: return "R64 SNORM"; 600 case MALI_RG1_SNORM: return "RG1 SNORM"; 601 case MALI_RG2_SNORM: return "RG2 SNORM"; 602 case MALI_RG4_SNORM: return "RG4 SNORM"; 603 case MALI_RG8_SNORM: return "RG8 SNORM"; 604 case MALI_RG16_SNORM: return "RG16 SNORM"; 605 case MALI_RG32_SNORM: return "RG32 SNORM"; 606 case MALI_RG64_SNORM: return "RG64 SNORM"; 607 case MALI_RGB1_SNORM: return "RGB1 SNORM"; 608 case MALI_RGB2_SNORM: return "RGB2 SNORM"; 609 case MALI_RGB4_SNORM: return "RGB4 SNORM"; 610 case MALI_RGB8_SNORM: return "RGB8 SNORM"; 611 case MALI_RGB16_SNORM: return "RGB16 SNORM"; 612 case MALI_RGB32_SNORM: return "RGB32 SNORM"; 613 case MALI_RGB64_SNORM: return "RGB64 SNORM"; 614 case MALI_RGBA1_SNORM: return "RGBA1 SNORM"; 615 case MALI_RGBA2_SNORM: return "RGBA2 SNORM"; 616 case MALI_RGBA4_SNORM: return "RGBA4 SNORM"; 617 case MALI_RGBA8_SNORM: return "RGBA8 SNORM"; 618 case MALI_RGBA16_SNORM: return "RGBA16 SNORM"; 619 case MALI_RGBA32_SNORM: return "RGBA32 SNORM"; 620 case MALI_RGBA64_SNORM: return "RGBA64 SNORM"; 621 case MALI_R1UI: return "R1UI"; 622 case MALI_R2UI: return "R2UI"; 623 case MALI_R4UI: return "R4UI"; 624 case MALI_R8UI: return "R8UI"; 625 case MALI_R16UI: return "R16UI"; 626 case MALI_R32UI: return "R32UI"; 627 case MALI_R64UI: return "R64UI"; 628 case MALI_R64F: return "R64F"; 629 case MALI_RG1UI: return "RG1UI"; 630 case MALI_RG2UI: return "RG2UI"; 631 case MALI_RG4UI: return "RG4UI"; 632 case MALI_RG8UI: return "RG8UI"; 633 case MALI_RG16UI: return "RG16UI"; 634 case MALI_RG32UI: return "RG32UI"; 635 case MALI_RG64UI: return "RG64UI"; 636 case MALI_RG64F: return "RG64F"; 637 case MALI_RGB1UI: return "RGB1UI"; 638 case MALI_RGB2UI: return "RGB2UI"; 639 case MALI_RGB4UI: return "RGB4UI"; 640 case MALI_RGB8UI: return "RGB8UI"; 641 case MALI_RGB16UI: return "RGB16UI"; 642 case MALI_RGB32UI: return "RGB32UI"; 643 case MALI_RGB64UI: return "RGB64UI"; 644 case MALI_RGB64F: return "RGB64F"; 645 case MALI_RGBA1UI: return "RGBA1UI"; 646 case MALI_RGBA2UI: return "RGBA2UI"; 647 case MALI_RGBA4UI: return "RGBA4UI"; 648 case MALI_RGBA8UI: return "RGBA8UI"; 649 case MALI_RGBA16UI: return "RGBA16UI"; 650 case MALI_RGBA32UI: return "RGBA32UI"; 651 case MALI_RGBA64UI: return "RGBA64UI"; 652 case MALI_RGBA64F: return "RGBA64F"; 653 case MALI_R1_UNORM: return "R1 UNORM"; 654 case MALI_R2_UNORM: return "R2 UNORM"; 655 case MALI_R4_UNORM: return "R4 UNORM"; 656 case MALI_R8_UNORM: return "R8 UNORM"; 657 case MALI_R16_UNORM: return "R16 UNORM"; 658 case MALI_R32_UNORM: return "R32 UNORM"; 659 case MALI_R64_UNORM: return "R64 UNORM"; 660 case MALI_R32F: return "R32F"; 661 case MALI_RG1_UNORM: return "RG1 UNORM"; 662 case MALI_RG2_UNORM: return "RG2 UNORM"; 663 case MALI_RG4_UNORM: return "RG4 UNORM"; 664 case MALI_RG8_UNORM: return "RG8 UNORM"; 665 case MALI_RG16_UNORM: return "RG16 UNORM"; 666 case MALI_RG32_UNORM: return "RG32 UNORM"; 667 case MALI_RG64_UNORM: return "RG64 UNORM"; 668 case MALI_RG32F: return "RG32F"; 669 case MALI_RGB1_UNORM: return "RGB1 UNORM"; 670 case MALI_RGB2_UNORM: return "RGB2 UNORM"; 671 case MALI_RGB4_UNORM: return "RGB4 UNORM"; 672 case MALI_RGB8_UNORM: return "RGB8 UNORM"; 673 case MALI_RGB16_UNORM: return "RGB16 UNORM"; 674 case MALI_RGB32_UNORM: return "RGB32 UNORM"; 675 case MALI_RGB64_UNORM: return "RGB64 UNORM"; 676 case MALI_RGB32F: return "RGB32F"; 677 case MALI_RGBA1_UNORM: return "RGBA1 UNORM"; 678 case MALI_RGBA2_UNORM: return "RGBA2 UNORM"; 679 case MALI_RGBA4_UNORM: return "RGBA4 UNORM"; 680 case MALI_RGBA8_UNORM: return "RGBA8 UNORM"; 681 case MALI_RGBA16_UNORM: return "RGBA16 UNORM"; 682 case MALI_RGBA32_UNORM: return "RGBA32 UNORM"; 683 case MALI_RGBA64_UNORM: return "RGBA64 UNORM"; 684 case MALI_RGBA32F: return "RGBA32F"; 685 case MALI_R1I: return "R1I"; 686 case MALI_R2I: return "R2I"; 687 case MALI_R4I: return "R4I"; 688 case MALI_R8I: return "R8I"; 689 case MALI_R16I: return "R16I"; 690 case MALI_R32I: return "R32I"; 691 case MALI_R64I: return "R64I"; 692 case MALI_R16F: return "R16F"; 693 case MALI_RG1I: return "RG1I"; 694 case MALI_RG2I: return "RG2I"; 695 case MALI_RG4I: return "RG4I"; 696 case MALI_RG8I: return "RG8I"; 697 case MALI_RG16I: return "RG16I"; 698 case MALI_RG32I: return "RG32I"; 699 case MALI_RG64I: return "RG64I"; 700 case MALI_RG16F: return "RG16F"; 701 case MALI_RGB1I: return "RGB1I"; 702 case MALI_RGB2I: return "RGB2I"; 703 case MALI_RGB4I: return "RGB4I"; 704 case MALI_RGB8I: return "RGB8I"; 705 case MALI_RGB16I: return "RGB16I"; 706 case MALI_RGB32I: return "RGB32I"; 707 case MALI_RGB64I: return "RGB64I"; 708 case MALI_RGB16F: return "RGB16F"; 709 case MALI_RGBA1I: return "RGBA1I"; 710 case MALI_RGBA2I: return "RGBA2I"; 711 case MALI_RGBA4I: return "RGBA4I"; 712 case MALI_RGBA8I: return "RGBA8I"; 713 case MALI_RGBA16I: return "RGBA16I"; 714 case MALI_RGBA32I: return "RGBA32I"; 715 case MALI_RGBA64I: return "RGBA64I"; 716 case MALI_RGBA16F: return "RGBA16F"; 717 case MALI_RGB5_A1_AU: return "RGB5 A1 AU"; 718 case MALI_RGB5_A1_PU: return "RGB5 A1 PU"; 719 case MALI_R5G6B5_AU: return "R5G6B5 AU"; 720 case MALI_R5G6B5_PU: return "R5G6B5 PU"; 721 case MALI_SNAP4_V: return "Snap4 V"; 722 case MALI_RGBA4_AU: return "RGBA4 AU"; 723 case MALI_RGBA4_PU: return "RGBA4 PU"; 724 case MALI_RGBA8_TB: return "RGBA8 TB"; 725 case MALI_RGB10_A2_TB: return "RGB10 A2 TB"; 726 case MALI_TESS_VERTEX_PACK: return "Tess Vertex Pack"; 727 case MALI_RGB8_A2_AU: return "RGB8 A2 AU"; 728 case MALI_RGB8_A2_PU: return "RGB8 A2 PU"; 729 default: return "XXX: INVALID"; 730 } 731} 732 733enum mali_yuv_swizzle { 734 MALI_YUV_SWIZZLE_YUVA = 0, 735 MALI_YUV_SWIZZLE_YVUA = 1, 736 MALI_YUV_SWIZZLE_UYVA = 2, 737 MALI_YUV_SWIZZLE_UVYA = 3, 738 MALI_YUV_SWIZZLE_VUYA = 4, 739 MALI_YUV_SWIZZLE_VYUA = 5, 740 MALI_YUV_SWIZZLE_Y00A = 6, 741 MALI_YUV_SWIZZLE_YXXA = 7, 742}; 743 744static inline const char * 745mali_yuv_swizzle_as_str(enum mali_yuv_swizzle imm) 746{ 747 switch (imm) { 748 case MALI_YUV_SWIZZLE_YUVA: return "YUVA"; 749 case MALI_YUV_SWIZZLE_YVUA: return "YVUA"; 750 case MALI_YUV_SWIZZLE_UYVA: return "UYVA"; 751 case MALI_YUV_SWIZZLE_UVYA: return "UVYA"; 752 case MALI_YUV_SWIZZLE_VUYA: return "VUYA"; 753 case MALI_YUV_SWIZZLE_VYUA: return "VYUA"; 754 case MALI_YUV_SWIZZLE_Y00A: return "Y00A"; 755 case MALI_YUV_SWIZZLE_YXXA: return "YXXA"; 756 default: return "XXX: INVALID"; 757 } 758} 759 760enum mali_yuv_conversion_mode { 761 MALI_YUV_CONVERSION_MODE_NO_CONVERSION = 0, 762 MALI_YUV_CONVERSION_MODE_BT_601 = 3, 763 MALI_YUV_CONVERSION_MODE_BT_709 = 4, 764 MALI_YUV_CONVERSION_MODE_BT_2020 = 6, 765}; 766 767static inline const char * 768mali_yuv_conversion_mode_as_str(enum mali_yuv_conversion_mode imm) 769{ 770 switch (imm) { 771 case MALI_YUV_CONVERSION_MODE_NO_CONVERSION: return "No Conversion"; 772 case MALI_YUV_CONVERSION_MODE_BT_601: return "BT 601"; 773 case MALI_YUV_CONVERSION_MODE_BT_709: return "BT 709"; 774 case MALI_YUV_CONVERSION_MODE_BT_2020: return "BT 2020"; 775 default: return "XXX: INVALID"; 776 } 777} 778 779enum mali_yuv_cr_siting { 780 MALI_YUV_CR_SITING_CO_SITED = 0, 781 MALI_YUV_CR_SITING_CENTER_Y = 1, 782 MALI_YUV_CR_SITING_CENTER_X = 2, 783 MALI_YUV_CR_SITING_CENTER = 3, 784 MALI_YUV_CR_SITING_ONE_QUARTER = 4, 785 MALI_YUV_CR_SITING_THREE_QUARTERS = 5, 786 MALI_YUV_CR_SITING_REPLICATED = 7, 787}; 788 789static inline const char * 790mali_yuv_cr_siting_as_str(enum mali_yuv_cr_siting imm) 791{ 792 switch (imm) { 793 case MALI_YUV_CR_SITING_CO_SITED: return "Co-Sited"; 794 case MALI_YUV_CR_SITING_CENTER_Y: return "Center Y"; 795 case MALI_YUV_CR_SITING_CENTER_X: return "Center X"; 796 case MALI_YUV_CR_SITING_CENTER: return "Center"; 797 case MALI_YUV_CR_SITING_ONE_QUARTER: return "One Quarter"; 798 case MALI_YUV_CR_SITING_THREE_QUARTERS: return "Three Quarters"; 799 case MALI_YUV_CR_SITING_REPLICATED: return "Replicated"; 800 default: return "XXX: INVALID"; 801 } 802} 803 804enum mali_astc_2d_dimension { 805 MALI_ASTC_2D_DIMENSION_4 = 0, 806 MALI_ASTC_2D_DIMENSION_5 = 1, 807 MALI_ASTC_2D_DIMENSION_6 = 2, 808 MALI_ASTC_2D_DIMENSION_8 = 4, 809 MALI_ASTC_2D_DIMENSION_10 = 6, 810 MALI_ASTC_2D_DIMENSION_12 = 7, 811}; 812 813static inline const char * 814mali_astc_2d_dimension_as_str(enum mali_astc_2d_dimension imm) 815{ 816 switch (imm) { 817 case MALI_ASTC_2D_DIMENSION_4: return "4"; 818 case MALI_ASTC_2D_DIMENSION_5: return "5"; 819 case MALI_ASTC_2D_DIMENSION_6: return "6"; 820 case MALI_ASTC_2D_DIMENSION_8: return "8"; 821 case MALI_ASTC_2D_DIMENSION_10: return "10"; 822 case MALI_ASTC_2D_DIMENSION_12: return "12"; 823 default: return "XXX: INVALID"; 824 } 825} 826 827enum mali_astc_3d_dimension { 828 MALI_ASTC_3D_DIMENSION_4 = 0, 829 MALI_ASTC_3D_DIMENSION_5 = 1, 830 MALI_ASTC_3D_DIMENSION_6 = 2, 831 MALI_ASTC_3D_DIMENSION_3 = 3, 832}; 833 834static inline const char * 835mali_astc_3d_dimension_as_str(enum mali_astc_3d_dimension imm) 836{ 837 switch (imm) { 838 case MALI_ASTC_3D_DIMENSION_4: return "4"; 839 case MALI_ASTC_3D_DIMENSION_5: return "5"; 840 case MALI_ASTC_3D_DIMENSION_6: return "6"; 841 case MALI_ASTC_3D_DIMENSION_3: return "3"; 842 default: return "XXX: INVALID"; 843 } 844} 845 846enum mali_pixel_kill { 847 MALI_PIXEL_KILL_FORCE_EARLY = 0, 848 MALI_PIXEL_KILL_STRONG_EARLY = 1, 849 MALI_PIXEL_KILL_WEAK_EARLY = 2, 850 MALI_PIXEL_KILL_FORCE_LATE = 3, 851}; 852 853static inline const char * 854mali_pixel_kill_as_str(enum mali_pixel_kill imm) 855{ 856 switch (imm) { 857 case MALI_PIXEL_KILL_FORCE_EARLY: return "Force Early"; 858 case MALI_PIXEL_KILL_STRONG_EARLY: return "Strong Early"; 859 case MALI_PIXEL_KILL_WEAK_EARLY: return "Weak Early"; 860 case MALI_PIXEL_KILL_FORCE_LATE: return "Force Late"; 861 default: return "XXX: INVALID"; 862 } 863} 864 865enum mali_block_format { 866 MALI_BLOCK_FORMAT_TILED_U_INTERLEAVED = 0, 867 MALI_BLOCK_FORMAT_TILED_LINEAR = 1, 868 MALI_BLOCK_FORMAT_LINEAR = 2, 869 MALI_BLOCK_FORMAT_AFBC = 3, 870}; 871 872static inline const char * 873mali_block_format_as_str(enum mali_block_format imm) 874{ 875 switch (imm) { 876 case MALI_BLOCK_FORMAT_TILED_U_INTERLEAVED: return "Tiled U-Interleaved"; 877 case MALI_BLOCK_FORMAT_TILED_LINEAR: return "Tiled Linear"; 878 case MALI_BLOCK_FORMAT_LINEAR: return "Linear"; 879 case MALI_BLOCK_FORMAT_AFBC: return "AFBC"; 880 default: return "XXX: INVALID"; 881 } 882} 883 884enum mali_mipmap_mode { 885 MALI_MIPMAP_MODE_NEAREST = 0, 886 MALI_MIPMAP_MODE_NONE = 1, 887 MALI_MIPMAP_MODE_TRILINEAR = 3, 888}; 889 890static inline const char * 891mali_mipmap_mode_as_str(enum mali_mipmap_mode imm) 892{ 893 switch (imm) { 894 case MALI_MIPMAP_MODE_NEAREST: return "Nearest"; 895 case MALI_MIPMAP_MODE_NONE: return "None"; 896 case MALI_MIPMAP_MODE_TRILINEAR: return "Trilinear"; 897 default: return "XXX: INVALID"; 898 } 899} 900 901enum mali_lod_algorithm { 902 MALI_LOD_ALGORITHM_ISOTROPIC = 0, 903 MALI_LOD_ALGORITHM_ANISOTROPIC = 3, 904}; 905 906static inline const char * 907mali_lod_algorithm_as_str(enum mali_lod_algorithm imm) 908{ 909 switch (imm) { 910 case MALI_LOD_ALGORITHM_ISOTROPIC: return "Isotropic"; 911 case MALI_LOD_ALGORITHM_ANISOTROPIC: return "Anisotropic"; 912 default: return "XXX: INVALID"; 913 } 914} 915 916enum mali_msaa { 917 MALI_MSAA_SINGLE = 0, 918 MALI_MSAA_AVERAGE = 1, 919 MALI_MSAA_MULTIPLE = 2, 920 MALI_MSAA_LAYERED = 3, 921}; 922 923static inline const char * 924mali_msaa_as_str(enum mali_msaa imm) 925{ 926 switch (imm) { 927 case MALI_MSAA_SINGLE: return "Single"; 928 case MALI_MSAA_AVERAGE: return "Average"; 929 case MALI_MSAA_MULTIPLE: return "Multiple"; 930 case MALI_MSAA_LAYERED: return "Layered"; 931 default: return "XXX: INVALID"; 932 } 933} 934 935enum mali_index_type { 936 MALI_INDEX_TYPE_NONE = 0, 937 MALI_INDEX_TYPE_UINT8 = 1, 938 MALI_INDEX_TYPE_UINT16 = 2, 939 MALI_INDEX_TYPE_UINT32 = 3, 940}; 941 942static inline const char * 943mali_index_type_as_str(enum mali_index_type imm) 944{ 945 switch (imm) { 946 case MALI_INDEX_TYPE_NONE: return "None"; 947 case MALI_INDEX_TYPE_UINT8: return "UINT8"; 948 case MALI_INDEX_TYPE_UINT16: return "UINT16"; 949 case MALI_INDEX_TYPE_UINT32: return "UINT32"; 950 default: return "XXX: INVALID"; 951 } 952} 953 954enum mali_occlusion_mode { 955 MALI_OCCLUSION_MODE_DISABLED = 0, 956 MALI_OCCLUSION_MODE_PREDICATE = 1, 957 MALI_OCCLUSION_MODE_COUNTER = 3, 958}; 959 960static inline const char * 961mali_occlusion_mode_as_str(enum mali_occlusion_mode imm) 962{ 963 switch (imm) { 964 case MALI_OCCLUSION_MODE_DISABLED: return "Disabled"; 965 case MALI_OCCLUSION_MODE_PREDICATE: return "Predicate"; 966 case MALI_OCCLUSION_MODE_COUNTER: return "Counter"; 967 default: return "XXX: INVALID"; 968 } 969} 970 971enum mali_stencil_op { 972 MALI_STENCIL_OP_KEEP = 0, 973 MALI_STENCIL_OP_REPLACE = 1, 974 MALI_STENCIL_OP_ZERO = 2, 975 MALI_STENCIL_OP_INVERT = 3, 976 MALI_STENCIL_OP_INCR_WRAP = 4, 977 MALI_STENCIL_OP_DECR_WRAP = 5, 978 MALI_STENCIL_OP_INCR_SAT = 6, 979 MALI_STENCIL_OP_DECR_SAT = 7, 980}; 981 982static inline const char * 983mali_stencil_op_as_str(enum mali_stencil_op imm) 984{ 985 switch (imm) { 986 case MALI_STENCIL_OP_KEEP: return "Keep"; 987 case MALI_STENCIL_OP_REPLACE: return "Replace"; 988 case MALI_STENCIL_OP_ZERO: return "Zero"; 989 case MALI_STENCIL_OP_INVERT: return "Invert"; 990 case MALI_STENCIL_OP_INCR_WRAP: return "Incr Wrap"; 991 case MALI_STENCIL_OP_DECR_WRAP: return "Decr Wrap"; 992 case MALI_STENCIL_OP_INCR_SAT: return "Incr Sat"; 993 case MALI_STENCIL_OP_DECR_SAT: return "Decr Sat"; 994 default: return "XXX: INVALID"; 995 } 996} 997 998enum mali_texture_dimension { 999 MALI_TEXTURE_DIMENSION_CUBE = 0, 1000 MALI_TEXTURE_DIMENSION_1D = 1, 1001 MALI_TEXTURE_DIMENSION_2D = 2, 1002 MALI_TEXTURE_DIMENSION_3D = 3, 1003}; 1004 1005static inline const char * 1006mali_texture_dimension_as_str(enum mali_texture_dimension imm) 1007{ 1008 switch (imm) { 1009 case MALI_TEXTURE_DIMENSION_CUBE: return "Cube"; 1010 case MALI_TEXTURE_DIMENSION_1D: return "1D"; 1011 case MALI_TEXTURE_DIMENSION_2D: return "2D"; 1012 case MALI_TEXTURE_DIMENSION_3D: return "3D"; 1013 default: return "XXX: INVALID"; 1014 } 1015} 1016 1017enum mali_texture_layout { 1018 MALI_TEXTURE_LAYOUT_TILED = 1, 1019 MALI_TEXTURE_LAYOUT_LINEAR = 2, 1020 MALI_TEXTURE_LAYOUT_AFBC = 12, 1021}; 1022 1023static inline const char * 1024mali_texture_layout_as_str(enum mali_texture_layout imm) 1025{ 1026 switch (imm) { 1027 case MALI_TEXTURE_LAYOUT_TILED: return "Tiled"; 1028 case MALI_TEXTURE_LAYOUT_LINEAR: return "Linear"; 1029 case MALI_TEXTURE_LAYOUT_AFBC: return "AFBC"; 1030 default: return "XXX: INVALID"; 1031 } 1032} 1033 1034enum mali_afbc_surface_flag { 1035 MALI_AFBC_SURFACE_FLAG_YTR = 1, 1036 MALI_AFBC_SURFACE_FLAG_SPLIT_BLOCK = 2, 1037 MALI_AFBC_SURFACE_FLAG_WIDE_BLOCK = 4, 1038 MALI_AFBC_SURFACE_FLAG_TILED_HEADER = 8, 1039 MALI_AFBC_SURFACE_FLAG_PREFETCH = 16, 1040 MALI_AFBC_SURFACE_FLAG_CHECK_PAYLOAD_RANGE = 32, 1041}; 1042 1043static inline const char * 1044mali_afbc_surface_flag_as_str(enum mali_afbc_surface_flag imm) 1045{ 1046 switch (imm) { 1047 case MALI_AFBC_SURFACE_FLAG_YTR: return "YTR"; 1048 case MALI_AFBC_SURFACE_FLAG_SPLIT_BLOCK: return "Split Block"; 1049 case MALI_AFBC_SURFACE_FLAG_WIDE_BLOCK: return "Wide Block"; 1050 case MALI_AFBC_SURFACE_FLAG_TILED_HEADER: return "Tiled Header"; 1051 case MALI_AFBC_SURFACE_FLAG_PREFETCH: return "Prefetch"; 1052 case MALI_AFBC_SURFACE_FLAG_CHECK_PAYLOAD_RANGE: return "Check Payload Range"; 1053 default: return "XXX: INVALID"; 1054 } 1055} 1056 1057enum mali_wrap_mode { 1058 MALI_WRAP_MODE_REPEAT = 8, 1059 MALI_WRAP_MODE_CLAMP_TO_EDGE = 9, 1060 MALI_WRAP_MODE_CLAMP_TO_BORDER = 11, 1061 MALI_WRAP_MODE_MIRRORED_REPEAT = 12, 1062 MALI_WRAP_MODE_MIRRORED_CLAMP_TO_EDGE = 13, 1063 MALI_WRAP_MODE_MIRRORED_CLAMP_TO_BORDER = 15, 1064}; 1065 1066static inline const char * 1067mali_wrap_mode_as_str(enum mali_wrap_mode imm) 1068{ 1069 switch (imm) { 1070 case MALI_WRAP_MODE_REPEAT: return "Repeat"; 1071 case MALI_WRAP_MODE_CLAMP_TO_EDGE: return "Clamp to Edge"; 1072 case MALI_WRAP_MODE_CLAMP_TO_BORDER: return "Clamp to Border"; 1073 case MALI_WRAP_MODE_MIRRORED_REPEAT: return "Mirrored Repeat"; 1074 case MALI_WRAP_MODE_MIRRORED_CLAMP_TO_EDGE: return "Mirrored Clamp to Edge"; 1075 case MALI_WRAP_MODE_MIRRORED_CLAMP_TO_BORDER: return "Mirrored Clamp to Border"; 1076 default: return "XXX: INVALID"; 1077 } 1078} 1079 1080struct MALI_ATTRIBUTE { 1081 uint32_t buffer_index; 1082 bool offset_enable; 1083 uint32_t format; 1084 int32_t offset; 1085}; 1086 1087#define MALI_ATTRIBUTE_header \ 1088 .offset_enable = true 1089 1090static inline void 1091MALI_ATTRIBUTE_pack(uint32_t * restrict cl, 1092 const struct MALI_ATTRIBUTE * restrict values) 1093{ 1094 cl[ 0] = __gen_uint(values->buffer_index, 0, 8) | 1095 __gen_uint(values->offset_enable, 9, 9) | 1096 __gen_uint(values->format, 10, 31); 1097 cl[ 1] = __gen_sint(values->offset, 0, 31); 1098} 1099 1100 1101#define MALI_ATTRIBUTE_LENGTH 8 1102#define MALI_ATTRIBUTE_ALIGN 8 1103struct mali_attribute_packed { uint32_t opaque[2]; }; 1104static inline void 1105MALI_ATTRIBUTE_unpack(const uint8_t * restrict cl, 1106 struct MALI_ATTRIBUTE * restrict values) 1107{ 1108 values->buffer_index = __gen_unpack_uint(cl, 0, 8); 1109 values->offset_enable = __gen_unpack_uint(cl, 9, 9); 1110 values->format = __gen_unpack_uint(cl, 10, 31); 1111 values->offset = __gen_unpack_sint(cl, 32, 63); 1112} 1113 1114static inline void 1115MALI_ATTRIBUTE_print(FILE *fp, const struct MALI_ATTRIBUTE * values, unsigned indent) 1116{ 1117 fprintf(fp, "%*sBuffer index: %u\n", indent, "", values->buffer_index); 1118 fprintf(fp, "%*sOffset enable: %s\n", indent, "", values->offset_enable ? "true" : "false"); 1119 mali_pixel_format_print(fp, values->format); 1120 fprintf(fp, "%*sOffset: %d\n", indent, "", values->offset); 1121} 1122 1123struct MALI_ATTRIBUTE_BUFFER { 1124 enum mali_attribute_type type; 1125 uint64_t pointer; 1126 uint32_t stride; 1127 uint32_t size; 1128 uint32_t divisor; 1129 uint32_t divisor_r; 1130 uint32_t divisor_p; 1131 uint32_t divisor_e; 1132}; 1133 1134#define MALI_ATTRIBUTE_BUFFER_header \ 1135 .type = MALI_ATTRIBUTE_TYPE_1D, \ 1136 .divisor = 1 1137 1138static inline void 1139MALI_ATTRIBUTE_BUFFER_pack(uint32_t * restrict cl, 1140 const struct MALI_ATTRIBUTE_BUFFER * restrict values) 1141{ 1142 assert((values->pointer & 0x3f) == 0); 1143 cl[ 0] = __gen_uint(values->type, 0, 5) | 1144 __gen_uint(values->pointer >> 6, 6, 55); 1145 cl[ 1] = __gen_uint(values->pointer >> 6, 6, 55) >> 32 | 1146 __gen_padded(values->divisor, 24, 31) | 1147 __gen_uint(values->divisor_r, 24, 28) | 1148 __gen_uint(values->divisor_p, 29, 31) | 1149 __gen_uint(values->divisor_e, 29, 29); 1150 cl[ 2] = __gen_uint(values->stride, 0, 31); 1151 cl[ 3] = __gen_uint(values->size, 0, 31); 1152} 1153 1154 1155#define MALI_ATTRIBUTE_BUFFER_LENGTH 16 1156#define MALI_ATTRIBUTE_BUFFER_ALIGN 32 1157struct mali_attribute_buffer_packed { uint32_t opaque[4]; }; 1158static inline void 1159MALI_ATTRIBUTE_BUFFER_unpack(const uint8_t * restrict cl, 1160 struct MALI_ATTRIBUTE_BUFFER * restrict values) 1161{ 1162 values->type = (enum mali_attribute_type)__gen_unpack_uint(cl, 0, 5); 1163 values->pointer = __gen_unpack_uint(cl, 6, 55) << 6; 1164 values->stride = __gen_unpack_uint(cl, 64, 95); 1165 values->size = __gen_unpack_uint(cl, 96, 127); 1166 values->divisor = __gen_unpack_padded(cl, 56, 63); 1167 values->divisor_r = __gen_unpack_uint(cl, 56, 60); 1168 values->divisor_p = __gen_unpack_uint(cl, 61, 63); 1169 values->divisor_e = __gen_unpack_uint(cl, 61, 61); 1170} 1171 1172static inline void 1173MALI_ATTRIBUTE_BUFFER_print(FILE *fp, const struct MALI_ATTRIBUTE_BUFFER * values, unsigned indent) 1174{ 1175 fprintf(fp, "%*sType: %s\n", indent, "", mali_attribute_type_as_str(values->type)); 1176 fprintf(fp, "%*sPointer: 0x%" PRIx64 "\n", indent, "", values->pointer); 1177 fprintf(fp, "%*sStride: %u\n", indent, "", values->stride); 1178 fprintf(fp, "%*sSize: %u\n", indent, "", values->size); 1179 fprintf(fp, "%*sDivisor: %u\n", indent, "", values->divisor); 1180 fprintf(fp, "%*sDivisor R: %u\n", indent, "", values->divisor_r); 1181 fprintf(fp, "%*sDivisor P: %u\n", indent, "", values->divisor_p); 1182 fprintf(fp, "%*sDivisor E: %u\n", indent, "", values->divisor_e); 1183} 1184 1185struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT { 1186 enum mali_attribute_type type; 1187 uint32_t divisor_numerator; 1188 uint32_t divisor; 1189}; 1190 1191#define MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_header\ 1192 .type = MALI_ATTRIBUTE_TYPE_CONTINUATION 1193 1194static inline void 1195MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_pack(uint32_t * restrict cl, 1196 const struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT * restrict values) 1197{ 1198 cl[ 0] = __gen_uint(values->type, 0, 5); 1199 cl[ 1] = __gen_uint(values->divisor_numerator, 0, 31); 1200 cl[ 2] = 0; 1201 cl[ 3] = __gen_uint(values->divisor, 0, 31); 1202} 1203 1204 1205#define MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_LENGTH 16 1206struct mali_attribute_buffer_continuation_npot_packed { uint32_t opaque[4]; }; 1207static inline void 1208MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_unpack(const uint8_t * restrict cl, 1209 struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT * restrict values) 1210{ 1211 if (((const uint32_t *) cl)[0] & 0xffffffc0) fprintf(stderr, "XXX: Invalid field of Attribute Buffer Continuation NPOT unpacked at word 0\n"); 1212 if (((const uint32_t *) cl)[2] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Attribute Buffer Continuation NPOT unpacked at word 2\n"); 1213 values->type = (enum mali_attribute_type)__gen_unpack_uint(cl, 0, 5); 1214 values->divisor_numerator = __gen_unpack_uint(cl, 32, 63); 1215 values->divisor = __gen_unpack_uint(cl, 96, 127); 1216} 1217 1218static inline void 1219MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_print(FILE *fp, const struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT * values, unsigned indent) 1220{ 1221 fprintf(fp, "%*sType: %s\n", indent, "", mali_attribute_type_as_str(values->type)); 1222 fprintf(fp, "%*sDivisor Numerator: %u\n", indent, "", values->divisor_numerator); 1223 fprintf(fp, "%*sDivisor: %u\n", indent, "", values->divisor); 1224} 1225 1226struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D { 1227 enum mali_attribute_type type; 1228 uint32_t s_dimension; 1229 uint32_t t_dimension; 1230 uint32_t r_dimension; 1231 uint32_t row_stride; 1232 uint32_t slice_stride; 1233}; 1234 1235#define MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D_header\ 1236 .type = MALI_ATTRIBUTE_TYPE_CONTINUATION 1237 1238static inline void 1239MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D_pack(uint32_t * restrict cl, 1240 const struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D * restrict values) 1241{ 1242 assert(values->s_dimension >= 1); 1243 assert(values->t_dimension >= 1); 1244 assert(values->r_dimension >= 1); 1245 cl[ 0] = __gen_uint(values->type, 0, 5) | 1246 __gen_uint(values->s_dimension - 1, 16, 31); 1247 cl[ 1] = __gen_uint(values->t_dimension - 1, 0, 15) | 1248 __gen_uint(values->r_dimension - 1, 16, 31); 1249 cl[ 2] = __gen_uint(values->row_stride, 0, 31); 1250 cl[ 3] = __gen_uint(values->slice_stride, 0, 31); 1251} 1252 1253 1254#define MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D_LENGTH 16 1255struct mali_attribute_buffer_continuation_3d_packed { uint32_t opaque[4]; }; 1256static inline void 1257MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D_unpack(const uint8_t * restrict cl, 1258 struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D * restrict values) 1259{ 1260 if (((const uint32_t *) cl)[0] & 0xffc0) fprintf(stderr, "XXX: Invalid field of Attribute Buffer Continuation 3D unpacked at word 0\n"); 1261 values->type = (enum mali_attribute_type)__gen_unpack_uint(cl, 0, 5); 1262 values->s_dimension = __gen_unpack_uint(cl, 16, 31) + 1; 1263 values->t_dimension = __gen_unpack_uint(cl, 32, 47) + 1; 1264 values->r_dimension = __gen_unpack_uint(cl, 48, 63) + 1; 1265 values->row_stride = __gen_unpack_uint(cl, 64, 95); 1266 values->slice_stride = __gen_unpack_uint(cl, 96, 127); 1267} 1268 1269static inline void 1270MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D_print(FILE *fp, const struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D * values, unsigned indent) 1271{ 1272 fprintf(fp, "%*sType: %s\n", indent, "", mali_attribute_type_as_str(values->type)); 1273 fprintf(fp, "%*sS dimension: %u\n", indent, "", values->s_dimension); 1274 fprintf(fp, "%*sT dimension: %u\n", indent, "", values->t_dimension); 1275 fprintf(fp, "%*sR dimension: %u\n", indent, "", values->r_dimension); 1276 fprintf(fp, "%*sRow Stride: %u\n", indent, "", values->row_stride); 1277 fprintf(fp, "%*sSlice Stride: %u\n", indent, "", values->slice_stride); 1278} 1279 1280enum mali_blend_operand_a { 1281 MALI_BLEND_OPERAND_A_ZERO = 1, 1282 MALI_BLEND_OPERAND_A_SRC = 2, 1283 MALI_BLEND_OPERAND_A_DEST = 3, 1284}; 1285 1286static inline const char * 1287mali_blend_operand_a_as_str(enum mali_blend_operand_a imm) 1288{ 1289 switch (imm) { 1290 case MALI_BLEND_OPERAND_A_ZERO: return "Zero"; 1291 case MALI_BLEND_OPERAND_A_SRC: return "Src"; 1292 case MALI_BLEND_OPERAND_A_DEST: return "Dest"; 1293 default: return "XXX: INVALID"; 1294 } 1295} 1296 1297enum mali_blend_operand_b { 1298 MALI_BLEND_OPERAND_B_SRC_MINUS_DEST = 0, 1299 MALI_BLEND_OPERAND_B_SRC_PLUS_DEST = 1, 1300 MALI_BLEND_OPERAND_B_SRC = 2, 1301 MALI_BLEND_OPERAND_B_DEST = 3, 1302}; 1303 1304static inline const char * 1305mali_blend_operand_b_as_str(enum mali_blend_operand_b imm) 1306{ 1307 switch (imm) { 1308 case MALI_BLEND_OPERAND_B_SRC_MINUS_DEST: return "Src Minus Dest"; 1309 case MALI_BLEND_OPERAND_B_SRC_PLUS_DEST: return "Src Plus Dest"; 1310 case MALI_BLEND_OPERAND_B_SRC: return "Src"; 1311 case MALI_BLEND_OPERAND_B_DEST: return "Dest"; 1312 default: return "XXX: INVALID"; 1313 } 1314} 1315 1316enum mali_blend_operand_c { 1317 MALI_BLEND_OPERAND_C_ZERO = 1, 1318 MALI_BLEND_OPERAND_C_SRC = 2, 1319 MALI_BLEND_OPERAND_C_DEST = 3, 1320 MALI_BLEND_OPERAND_C_SRC_X_2 = 4, 1321 MALI_BLEND_OPERAND_C_SRC_ALPHA = 5, 1322 MALI_BLEND_OPERAND_C_DEST_ALPHA = 6, 1323 MALI_BLEND_OPERAND_C_CONSTANT = 7, 1324}; 1325 1326static inline const char * 1327mali_blend_operand_c_as_str(enum mali_blend_operand_c imm) 1328{ 1329 switch (imm) { 1330 case MALI_BLEND_OPERAND_C_ZERO: return "Zero"; 1331 case MALI_BLEND_OPERAND_C_SRC: return "Src"; 1332 case MALI_BLEND_OPERAND_C_DEST: return "Dest"; 1333 case MALI_BLEND_OPERAND_C_SRC_X_2: return "Src x 2"; 1334 case MALI_BLEND_OPERAND_C_SRC_ALPHA: return "Src Alpha"; 1335 case MALI_BLEND_OPERAND_C_DEST_ALPHA: return "Dest Alpha"; 1336 case MALI_BLEND_OPERAND_C_CONSTANT: return "Constant"; 1337 default: return "XXX: INVALID"; 1338 } 1339} 1340 1341struct MALI_BLEND_FUNCTION { 1342 enum mali_blend_operand_a a; 1343 bool negate_a; 1344 enum mali_blend_operand_b b; 1345 bool negate_b; 1346 enum mali_blend_operand_c c; 1347 bool invert_c; 1348}; 1349 1350#define MALI_BLEND_FUNCTION_header \ 1351 0 1352 1353static inline void 1354MALI_BLEND_FUNCTION_print(FILE *fp, const struct MALI_BLEND_FUNCTION * values, unsigned indent) 1355{ 1356 fprintf(fp, "%*sA: %s\n", indent, "", mali_blend_operand_a_as_str(values->a)); 1357 fprintf(fp, "%*sNegate A: %s\n", indent, "", values->negate_a ? "true" : "false"); 1358 fprintf(fp, "%*sB: %s\n", indent, "", mali_blend_operand_b_as_str(values->b)); 1359 fprintf(fp, "%*sNegate B: %s\n", indent, "", values->negate_b ? "true" : "false"); 1360 fprintf(fp, "%*sC: %s\n", indent, "", mali_blend_operand_c_as_str(values->c)); 1361 fprintf(fp, "%*sInvert C: %s\n", indent, "", values->invert_c ? "true" : "false"); 1362} 1363 1364struct MALI_BLEND_EQUATION { 1365 struct MALI_BLEND_FUNCTION rgb; 1366 struct MALI_BLEND_FUNCTION alpha; 1367 uint32_t color_mask; 1368}; 1369 1370#define MALI_BLEND_EQUATION_header \ 1371 .rgb = { MALI_BLEND_FUNCTION_header }, \ 1372 .alpha = { MALI_BLEND_FUNCTION_header } 1373 1374static inline void 1375MALI_BLEND_EQUATION_pack(uint32_t * restrict cl, 1376 const struct MALI_BLEND_EQUATION * restrict values) 1377{ 1378 cl[ 0] = __gen_uint(values->rgb.a, 0, 1) | 1379 __gen_uint(values->rgb.negate_a, 3, 3) | 1380 __gen_uint(values->rgb.b, 4, 5) | 1381 __gen_uint(values->rgb.negate_b, 7, 7) | 1382 __gen_uint(values->rgb.c, 8, 10) | 1383 __gen_uint(values->rgb.invert_c, 11, 11) | 1384 __gen_uint(values->alpha.a, 12, 13) | 1385 __gen_uint(values->alpha.negate_a, 15, 15) | 1386 __gen_uint(values->alpha.b, 16, 17) | 1387 __gen_uint(values->alpha.negate_b, 19, 19) | 1388 __gen_uint(values->alpha.c, 20, 22) | 1389 __gen_uint(values->alpha.invert_c, 23, 23) | 1390 __gen_uint(values->color_mask, 28, 31); 1391} 1392 1393 1394#define MALI_BLEND_EQUATION_LENGTH 4 1395struct mali_blend_equation_packed { uint32_t opaque[1]; }; 1396static inline void 1397MALI_BLEND_EQUATION_unpack(const uint8_t * restrict cl, 1398 struct MALI_BLEND_EQUATION * restrict values) 1399{ 1400 if (((const uint32_t *) cl)[0] & 0xf044044) fprintf(stderr, "XXX: Invalid field of Blend Equation unpacked at word 0\n"); 1401 values->rgb.a = (enum mali_blend_operand_a)__gen_unpack_uint(cl, 0, 1); 1402 values->rgb.negate_a = __gen_unpack_uint(cl, 3, 3); 1403 values->rgb.b = (enum mali_blend_operand_b)__gen_unpack_uint(cl, 4, 5); 1404 values->rgb.negate_b = __gen_unpack_uint(cl, 7, 7); 1405 values->rgb.c = (enum mali_blend_operand_c)__gen_unpack_uint(cl, 8, 10); 1406 values->rgb.invert_c = __gen_unpack_uint(cl, 11, 11); 1407 values->alpha.a = (enum mali_blend_operand_a)__gen_unpack_uint(cl, 12, 13); 1408 values->alpha.negate_a = __gen_unpack_uint(cl, 15, 15); 1409 values->alpha.b = (enum mali_blend_operand_b)__gen_unpack_uint(cl, 16, 17); 1410 values->alpha.negate_b = __gen_unpack_uint(cl, 19, 19); 1411 values->alpha.c = (enum mali_blend_operand_c)__gen_unpack_uint(cl, 20, 22); 1412 values->alpha.invert_c = __gen_unpack_uint(cl, 23, 23); 1413 values->color_mask = __gen_unpack_uint(cl, 28, 31); 1414} 1415 1416static inline void 1417MALI_BLEND_EQUATION_print(FILE *fp, const struct MALI_BLEND_EQUATION * values, unsigned indent) 1418{ 1419 fprintf(fp, "%*sRGB:\n", indent, ""); 1420 MALI_BLEND_FUNCTION_print(fp, &values->rgb, indent + 2); 1421 fprintf(fp, "%*sAlpha:\n", indent, ""); 1422 MALI_BLEND_FUNCTION_print(fp, &values->alpha, indent + 2); 1423 fprintf(fp, "%*sColor Mask: %u\n", indent, "", values->color_mask); 1424} 1425 1426enum mali_register_file_format { 1427 MALI_REGISTER_FILE_FORMAT_F16 = 0, 1428 MALI_REGISTER_FILE_FORMAT_F32 = 1, 1429 MALI_REGISTER_FILE_FORMAT_I32 = 2, 1430 MALI_REGISTER_FILE_FORMAT_U32 = 3, 1431 MALI_REGISTER_FILE_FORMAT_I16 = 4, 1432 MALI_REGISTER_FILE_FORMAT_U16 = 5, 1433}; 1434 1435static inline const char * 1436mali_register_file_format_as_str(enum mali_register_file_format imm) 1437{ 1438 switch (imm) { 1439 case MALI_REGISTER_FILE_FORMAT_F16: return "F16"; 1440 case MALI_REGISTER_FILE_FORMAT_F32: return "F32"; 1441 case MALI_REGISTER_FILE_FORMAT_I32: return "I32"; 1442 case MALI_REGISTER_FILE_FORMAT_U32: return "U32"; 1443 case MALI_REGISTER_FILE_FORMAT_I16: return "I16"; 1444 case MALI_REGISTER_FILE_FORMAT_U16: return "U16"; 1445 default: return "XXX: INVALID"; 1446 } 1447} 1448 1449enum mali_message_type { 1450 MALI_MESSAGE_TYPE_DISABLED = 0, 1451 MALI_MESSAGE_TYPE_LD_VAR = 1, 1452 MALI_MESSAGE_TYPE_VAR_TEX = 2, 1453}; 1454 1455static inline const char * 1456mali_message_type_as_str(enum mali_message_type imm) 1457{ 1458 switch (imm) { 1459 case MALI_MESSAGE_TYPE_DISABLED: return "Disabled"; 1460 case MALI_MESSAGE_TYPE_LD_VAR: return "LD_VAR"; 1461 case MALI_MESSAGE_TYPE_VAR_TEX: return "VAR_TEX"; 1462 default: return "XXX: INVALID"; 1463 } 1464} 1465 1466enum mali_message_preload_register_format { 1467 MALI_MESSAGE_PRELOAD_REGISTER_FORMAT_F32 = 0, 1468 MALI_MESSAGE_PRELOAD_REGISTER_FORMAT_F16 = 1, 1469}; 1470 1471static inline const char * 1472mali_message_preload_register_format_as_str(enum mali_message_preload_register_format imm) 1473{ 1474 switch (imm) { 1475 case MALI_MESSAGE_PRELOAD_REGISTER_FORMAT_F32: return "F32"; 1476 case MALI_MESSAGE_PRELOAD_REGISTER_FORMAT_F16: return "F16"; 1477 default: return "XXX: INVALID"; 1478 } 1479} 1480 1481enum mali_blend_mode { 1482 MALI_BLEND_MODE_SHADER = 0, 1483 MALI_BLEND_MODE_OPAQUE = 1, 1484 MALI_BLEND_MODE_FIXED_FUNCTION = 2, 1485 MALI_BLEND_MODE_OFF = 3, 1486}; 1487 1488static inline const char * 1489mali_blend_mode_as_str(enum mali_blend_mode imm) 1490{ 1491 switch (imm) { 1492 case MALI_BLEND_MODE_SHADER: return "Shader"; 1493 case MALI_BLEND_MODE_OPAQUE: return "Opaque"; 1494 case MALI_BLEND_MODE_FIXED_FUNCTION: return "Fixed-Function"; 1495 case MALI_BLEND_MODE_OFF: return "Off"; 1496 default: return "XXX: INVALID"; 1497 } 1498} 1499 1500struct MALI_BLEND_SHADER { 1501 uint32_t return_value; 1502 uint32_t pc; 1503}; 1504 1505#define MALI_BLEND_SHADER_header \ 1506 0 1507 1508static inline void 1509MALI_BLEND_SHADER_pack(uint32_t * restrict cl, 1510 const struct MALI_BLEND_SHADER * restrict values) 1511{ 1512 assert((values->return_value & 0x7) == 0); 1513 assert((values->pc & 0xf) == 0); 1514 cl[ 0] = __gen_uint(values->return_value >> 3, 3, 31); 1515 cl[ 1] = __gen_uint(values->pc >> 4, 4, 31); 1516} 1517 1518 1519#define MALI_BLEND_SHADER_LENGTH 8 1520struct mali_blend_shader_packed { uint32_t opaque[2]; }; 1521static inline void 1522MALI_BLEND_SHADER_unpack(const uint8_t * restrict cl, 1523 struct MALI_BLEND_SHADER * restrict values) 1524{ 1525 if (((const uint32_t *) cl)[0] & 0x7) fprintf(stderr, "XXX: Invalid field of Blend Shader unpacked at word 0\n"); 1526 if (((const uint32_t *) cl)[1] & 0xf) fprintf(stderr, "XXX: Invalid field of Blend Shader unpacked at word 1\n"); 1527 values->return_value = __gen_unpack_uint(cl, 3, 31) << 3; 1528 values->pc = __gen_unpack_uint(cl, 36, 63) << 4; 1529} 1530 1531static inline void 1532MALI_BLEND_SHADER_print(FILE *fp, const struct MALI_BLEND_SHADER * values, unsigned indent) 1533{ 1534 fprintf(fp, "%*sReturn Value: %u\n", indent, "", values->return_value); 1535 fprintf(fp, "%*sPC: %u\n", indent, "", values->pc); 1536} 1537 1538struct MALI_INTERNAL_CONVERSION { 1539 uint32_t memory_format; 1540 bool raw; 1541 enum mali_register_file_format register_format; 1542}; 1543 1544#define MALI_INTERNAL_CONVERSION_header \ 1545 0 1546 1547static inline void 1548MALI_INTERNAL_CONVERSION_pack(uint32_t * restrict cl, 1549 const struct MALI_INTERNAL_CONVERSION * restrict values) 1550{ 1551 cl[ 0] = __gen_uint(values->memory_format, 0, 21) | 1552 __gen_uint(values->raw, 22, 22) | 1553 __gen_uint(values->register_format, 24, 26); 1554} 1555 1556 1557#define MALI_INTERNAL_CONVERSION_LENGTH 4 1558struct mali_internal_conversion_packed { uint32_t opaque[1]; }; 1559static inline void 1560MALI_INTERNAL_CONVERSION_unpack(const uint8_t * restrict cl, 1561 struct MALI_INTERNAL_CONVERSION * restrict values) 1562{ 1563 if (((const uint32_t *) cl)[0] & 0xf8800000) fprintf(stderr, "XXX: Invalid field of Internal Conversion unpacked at word 0\n"); 1564 values->memory_format = __gen_unpack_uint(cl, 0, 21); 1565 values->raw = __gen_unpack_uint(cl, 22, 22); 1566 values->register_format = (enum mali_register_file_format)__gen_unpack_uint(cl, 24, 26); 1567} 1568 1569static inline void 1570MALI_INTERNAL_CONVERSION_print(FILE *fp, const struct MALI_INTERNAL_CONVERSION * values, unsigned indent) 1571{ 1572 mali_pixel_format_print(fp, values->memory_format); 1573 fprintf(fp, "%*sRaw: %s\n", indent, "", values->raw ? "true" : "false"); 1574 fprintf(fp, "%*sRegister Format: %s\n", indent, "", mali_register_file_format_as_str(values->register_format)); 1575} 1576 1577struct MALI_BLEND_FIXED_FUNCTION { 1578 uint32_t num_comps; 1579 bool alpha_zero_nop; 1580 bool alpha_one_store; 1581 uint32_t rt; 1582#define MALI_BIFROST_BLEND_MAX_RT 8 1583 struct MALI_INTERNAL_CONVERSION conversion; 1584}; 1585 1586#define MALI_BLEND_FIXED_FUNCTION_header \ 1587 .num_comps = 1, \ 1588 .conversion = { MALI_INTERNAL_CONVERSION_header } 1589 1590static inline void 1591MALI_BLEND_FIXED_FUNCTION_pack(uint32_t * restrict cl, 1592 const struct MALI_BLEND_FIXED_FUNCTION * restrict values) 1593{ 1594 assert(values->num_comps >= 1); 1595 cl[ 0] = __gen_uint(values->num_comps - 1, 3, 4) | 1596 __gen_uint(values->alpha_zero_nop, 5, 5) | 1597 __gen_uint(values->alpha_one_store, 6, 6) | 1598 __gen_uint(values->rt, 16, 19); 1599 cl[ 1] = __gen_uint(values->conversion.memory_format, 0, 21) | 1600 __gen_uint(values->conversion.raw, 22, 22) | 1601 __gen_uint(values->conversion.register_format, 24, 26); 1602} 1603 1604 1605#define MALI_BLEND_FIXED_FUNCTION_LENGTH 8 1606struct mali_blend_fixed_function_packed { uint32_t opaque[2]; }; 1607static inline void 1608MALI_BLEND_FIXED_FUNCTION_unpack(const uint8_t * restrict cl, 1609 struct MALI_BLEND_FIXED_FUNCTION * restrict values) 1610{ 1611 if (((const uint32_t *) cl)[0] & 0xfff0ff87) fprintf(stderr, "XXX: Invalid field of Blend Fixed-Function unpacked at word 0\n"); 1612 if (((const uint32_t *) cl)[1] & 0xf8800000) fprintf(stderr, "XXX: Invalid field of Blend Fixed-Function unpacked at word 1\n"); 1613 values->num_comps = __gen_unpack_uint(cl, 3, 4) + 1; 1614 values->alpha_zero_nop = __gen_unpack_uint(cl, 5, 5); 1615 values->alpha_one_store = __gen_unpack_uint(cl, 6, 6); 1616 values->rt = __gen_unpack_uint(cl, 16, 19); 1617 values->conversion.memory_format = __gen_unpack_uint(cl, 32, 53); 1618 values->conversion.raw = __gen_unpack_uint(cl, 54, 54); 1619 values->conversion.register_format = (enum mali_register_file_format)__gen_unpack_uint(cl, 56, 58); 1620} 1621 1622static inline void 1623MALI_BLEND_FIXED_FUNCTION_print(FILE *fp, const struct MALI_BLEND_FIXED_FUNCTION * values, unsigned indent) 1624{ 1625 fprintf(fp, "%*sNum Comps: %u\n", indent, "", values->num_comps); 1626 fprintf(fp, "%*sAlpha Zero NOP: %s\n", indent, "", values->alpha_zero_nop ? "true" : "false"); 1627 fprintf(fp, "%*sAlpha One Store: %s\n", indent, "", values->alpha_one_store ? "true" : "false"); 1628 fprintf(fp, "%*sRT: %u\n", indent, "", values->rt); 1629 fprintf(fp, "%*sConversion:\n", indent, ""); 1630 MALI_INTERNAL_CONVERSION_print(fp, &values->conversion, indent + 2); 1631} 1632 1633struct MALI_INTERNAL_BLEND { 1634 enum mali_blend_mode mode; 1635 struct MALI_BLEND_SHADER shader; 1636 struct MALI_BLEND_FIXED_FUNCTION fixed_function; 1637}; 1638 1639#define MALI_INTERNAL_BLEND_header \ 1640 .shader = { MALI_BLEND_SHADER_header }, \ 1641 .fixed_function = { MALI_BLEND_FIXED_FUNCTION_header } 1642 1643static inline void 1644MALI_INTERNAL_BLEND_pack(uint32_t * restrict cl, 1645 const struct MALI_INTERNAL_BLEND * restrict values) 1646{ 1647 cl[ 0] = __gen_uint(values->mode, 0, 1) | 1648 __gen_uint(values->shader.return_value >> 3, 3, 31) | 1649 __gen_uint(values->fixed_function.num_comps - 1, 3, 4) | 1650 __gen_uint(values->fixed_function.alpha_zero_nop, 5, 5) | 1651 __gen_uint(values->fixed_function.alpha_one_store, 6, 6) | 1652 __gen_uint(values->fixed_function.rt, 16, 19); 1653 cl[ 1] = __gen_uint(values->shader.pc >> 4, 4, 31) | 1654 __gen_uint(values->fixed_function.conversion.memory_format, 0, 21) | 1655 __gen_uint(values->fixed_function.conversion.raw, 22, 22) | 1656 __gen_uint(values->fixed_function.conversion.register_format, 24, 26); 1657} 1658 1659 1660#define MALI_INTERNAL_BLEND_LENGTH 8 1661struct mali_internal_blend_packed { uint32_t opaque[2]; }; 1662static inline void 1663MALI_INTERNAL_BLEND_unpack(const uint8_t * restrict cl, 1664 struct MALI_INTERNAL_BLEND * restrict values) 1665{ 1666 if (((const uint32_t *) cl)[0] & 0x4) fprintf(stderr, "XXX: Invalid field of Internal Blend unpacked at word 0\n"); 1667 values->mode = (enum mali_blend_mode)__gen_unpack_uint(cl, 0, 1); 1668 values->shader.return_value = __gen_unpack_uint(cl, 3, 31) << 3; 1669 values->shader.pc = __gen_unpack_uint(cl, 36, 63) << 4; 1670 values->fixed_function.num_comps = __gen_unpack_uint(cl, 3, 4) + 1; 1671 values->fixed_function.alpha_zero_nop = __gen_unpack_uint(cl, 5, 5); 1672 values->fixed_function.alpha_one_store = __gen_unpack_uint(cl, 6, 6); 1673 values->fixed_function.rt = __gen_unpack_uint(cl, 16, 19); 1674 values->fixed_function.conversion.memory_format = __gen_unpack_uint(cl, 32, 53); 1675 values->fixed_function.conversion.raw = __gen_unpack_uint(cl, 54, 54); 1676 values->fixed_function.conversion.register_format = (enum mali_register_file_format)__gen_unpack_uint(cl, 56, 58); 1677} 1678 1679static inline void 1680MALI_INTERNAL_BLEND_print(FILE *fp, const struct MALI_INTERNAL_BLEND * values, unsigned indent) 1681{ 1682 fprintf(fp, "%*sMode: %s\n", indent, "", mali_blend_mode_as_str(values->mode)); 1683 fprintf(fp, "%*sShader:\n", indent, ""); 1684 MALI_BLEND_SHADER_print(fp, &values->shader, indent + 2); 1685 fprintf(fp, "%*sFixed-Function:\n", indent, ""); 1686 MALI_BLEND_FIXED_FUNCTION_print(fp, &values->fixed_function, indent + 2); 1687} 1688 1689struct MALI_BLEND { 1690 bool load_destination; 1691 bool alpha_to_one; 1692 bool enable; 1693 bool srgb; 1694 bool round_to_fb_precision; 1695 uint32_t constant; 1696 struct MALI_BLEND_EQUATION equation; 1697 struct MALI_INTERNAL_BLEND internal; 1698}; 1699 1700#define MALI_BLEND_header \ 1701 .load_destination = false, \ 1702 .enable = true, \ 1703 .srgb = false, \ 1704 .round_to_fb_precision = false, \ 1705 .equation = { MALI_BLEND_EQUATION_header }, \ 1706 .internal = { MALI_INTERNAL_BLEND_header } 1707 1708static inline void 1709MALI_BLEND_pack(uint32_t * restrict cl, 1710 const struct MALI_BLEND * restrict values) 1711{ 1712 cl[ 0] = __gen_uint(values->load_destination, 0, 0) | 1713 __gen_uint(values->alpha_to_one, 8, 8) | 1714 __gen_uint(values->enable, 9, 9) | 1715 __gen_uint(values->srgb, 10, 10) | 1716 __gen_uint(values->round_to_fb_precision, 11, 11) | 1717 __gen_uint(values->constant, 16, 31); 1718 cl[ 1] = __gen_uint(values->equation.rgb.a, 0, 1) | 1719 __gen_uint(values->equation.rgb.negate_a, 3, 3) | 1720 __gen_uint(values->equation.rgb.b, 4, 5) | 1721 __gen_uint(values->equation.rgb.negate_b, 7, 7) | 1722 __gen_uint(values->equation.rgb.c, 8, 10) | 1723 __gen_uint(values->equation.rgb.invert_c, 11, 11) | 1724 __gen_uint(values->equation.alpha.a, 12, 13) | 1725 __gen_uint(values->equation.alpha.negate_a, 15, 15) | 1726 __gen_uint(values->equation.alpha.b, 16, 17) | 1727 __gen_uint(values->equation.alpha.negate_b, 19, 19) | 1728 __gen_uint(values->equation.alpha.c, 20, 22) | 1729 __gen_uint(values->equation.alpha.invert_c, 23, 23) | 1730 __gen_uint(values->equation.color_mask, 28, 31); 1731 cl[ 2] = __gen_uint(values->internal.mode, 0, 1) | 1732 __gen_uint(values->internal.shader.return_value >> 3, 3, 31) | 1733 __gen_uint(values->internal.fixed_function.num_comps - 1, 3, 4) | 1734 __gen_uint(values->internal.fixed_function.alpha_zero_nop, 5, 5) | 1735 __gen_uint(values->internal.fixed_function.alpha_one_store, 6, 6) | 1736 __gen_uint(values->internal.fixed_function.rt, 16, 19); 1737 cl[ 3] = __gen_uint(values->internal.shader.pc >> 4, 4, 31) | 1738 __gen_uint(values->internal.fixed_function.conversion.memory_format, 0, 21) | 1739 __gen_uint(values->internal.fixed_function.conversion.raw, 22, 22) | 1740 __gen_uint(values->internal.fixed_function.conversion.register_format, 24, 26); 1741} 1742 1743 1744#define MALI_BLEND_LENGTH 16 1745#define MALI_BLEND_ALIGN 16 1746struct mali_blend_packed { uint32_t opaque[4]; }; 1747static inline void 1748MALI_BLEND_unpack(const uint8_t * restrict cl, 1749 struct MALI_BLEND * restrict values) 1750{ 1751 if (((const uint32_t *) cl)[0] & 0xf0fe) fprintf(stderr, "XXX: Invalid field of Blend unpacked at word 0\n"); 1752 if (((const uint32_t *) cl)[1] & 0xf044044) fprintf(stderr, "XXX: Invalid field of Blend unpacked at word 1\n"); 1753 if (((const uint32_t *) cl)[2] & 0x4) fprintf(stderr, "XXX: Invalid field of Blend unpacked at word 2\n"); 1754 values->load_destination = __gen_unpack_uint(cl, 0, 0); 1755 values->alpha_to_one = __gen_unpack_uint(cl, 8, 8); 1756 values->enable = __gen_unpack_uint(cl, 9, 9); 1757 values->srgb = __gen_unpack_uint(cl, 10, 10); 1758 values->round_to_fb_precision = __gen_unpack_uint(cl, 11, 11); 1759 values->constant = __gen_unpack_uint(cl, 16, 31); 1760 values->equation.rgb.a = (enum mali_blend_operand_a)__gen_unpack_uint(cl, 32, 33); 1761 values->equation.rgb.negate_a = __gen_unpack_uint(cl, 35, 35); 1762 values->equation.rgb.b = (enum mali_blend_operand_b)__gen_unpack_uint(cl, 36, 37); 1763 values->equation.rgb.negate_b = __gen_unpack_uint(cl, 39, 39); 1764 values->equation.rgb.c = (enum mali_blend_operand_c)__gen_unpack_uint(cl, 40, 42); 1765 values->equation.rgb.invert_c = __gen_unpack_uint(cl, 43, 43); 1766 values->equation.alpha.a = (enum mali_blend_operand_a)__gen_unpack_uint(cl, 44, 45); 1767 values->equation.alpha.negate_a = __gen_unpack_uint(cl, 47, 47); 1768 values->equation.alpha.b = (enum mali_blend_operand_b)__gen_unpack_uint(cl, 48, 49); 1769 values->equation.alpha.negate_b = __gen_unpack_uint(cl, 51, 51); 1770 values->equation.alpha.c = (enum mali_blend_operand_c)__gen_unpack_uint(cl, 52, 54); 1771 values->equation.alpha.invert_c = __gen_unpack_uint(cl, 55, 55); 1772 values->equation.color_mask = __gen_unpack_uint(cl, 60, 63); 1773 values->internal.mode = (enum mali_blend_mode)__gen_unpack_uint(cl, 64, 65); 1774 values->internal.shader.return_value = __gen_unpack_uint(cl, 67, 95) << 3; 1775 values->internal.shader.pc = __gen_unpack_uint(cl, 100, 127) << 4; 1776 values->internal.fixed_function.num_comps = __gen_unpack_uint(cl, 67, 68) + 1; 1777 values->internal.fixed_function.alpha_zero_nop = __gen_unpack_uint(cl, 69, 69); 1778 values->internal.fixed_function.alpha_one_store = __gen_unpack_uint(cl, 70, 70); 1779 values->internal.fixed_function.rt = __gen_unpack_uint(cl, 80, 83); 1780 values->internal.fixed_function.conversion.memory_format = __gen_unpack_uint(cl, 96, 117); 1781 values->internal.fixed_function.conversion.raw = __gen_unpack_uint(cl, 118, 118); 1782 values->internal.fixed_function.conversion.register_format = (enum mali_register_file_format)__gen_unpack_uint(cl, 120, 122); 1783} 1784 1785static inline void 1786MALI_BLEND_print(FILE *fp, const struct MALI_BLEND * values, unsigned indent) 1787{ 1788 fprintf(fp, "%*sLoad Destination: %s\n", indent, "", values->load_destination ? "true" : "false"); 1789 fprintf(fp, "%*sAlpha To One: %s\n", indent, "", values->alpha_to_one ? "true" : "false"); 1790 fprintf(fp, "%*sEnable: %s\n", indent, "", values->enable ? "true" : "false"); 1791 fprintf(fp, "%*ssRGB: %s\n", indent, "", values->srgb ? "true" : "false"); 1792 fprintf(fp, "%*sRound to FB precision: %s\n", indent, "", values->round_to_fb_precision ? "true" : "false"); 1793 fprintf(fp, "%*sConstant: %u\n", indent, "", values->constant); 1794 fprintf(fp, "%*sEquation:\n", indent, ""); 1795 MALI_BLEND_EQUATION_print(fp, &values->equation, indent + 2); 1796 fprintf(fp, "%*sInternal:\n", indent, ""); 1797 MALI_INTERNAL_BLEND_print(fp, &values->internal, indent + 2); 1798} 1799 1800struct MALI_INVOCATION { 1801 uint32_t invocations; 1802 uint32_t size_y_shift; 1803 uint32_t size_z_shift; 1804 uint32_t workgroups_x_shift; 1805 uint32_t workgroups_y_shift; 1806 uint32_t workgroups_z_shift; 1807 uint32_t thread_group_split; 1808#define MALI_SPLIT_MIN_EFFICIENT 2 1809}; 1810 1811#define MALI_INVOCATION_header \ 1812 0 1813 1814static inline void 1815MALI_INVOCATION_pack(uint32_t * restrict cl, 1816 const struct MALI_INVOCATION * restrict values) 1817{ 1818 cl[ 0] = __gen_uint(values->invocations, 0, 31); 1819 cl[ 1] = __gen_uint(values->size_y_shift, 0, 4) | 1820 __gen_uint(values->size_z_shift, 5, 9) | 1821 __gen_uint(values->workgroups_x_shift, 10, 15) | 1822 __gen_uint(values->workgroups_y_shift, 16, 21) | 1823 __gen_uint(values->workgroups_z_shift, 22, 27) | 1824 __gen_uint(values->thread_group_split, 28, 31); 1825} 1826 1827 1828#define MALI_INVOCATION_LENGTH 8 1829struct mali_invocation_packed { uint32_t opaque[2]; }; 1830static inline void 1831MALI_INVOCATION_unpack(const uint8_t * restrict cl, 1832 struct MALI_INVOCATION * restrict values) 1833{ 1834 values->invocations = __gen_unpack_uint(cl, 0, 31); 1835 values->size_y_shift = __gen_unpack_uint(cl, 32, 36); 1836 values->size_z_shift = __gen_unpack_uint(cl, 37, 41); 1837 values->workgroups_x_shift = __gen_unpack_uint(cl, 42, 47); 1838 values->workgroups_y_shift = __gen_unpack_uint(cl, 48, 53); 1839 values->workgroups_z_shift = __gen_unpack_uint(cl, 54, 59); 1840 values->thread_group_split = __gen_unpack_uint(cl, 60, 63); 1841} 1842 1843static inline void 1844MALI_INVOCATION_print(FILE *fp, const struct MALI_INVOCATION * values, unsigned indent) 1845{ 1846 fprintf(fp, "%*sInvocations: %u\n", indent, "", values->invocations); 1847 fprintf(fp, "%*sSize Y shift: %u\n", indent, "", values->size_y_shift); 1848 fprintf(fp, "%*sSize Z shift: %u\n", indent, "", values->size_z_shift); 1849 fprintf(fp, "%*sWorkgroups X shift: %u\n", indent, "", values->workgroups_x_shift); 1850 fprintf(fp, "%*sWorkgroups Y shift: %u\n", indent, "", values->workgroups_y_shift); 1851 fprintf(fp, "%*sWorkgroups Z shift: %u\n", indent, "", values->workgroups_z_shift); 1852 fprintf(fp, "%*sThread group split: %u\n", indent, "", values->thread_group_split); 1853} 1854 1855enum mali_point_size_array_format { 1856 MALI_POINT_SIZE_ARRAY_FORMAT_NONE = 0, 1857 MALI_POINT_SIZE_ARRAY_FORMAT_FP16 = 2, 1858 MALI_POINT_SIZE_ARRAY_FORMAT_FP32 = 3, 1859}; 1860 1861static inline const char * 1862mali_point_size_array_format_as_str(enum mali_point_size_array_format imm) 1863{ 1864 switch (imm) { 1865 case MALI_POINT_SIZE_ARRAY_FORMAT_NONE: return "None"; 1866 case MALI_POINT_SIZE_ARRAY_FORMAT_FP16: return "FP16"; 1867 case MALI_POINT_SIZE_ARRAY_FORMAT_FP32: return "FP32"; 1868 default: return "XXX: INVALID"; 1869 } 1870} 1871 1872enum mali_primitive_restart { 1873 MALI_PRIMITIVE_RESTART_NONE = 0, 1874 MALI_PRIMITIVE_RESTART_IMPLICIT = 2, 1875 MALI_PRIMITIVE_RESTART_EXPLICIT = 3, 1876}; 1877 1878static inline const char * 1879mali_primitive_restart_as_str(enum mali_primitive_restart imm) 1880{ 1881 switch (imm) { 1882 case MALI_PRIMITIVE_RESTART_NONE: return "None"; 1883 case MALI_PRIMITIVE_RESTART_IMPLICIT: return "Implicit"; 1884 case MALI_PRIMITIVE_RESTART_EXPLICIT: return "Explicit"; 1885 default: return "XXX: INVALID"; 1886 } 1887} 1888 1889struct MALI_PRIMITIVE { 1890 enum mali_draw_mode draw_mode; 1891 enum mali_index_type index_type; 1892 enum mali_point_size_array_format point_size_array_format; 1893 bool primitive_index_enable; 1894 bool primitive_index_writeback; 1895 bool first_provoking_vertex; 1896 bool low_depth_cull; 1897 bool high_depth_cull; 1898 bool secondary_shader; 1899 enum mali_primitive_restart primitive_restart; 1900 uint32_t job_task_split; 1901 uint32_t base_vertex_offset; 1902 uint32_t primitive_restart_index; 1903 uint32_t index_count; 1904 uint64_t indices; 1905}; 1906 1907#define MALI_PRIMITIVE_header \ 1908 .draw_mode = MALI_DRAW_MODE_NONE, \ 1909 .index_type = MALI_INDEX_TYPE_NONE, \ 1910 .first_provoking_vertex = true, \ 1911 .low_depth_cull = true, \ 1912 .high_depth_cull = true 1913 1914static inline void 1915MALI_PRIMITIVE_pack(uint32_t * restrict cl, 1916 const struct MALI_PRIMITIVE * restrict values) 1917{ 1918 assert(values->index_count >= 1); 1919 cl[ 0] = __gen_uint(values->draw_mode, 0, 7) | 1920 __gen_uint(values->index_type, 8, 10) | 1921 __gen_uint(values->point_size_array_format, 11, 12) | 1922 __gen_uint(values->primitive_index_enable, 13, 13) | 1923 __gen_uint(values->primitive_index_writeback, 14, 14) | 1924 __gen_uint(values->first_provoking_vertex, 15, 15) | 1925 __gen_uint(values->low_depth_cull, 16, 16) | 1926 __gen_uint(values->high_depth_cull, 17, 17) | 1927 __gen_uint(values->secondary_shader, 18, 18) | 1928 __gen_uint(values->primitive_restart, 19, 20) | 1929 __gen_uint(values->job_task_split, 26, 31); 1930 cl[ 1] = __gen_uint(values->base_vertex_offset, 0, 31); 1931 cl[ 2] = __gen_uint(values->primitive_restart_index, 0, 31); 1932 cl[ 3] = __gen_uint(values->index_count - 1, 0, 31); 1933 cl[ 4] = __gen_uint(values->indices, 0, 63); 1934 cl[ 5] = __gen_uint(values->indices, 0, 63) >> 32; 1935} 1936 1937 1938#define MALI_PRIMITIVE_LENGTH 24 1939struct mali_primitive_packed { uint32_t opaque[6]; }; 1940static inline void 1941MALI_PRIMITIVE_unpack(const uint8_t * restrict cl, 1942 struct MALI_PRIMITIVE * restrict values) 1943{ 1944 if (((const uint32_t *) cl)[0] & 0x3e00000) fprintf(stderr, "XXX: Invalid field of Primitive unpacked at word 0\n"); 1945 values->draw_mode = (enum mali_draw_mode)__gen_unpack_uint(cl, 0, 7); 1946 values->index_type = (enum mali_index_type)__gen_unpack_uint(cl, 8, 10); 1947 values->point_size_array_format = (enum mali_point_size_array_format)__gen_unpack_uint(cl, 11, 12); 1948 values->primitive_index_enable = __gen_unpack_uint(cl, 13, 13); 1949 values->primitive_index_writeback = __gen_unpack_uint(cl, 14, 14); 1950 values->first_provoking_vertex = __gen_unpack_uint(cl, 15, 15); 1951 values->low_depth_cull = __gen_unpack_uint(cl, 16, 16); 1952 values->high_depth_cull = __gen_unpack_uint(cl, 17, 17); 1953 values->secondary_shader = __gen_unpack_uint(cl, 18, 18); 1954 values->primitive_restart = (enum mali_primitive_restart)__gen_unpack_uint(cl, 19, 20); 1955 values->job_task_split = __gen_unpack_uint(cl, 26, 31); 1956 values->base_vertex_offset = __gen_unpack_uint(cl, 32, 63); 1957 values->primitive_restart_index = __gen_unpack_uint(cl, 64, 95); 1958 values->index_count = __gen_unpack_uint(cl, 96, 127) + 1; 1959 values->indices = __gen_unpack_uint(cl, 128, 191); 1960} 1961 1962static inline void 1963MALI_PRIMITIVE_print(FILE *fp, const struct MALI_PRIMITIVE * values, unsigned indent) 1964{ 1965 fprintf(fp, "%*sDraw mode: %s\n", indent, "", mali_draw_mode_as_str(values->draw_mode)); 1966 fprintf(fp, "%*sIndex type: %s\n", indent, "", mali_index_type_as_str(values->index_type)); 1967 fprintf(fp, "%*sPoint size array format: %s\n", indent, "", mali_point_size_array_format_as_str(values->point_size_array_format)); 1968 fprintf(fp, "%*sPrimitive Index Enable: %s\n", indent, "", values->primitive_index_enable ? "true" : "false"); 1969 fprintf(fp, "%*sPrimitive Index Writeback: %s\n", indent, "", values->primitive_index_writeback ? "true" : "false"); 1970 fprintf(fp, "%*sFirst provoking vertex: %s\n", indent, "", values->first_provoking_vertex ? "true" : "false"); 1971 fprintf(fp, "%*sLow Depth Cull: %s\n", indent, "", values->low_depth_cull ? "true" : "false"); 1972 fprintf(fp, "%*sHigh Depth Cull: %s\n", indent, "", values->high_depth_cull ? "true" : "false"); 1973 fprintf(fp, "%*sSecondary Shader: %s\n", indent, "", values->secondary_shader ? "true" : "false"); 1974 fprintf(fp, "%*sPrimitive restart: %s\n", indent, "", mali_primitive_restart_as_str(values->primitive_restart)); 1975 fprintf(fp, "%*sJob Task Split: %u\n", indent, "", values->job_task_split); 1976 fprintf(fp, "%*sBase vertex offset: %u\n", indent, "", values->base_vertex_offset); 1977 fprintf(fp, "%*sPrimitive Restart Index: %u\n", indent, "", values->primitive_restart_index); 1978 fprintf(fp, "%*sIndex count: %u\n", indent, "", values->index_count); 1979 fprintf(fp, "%*sIndices: 0x%" PRIx64 "\n", indent, "", values->indices); 1980} 1981 1982struct MALI_DRAW { 1983 bool four_components_per_vertex; 1984 bool draw_descriptor_is_64b; 1985 enum mali_occlusion_mode occlusion_query; 1986 bool front_face_ccw; 1987 bool cull_front_face; 1988 bool cull_back_face; 1989 uint32_t flat_shading_vertex; 1990 bool exclude_filtered_perf_counters; 1991 bool primitive_barrier; 1992 bool clean_fragment_write; 1993 uint32_t instance_size; 1994 uint32_t instance_primitive_size; 1995 uint32_t offset_start; 1996 uint32_t primitive_index_base; 1997 uint64_t position; 1998 uint64_t uniform_buffers; 1999 uint64_t textures; 2000 uint64_t samplers; 2001 uint64_t push_uniforms; 2002 uint64_t state; 2003 uint64_t attribute_buffers; 2004 uint64_t attributes; 2005 uint64_t varying_buffers; 2006 uint64_t varyings; 2007 uint64_t viewport; 2008 uint64_t occlusion; 2009 uint64_t thread_storage; 2010 uint64_t fbd; 2011}; 2012 2013#define MALI_DRAW_header \ 2014 .occlusion_query = MALI_OCCLUSION_MODE_DISABLED, \ 2015 .instance_size = 1, \ 2016 .instance_primitive_size = 1 2017 2018static inline void 2019MALI_DRAW_pack(uint32_t * restrict cl, 2020 const struct MALI_DRAW * restrict values) 2021{ 2022 cl[ 0] = __gen_uint(values->four_components_per_vertex, 0, 0) | 2023 __gen_uint(values->draw_descriptor_is_64b, 1, 1) | 2024 __gen_uint(values->occlusion_query, 3, 4) | 2025 __gen_uint(values->front_face_ccw, 5, 5) | 2026 __gen_uint(values->cull_front_face, 6, 6) | 2027 __gen_uint(values->cull_back_face, 7, 7) | 2028 __gen_uint(values->flat_shading_vertex, 8, 8) | 2029 __gen_uint(values->exclude_filtered_perf_counters, 9, 9) | 2030 __gen_uint(values->primitive_barrier, 10, 10) | 2031 __gen_uint(values->clean_fragment_write, 11, 11) | 2032 __gen_padded(values->instance_size, 16, 23) | 2033 __gen_padded(values->instance_primitive_size, 24, 31); 2034 cl[ 1] = __gen_uint(values->offset_start, 0, 31); 2035 cl[ 2] = __gen_uint(values->primitive_index_base, 0, 31); 2036 cl[ 3] = 0; 2037 cl[ 4] = __gen_uint(values->position, 0, 63); 2038 cl[ 5] = __gen_uint(values->position, 0, 63) >> 32; 2039 cl[ 6] = __gen_uint(values->uniform_buffers, 0, 63); 2040 cl[ 7] = __gen_uint(values->uniform_buffers, 0, 63) >> 32; 2041 cl[ 8] = __gen_uint(values->textures, 0, 63); 2042 cl[ 9] = __gen_uint(values->textures, 0, 63) >> 32; 2043 cl[10] = __gen_uint(values->samplers, 0, 63); 2044 cl[11] = __gen_uint(values->samplers, 0, 63) >> 32; 2045 cl[12] = __gen_uint(values->push_uniforms, 0, 63); 2046 cl[13] = __gen_uint(values->push_uniforms, 0, 63) >> 32; 2047 cl[14] = __gen_uint(values->state, 0, 63); 2048 cl[15] = __gen_uint(values->state, 0, 63) >> 32; 2049 cl[16] = __gen_uint(values->attribute_buffers, 0, 63); 2050 cl[17] = __gen_uint(values->attribute_buffers, 0, 63) >> 32; 2051 cl[18] = __gen_uint(values->attributes, 0, 63); 2052 cl[19] = __gen_uint(values->attributes, 0, 63) >> 32; 2053 cl[20] = __gen_uint(values->varying_buffers, 0, 63); 2054 cl[21] = __gen_uint(values->varying_buffers, 0, 63) >> 32; 2055 cl[22] = __gen_uint(values->varyings, 0, 63); 2056 cl[23] = __gen_uint(values->varyings, 0, 63) >> 32; 2057 cl[24] = __gen_uint(values->viewport, 0, 63); 2058 cl[25] = __gen_uint(values->viewport, 0, 63) >> 32; 2059 cl[26] = __gen_uint(values->occlusion, 0, 63); 2060 cl[27] = __gen_uint(values->occlusion, 0, 63) >> 32; 2061 cl[28] = __gen_uint(values->thread_storage, 0, 63) | 2062 __gen_uint(values->fbd, 0, 63); 2063 cl[29] = __gen_uint(values->thread_storage, 0, 63) >> 32 | 2064 __gen_uint(values->fbd, 0, 63) >> 32; 2065 cl[30] = 0; 2066 cl[31] = 0; 2067} 2068 2069 2070#define MALI_DRAW_LENGTH 128 2071#define MALI_DRAW_ALIGN 64 2072struct mali_draw_packed { uint32_t opaque[32]; }; 2073static inline void 2074MALI_DRAW_unpack(const uint8_t * restrict cl, 2075 struct MALI_DRAW * restrict values) 2076{ 2077 if (((const uint32_t *) cl)[0] & 0xf004) fprintf(stderr, "XXX: Invalid field of Draw unpacked at word 0\n"); 2078 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Draw unpacked at word 3\n"); 2079 if (((const uint32_t *) cl)[30] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Draw unpacked at word 30\n"); 2080 if (((const uint32_t *) cl)[31] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Draw unpacked at word 31\n"); 2081 values->four_components_per_vertex = __gen_unpack_uint(cl, 0, 0); 2082 values->draw_descriptor_is_64b = __gen_unpack_uint(cl, 1, 1); 2083 values->occlusion_query = (enum mali_occlusion_mode)__gen_unpack_uint(cl, 3, 4); 2084 values->front_face_ccw = __gen_unpack_uint(cl, 5, 5); 2085 values->cull_front_face = __gen_unpack_uint(cl, 6, 6); 2086 values->cull_back_face = __gen_unpack_uint(cl, 7, 7); 2087 values->flat_shading_vertex = __gen_unpack_uint(cl, 8, 8); 2088 values->exclude_filtered_perf_counters = __gen_unpack_uint(cl, 9, 9); 2089 values->primitive_barrier = __gen_unpack_uint(cl, 10, 10); 2090 values->clean_fragment_write = __gen_unpack_uint(cl, 11, 11); 2091 values->instance_size = __gen_unpack_padded(cl, 16, 23); 2092 values->instance_primitive_size = __gen_unpack_padded(cl, 24, 31); 2093 values->offset_start = __gen_unpack_uint(cl, 32, 63); 2094 values->primitive_index_base = __gen_unpack_uint(cl, 64, 95); 2095 values->position = __gen_unpack_uint(cl, 128, 191); 2096 values->uniform_buffers = __gen_unpack_uint(cl, 192, 255); 2097 values->textures = __gen_unpack_uint(cl, 256, 319); 2098 values->samplers = __gen_unpack_uint(cl, 320, 383); 2099 values->push_uniforms = __gen_unpack_uint(cl, 384, 447); 2100 values->state = __gen_unpack_uint(cl, 448, 511); 2101 values->attribute_buffers = __gen_unpack_uint(cl, 512, 575); 2102 values->attributes = __gen_unpack_uint(cl, 576, 639); 2103 values->varying_buffers = __gen_unpack_uint(cl, 640, 703); 2104 values->varyings = __gen_unpack_uint(cl, 704, 767); 2105 values->viewport = __gen_unpack_uint(cl, 768, 831); 2106 values->occlusion = __gen_unpack_uint(cl, 832, 895); 2107 values->thread_storage = __gen_unpack_uint(cl, 896, 959); 2108 values->fbd = __gen_unpack_uint(cl, 896, 959); 2109} 2110 2111static inline void 2112MALI_DRAW_print(FILE *fp, const struct MALI_DRAW * values, unsigned indent) 2113{ 2114 fprintf(fp, "%*sFour Components Per Vertex: %s\n", indent, "", values->four_components_per_vertex ? "true" : "false"); 2115 fprintf(fp, "%*sDraw Descriptor Is 64b: %s\n", indent, "", values->draw_descriptor_is_64b ? "true" : "false"); 2116 fprintf(fp, "%*sOcclusion query: %s\n", indent, "", mali_occlusion_mode_as_str(values->occlusion_query)); 2117 fprintf(fp, "%*sFront face CCW: %s\n", indent, "", values->front_face_ccw ? "true" : "false"); 2118 fprintf(fp, "%*sCull front face: %s\n", indent, "", values->cull_front_face ? "true" : "false"); 2119 fprintf(fp, "%*sCull back face: %s\n", indent, "", values->cull_back_face ? "true" : "false"); 2120 fprintf(fp, "%*sFlat Shading Vertex: %u\n", indent, "", values->flat_shading_vertex); 2121 fprintf(fp, "%*sExclude Filtered Perf Counters: %s\n", indent, "", values->exclude_filtered_perf_counters ? "true" : "false"); 2122 fprintf(fp, "%*sPrimitive Barrier: %s\n", indent, "", values->primitive_barrier ? "true" : "false"); 2123 fprintf(fp, "%*sClean Fragment Write: %s\n", indent, "", values->clean_fragment_write ? "true" : "false"); 2124 fprintf(fp, "%*sInstance Size: %u\n", indent, "", values->instance_size); 2125 fprintf(fp, "%*sInstance Primitive Size: %u\n", indent, "", values->instance_primitive_size); 2126 fprintf(fp, "%*sOffset start: %u\n", indent, "", values->offset_start); 2127 fprintf(fp, "%*sPrimitive Index Base: %u\n", indent, "", values->primitive_index_base); 2128 fprintf(fp, "%*sPosition: 0x%" PRIx64 "\n", indent, "", values->position); 2129 fprintf(fp, "%*sUniform buffers: 0x%" PRIx64 "\n", indent, "", values->uniform_buffers); 2130 fprintf(fp, "%*sTextures: 0x%" PRIx64 "\n", indent, "", values->textures); 2131 fprintf(fp, "%*sSamplers: 0x%" PRIx64 "\n", indent, "", values->samplers); 2132 fprintf(fp, "%*sPush uniforms: 0x%" PRIx64 "\n", indent, "", values->push_uniforms); 2133 fprintf(fp, "%*sState: 0x%" PRIx64 "\n", indent, "", values->state); 2134 fprintf(fp, "%*sAttribute buffers: 0x%" PRIx64 "\n", indent, "", values->attribute_buffers); 2135 fprintf(fp, "%*sAttributes: 0x%" PRIx64 "\n", indent, "", values->attributes); 2136 fprintf(fp, "%*sVarying buffers: 0x%" PRIx64 "\n", indent, "", values->varying_buffers); 2137 fprintf(fp, "%*sVaryings: 0x%" PRIx64 "\n", indent, "", values->varyings); 2138 fprintf(fp, "%*sViewport: 0x%" PRIx64 "\n", indent, "", values->viewport); 2139 fprintf(fp, "%*sOcclusion: 0x%" PRIx64 "\n", indent, "", values->occlusion); 2140 fprintf(fp, "%*sThread Storage: 0x%" PRIx64 "\n", indent, "", values->thread_storage); 2141 fprintf(fp, "%*sFBD: 0x%" PRIx64 "\n", indent, "", values->fbd); 2142} 2143 2144struct MALI_SURFACE { 2145 uint64_t pointer; 2146}; 2147 2148#define MALI_SURFACE_header \ 2149 0 2150 2151static inline void 2152MALI_SURFACE_pack(uint32_t * restrict cl, 2153 const struct MALI_SURFACE * restrict values) 2154{ 2155 cl[ 0] = __gen_uint(values->pointer, 0, 63); 2156 cl[ 1] = __gen_uint(values->pointer, 0, 63) >> 32; 2157} 2158 2159 2160#define MALI_SURFACE_LENGTH 8 2161#define MALI_SURFACE_ALIGN 8 2162struct mali_surface_packed { uint32_t opaque[2]; }; 2163static inline void 2164MALI_SURFACE_unpack(const uint8_t * restrict cl, 2165 struct MALI_SURFACE * restrict values) 2166{ 2167 values->pointer = __gen_unpack_uint(cl, 0, 63); 2168} 2169 2170static inline void 2171MALI_SURFACE_print(FILE *fp, const struct MALI_SURFACE * values, unsigned indent) 2172{ 2173 fprintf(fp, "%*sPointer: 0x%" PRIx64 "\n", indent, "", values->pointer); 2174} 2175 2176struct MALI_SURFACE_WITH_STRIDE { 2177 uint64_t pointer; 2178 int32_t row_stride; 2179 int32_t surface_stride; 2180}; 2181 2182#define MALI_SURFACE_WITH_STRIDE_header \ 2183 0 2184 2185static inline void 2186MALI_SURFACE_WITH_STRIDE_pack(uint32_t * restrict cl, 2187 const struct MALI_SURFACE_WITH_STRIDE * restrict values) 2188{ 2189 cl[ 0] = __gen_uint(values->pointer, 0, 63); 2190 cl[ 1] = __gen_uint(values->pointer, 0, 63) >> 32; 2191 cl[ 2] = __gen_sint(values->row_stride, 0, 31); 2192 cl[ 3] = __gen_sint(values->surface_stride, 0, 31); 2193} 2194 2195 2196#define MALI_SURFACE_WITH_STRIDE_LENGTH 16 2197#define MALI_SURFACE_WITH_STRIDE_ALIGN 8 2198struct mali_surface_with_stride_packed { uint32_t opaque[4]; }; 2199static inline void 2200MALI_SURFACE_WITH_STRIDE_unpack(const uint8_t * restrict cl, 2201 struct MALI_SURFACE_WITH_STRIDE * restrict values) 2202{ 2203 values->pointer = __gen_unpack_uint(cl, 0, 63); 2204 values->row_stride = __gen_unpack_sint(cl, 64, 95); 2205 values->surface_stride = __gen_unpack_sint(cl, 96, 127); 2206} 2207 2208static inline void 2209MALI_SURFACE_WITH_STRIDE_print(FILE *fp, const struct MALI_SURFACE_WITH_STRIDE * values, unsigned indent) 2210{ 2211 fprintf(fp, "%*sPointer: 0x%" PRIx64 "\n", indent, "", values->pointer); 2212 fprintf(fp, "%*sRow stride: %d\n", indent, "", values->row_stride); 2213 fprintf(fp, "%*sSurface stride: %d\n", indent, "", values->surface_stride); 2214} 2215 2216struct MALI_SAMPLER { 2217 uint32_t type; 2218 enum mali_wrap_mode wrap_mode_r; 2219 enum mali_wrap_mode wrap_mode_t; 2220 enum mali_wrap_mode wrap_mode_s; 2221 bool round_to_nearest_even; 2222 bool srgb_override; 2223 bool seamless_cube_map; 2224 bool clamp_integer_coordinates; 2225 bool normalized_coordinates; 2226 bool clamp_integer_array_indices; 2227 bool minify_nearest; 2228 bool magnify_nearest; 2229 bool magnify_cutoff; 2230 enum mali_mipmap_mode mipmap_mode; 2231 uint32_t minimum_lod; 2232 enum mali_func compare_function; 2233 uint32_t maximum_lod; 2234 int32_t lod_bias; 2235 uint32_t maximum_anisotropy; 2236 enum mali_lod_algorithm lod_algorithm; 2237 uint32_t border_color_r; 2238 uint32_t border_color_g; 2239 uint32_t border_color_b; 2240 uint32_t border_color_a; 2241}; 2242 2243#define MALI_SAMPLER_header \ 2244 .type = 1, \ 2245 .wrap_mode_r = MALI_WRAP_MODE_CLAMP_TO_EDGE, \ 2246 .wrap_mode_t = MALI_WRAP_MODE_CLAMP_TO_EDGE, \ 2247 .wrap_mode_s = MALI_WRAP_MODE_CLAMP_TO_EDGE, \ 2248 .round_to_nearest_even = false, \ 2249 .srgb_override = false, \ 2250 .seamless_cube_map = true, \ 2251 .normalized_coordinates = true, \ 2252 .clamp_integer_array_indices = true, \ 2253 .minify_nearest = false, \ 2254 .magnify_nearest = false, \ 2255 .magnify_cutoff = false, \ 2256 .mipmap_mode = MALI_MIPMAP_MODE_NEAREST, \ 2257 .minimum_lod = 0, \ 2258 .compare_function = MALI_FUNC_NEVER, \ 2259 .maximum_lod = 0, \ 2260 .lod_bias = 0, \ 2261 .maximum_anisotropy = 1, \ 2262 .lod_algorithm = MALI_LOD_ALGORITHM_ISOTROPIC, \ 2263 .border_color_r = 0.0, \ 2264 .border_color_g = 0.0, \ 2265 .border_color_b = 0.0, \ 2266 .border_color_a = 0.0 2267 2268static inline void 2269MALI_SAMPLER_pack(uint32_t * restrict cl, 2270 const struct MALI_SAMPLER * restrict values) 2271{ 2272 assert(values->maximum_anisotropy >= 1); 2273 cl[ 0] = __gen_uint(values->type, 0, 3) | 2274 __gen_uint(values->wrap_mode_r, 8, 11) | 2275 __gen_uint(values->wrap_mode_t, 12, 15) | 2276 __gen_uint(values->wrap_mode_s, 16, 19) | 2277 __gen_uint(values->round_to_nearest_even, 21, 21) | 2278 __gen_uint(values->srgb_override, 22, 22) | 2279 __gen_uint(values->seamless_cube_map, 23, 23) | 2280 __gen_uint(values->clamp_integer_coordinates, 24, 24) | 2281 __gen_uint(values->normalized_coordinates, 25, 25) | 2282 __gen_uint(values->clamp_integer_array_indices, 26, 26) | 2283 __gen_uint(values->minify_nearest, 27, 27) | 2284 __gen_uint(values->magnify_nearest, 28, 28) | 2285 __gen_uint(values->magnify_cutoff, 29, 29) | 2286 __gen_uint(values->mipmap_mode, 30, 31); 2287 cl[ 1] = __gen_uint(values->minimum_lod, 0, 12) | 2288 __gen_uint(values->compare_function, 13, 15) | 2289 __gen_uint(values->maximum_lod, 16, 28); 2290 cl[ 2] = __gen_sint(values->lod_bias, 0, 15) | 2291 __gen_uint(values->maximum_anisotropy - 1, 16, 20) | 2292 __gen_uint(values->lod_algorithm, 24, 25); 2293 cl[ 3] = 0; 2294 cl[ 4] = __gen_uint(values->border_color_r, 0, 31); 2295 cl[ 5] = __gen_uint(values->border_color_g, 0, 31); 2296 cl[ 6] = __gen_uint(values->border_color_b, 0, 31); 2297 cl[ 7] = __gen_uint(values->border_color_a, 0, 31); 2298} 2299 2300 2301#define MALI_SAMPLER_LENGTH 32 2302#define MALI_SAMPLER_ALIGN 32 2303struct mali_sampler_packed { uint32_t opaque[8]; }; 2304static inline void 2305MALI_SAMPLER_unpack(const uint8_t * restrict cl, 2306 struct MALI_SAMPLER * restrict values) 2307{ 2308 if (((const uint32_t *) cl)[0] & 0x1000f0) fprintf(stderr, "XXX: Invalid field of Sampler unpacked at word 0\n"); 2309 if (((const uint32_t *) cl)[1] & 0xe0000000) fprintf(stderr, "XXX: Invalid field of Sampler unpacked at word 1\n"); 2310 if (((const uint32_t *) cl)[2] & 0xfce00000) fprintf(stderr, "XXX: Invalid field of Sampler unpacked at word 2\n"); 2311 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Sampler unpacked at word 3\n"); 2312 values->type = __gen_unpack_uint(cl, 0, 3); 2313 values->wrap_mode_r = (enum mali_wrap_mode)__gen_unpack_uint(cl, 8, 11); 2314 values->wrap_mode_t = (enum mali_wrap_mode)__gen_unpack_uint(cl, 12, 15); 2315 values->wrap_mode_s = (enum mali_wrap_mode)__gen_unpack_uint(cl, 16, 19); 2316 values->round_to_nearest_even = __gen_unpack_uint(cl, 21, 21); 2317 values->srgb_override = __gen_unpack_uint(cl, 22, 22); 2318 values->seamless_cube_map = __gen_unpack_uint(cl, 23, 23); 2319 values->clamp_integer_coordinates = __gen_unpack_uint(cl, 24, 24); 2320 values->normalized_coordinates = __gen_unpack_uint(cl, 25, 25); 2321 values->clamp_integer_array_indices = __gen_unpack_uint(cl, 26, 26); 2322 values->minify_nearest = __gen_unpack_uint(cl, 27, 27); 2323 values->magnify_nearest = __gen_unpack_uint(cl, 28, 28); 2324 values->magnify_cutoff = __gen_unpack_uint(cl, 29, 29); 2325 values->mipmap_mode = (enum mali_mipmap_mode)__gen_unpack_uint(cl, 30, 31); 2326 values->minimum_lod = __gen_unpack_uint(cl, 32, 44); 2327 values->compare_function = (enum mali_func)__gen_unpack_uint(cl, 45, 47); 2328 values->maximum_lod = __gen_unpack_uint(cl, 48, 60); 2329 values->lod_bias = __gen_unpack_sint(cl, 64, 79); 2330 values->maximum_anisotropy = __gen_unpack_uint(cl, 80, 84) + 1; 2331 values->lod_algorithm = (enum mali_lod_algorithm)__gen_unpack_uint(cl, 88, 89); 2332 values->border_color_r = __gen_unpack_uint(cl, 128, 159); 2333 values->border_color_g = __gen_unpack_uint(cl, 160, 191); 2334 values->border_color_b = __gen_unpack_uint(cl, 192, 223); 2335 values->border_color_a = __gen_unpack_uint(cl, 224, 255); 2336} 2337 2338static inline void 2339MALI_SAMPLER_print(FILE *fp, const struct MALI_SAMPLER * values, unsigned indent) 2340{ 2341 fprintf(fp, "%*sType: %u\n", indent, "", values->type); 2342 fprintf(fp, "%*sWrap Mode R: %s\n", indent, "", mali_wrap_mode_as_str(values->wrap_mode_r)); 2343 fprintf(fp, "%*sWrap Mode T: %s\n", indent, "", mali_wrap_mode_as_str(values->wrap_mode_t)); 2344 fprintf(fp, "%*sWrap Mode S: %s\n", indent, "", mali_wrap_mode_as_str(values->wrap_mode_s)); 2345 fprintf(fp, "%*sRound to nearest even: %s\n", indent, "", values->round_to_nearest_even ? "true" : "false"); 2346 fprintf(fp, "%*ssRGB override: %s\n", indent, "", values->srgb_override ? "true" : "false"); 2347 fprintf(fp, "%*sSeamless Cube Map: %s\n", indent, "", values->seamless_cube_map ? "true" : "false"); 2348 fprintf(fp, "%*sClamp integer coordinates: %s\n", indent, "", values->clamp_integer_coordinates ? "true" : "false"); 2349 fprintf(fp, "%*sNormalized Coordinates: %s\n", indent, "", values->normalized_coordinates ? "true" : "false"); 2350 fprintf(fp, "%*sClamp integer array indices: %s\n", indent, "", values->clamp_integer_array_indices ? "true" : "false"); 2351 fprintf(fp, "%*sMinify nearest: %s\n", indent, "", values->minify_nearest ? "true" : "false"); 2352 fprintf(fp, "%*sMagnify nearest: %s\n", indent, "", values->magnify_nearest ? "true" : "false"); 2353 fprintf(fp, "%*sMagnify cutoff: %s\n", indent, "", values->magnify_cutoff ? "true" : "false"); 2354 fprintf(fp, "%*sMipmap Mode: %s\n", indent, "", mali_mipmap_mode_as_str(values->mipmap_mode)); 2355 fprintf(fp, "%*sMinimum LOD: %u\n", indent, "", values->minimum_lod); 2356 fprintf(fp, "%*sCompare Function: %s\n", indent, "", mali_func_as_str(values->compare_function)); 2357 fprintf(fp, "%*sMaximum LOD: %u\n", indent, "", values->maximum_lod); 2358 fprintf(fp, "%*sLOD bias: %d\n", indent, "", values->lod_bias); 2359 fprintf(fp, "%*sMaximum anisotropy: %u\n", indent, "", values->maximum_anisotropy); 2360 fprintf(fp, "%*sLOD algorithm: %s\n", indent, "", mali_lod_algorithm_as_str(values->lod_algorithm)); 2361 fprintf(fp, "%*sBorder Color R: 0x%X (%f)\n", indent, "", values->border_color_r, uif(values->border_color_r)); 2362 fprintf(fp, "%*sBorder Color G: 0x%X (%f)\n", indent, "", values->border_color_g, uif(values->border_color_g)); 2363 fprintf(fp, "%*sBorder Color B: 0x%X (%f)\n", indent, "", values->border_color_b, uif(values->border_color_b)); 2364 fprintf(fp, "%*sBorder Color A: 0x%X (%f)\n", indent, "", values->border_color_a, uif(values->border_color_a)); 2365} 2366 2367struct MALI_TEXTURE { 2368 uint32_t type; 2369 enum mali_texture_dimension dimension; 2370 bool sample_corner_position; 2371 bool normalize_coordinates; 2372 uint32_t format; 2373 uint32_t width; 2374 uint32_t height; 2375 uint32_t swizzle; 2376 enum mali_texture_layout texel_ordering; 2377 uint32_t levels; 2378 uint32_t minimum_level; 2379 uint32_t minimum_lod; 2380 uint32_t sample_count; 2381 uint32_t maximum_lod; 2382 uint64_t surfaces; 2383 uint32_t array_size; 2384 uint32_t depth; 2385}; 2386 2387#define MALI_TEXTURE_header \ 2388 .type = 2, \ 2389 .sample_corner_position = false, \ 2390 .normalize_coordinates = false, \ 2391 .levels = 1, \ 2392 .minimum_lod = 0, \ 2393 .sample_count = 1, \ 2394 .maximum_lod = 0, \ 2395 .array_size = 1, \ 2396 .depth = 1 2397 2398static inline void 2399MALI_TEXTURE_pack(uint32_t * restrict cl, 2400 const struct MALI_TEXTURE * restrict values) 2401{ 2402 assert(values->width >= 1); 2403 assert(values->height >= 1); 2404 assert(values->levels >= 1); 2405 assert(util_is_power_of_two_nonzero(values->sample_count)); 2406 assert(values->array_size >= 1); 2407 assert(values->depth >= 1); 2408 cl[ 0] = __gen_uint(values->type, 0, 3) | 2409 __gen_uint(values->dimension, 4, 5) | 2410 __gen_uint(values->sample_corner_position, 8, 8) | 2411 __gen_uint(values->normalize_coordinates, 9, 9) | 2412 __gen_uint(values->format, 10, 31); 2413 cl[ 1] = __gen_uint(values->width - 1, 0, 15) | 2414 __gen_uint(values->height - 1, 16, 31); 2415 cl[ 2] = __gen_uint(values->swizzle, 0, 11) | 2416 __gen_uint(values->texel_ordering, 12, 15) | 2417 __gen_uint(values->levels - 1, 16, 20) | 2418 __gen_uint(values->minimum_level, 24, 28); 2419 cl[ 3] = __gen_uint(values->minimum_lod, 0, 12) | 2420 __gen_uint(util_logbase2(values->sample_count), 13, 15) | 2421 __gen_uint(values->maximum_lod, 16, 28); 2422 cl[ 4] = __gen_uint(values->surfaces, 0, 63); 2423 cl[ 5] = __gen_uint(values->surfaces, 0, 63) >> 32; 2424 cl[ 6] = __gen_uint(values->array_size - 1, 0, 15); 2425 cl[ 7] = __gen_uint(values->depth - 1, 0, 15); 2426} 2427 2428 2429#define MALI_TEXTURE_LENGTH 32 2430#define MALI_TEXTURE_ALIGN 32 2431struct mali_texture_packed { uint32_t opaque[8]; }; 2432static inline void 2433MALI_TEXTURE_unpack(const uint8_t * restrict cl, 2434 struct MALI_TEXTURE * restrict values) 2435{ 2436 if (((const uint32_t *) cl)[0] & 0xc0) fprintf(stderr, "XXX: Invalid field of Texture unpacked at word 0\n"); 2437 if (((const uint32_t *) cl)[2] & 0xe0e00000) fprintf(stderr, "XXX: Invalid field of Texture unpacked at word 2\n"); 2438 if (((const uint32_t *) cl)[3] & 0xe0000000) fprintf(stderr, "XXX: Invalid field of Texture unpacked at word 3\n"); 2439 if (((const uint32_t *) cl)[6] & 0xffff0000) fprintf(stderr, "XXX: Invalid field of Texture unpacked at word 6\n"); 2440 if (((const uint32_t *) cl)[7] & 0xffff0000) fprintf(stderr, "XXX: Invalid field of Texture unpacked at word 7\n"); 2441 values->type = __gen_unpack_uint(cl, 0, 3); 2442 values->dimension = (enum mali_texture_dimension)__gen_unpack_uint(cl, 4, 5); 2443 values->sample_corner_position = __gen_unpack_uint(cl, 8, 8); 2444 values->normalize_coordinates = __gen_unpack_uint(cl, 9, 9); 2445 values->format = __gen_unpack_uint(cl, 10, 31); 2446 values->width = __gen_unpack_uint(cl, 32, 47) + 1; 2447 values->height = __gen_unpack_uint(cl, 48, 63) + 1; 2448 values->swizzle = __gen_unpack_uint(cl, 64, 75); 2449 values->texel_ordering = (enum mali_texture_layout)__gen_unpack_uint(cl, 76, 79); 2450 values->levels = __gen_unpack_uint(cl, 80, 84) + 1; 2451 values->minimum_level = __gen_unpack_uint(cl, 88, 92); 2452 values->minimum_lod = __gen_unpack_uint(cl, 96, 108); 2453 values->sample_count = 1U << __gen_unpack_uint(cl, 109, 111); 2454 values->maximum_lod = __gen_unpack_uint(cl, 112, 124); 2455 values->surfaces = __gen_unpack_uint(cl, 128, 191); 2456 values->array_size = __gen_unpack_uint(cl, 192, 207) + 1; 2457 values->depth = __gen_unpack_uint(cl, 224, 239) + 1; 2458} 2459 2460static inline void 2461MALI_TEXTURE_print(FILE *fp, const struct MALI_TEXTURE * values, unsigned indent) 2462{ 2463 fprintf(fp, "%*sType: %u\n", indent, "", values->type); 2464 fprintf(fp, "%*sDimension: %s\n", indent, "", mali_texture_dimension_as_str(values->dimension)); 2465 fprintf(fp, "%*sSample corner position: %s\n", indent, "", values->sample_corner_position ? "true" : "false"); 2466 fprintf(fp, "%*sNormalize coordinates: %s\n", indent, "", values->normalize_coordinates ? "true" : "false"); 2467 mali_pixel_format_print(fp, values->format); 2468 fprintf(fp, "%*sWidth: %u\n", indent, "", values->width); 2469 fprintf(fp, "%*sHeight: %u\n", indent, "", values->height); 2470 fprintf(fp, "%*sSwizzle: %u\n", indent, "", values->swizzle); 2471 fprintf(fp, "%*sTexel ordering: %s\n", indent, "", mali_texture_layout_as_str(values->texel_ordering)); 2472 fprintf(fp, "%*sLevels: %u\n", indent, "", values->levels); 2473 fprintf(fp, "%*sMinimum level: %u\n", indent, "", values->minimum_level); 2474 fprintf(fp, "%*sMinimum LOD: %u\n", indent, "", values->minimum_lod); 2475 fprintf(fp, "%*sSample count: %u\n", indent, "", values->sample_count); 2476 fprintf(fp, "%*sMaximum LOD: %u\n", indent, "", values->maximum_lod); 2477 fprintf(fp, "%*sSurfaces: 0x%" PRIx64 "\n", indent, "", values->surfaces); 2478 fprintf(fp, "%*sArray size: %u\n", indent, "", values->array_size); 2479 fprintf(fp, "%*sDepth: %u\n", indent, "", values->depth); 2480} 2481 2482enum mali_shader_register_allocation { 2483 MALI_SHADER_REGISTER_ALLOCATION_64_PER_THREAD = 0, 2484 MALI_SHADER_REGISTER_ALLOCATION_32_PER_THREAD = 2, 2485}; 2486 2487static inline const char * 2488mali_shader_register_allocation_as_str(enum mali_shader_register_allocation imm) 2489{ 2490 switch (imm) { 2491 case MALI_SHADER_REGISTER_ALLOCATION_64_PER_THREAD: return "64 Per Thread"; 2492 case MALI_SHADER_REGISTER_ALLOCATION_32_PER_THREAD: return "32 Per Thread"; 2493 default: return "XXX: INVALID"; 2494 } 2495} 2496 2497struct MALI_RENDERER_PROPERTIES { 2498 uint32_t uniform_buffer_count; 2499 enum mali_depth_source depth_source; 2500 bool shader_contains_barrier; 2501 enum mali_shader_register_allocation shader_register_allocation; 2502 bool shader_modifies_coverage; 2503 bool allow_forward_pixel_to_kill; 2504 bool allow_forward_pixel_to_be_killed; 2505 enum mali_pixel_kill pixel_kill_operation; 2506 enum mali_pixel_kill zs_update_operation; 2507 bool point_sprite_coord_origin_max_y; 2508 bool stencil_from_shader; 2509}; 2510 2511#define MALI_RENDERER_PROPERTIES_header \ 2512 .depth_source = MALI_DEPTH_SOURCE_MINIMUM 2513 2514static inline void 2515MALI_RENDERER_PROPERTIES_pack(uint32_t * restrict cl, 2516 const struct MALI_RENDERER_PROPERTIES * restrict values) 2517{ 2518 cl[ 0] = __gen_uint(values->uniform_buffer_count, 0, 7) | 2519 __gen_uint(values->depth_source, 8, 9) | 2520 __gen_uint(values->shader_contains_barrier, 11, 11) | 2521 __gen_uint(values->shader_register_allocation, 12, 13) | 2522 __gen_uint(values->shader_modifies_coverage, 16, 16) | 2523 __gen_uint(values->allow_forward_pixel_to_kill, 19, 19) | 2524 __gen_uint(values->allow_forward_pixel_to_be_killed, 20, 20) | 2525 __gen_uint(values->pixel_kill_operation, 21, 22) | 2526 __gen_uint(values->zs_update_operation, 23, 24) | 2527 __gen_uint(values->point_sprite_coord_origin_max_y, 27, 27) | 2528 __gen_uint(values->stencil_from_shader, 28, 28); 2529} 2530 2531 2532#define MALI_RENDERER_PROPERTIES_LENGTH 4 2533struct mali_renderer_properties_packed { uint32_t opaque[1]; }; 2534static inline void 2535MALI_RENDERER_PROPERTIES_unpack(const uint8_t * restrict cl, 2536 struct MALI_RENDERER_PROPERTIES * restrict values) 2537{ 2538 if (((const uint32_t *) cl)[0] & 0xe606c400) fprintf(stderr, "XXX: Invalid field of Renderer Properties unpacked at word 0\n"); 2539 values->uniform_buffer_count = __gen_unpack_uint(cl, 0, 7); 2540 values->depth_source = (enum mali_depth_source)__gen_unpack_uint(cl, 8, 9); 2541 values->shader_contains_barrier = __gen_unpack_uint(cl, 11, 11); 2542 values->shader_register_allocation = (enum mali_shader_register_allocation)__gen_unpack_uint(cl, 12, 13); 2543 values->shader_modifies_coverage = __gen_unpack_uint(cl, 16, 16); 2544 values->allow_forward_pixel_to_kill = __gen_unpack_uint(cl, 19, 19); 2545 values->allow_forward_pixel_to_be_killed = __gen_unpack_uint(cl, 20, 20); 2546 values->pixel_kill_operation = (enum mali_pixel_kill)__gen_unpack_uint(cl, 21, 22); 2547 values->zs_update_operation = (enum mali_pixel_kill)__gen_unpack_uint(cl, 23, 24); 2548 values->point_sprite_coord_origin_max_y = __gen_unpack_uint(cl, 27, 27); 2549 values->stencil_from_shader = __gen_unpack_uint(cl, 28, 28); 2550} 2551 2552static inline void 2553MALI_RENDERER_PROPERTIES_print(FILE *fp, const struct MALI_RENDERER_PROPERTIES * values, unsigned indent) 2554{ 2555 fprintf(fp, "%*sUniform buffer count: %u\n", indent, "", values->uniform_buffer_count); 2556 fprintf(fp, "%*sDepth source: %s\n", indent, "", mali_depth_source_as_str(values->depth_source)); 2557 fprintf(fp, "%*sShader contains barrier: %s\n", indent, "", values->shader_contains_barrier ? "true" : "false"); 2558 fprintf(fp, "%*sShader register allocation: %s\n", indent, "", mali_shader_register_allocation_as_str(values->shader_register_allocation)); 2559 fprintf(fp, "%*sShader modifies coverage: %s\n", indent, "", values->shader_modifies_coverage ? "true" : "false"); 2560 fprintf(fp, "%*sAllow forward pixel to kill: %s\n", indent, "", values->allow_forward_pixel_to_kill ? "true" : "false"); 2561 fprintf(fp, "%*sAllow forward pixel to be killed: %s\n", indent, "", values->allow_forward_pixel_to_be_killed ? "true" : "false"); 2562 fprintf(fp, "%*sPixel kill operation: %s\n", indent, "", mali_pixel_kill_as_str(values->pixel_kill_operation)); 2563 fprintf(fp, "%*sZS update operation: %s\n", indent, "", mali_pixel_kill_as_str(values->zs_update_operation)); 2564 fprintf(fp, "%*sPoint sprite coord origin max Y: %s\n", indent, "", values->point_sprite_coord_origin_max_y ? "true" : "false"); 2565 fprintf(fp, "%*sStencil from shader: %s\n", indent, "", values->stencil_from_shader ? "true" : "false"); 2566} 2567 2568struct MALI_COMPUTE_PRELOAD { 2569 bool pc; 2570 bool local_invocation_xy; 2571 bool local_invocation_z; 2572 bool work_group_x; 2573 bool work_group_y; 2574 bool work_group_z; 2575 bool global_invocation_x; 2576 bool global_invocation_y; 2577 bool global_invocation_z; 2578}; 2579 2580#define MALI_COMPUTE_PRELOAD_header \ 2581 0 2582 2583static inline void 2584MALI_COMPUTE_PRELOAD_print(FILE *fp, const struct MALI_COMPUTE_PRELOAD * values, unsigned indent) 2585{ 2586 fprintf(fp, "%*sPC: %s\n", indent, "", values->pc ? "true" : "false"); 2587 fprintf(fp, "%*sLocal Invocation XY: %s\n", indent, "", values->local_invocation_xy ? "true" : "false"); 2588 fprintf(fp, "%*sLocal Invocation Z: %s\n", indent, "", values->local_invocation_z ? "true" : "false"); 2589 fprintf(fp, "%*sWork group X: %s\n", indent, "", values->work_group_x ? "true" : "false"); 2590 fprintf(fp, "%*sWork group Y: %s\n", indent, "", values->work_group_y ? "true" : "false"); 2591 fprintf(fp, "%*sWork group Z: %s\n", indent, "", values->work_group_z ? "true" : "false"); 2592 fprintf(fp, "%*sGlobal Invocation X: %s\n", indent, "", values->global_invocation_x ? "true" : "false"); 2593 fprintf(fp, "%*sGlobal Invocation Y: %s\n", indent, "", values->global_invocation_y ? "true" : "false"); 2594 fprintf(fp, "%*sGlobal Invocation Z: %s\n", indent, "", values->global_invocation_z ? "true" : "false"); 2595} 2596 2597enum mali_warp_limit { 2598 MALI_WARP_LIMIT_NONE = 0, 2599 MALI_WARP_LIMIT_2 = 1, 2600 MALI_WARP_LIMIT_4 = 2, 2601 MALI_WARP_LIMIT_8 = 3, 2602}; 2603 2604static inline const char * 2605mali_warp_limit_as_str(enum mali_warp_limit imm) 2606{ 2607 switch (imm) { 2608 case MALI_WARP_LIMIT_NONE: return "None"; 2609 case MALI_WARP_LIMIT_2: return "2"; 2610 case MALI_WARP_LIMIT_4: return "4"; 2611 case MALI_WARP_LIMIT_8: return "8"; 2612 default: return "XXX: INVALID"; 2613 } 2614} 2615 2616struct MALI_VERTEX_PRELOAD { 2617 enum mali_warp_limit warp_limit; 2618 bool pc; 2619 bool position_result_address_lo; 2620 bool position_result_address_hi; 2621 bool vertex_id; 2622 bool instance_id; 2623}; 2624 2625#define MALI_VERTEX_PRELOAD_header \ 2626 0 2627 2628static inline void 2629MALI_VERTEX_PRELOAD_print(FILE *fp, const struct MALI_VERTEX_PRELOAD * values, unsigned indent) 2630{ 2631 fprintf(fp, "%*sWarp limit: %s\n", indent, "", mali_warp_limit_as_str(values->warp_limit)); 2632 fprintf(fp, "%*sPC: %s\n", indent, "", values->pc ? "true" : "false"); 2633 fprintf(fp, "%*sPosition result address lo: %s\n", indent, "", values->position_result_address_lo ? "true" : "false"); 2634 fprintf(fp, "%*sPosition result address hi: %s\n", indent, "", values->position_result_address_hi ? "true" : "false"); 2635 fprintf(fp, "%*sVertex ID: %s\n", indent, "", values->vertex_id ? "true" : "false"); 2636 fprintf(fp, "%*sInstance ID: %s\n", indent, "", values->instance_id ? "true" : "false"); 2637} 2638 2639struct MALI_FRAGMENT_PRELOAD { 2640 bool pc; 2641 bool coverage; 2642 bool primitive_id; 2643 bool primitive_flags; 2644 bool fragment_position; 2645 bool sample_mask_id; 2646}; 2647 2648#define MALI_FRAGMENT_PRELOAD_header \ 2649 0 2650 2651static inline void 2652MALI_FRAGMENT_PRELOAD_print(FILE *fp, const struct MALI_FRAGMENT_PRELOAD * values, unsigned indent) 2653{ 2654 fprintf(fp, "%*sPC: %s\n", indent, "", values->pc ? "true" : "false"); 2655 fprintf(fp, "%*sCoverage: %s\n", indent, "", values->coverage ? "true" : "false"); 2656 fprintf(fp, "%*sPrimitive ID: %s\n", indent, "", values->primitive_id ? "true" : "false"); 2657 fprintf(fp, "%*sPrimitive flags: %s\n", indent, "", values->primitive_flags ? "true" : "false"); 2658 fprintf(fp, "%*sFragment position: %s\n", indent, "", values->fragment_position ? "true" : "false"); 2659 fprintf(fp, "%*sSample mask/ID: %s\n", indent, "", values->sample_mask_id ? "true" : "false"); 2660} 2661 2662struct MALI_PRELOAD { 2663 struct MALI_COMPUTE_PRELOAD compute; 2664 struct MALI_VERTEX_PRELOAD vertex; 2665 struct MALI_FRAGMENT_PRELOAD fragment; 2666 uint32_t uniform_count; 2667}; 2668 2669#define MALI_PRELOAD_header \ 2670 .compute = { MALI_COMPUTE_PRELOAD_header }, \ 2671 .vertex = { MALI_VERTEX_PRELOAD_header }, \ 2672 .fragment = { MALI_FRAGMENT_PRELOAD_header } 2673 2674static inline void 2675MALI_PRELOAD_pack(uint32_t * restrict cl, 2676 const struct MALI_PRELOAD * restrict values) 2677{ 2678 cl[ 0] = __gen_uint(values->compute.pc, 6, 6) | 2679 __gen_uint(values->compute.local_invocation_xy, 7, 7) | 2680 __gen_uint(values->compute.local_invocation_z, 8, 8) | 2681 __gen_uint(values->compute.work_group_x, 9, 9) | 2682 __gen_uint(values->compute.work_group_y, 10, 10) | 2683 __gen_uint(values->compute.work_group_z, 11, 11) | 2684 __gen_uint(values->compute.global_invocation_x, 12, 12) | 2685 __gen_uint(values->compute.global_invocation_y, 13, 13) | 2686 __gen_uint(values->compute.global_invocation_z, 14, 14) | 2687 __gen_uint(values->vertex.warp_limit, 0, 1) | 2688 __gen_uint(values->vertex.pc, 6, 6) | 2689 __gen_uint(values->vertex.position_result_address_lo, 10, 10) | 2690 __gen_uint(values->vertex.position_result_address_hi, 11, 11) | 2691 __gen_uint(values->vertex.vertex_id, 13, 13) | 2692 __gen_uint(values->vertex.instance_id, 14, 14) | 2693 __gen_uint(values->fragment.pc, 6, 6) | 2694 __gen_uint(values->fragment.coverage, 7, 7) | 2695 __gen_uint(values->fragment.primitive_id, 9, 9) | 2696 __gen_uint(values->fragment.primitive_flags, 10, 10) | 2697 __gen_uint(values->fragment.fragment_position, 11, 11) | 2698 __gen_uint(values->fragment.sample_mask_id, 13, 13) | 2699 __gen_uint(values->uniform_count, 15, 21); 2700} 2701 2702 2703#define MALI_PRELOAD_LENGTH 4 2704struct mali_preload_packed { uint32_t opaque[1]; }; 2705static inline void 2706MALI_PRELOAD_unpack(const uint8_t * restrict cl, 2707 struct MALI_PRELOAD * restrict values) 2708{ 2709 if (((const uint32_t *) cl)[0] & 0xffc0003c) fprintf(stderr, "XXX: Invalid field of Preload unpacked at word 0\n"); 2710 values->compute.pc = __gen_unpack_uint(cl, 6, 6); 2711 values->compute.local_invocation_xy = __gen_unpack_uint(cl, 7, 7); 2712 values->compute.local_invocation_z = __gen_unpack_uint(cl, 8, 8); 2713 values->compute.work_group_x = __gen_unpack_uint(cl, 9, 9); 2714 values->compute.work_group_y = __gen_unpack_uint(cl, 10, 10); 2715 values->compute.work_group_z = __gen_unpack_uint(cl, 11, 11); 2716 values->compute.global_invocation_x = __gen_unpack_uint(cl, 12, 12); 2717 values->compute.global_invocation_y = __gen_unpack_uint(cl, 13, 13); 2718 values->compute.global_invocation_z = __gen_unpack_uint(cl, 14, 14); 2719 values->vertex.warp_limit = (enum mali_warp_limit)__gen_unpack_uint(cl, 0, 1); 2720 values->vertex.pc = __gen_unpack_uint(cl, 6, 6); 2721 values->vertex.position_result_address_lo = __gen_unpack_uint(cl, 10, 10); 2722 values->vertex.position_result_address_hi = __gen_unpack_uint(cl, 11, 11); 2723 values->vertex.vertex_id = __gen_unpack_uint(cl, 13, 13); 2724 values->vertex.instance_id = __gen_unpack_uint(cl, 14, 14); 2725 values->fragment.pc = __gen_unpack_uint(cl, 6, 6); 2726 values->fragment.coverage = __gen_unpack_uint(cl, 7, 7); 2727 values->fragment.primitive_id = __gen_unpack_uint(cl, 9, 9); 2728 values->fragment.primitive_flags = __gen_unpack_uint(cl, 10, 10); 2729 values->fragment.fragment_position = __gen_unpack_uint(cl, 11, 11); 2730 values->fragment.sample_mask_id = __gen_unpack_uint(cl, 13, 13); 2731 values->uniform_count = __gen_unpack_uint(cl, 15, 21); 2732} 2733 2734static inline void 2735MALI_PRELOAD_print(FILE *fp, const struct MALI_PRELOAD * values, unsigned indent) 2736{ 2737 fprintf(fp, "%*sCompute:\n", indent, ""); 2738 MALI_COMPUTE_PRELOAD_print(fp, &values->compute, indent + 2); 2739 fprintf(fp, "%*sVertex:\n", indent, ""); 2740 MALI_VERTEX_PRELOAD_print(fp, &values->vertex, indent + 2); 2741 fprintf(fp, "%*sFragment:\n", indent, ""); 2742 MALI_FRAGMENT_PRELOAD_print(fp, &values->fragment, indent + 2); 2743 fprintf(fp, "%*sUniform count: %u\n", indent, "", values->uniform_count); 2744} 2745 2746struct MALI_SHADER { 2747 uint64_t shader; 2748 uint32_t sampler_count; 2749 uint32_t texture_count; 2750 uint32_t attribute_count; 2751 uint32_t varying_count; 2752}; 2753 2754#define MALI_SHADER_header \ 2755 0 2756 2757static inline void 2758MALI_SHADER_pack(uint32_t * restrict cl, 2759 const struct MALI_SHADER * restrict values) 2760{ 2761 cl[ 0] = __gen_uint(values->shader, 0, 63); 2762 cl[ 1] = __gen_uint(values->shader, 0, 63) >> 32; 2763 cl[ 2] = __gen_uint(values->sampler_count, 0, 15) | 2764 __gen_uint(values->texture_count, 16, 31); 2765 cl[ 3] = __gen_uint(values->attribute_count, 0, 15) | 2766 __gen_uint(values->varying_count, 16, 31); 2767} 2768 2769 2770#define MALI_SHADER_LENGTH 16 2771struct mali_shader_packed { uint32_t opaque[4]; }; 2772static inline void 2773MALI_SHADER_unpack(const uint8_t * restrict cl, 2774 struct MALI_SHADER * restrict values) 2775{ 2776 values->shader = __gen_unpack_uint(cl, 0, 63); 2777 values->sampler_count = __gen_unpack_uint(cl, 64, 79); 2778 values->texture_count = __gen_unpack_uint(cl, 80, 95); 2779 values->attribute_count = __gen_unpack_uint(cl, 96, 111); 2780 values->varying_count = __gen_unpack_uint(cl, 112, 127); 2781} 2782 2783static inline void 2784MALI_SHADER_print(FILE *fp, const struct MALI_SHADER * values, unsigned indent) 2785{ 2786 fprintf(fp, "%*sShader: 0x%" PRIx64 "\n", indent, "", values->shader); 2787 fprintf(fp, "%*sSampler count: %u\n", indent, "", values->sampler_count); 2788 fprintf(fp, "%*sTexture count: %u\n", indent, "", values->texture_count); 2789 fprintf(fp, "%*sAttribute count: %u\n", indent, "", values->attribute_count); 2790 fprintf(fp, "%*sVarying count: %u\n", indent, "", values->varying_count); 2791} 2792 2793struct MALI_MULTISAMPLE_MISC { 2794 uint32_t sample_mask; 2795 bool multisample_enable; 2796 bool multisample_late_coverage; 2797 bool evaluate_per_sample; 2798 bool fixed_function_depth_range_fixed; 2799 bool shader_depth_range_fixed; 2800 bool overdraw_alpha1; 2801 bool overdraw_alpha0; 2802 enum mali_func depth_function; 2803 bool depth_write_mask; 2804 bool fixed_function_near_discard; 2805 bool fixed_function_far_discard; 2806 bool fragment_near_discard; 2807 bool fragment_far_discard; 2808}; 2809 2810#define MALI_MULTISAMPLE_MISC_header \ 2811 0 2812 2813static inline void 2814MALI_MULTISAMPLE_MISC_pack(uint32_t * restrict cl, 2815 const struct MALI_MULTISAMPLE_MISC * restrict values) 2816{ 2817 cl[ 0] = __gen_uint(values->sample_mask, 0, 15) | 2818 __gen_uint(values->multisample_enable, 16, 16) | 2819 __gen_uint(values->multisample_late_coverage, 17, 17) | 2820 __gen_uint(values->evaluate_per_sample, 18, 18) | 2821 __gen_uint(values->fixed_function_depth_range_fixed, 19, 19) | 2822 __gen_uint(values->shader_depth_range_fixed, 20, 20) | 2823 __gen_uint(values->overdraw_alpha1, 22, 22) | 2824 __gen_uint(values->overdraw_alpha0, 23, 23) | 2825 __gen_uint(values->depth_function, 24, 26) | 2826 __gen_uint(values->depth_write_mask, 27, 27) | 2827 __gen_uint(values->fixed_function_near_discard, 28, 28) | 2828 __gen_uint(values->fixed_function_far_discard, 29, 29) | 2829 __gen_uint(values->fragment_near_discard, 30, 30) | 2830 __gen_uint(values->fragment_far_discard, 31, 31); 2831} 2832 2833 2834#define MALI_MULTISAMPLE_MISC_LENGTH 4 2835struct mali_multisample_misc_packed { uint32_t opaque[1]; }; 2836static inline void 2837MALI_MULTISAMPLE_MISC_unpack(const uint8_t * restrict cl, 2838 struct MALI_MULTISAMPLE_MISC * restrict values) 2839{ 2840 if (((const uint32_t *) cl)[0] & 0x200000) fprintf(stderr, "XXX: Invalid field of Multisample, Misc unpacked at word 0\n"); 2841 values->sample_mask = __gen_unpack_uint(cl, 0, 15); 2842 values->multisample_enable = __gen_unpack_uint(cl, 16, 16); 2843 values->multisample_late_coverage = __gen_unpack_uint(cl, 17, 17); 2844 values->evaluate_per_sample = __gen_unpack_uint(cl, 18, 18); 2845 values->fixed_function_depth_range_fixed = __gen_unpack_uint(cl, 19, 19); 2846 values->shader_depth_range_fixed = __gen_unpack_uint(cl, 20, 20); 2847 values->overdraw_alpha1 = __gen_unpack_uint(cl, 22, 22); 2848 values->overdraw_alpha0 = __gen_unpack_uint(cl, 23, 23); 2849 values->depth_function = (enum mali_func)__gen_unpack_uint(cl, 24, 26); 2850 values->depth_write_mask = __gen_unpack_uint(cl, 27, 27); 2851 values->fixed_function_near_discard = __gen_unpack_uint(cl, 28, 28); 2852 values->fixed_function_far_discard = __gen_unpack_uint(cl, 29, 29); 2853 values->fragment_near_discard = __gen_unpack_uint(cl, 30, 30); 2854 values->fragment_far_discard = __gen_unpack_uint(cl, 31, 31); 2855} 2856 2857static inline void 2858MALI_MULTISAMPLE_MISC_print(FILE *fp, const struct MALI_MULTISAMPLE_MISC * values, unsigned indent) 2859{ 2860 fprintf(fp, "%*sSample mask: %u\n", indent, "", values->sample_mask); 2861 fprintf(fp, "%*sMultisample enable: %s\n", indent, "", values->multisample_enable ? "true" : "false"); 2862 fprintf(fp, "%*sMultisample late coverage: %s\n", indent, "", values->multisample_late_coverage ? "true" : "false"); 2863 fprintf(fp, "%*sEvaluate per-sample: %s\n", indent, "", values->evaluate_per_sample ? "true" : "false"); 2864 fprintf(fp, "%*sFixed-function depth range fixed: %s\n", indent, "", values->fixed_function_depth_range_fixed ? "true" : "false"); 2865 fprintf(fp, "%*sShader depth range fixed: %s\n", indent, "", values->shader_depth_range_fixed ? "true" : "false"); 2866 fprintf(fp, "%*sOverdraw alpha1: %s\n", indent, "", values->overdraw_alpha1 ? "true" : "false"); 2867 fprintf(fp, "%*sOverdraw alpha0: %s\n", indent, "", values->overdraw_alpha0 ? "true" : "false"); 2868 fprintf(fp, "%*sDepth function: %s\n", indent, "", mali_func_as_str(values->depth_function)); 2869 fprintf(fp, "%*sDepth write mask: %s\n", indent, "", values->depth_write_mask ? "true" : "false"); 2870 fprintf(fp, "%*sFixed-function near discard: %s\n", indent, "", values->fixed_function_near_discard ? "true" : "false"); 2871 fprintf(fp, "%*sFixed-function far discard: %s\n", indent, "", values->fixed_function_far_discard ? "true" : "false"); 2872 fprintf(fp, "%*sFragment near discard: %s\n", indent, "", values->fragment_near_discard ? "true" : "false"); 2873 fprintf(fp, "%*sFragment far discard: %s\n", indent, "", values->fragment_far_discard ? "true" : "false"); 2874} 2875 2876struct MALI_STENCIL_MASK_MISC { 2877 uint32_t stencil_mask_front; 2878 uint32_t stencil_mask_back; 2879 bool stencil_enable; 2880 bool alpha_to_coverage; 2881 bool alpha_to_coverage_invert; 2882 enum mali_func alpha_test_compare_function; 2883 bool force_seamless_cubemaps; 2884 bool depth_range_1; 2885 bool depth_range_2; 2886 bool single_sampled_lines; 2887 bool point_snap; 2888}; 2889 2890#define MALI_STENCIL_MASK_MISC_header \ 2891 0 2892 2893static inline void 2894MALI_STENCIL_MASK_MISC_pack(uint32_t * restrict cl, 2895 const struct MALI_STENCIL_MASK_MISC * restrict values) 2896{ 2897 cl[ 0] = __gen_uint(values->stencil_mask_front, 0, 7) | 2898 __gen_uint(values->stencil_mask_back, 8, 15) | 2899 __gen_uint(values->stencil_enable, 16, 16) | 2900 __gen_uint(values->alpha_to_coverage, 17, 17) | 2901 __gen_uint(values->alpha_to_coverage_invert, 18, 18) | 2902 __gen_uint(values->alpha_test_compare_function, 21, 23) | 2903 __gen_uint(values->force_seamless_cubemaps, 26, 26) | 2904 __gen_uint(values->depth_range_1, 28, 28) | 2905 __gen_uint(values->depth_range_2, 29, 29) | 2906 __gen_uint(values->single_sampled_lines, 30, 30) | 2907 __gen_uint(values->point_snap, 31, 31); 2908} 2909 2910 2911#define MALI_STENCIL_MASK_MISC_LENGTH 4 2912struct mali_stencil_mask_misc_packed { uint32_t opaque[1]; }; 2913static inline void 2914MALI_STENCIL_MASK_MISC_unpack(const uint8_t * restrict cl, 2915 struct MALI_STENCIL_MASK_MISC * restrict values) 2916{ 2917 if (((const uint32_t *) cl)[0] & 0xb180000) fprintf(stderr, "XXX: Invalid field of Stencil Mask, Misc unpacked at word 0\n"); 2918 values->stencil_mask_front = __gen_unpack_uint(cl, 0, 7); 2919 values->stencil_mask_back = __gen_unpack_uint(cl, 8, 15); 2920 values->stencil_enable = __gen_unpack_uint(cl, 16, 16); 2921 values->alpha_to_coverage = __gen_unpack_uint(cl, 17, 17); 2922 values->alpha_to_coverage_invert = __gen_unpack_uint(cl, 18, 18); 2923 values->alpha_test_compare_function = (enum mali_func)__gen_unpack_uint(cl, 21, 23); 2924 values->force_seamless_cubemaps = __gen_unpack_uint(cl, 26, 26); 2925 values->depth_range_1 = __gen_unpack_uint(cl, 28, 28); 2926 values->depth_range_2 = __gen_unpack_uint(cl, 29, 29); 2927 values->single_sampled_lines = __gen_unpack_uint(cl, 30, 30); 2928 values->point_snap = __gen_unpack_uint(cl, 31, 31); 2929} 2930 2931static inline void 2932MALI_STENCIL_MASK_MISC_print(FILE *fp, const struct MALI_STENCIL_MASK_MISC * values, unsigned indent) 2933{ 2934 fprintf(fp, "%*sStencil mask front: %u\n", indent, "", values->stencil_mask_front); 2935 fprintf(fp, "%*sStencil mask back: %u\n", indent, "", values->stencil_mask_back); 2936 fprintf(fp, "%*sStencil enable: %s\n", indent, "", values->stencil_enable ? "true" : "false"); 2937 fprintf(fp, "%*sAlpha-to-coverage: %s\n", indent, "", values->alpha_to_coverage ? "true" : "false"); 2938 fprintf(fp, "%*sAlpha-to-coverage Invert: %s\n", indent, "", values->alpha_to_coverage_invert ? "true" : "false"); 2939 fprintf(fp, "%*sAlpha test compare function: %s\n", indent, "", mali_func_as_str(values->alpha_test_compare_function)); 2940 fprintf(fp, "%*sForce seamless cubemaps: %s\n", indent, "", values->force_seamless_cubemaps ? "true" : "false"); 2941 fprintf(fp, "%*sDepth Range 1: %s\n", indent, "", values->depth_range_1 ? "true" : "false"); 2942 fprintf(fp, "%*sDepth Range 2: %s\n", indent, "", values->depth_range_2 ? "true" : "false"); 2943 fprintf(fp, "%*sSingle-sampled lines: %s\n", indent, "", values->single_sampled_lines ? "true" : "false"); 2944 fprintf(fp, "%*sPoint snap: %s\n", indent, "", values->point_snap ? "true" : "false"); 2945} 2946 2947struct MALI_STENCIL { 2948 uint32_t reference_value; 2949 uint32_t mask; 2950 enum mali_func compare_function; 2951 enum mali_stencil_op stencil_fail; 2952 enum mali_stencil_op depth_fail; 2953 enum mali_stencil_op depth_pass; 2954}; 2955 2956#define MALI_STENCIL_header \ 2957 0 2958 2959static inline void 2960MALI_STENCIL_pack(uint32_t * restrict cl, 2961 const struct MALI_STENCIL * restrict values) 2962{ 2963 cl[ 0] = __gen_uint(values->reference_value, 0, 7) | 2964 __gen_uint(values->mask, 8, 15) | 2965 __gen_uint(values->compare_function, 16, 18) | 2966 __gen_uint(values->stencil_fail, 19, 21) | 2967 __gen_uint(values->depth_fail, 22, 24) | 2968 __gen_uint(values->depth_pass, 25, 27); 2969} 2970 2971 2972#define MALI_STENCIL_LENGTH 4 2973struct mali_stencil_packed { uint32_t opaque[1]; }; 2974static inline void 2975MALI_STENCIL_unpack(const uint8_t * restrict cl, 2976 struct MALI_STENCIL * restrict values) 2977{ 2978 if (((const uint32_t *) cl)[0] & 0xf0000000) fprintf(stderr, "XXX: Invalid field of Stencil unpacked at word 0\n"); 2979 values->reference_value = __gen_unpack_uint(cl, 0, 7); 2980 values->mask = __gen_unpack_uint(cl, 8, 15); 2981 values->compare_function = (enum mali_func)__gen_unpack_uint(cl, 16, 18); 2982 values->stencil_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 19, 21); 2983 values->depth_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 22, 24); 2984 values->depth_pass = (enum mali_stencil_op)__gen_unpack_uint(cl, 25, 27); 2985} 2986 2987static inline void 2988MALI_STENCIL_print(FILE *fp, const struct MALI_STENCIL * values, unsigned indent) 2989{ 2990 fprintf(fp, "%*sReference Value: %u\n", indent, "", values->reference_value); 2991 fprintf(fp, "%*sMask: %u\n", indent, "", values->mask); 2992 fprintf(fp, "%*sCompare Function: %s\n", indent, "", mali_func_as_str(values->compare_function)); 2993 fprintf(fp, "%*sStencil Fail: %s\n", indent, "", mali_stencil_op_as_str(values->stencil_fail)); 2994 fprintf(fp, "%*sDepth Fail: %s\n", indent, "", mali_stencil_op_as_str(values->depth_fail)); 2995 fprintf(fp, "%*sDepth Pass: %s\n", indent, "", mali_stencil_op_as_str(values->depth_pass)); 2996} 2997 2998struct MALI_LD_VAR_PRELOAD { 2999 uint32_t varying_index; 3000 enum mali_message_preload_register_format register_format; 3001 uint32_t num_components; 3002}; 3003 3004#define MALI_LD_VAR_PRELOAD_header \ 3005 .num_components = 1 3006 3007static inline void 3008MALI_LD_VAR_PRELOAD_print(FILE *fp, const struct MALI_LD_VAR_PRELOAD * values, unsigned indent) 3009{ 3010 fprintf(fp, "%*sVarying Index: %u\n", indent, "", values->varying_index); 3011 fprintf(fp, "%*sRegister Format: %s\n", indent, "", mali_message_preload_register_format_as_str(values->register_format)); 3012 fprintf(fp, "%*sNum Components: %u\n", indent, "", values->num_components); 3013} 3014 3015struct MALI_VAR_TEX_PRELOAD { 3016 uint32_t varying_index; 3017 uint32_t sampler_index; 3018 enum mali_message_preload_register_format register_format; 3019 bool skip; 3020 bool zero_lod; 3021}; 3022 3023#define MALI_VAR_TEX_PRELOAD_header \ 3024 0 3025 3026static inline void 3027MALI_VAR_TEX_PRELOAD_print(FILE *fp, const struct MALI_VAR_TEX_PRELOAD * values, unsigned indent) 3028{ 3029 fprintf(fp, "%*sVarying Index: %u\n", indent, "", values->varying_index); 3030 fprintf(fp, "%*sSampler Index: %u\n", indent, "", values->sampler_index); 3031 fprintf(fp, "%*sRegister Format: %s\n", indent, "", mali_message_preload_register_format_as_str(values->register_format)); 3032 fprintf(fp, "%*sSkip: %s\n", indent, "", values->skip ? "true" : "false"); 3033 fprintf(fp, "%*sZero LOD: %s\n", indent, "", values->zero_lod ? "true" : "false"); 3034} 3035 3036struct MALI_MESSAGE_PRELOAD { 3037 enum mali_message_type type; 3038 struct MALI_LD_VAR_PRELOAD ld_var; 3039 struct MALI_VAR_TEX_PRELOAD var_tex; 3040}; 3041 3042#define MALI_MESSAGE_PRELOAD_header \ 3043 .ld_var = { MALI_LD_VAR_PRELOAD_header }, \ 3044 .var_tex = { MALI_VAR_TEX_PRELOAD_header } 3045 3046static inline void 3047MALI_MESSAGE_PRELOAD_pack(uint32_t * restrict cl, 3048 const struct MALI_MESSAGE_PRELOAD * restrict values) 3049{ 3050 cl[ 0] = __gen_uint(values->type, 0, 3) | 3051 __gen_uint(values->ld_var.varying_index, 4, 8) | 3052 __gen_uint(values->ld_var.register_format, 9, 10) | 3053 __gen_uint(values->ld_var.num_components - 1, 11, 12) | 3054 __gen_uint(values->var_tex.varying_index, 4, 6) | 3055 __gen_uint(values->var_tex.sampler_index, 7, 8) | 3056 __gen_uint(values->var_tex.register_format, 9, 10) | 3057 __gen_uint(values->var_tex.skip, 14, 14) | 3058 __gen_uint(values->var_tex.zero_lod, 15, 15); 3059} 3060 3061 3062#define MALI_MESSAGE_PRELOAD_LENGTH 4 3063struct mali_message_preload_packed { uint32_t opaque[1]; }; 3064static inline void 3065MALI_MESSAGE_PRELOAD_unpack(const uint8_t * restrict cl, 3066 struct MALI_MESSAGE_PRELOAD * restrict values) 3067{ 3068 if (((const uint32_t *) cl)[0] & 0xffff2000) fprintf(stderr, "XXX: Invalid field of Message Preload unpacked at word 0\n"); 3069 values->type = (enum mali_message_type)__gen_unpack_uint(cl, 0, 3); 3070 values->ld_var.varying_index = __gen_unpack_uint(cl, 4, 8); 3071 values->ld_var.register_format = (enum mali_message_preload_register_format)__gen_unpack_uint(cl, 9, 10); 3072 values->ld_var.num_components = __gen_unpack_uint(cl, 11, 12) + 1; 3073 values->var_tex.varying_index = __gen_unpack_uint(cl, 4, 6); 3074 values->var_tex.sampler_index = __gen_unpack_uint(cl, 7, 8); 3075 values->var_tex.register_format = (enum mali_message_preload_register_format)__gen_unpack_uint(cl, 9, 10); 3076 values->var_tex.skip = __gen_unpack_uint(cl, 14, 14); 3077 values->var_tex.zero_lod = __gen_unpack_uint(cl, 15, 15); 3078} 3079 3080static inline void 3081MALI_MESSAGE_PRELOAD_print(FILE *fp, const struct MALI_MESSAGE_PRELOAD * values, unsigned indent) 3082{ 3083 fprintf(fp, "%*sType: %s\n", indent, "", mali_message_type_as_str(values->type)); 3084 fprintf(fp, "%*sLD_VAR:\n", indent, ""); 3085 MALI_LD_VAR_PRELOAD_print(fp, &values->ld_var, indent + 2); 3086 fprintf(fp, "%*sVAR_TEX:\n", indent, ""); 3087 MALI_VAR_TEX_PRELOAD_print(fp, &values->var_tex, indent + 2); 3088} 3089 3090struct MALI_RENDERER_STATE { 3091 struct MALI_SHADER shader; 3092 struct MALI_RENDERER_PROPERTIES properties; 3093 float depth_units; 3094 float depth_factor; 3095 float depth_bias_clamp; 3096 struct MALI_MULTISAMPLE_MISC multisample_misc; 3097 struct MALI_STENCIL_MASK_MISC stencil_mask_misc; 3098 struct MALI_STENCIL stencil_front; 3099 struct MALI_STENCIL stencil_back; 3100 struct MALI_PRELOAD preload; 3101 float alpha_reference; 3102 uint32_t thread_balancing; 3103 struct MALI_PRELOAD secondary_preload; 3104 uint64_t secondary_shader; 3105}; 3106 3107#define MALI_RENDERER_STATE_header \ 3108 .shader = { MALI_SHADER_header }, \ 3109 .properties = { MALI_RENDERER_PROPERTIES_header }, \ 3110 .multisample_misc = { MALI_MULTISAMPLE_MISC_header }, \ 3111 .stencil_mask_misc = { MALI_STENCIL_MASK_MISC_header }, \ 3112 .stencil_front = { MALI_STENCIL_header }, \ 3113 .stencil_back = { MALI_STENCIL_header }, \ 3114 .preload = { MALI_PRELOAD_header }, \ 3115 .secondary_preload = { MALI_PRELOAD_header } 3116 3117static inline void 3118MALI_RENDERER_STATE_pack(uint32_t * restrict cl, 3119 const struct MALI_RENDERER_STATE * restrict values) 3120{ 3121 cl[ 0] = __gen_uint(values->shader.shader, 0, 63); 3122 cl[ 1] = __gen_uint(values->shader.shader, 0, 63) >> 32; 3123 cl[ 2] = __gen_uint(values->shader.sampler_count, 0, 15) | 3124 __gen_uint(values->shader.texture_count, 16, 31); 3125 cl[ 3] = __gen_uint(values->shader.attribute_count, 0, 15) | 3126 __gen_uint(values->shader.varying_count, 16, 31); 3127 cl[ 4] = __gen_uint(values->properties.uniform_buffer_count, 0, 7) | 3128 __gen_uint(values->properties.depth_source, 8, 9) | 3129 __gen_uint(values->properties.shader_contains_barrier, 11, 11) | 3130 __gen_uint(values->properties.shader_register_allocation, 12, 13) | 3131 __gen_uint(values->properties.shader_modifies_coverage, 16, 16) | 3132 __gen_uint(values->properties.allow_forward_pixel_to_kill, 19, 19) | 3133 __gen_uint(values->properties.allow_forward_pixel_to_be_killed, 20, 20) | 3134 __gen_uint(values->properties.pixel_kill_operation, 21, 22) | 3135 __gen_uint(values->properties.zs_update_operation, 23, 24) | 3136 __gen_uint(values->properties.point_sprite_coord_origin_max_y, 27, 27) | 3137 __gen_uint(values->properties.stencil_from_shader, 28, 28); 3138 cl[ 5] = __gen_uint(fui(values->depth_units), 0, 32); 3139 cl[ 6] = __gen_uint(fui(values->depth_factor), 0, 32); 3140 cl[ 7] = __gen_uint(fui(values->depth_bias_clamp), 0, 32); 3141 cl[ 8] = __gen_uint(values->multisample_misc.sample_mask, 0, 15) | 3142 __gen_uint(values->multisample_misc.multisample_enable, 16, 16) | 3143 __gen_uint(values->multisample_misc.multisample_late_coverage, 17, 17) | 3144 __gen_uint(values->multisample_misc.evaluate_per_sample, 18, 18) | 3145 __gen_uint(values->multisample_misc.fixed_function_depth_range_fixed, 19, 19) | 3146 __gen_uint(values->multisample_misc.shader_depth_range_fixed, 20, 20) | 3147 __gen_uint(values->multisample_misc.overdraw_alpha1, 22, 22) | 3148 __gen_uint(values->multisample_misc.overdraw_alpha0, 23, 23) | 3149 __gen_uint(values->multisample_misc.depth_function, 24, 26) | 3150 __gen_uint(values->multisample_misc.depth_write_mask, 27, 27) | 3151 __gen_uint(values->multisample_misc.fixed_function_near_discard, 28, 28) | 3152 __gen_uint(values->multisample_misc.fixed_function_far_discard, 29, 29) | 3153 __gen_uint(values->multisample_misc.fragment_near_discard, 30, 30) | 3154 __gen_uint(values->multisample_misc.fragment_far_discard, 31, 31); 3155 cl[ 9] = __gen_uint(values->stencil_mask_misc.stencil_mask_front, 0, 7) | 3156 __gen_uint(values->stencil_mask_misc.stencil_mask_back, 8, 15) | 3157 __gen_uint(values->stencil_mask_misc.stencil_enable, 16, 16) | 3158 __gen_uint(values->stencil_mask_misc.alpha_to_coverage, 17, 17) | 3159 __gen_uint(values->stencil_mask_misc.alpha_to_coverage_invert, 18, 18) | 3160 __gen_uint(values->stencil_mask_misc.alpha_test_compare_function, 21, 23) | 3161 __gen_uint(values->stencil_mask_misc.force_seamless_cubemaps, 26, 26) | 3162 __gen_uint(values->stencil_mask_misc.depth_range_1, 28, 28) | 3163 __gen_uint(values->stencil_mask_misc.depth_range_2, 29, 29) | 3164 __gen_uint(values->stencil_mask_misc.single_sampled_lines, 30, 30) | 3165 __gen_uint(values->stencil_mask_misc.point_snap, 31, 31); 3166 cl[10] = __gen_uint(values->stencil_front.reference_value, 0, 7) | 3167 __gen_uint(values->stencil_front.mask, 8, 15) | 3168 __gen_uint(values->stencil_front.compare_function, 16, 18) | 3169 __gen_uint(values->stencil_front.stencil_fail, 19, 21) | 3170 __gen_uint(values->stencil_front.depth_fail, 22, 24) | 3171 __gen_uint(values->stencil_front.depth_pass, 25, 27); 3172 cl[11] = __gen_uint(values->stencil_back.reference_value, 0, 7) | 3173 __gen_uint(values->stencil_back.mask, 8, 15) | 3174 __gen_uint(values->stencil_back.compare_function, 16, 18) | 3175 __gen_uint(values->stencil_back.stencil_fail, 19, 21) | 3176 __gen_uint(values->stencil_back.depth_fail, 22, 24) | 3177 __gen_uint(values->stencil_back.depth_pass, 25, 27); 3178 cl[12] = __gen_uint(values->preload.compute.pc, 6, 6) | 3179 __gen_uint(values->preload.compute.local_invocation_xy, 7, 7) | 3180 __gen_uint(values->preload.compute.local_invocation_z, 8, 8) | 3181 __gen_uint(values->preload.compute.work_group_x, 9, 9) | 3182 __gen_uint(values->preload.compute.work_group_y, 10, 10) | 3183 __gen_uint(values->preload.compute.work_group_z, 11, 11) | 3184 __gen_uint(values->preload.compute.global_invocation_x, 12, 12) | 3185 __gen_uint(values->preload.compute.global_invocation_y, 13, 13) | 3186 __gen_uint(values->preload.compute.global_invocation_z, 14, 14) | 3187 __gen_uint(values->preload.vertex.warp_limit, 0, 1) | 3188 __gen_uint(values->preload.vertex.pc, 6, 6) | 3189 __gen_uint(values->preload.vertex.position_result_address_lo, 10, 10) | 3190 __gen_uint(values->preload.vertex.position_result_address_hi, 11, 11) | 3191 __gen_uint(values->preload.vertex.vertex_id, 13, 13) | 3192 __gen_uint(values->preload.vertex.instance_id, 14, 14) | 3193 __gen_uint(values->preload.fragment.pc, 6, 6) | 3194 __gen_uint(values->preload.fragment.coverage, 7, 7) | 3195 __gen_uint(values->preload.fragment.primitive_id, 9, 9) | 3196 __gen_uint(values->preload.fragment.primitive_flags, 10, 10) | 3197 __gen_uint(values->preload.fragment.fragment_position, 11, 11) | 3198 __gen_uint(values->preload.fragment.sample_mask_id, 13, 13) | 3199 __gen_uint(values->preload.uniform_count, 15, 21) | 3200 __gen_uint(fui(values->alpha_reference), 0, 32); 3201 cl[13] = __gen_uint(values->thread_balancing, 0, 15) | 3202 __gen_uint(values->secondary_preload.compute.pc, 6, 6) | 3203 __gen_uint(values->secondary_preload.compute.local_invocation_xy, 7, 7) | 3204 __gen_uint(values->secondary_preload.compute.local_invocation_z, 8, 8) | 3205 __gen_uint(values->secondary_preload.compute.work_group_x, 9, 9) | 3206 __gen_uint(values->secondary_preload.compute.work_group_y, 10, 10) | 3207 __gen_uint(values->secondary_preload.compute.work_group_z, 11, 11) | 3208 __gen_uint(values->secondary_preload.compute.global_invocation_x, 12, 12) | 3209 __gen_uint(values->secondary_preload.compute.global_invocation_y, 13, 13) | 3210 __gen_uint(values->secondary_preload.compute.global_invocation_z, 14, 14) | 3211 __gen_uint(values->secondary_preload.vertex.warp_limit, 0, 1) | 3212 __gen_uint(values->secondary_preload.vertex.pc, 6, 6) | 3213 __gen_uint(values->secondary_preload.vertex.position_result_address_lo, 10, 10) | 3214 __gen_uint(values->secondary_preload.vertex.position_result_address_hi, 11, 11) | 3215 __gen_uint(values->secondary_preload.vertex.vertex_id, 13, 13) | 3216 __gen_uint(values->secondary_preload.vertex.instance_id, 14, 14) | 3217 __gen_uint(values->secondary_preload.fragment.pc, 6, 6) | 3218 __gen_uint(values->secondary_preload.fragment.coverage, 7, 7) | 3219 __gen_uint(values->secondary_preload.fragment.primitive_id, 9, 9) | 3220 __gen_uint(values->secondary_preload.fragment.primitive_flags, 10, 10) | 3221 __gen_uint(values->secondary_preload.fragment.fragment_position, 11, 11) | 3222 __gen_uint(values->secondary_preload.fragment.sample_mask_id, 13, 13) | 3223 __gen_uint(values->secondary_preload.uniform_count, 15, 21); 3224 cl[14] = __gen_uint(values->secondary_shader, 0, 63); 3225 cl[15] = __gen_uint(values->secondary_shader, 0, 63) >> 32; 3226} 3227 3228 3229#define MALI_RENDERER_STATE_LENGTH 64 3230#define MALI_RENDERER_STATE_ALIGN 64 3231struct mali_renderer_state_packed { uint32_t opaque[16]; }; 3232static inline void 3233MALI_RENDERER_STATE_unpack(const uint8_t * restrict cl, 3234 struct MALI_RENDERER_STATE * restrict values) 3235{ 3236 if (((const uint32_t *) cl)[4] & 0xe606c400) fprintf(stderr, "XXX: Invalid field of Renderer State unpacked at word 4\n"); 3237 if (((const uint32_t *) cl)[8] & 0x200000) fprintf(stderr, "XXX: Invalid field of Renderer State unpacked at word 8\n"); 3238 if (((const uint32_t *) cl)[9] & 0xb180000) fprintf(stderr, "XXX: Invalid field of Renderer State unpacked at word 9\n"); 3239 if (((const uint32_t *) cl)[10] & 0xf0000000) fprintf(stderr, "XXX: Invalid field of Renderer State unpacked at word 10\n"); 3240 if (((const uint32_t *) cl)[11] & 0xf0000000) fprintf(stderr, "XXX: Invalid field of Renderer State unpacked at word 11\n"); 3241 if (((const uint32_t *) cl)[13] & 0xffc00000) fprintf(stderr, "XXX: Invalid field of Renderer State unpacked at word 13\n"); 3242 values->shader.shader = __gen_unpack_uint(cl, 0, 63); 3243 values->shader.sampler_count = __gen_unpack_uint(cl, 64, 79); 3244 values->shader.texture_count = __gen_unpack_uint(cl, 80, 95); 3245 values->shader.attribute_count = __gen_unpack_uint(cl, 96, 111); 3246 values->shader.varying_count = __gen_unpack_uint(cl, 112, 127); 3247 values->properties.uniform_buffer_count = __gen_unpack_uint(cl, 128, 135); 3248 values->properties.depth_source = (enum mali_depth_source)__gen_unpack_uint(cl, 136, 137); 3249 values->properties.shader_contains_barrier = __gen_unpack_uint(cl, 139, 139); 3250 values->properties.shader_register_allocation = (enum mali_shader_register_allocation)__gen_unpack_uint(cl, 140, 141); 3251 values->properties.shader_modifies_coverage = __gen_unpack_uint(cl, 144, 144); 3252 values->properties.allow_forward_pixel_to_kill = __gen_unpack_uint(cl, 147, 147); 3253 values->properties.allow_forward_pixel_to_be_killed = __gen_unpack_uint(cl, 148, 148); 3254 values->properties.pixel_kill_operation = (enum mali_pixel_kill)__gen_unpack_uint(cl, 149, 150); 3255 values->properties.zs_update_operation = (enum mali_pixel_kill)__gen_unpack_uint(cl, 151, 152); 3256 values->properties.point_sprite_coord_origin_max_y = __gen_unpack_uint(cl, 155, 155); 3257 values->properties.stencil_from_shader = __gen_unpack_uint(cl, 156, 156); 3258 values->depth_units = __gen_unpack_float(cl, 160, 191); 3259 values->depth_factor = __gen_unpack_float(cl, 192, 223); 3260 values->depth_bias_clamp = __gen_unpack_float(cl, 224, 255); 3261 values->multisample_misc.sample_mask = __gen_unpack_uint(cl, 256, 271); 3262 values->multisample_misc.multisample_enable = __gen_unpack_uint(cl, 272, 272); 3263 values->multisample_misc.multisample_late_coverage = __gen_unpack_uint(cl, 273, 273); 3264 values->multisample_misc.evaluate_per_sample = __gen_unpack_uint(cl, 274, 274); 3265 values->multisample_misc.fixed_function_depth_range_fixed = __gen_unpack_uint(cl, 275, 275); 3266 values->multisample_misc.shader_depth_range_fixed = __gen_unpack_uint(cl, 276, 276); 3267 values->multisample_misc.overdraw_alpha1 = __gen_unpack_uint(cl, 278, 278); 3268 values->multisample_misc.overdraw_alpha0 = __gen_unpack_uint(cl, 279, 279); 3269 values->multisample_misc.depth_function = (enum mali_func)__gen_unpack_uint(cl, 280, 282); 3270 values->multisample_misc.depth_write_mask = __gen_unpack_uint(cl, 283, 283); 3271 values->multisample_misc.fixed_function_near_discard = __gen_unpack_uint(cl, 284, 284); 3272 values->multisample_misc.fixed_function_far_discard = __gen_unpack_uint(cl, 285, 285); 3273 values->multisample_misc.fragment_near_discard = __gen_unpack_uint(cl, 286, 286); 3274 values->multisample_misc.fragment_far_discard = __gen_unpack_uint(cl, 287, 287); 3275 values->stencil_mask_misc.stencil_mask_front = __gen_unpack_uint(cl, 288, 295); 3276 values->stencil_mask_misc.stencil_mask_back = __gen_unpack_uint(cl, 296, 303); 3277 values->stencil_mask_misc.stencil_enable = __gen_unpack_uint(cl, 304, 304); 3278 values->stencil_mask_misc.alpha_to_coverage = __gen_unpack_uint(cl, 305, 305); 3279 values->stencil_mask_misc.alpha_to_coverage_invert = __gen_unpack_uint(cl, 306, 306); 3280 values->stencil_mask_misc.alpha_test_compare_function = (enum mali_func)__gen_unpack_uint(cl, 309, 311); 3281 values->stencil_mask_misc.force_seamless_cubemaps = __gen_unpack_uint(cl, 314, 314); 3282 values->stencil_mask_misc.depth_range_1 = __gen_unpack_uint(cl, 316, 316); 3283 values->stencil_mask_misc.depth_range_2 = __gen_unpack_uint(cl, 317, 317); 3284 values->stencil_mask_misc.single_sampled_lines = __gen_unpack_uint(cl, 318, 318); 3285 values->stencil_mask_misc.point_snap = __gen_unpack_uint(cl, 319, 319); 3286 values->stencil_front.reference_value = __gen_unpack_uint(cl, 320, 327); 3287 values->stencil_front.mask = __gen_unpack_uint(cl, 328, 335); 3288 values->stencil_front.compare_function = (enum mali_func)__gen_unpack_uint(cl, 336, 338); 3289 values->stencil_front.stencil_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 339, 341); 3290 values->stencil_front.depth_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 342, 344); 3291 values->stencil_front.depth_pass = (enum mali_stencil_op)__gen_unpack_uint(cl, 345, 347); 3292 values->stencil_back.reference_value = __gen_unpack_uint(cl, 352, 359); 3293 values->stencil_back.mask = __gen_unpack_uint(cl, 360, 367); 3294 values->stencil_back.compare_function = (enum mali_func)__gen_unpack_uint(cl, 368, 370); 3295 values->stencil_back.stencil_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 371, 373); 3296 values->stencil_back.depth_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 374, 376); 3297 values->stencil_back.depth_pass = (enum mali_stencil_op)__gen_unpack_uint(cl, 377, 379); 3298 values->preload.compute.pc = __gen_unpack_uint(cl, 390, 390); 3299 values->preload.compute.local_invocation_xy = __gen_unpack_uint(cl, 391, 391); 3300 values->preload.compute.local_invocation_z = __gen_unpack_uint(cl, 392, 392); 3301 values->preload.compute.work_group_x = __gen_unpack_uint(cl, 393, 393); 3302 values->preload.compute.work_group_y = __gen_unpack_uint(cl, 394, 394); 3303 values->preload.compute.work_group_z = __gen_unpack_uint(cl, 395, 395); 3304 values->preload.compute.global_invocation_x = __gen_unpack_uint(cl, 396, 396); 3305 values->preload.compute.global_invocation_y = __gen_unpack_uint(cl, 397, 397); 3306 values->preload.compute.global_invocation_z = __gen_unpack_uint(cl, 398, 398); 3307 values->preload.vertex.warp_limit = (enum mali_warp_limit)__gen_unpack_uint(cl, 384, 385); 3308 values->preload.vertex.pc = __gen_unpack_uint(cl, 390, 390); 3309 values->preload.vertex.position_result_address_lo = __gen_unpack_uint(cl, 394, 394); 3310 values->preload.vertex.position_result_address_hi = __gen_unpack_uint(cl, 395, 395); 3311 values->preload.vertex.vertex_id = __gen_unpack_uint(cl, 397, 397); 3312 values->preload.vertex.instance_id = __gen_unpack_uint(cl, 398, 398); 3313 values->preload.fragment.pc = __gen_unpack_uint(cl, 390, 390); 3314 values->preload.fragment.coverage = __gen_unpack_uint(cl, 391, 391); 3315 values->preload.fragment.primitive_id = __gen_unpack_uint(cl, 393, 393); 3316 values->preload.fragment.primitive_flags = __gen_unpack_uint(cl, 394, 394); 3317 values->preload.fragment.fragment_position = __gen_unpack_uint(cl, 395, 395); 3318 values->preload.fragment.sample_mask_id = __gen_unpack_uint(cl, 397, 397); 3319 values->preload.uniform_count = __gen_unpack_uint(cl, 399, 405); 3320 values->alpha_reference = __gen_unpack_float(cl, 384, 415); 3321 values->thread_balancing = __gen_unpack_uint(cl, 416, 431); 3322 values->secondary_preload.compute.pc = __gen_unpack_uint(cl, 422, 422); 3323 values->secondary_preload.compute.local_invocation_xy = __gen_unpack_uint(cl, 423, 423); 3324 values->secondary_preload.compute.local_invocation_z = __gen_unpack_uint(cl, 424, 424); 3325 values->secondary_preload.compute.work_group_x = __gen_unpack_uint(cl, 425, 425); 3326 values->secondary_preload.compute.work_group_y = __gen_unpack_uint(cl, 426, 426); 3327 values->secondary_preload.compute.work_group_z = __gen_unpack_uint(cl, 427, 427); 3328 values->secondary_preload.compute.global_invocation_x = __gen_unpack_uint(cl, 428, 428); 3329 values->secondary_preload.compute.global_invocation_y = __gen_unpack_uint(cl, 429, 429); 3330 values->secondary_preload.compute.global_invocation_z = __gen_unpack_uint(cl, 430, 430); 3331 values->secondary_preload.vertex.warp_limit = (enum mali_warp_limit)__gen_unpack_uint(cl, 416, 417); 3332 values->secondary_preload.vertex.pc = __gen_unpack_uint(cl, 422, 422); 3333 values->secondary_preload.vertex.position_result_address_lo = __gen_unpack_uint(cl, 426, 426); 3334 values->secondary_preload.vertex.position_result_address_hi = __gen_unpack_uint(cl, 427, 427); 3335 values->secondary_preload.vertex.vertex_id = __gen_unpack_uint(cl, 429, 429); 3336 values->secondary_preload.vertex.instance_id = __gen_unpack_uint(cl, 430, 430); 3337 values->secondary_preload.fragment.pc = __gen_unpack_uint(cl, 422, 422); 3338 values->secondary_preload.fragment.coverage = __gen_unpack_uint(cl, 423, 423); 3339 values->secondary_preload.fragment.primitive_id = __gen_unpack_uint(cl, 425, 425); 3340 values->secondary_preload.fragment.primitive_flags = __gen_unpack_uint(cl, 426, 426); 3341 values->secondary_preload.fragment.fragment_position = __gen_unpack_uint(cl, 427, 427); 3342 values->secondary_preload.fragment.sample_mask_id = __gen_unpack_uint(cl, 429, 429); 3343 values->secondary_preload.uniform_count = __gen_unpack_uint(cl, 431, 437); 3344 values->secondary_shader = __gen_unpack_uint(cl, 448, 511); 3345} 3346 3347static inline void 3348MALI_RENDERER_STATE_print(FILE *fp, const struct MALI_RENDERER_STATE * values, unsigned indent) 3349{ 3350 fprintf(fp, "%*sShader:\n", indent, ""); 3351 MALI_SHADER_print(fp, &values->shader, indent + 2); 3352 fprintf(fp, "%*sProperties:\n", indent, ""); 3353 MALI_RENDERER_PROPERTIES_print(fp, &values->properties, indent + 2); 3354 fprintf(fp, "%*sDepth units: %f\n", indent, "", values->depth_units); 3355 fprintf(fp, "%*sDepth factor: %f\n", indent, "", values->depth_factor); 3356 fprintf(fp, "%*sDepth bias clamp: %f\n", indent, "", values->depth_bias_clamp); 3357 fprintf(fp, "%*sMultisample, Misc:\n", indent, ""); 3358 MALI_MULTISAMPLE_MISC_print(fp, &values->multisample_misc, indent + 2); 3359 fprintf(fp, "%*sStencil Mask, Misc:\n", indent, ""); 3360 MALI_STENCIL_MASK_MISC_print(fp, &values->stencil_mask_misc, indent + 2); 3361 fprintf(fp, "%*sStencil front:\n", indent, ""); 3362 MALI_STENCIL_print(fp, &values->stencil_front, indent + 2); 3363 fprintf(fp, "%*sStencil back:\n", indent, ""); 3364 MALI_STENCIL_print(fp, &values->stencil_back, indent + 2); 3365 fprintf(fp, "%*sPreload:\n", indent, ""); 3366 MALI_PRELOAD_print(fp, &values->preload, indent + 2); 3367 fprintf(fp, "%*sAlpha reference: %f\n", indent, "", values->alpha_reference); 3368 fprintf(fp, "%*sThread Balancing: %u\n", indent, "", values->thread_balancing); 3369 fprintf(fp, "%*sSecondary preload:\n", indent, ""); 3370 MALI_PRELOAD_print(fp, &values->secondary_preload, indent + 2); 3371 fprintf(fp, "%*sSecondary shader: 0x%" PRIx64 "\n", indent, "", values->secondary_shader); 3372} 3373 3374struct MALI_UNIFORM_BUFFER { 3375 uint32_t entries; 3376 uint64_t pointer; 3377}; 3378 3379#define MALI_UNIFORM_BUFFER_header \ 3380 0 3381 3382static inline void 3383MALI_UNIFORM_BUFFER_pack(uint32_t * restrict cl, 3384 const struct MALI_UNIFORM_BUFFER * restrict values) 3385{ 3386 assert(values->entries >= 1); 3387 assert((values->pointer & 0xf) == 0); 3388 cl[ 0] = __gen_uint(values->entries - 1, 0, 11) | 3389 __gen_uint(values->pointer >> 4, 12, 63); 3390 cl[ 1] = __gen_uint(values->pointer >> 4, 12, 63) >> 32; 3391} 3392 3393 3394#define MALI_UNIFORM_BUFFER_LENGTH 8 3395#define MALI_UNIFORM_BUFFER_ALIGN 8 3396struct mali_uniform_buffer_packed { uint32_t opaque[2]; }; 3397static inline void 3398MALI_UNIFORM_BUFFER_unpack(const uint8_t * restrict cl, 3399 struct MALI_UNIFORM_BUFFER * restrict values) 3400{ 3401 values->entries = __gen_unpack_uint(cl, 0, 11) + 1; 3402 values->pointer = __gen_unpack_uint(cl, 12, 63) << 4; 3403} 3404 3405static inline void 3406MALI_UNIFORM_BUFFER_print(FILE *fp, const struct MALI_UNIFORM_BUFFER * values, unsigned indent) 3407{ 3408 fprintf(fp, "%*sEntries: %u\n", indent, "", values->entries); 3409 fprintf(fp, "%*sPointer: 0x%" PRIx64 "\n", indent, "", values->pointer); 3410} 3411 3412struct MALI_VIEWPORT { 3413 float minimum_x; 3414 float minimum_y; 3415 float maximum_x; 3416 float maximum_y; 3417 float minimum_z; 3418 float maximum_z; 3419 uint32_t scissor_minimum_x; 3420 uint32_t scissor_minimum_y; 3421 uint32_t scissor_maximum_x; 3422 uint32_t scissor_maximum_y; 3423}; 3424 3425#define MALI_VIEWPORT_header \ 3426 .minimum_x = -INFINITY, \ 3427 .minimum_y = -INFINITY, \ 3428 .maximum_x = +INFINITY, \ 3429 .maximum_y = +INFINITY, \ 3430 .minimum_z = 0.0, \ 3431 .maximum_z = 1.0, \ 3432 .scissor_minimum_x = 0, \ 3433 .scissor_minimum_y = 0 3434 3435static inline void 3436MALI_VIEWPORT_pack(uint32_t * restrict cl, 3437 const struct MALI_VIEWPORT * restrict values) 3438{ 3439 cl[ 0] = __gen_uint(fui(values->minimum_x), 0, 32); 3440 cl[ 1] = __gen_uint(fui(values->minimum_y), 0, 32); 3441 cl[ 2] = __gen_uint(fui(values->maximum_x), 0, 32); 3442 cl[ 3] = __gen_uint(fui(values->maximum_y), 0, 32); 3443 cl[ 4] = __gen_uint(fui(values->minimum_z), 0, 32); 3444 cl[ 5] = __gen_uint(fui(values->maximum_z), 0, 32); 3445 cl[ 6] = __gen_uint(values->scissor_minimum_x, 0, 15) | 3446 __gen_uint(values->scissor_minimum_y, 16, 31); 3447 cl[ 7] = __gen_uint(values->scissor_maximum_x, 0, 15) | 3448 __gen_uint(values->scissor_maximum_y, 16, 31); 3449} 3450 3451 3452#define MALI_VIEWPORT_LENGTH 32 3453#define MALI_VIEWPORT_ALIGN 32 3454struct mali_viewport_packed { uint32_t opaque[8]; }; 3455static inline void 3456MALI_VIEWPORT_unpack(const uint8_t * restrict cl, 3457 struct MALI_VIEWPORT * restrict values) 3458{ 3459 values->minimum_x = __gen_unpack_float(cl, 0, 31); 3460 values->minimum_y = __gen_unpack_float(cl, 32, 63); 3461 values->maximum_x = __gen_unpack_float(cl, 64, 95); 3462 values->maximum_y = __gen_unpack_float(cl, 96, 127); 3463 values->minimum_z = __gen_unpack_float(cl, 128, 159); 3464 values->maximum_z = __gen_unpack_float(cl, 160, 191); 3465 values->scissor_minimum_x = __gen_unpack_uint(cl, 192, 207); 3466 values->scissor_minimum_y = __gen_unpack_uint(cl, 208, 223); 3467 values->scissor_maximum_x = __gen_unpack_uint(cl, 224, 239); 3468 values->scissor_maximum_y = __gen_unpack_uint(cl, 240, 255); 3469} 3470 3471static inline void 3472MALI_VIEWPORT_print(FILE *fp, const struct MALI_VIEWPORT * values, unsigned indent) 3473{ 3474 fprintf(fp, "%*sMinimum X: %f\n", indent, "", values->minimum_x); 3475 fprintf(fp, "%*sMinimum Y: %f\n", indent, "", values->minimum_y); 3476 fprintf(fp, "%*sMaximum X: %f\n", indent, "", values->maximum_x); 3477 fprintf(fp, "%*sMaximum Y: %f\n", indent, "", values->maximum_y); 3478 fprintf(fp, "%*sMinimum Z: %f\n", indent, "", values->minimum_z); 3479 fprintf(fp, "%*sMaximum Z: %f\n", indent, "", values->maximum_z); 3480 fprintf(fp, "%*sScissor Minimum X: %u\n", indent, "", values->scissor_minimum_x); 3481 fprintf(fp, "%*sScissor Minimum Y: %u\n", indent, "", values->scissor_minimum_y); 3482 fprintf(fp, "%*sScissor Maximum X: %u\n", indent, "", values->scissor_maximum_x); 3483 fprintf(fp, "%*sScissor Maximum Y: %u\n", indent, "", values->scissor_maximum_y); 3484} 3485 3486struct MALI_LOCAL_STORAGE { 3487 uint32_t tls_size; 3488 uint32_t tls_initial_stack_pointer_offset; 3489 uint32_t wls_instances; 3490#define MALI_LOCAL_STORAGE_NO_WORKGROUP_MEM 2147483648 3491 uint32_t wls_size_base; 3492 uint32_t wls_size_scale; 3493 uint64_t tls_base_pointer; 3494 uint64_t wls_base_pointer; 3495}; 3496 3497#define MALI_LOCAL_STORAGE_header \ 3498 .wls_instances = MALI_LOCAL_STORAGE_NO_WORKGROUP_MEM 3499 3500static inline void 3501MALI_LOCAL_STORAGE_pack(uint32_t * restrict cl, 3502 const struct MALI_LOCAL_STORAGE * restrict values) 3503{ 3504 assert(util_is_power_of_two_nonzero(values->wls_instances)); 3505 cl[ 0] = __gen_uint(values->tls_size, 0, 4) | 3506 __gen_uint(values->tls_initial_stack_pointer_offset, 5, 31); 3507 cl[ 1] = __gen_uint(util_logbase2(values->wls_instances), 0, 4) | 3508 __gen_uint(values->wls_size_base, 5, 6) | 3509 __gen_uint(values->wls_size_scale, 8, 12); 3510 cl[ 2] = __gen_uint(values->tls_base_pointer, 0, 63); 3511 cl[ 3] = __gen_uint(values->tls_base_pointer, 0, 63) >> 32; 3512 cl[ 4] = __gen_uint(values->wls_base_pointer, 0, 63); 3513 cl[ 5] = __gen_uint(values->wls_base_pointer, 0, 63) >> 32; 3514 cl[ 6] = 0; 3515 cl[ 7] = 0; 3516} 3517 3518 3519#define MALI_LOCAL_STORAGE_LENGTH 32 3520#define MALI_LOCAL_STORAGE_ALIGN 64 3521struct mali_local_storage_packed { uint32_t opaque[8]; }; 3522static inline void 3523MALI_LOCAL_STORAGE_unpack(const uint8_t * restrict cl, 3524 struct MALI_LOCAL_STORAGE * restrict values) 3525{ 3526 if (((const uint32_t *) cl)[1] & 0xffffe080) fprintf(stderr, "XXX: Invalid field of Local Storage unpacked at word 1\n"); 3527 if (((const uint32_t *) cl)[6] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Local Storage unpacked at word 6\n"); 3528 if (((const uint32_t *) cl)[7] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Local Storage unpacked at word 7\n"); 3529 values->tls_size = __gen_unpack_uint(cl, 0, 4); 3530 values->tls_initial_stack_pointer_offset = __gen_unpack_uint(cl, 5, 31); 3531 values->wls_instances = 1U << __gen_unpack_uint(cl, 32, 36); 3532 values->wls_size_base = __gen_unpack_uint(cl, 37, 38); 3533 values->wls_size_scale = __gen_unpack_uint(cl, 40, 44); 3534 values->tls_base_pointer = __gen_unpack_uint(cl, 64, 127); 3535 values->wls_base_pointer = __gen_unpack_uint(cl, 128, 191); 3536} 3537 3538static inline void 3539MALI_LOCAL_STORAGE_print(FILE *fp, const struct MALI_LOCAL_STORAGE * values, unsigned indent) 3540{ 3541 fprintf(fp, "%*sTLS Size: %u\n", indent, "", values->tls_size); 3542 fprintf(fp, "%*sTLS Initial Stack Pointer Offset: %u\n", indent, "", values->tls_initial_stack_pointer_offset); 3543 fprintf(fp, "%*sWLS Instances: %u\n", indent, "", values->wls_instances); 3544 fprintf(fp, "%*sWLS Size Base: %u\n", indent, "", values->wls_size_base); 3545 fprintf(fp, "%*sWLS Size Scale: %u\n", indent, "", values->wls_size_scale); 3546 fprintf(fp, "%*sTLS Base Pointer: 0x%" PRIx64 "\n", indent, "", values->tls_base_pointer); 3547 fprintf(fp, "%*sWLS Base Pointer: 0x%" PRIx64 "\n", indent, "", values->wls_base_pointer); 3548} 3549 3550enum mali_color_buffer_internal_format { 3551 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW_VALUE = 0, 3552 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R8G8B8A8 = 1, 3553 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R10G10B10A2 = 2, 3554 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R8G8B8A2 = 3, 3555 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R4G4B4A4 = 4, 3556 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R5G6B5A0 = 5, 3557 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R5G5B5A1 = 6, 3558 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW8 = 32, 3559 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW16 = 33, 3560 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW32 = 34, 3561 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW64 = 35, 3562 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW128 = 36, 3563}; 3564 3565static inline const char * 3566mali_color_buffer_internal_format_as_str(enum mali_color_buffer_internal_format imm) 3567{ 3568 switch (imm) { 3569 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW_VALUE: return "Raw Value"; 3570 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R8G8B8A8: return "R8G8B8A8"; 3571 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R10G10B10A2: return "R10G10B10A2"; 3572 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R8G8B8A2: return "R8G8B8A2"; 3573 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R4G4B4A4: return "R4G4B4A4"; 3574 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R5G6B5A0: return "R5G6B5A0"; 3575 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R5G5B5A1: return "R5G5B5A1"; 3576 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW8: return "RAW8"; 3577 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW16: return "RAW16"; 3578 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW32: return "RAW32"; 3579 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW64: return "RAW64"; 3580 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW128: return "RAW128"; 3581 default: return "XXX: INVALID"; 3582 } 3583} 3584 3585enum mali_color_format { 3586 MALI_COLOR_FORMAT_RAW8 = 0, 3587 MALI_COLOR_FORMAT_RAW16 = 1, 3588 MALI_COLOR_FORMAT_RAW24 = 2, 3589 MALI_COLOR_FORMAT_RAW32 = 3, 3590 MALI_COLOR_FORMAT_RAW48 = 4, 3591 MALI_COLOR_FORMAT_RAW64 = 5, 3592 MALI_COLOR_FORMAT_RAW96 = 6, 3593 MALI_COLOR_FORMAT_RAW128 = 7, 3594 MALI_COLOR_FORMAT_RAW192 = 8, 3595 MALI_COLOR_FORMAT_RAW256 = 9, 3596 MALI_COLOR_FORMAT_RAW384 = 10, 3597 MALI_COLOR_FORMAT_RAW512 = 11, 3598 MALI_COLOR_FORMAT_RAW768 = 12, 3599 MALI_COLOR_FORMAT_RAW1024 = 13, 3600 MALI_COLOR_FORMAT_RAW1536 = 14, 3601 MALI_COLOR_FORMAT_RAW2048 = 15, 3602 MALI_COLOR_FORMAT_R8 = 16, 3603 MALI_COLOR_FORMAT_R8G8 = 17, 3604 MALI_COLOR_FORMAT_R8G8B8 = 18, 3605 MALI_COLOR_FORMAT_R8G8B8A8 = 19, 3606 MALI_COLOR_FORMAT_R4G4B4A4 = 20, 3607 MALI_COLOR_FORMAT_R5G6B5 = 21, 3608 MALI_COLOR_FORMAT_R8G8B8_FROM_R8G8B8A2 = 22, 3609 MALI_COLOR_FORMAT_R10G10B10A2 = 24, 3610 MALI_COLOR_FORMAT_A2B10G10R10 = 25, 3611 MALI_COLOR_FORMAT_R5G5B5A1 = 28, 3612 MALI_COLOR_FORMAT_A1B5G5R5 = 29, 3613 MALI_COLOR_FORMAT_NATIVE = 31, 3614}; 3615 3616static inline const char * 3617mali_color_format_as_str(enum mali_color_format imm) 3618{ 3619 switch (imm) { 3620 case MALI_COLOR_FORMAT_RAW8: return "RAW8"; 3621 case MALI_COLOR_FORMAT_RAW16: return "RAW16"; 3622 case MALI_COLOR_FORMAT_RAW24: return "RAW24"; 3623 case MALI_COLOR_FORMAT_RAW32: return "RAW32"; 3624 case MALI_COLOR_FORMAT_RAW48: return "RAW48"; 3625 case MALI_COLOR_FORMAT_RAW64: return "RAW64"; 3626 case MALI_COLOR_FORMAT_RAW96: return "RAW96"; 3627 case MALI_COLOR_FORMAT_RAW128: return "RAW128"; 3628 case MALI_COLOR_FORMAT_RAW192: return "RAW192"; 3629 case MALI_COLOR_FORMAT_RAW256: return "RAW256"; 3630 case MALI_COLOR_FORMAT_RAW384: return "RAW384"; 3631 case MALI_COLOR_FORMAT_RAW512: return "RAW512"; 3632 case MALI_COLOR_FORMAT_RAW768: return "RAW768"; 3633 case MALI_COLOR_FORMAT_RAW1024: return "RAW1024"; 3634 case MALI_COLOR_FORMAT_RAW1536: return "RAW1536"; 3635 case MALI_COLOR_FORMAT_RAW2048: return "RAW2048"; 3636 case MALI_COLOR_FORMAT_R8: return "R8"; 3637 case MALI_COLOR_FORMAT_R8G8: return "R8G8"; 3638 case MALI_COLOR_FORMAT_R8G8B8: return "R8G8B8"; 3639 case MALI_COLOR_FORMAT_R8G8B8A8: return "R8G8B8A8"; 3640 case MALI_COLOR_FORMAT_R4G4B4A4: return "R4G4B4A4"; 3641 case MALI_COLOR_FORMAT_R5G6B5: return "R5G6B5"; 3642 case MALI_COLOR_FORMAT_R8G8B8_FROM_R8G8B8A2: return "R8G8B8_FROM_R8G8B8A2"; 3643 case MALI_COLOR_FORMAT_R10G10B10A2: return "R10G10B10A2"; 3644 case MALI_COLOR_FORMAT_A2B10G10R10: return "A2B10G10R10"; 3645 case MALI_COLOR_FORMAT_R5G5B5A1: return "R5G5B5A1"; 3646 case MALI_COLOR_FORMAT_A1B5G5R5: return "A1B5G5R5"; 3647 case MALI_COLOR_FORMAT_NATIVE: return "NATIVE"; 3648 default: return "XXX: INVALID"; 3649 } 3650} 3651 3652enum mali_downsampling_accumulation_mode { 3653 MALI_DOWNSAMPLING_ACCUMULATION_MODE_UNSIGNED_NORMALIZED_INTEGER = 0, 3654 MALI_DOWNSAMPLING_ACCUMULATION_MODE_SIGNED_NORMALIZED_INTEGER = 1, 3655}; 3656 3657static inline const char * 3658mali_downsampling_accumulation_mode_as_str(enum mali_downsampling_accumulation_mode imm) 3659{ 3660 switch (imm) { 3661 case MALI_DOWNSAMPLING_ACCUMULATION_MODE_UNSIGNED_NORMALIZED_INTEGER: return "Unsigned normalized integer"; 3662 case MALI_DOWNSAMPLING_ACCUMULATION_MODE_SIGNED_NORMALIZED_INTEGER: return "Signed normalized integer"; 3663 default: return "XXX: INVALID"; 3664 } 3665} 3666 3667enum mali_sample_layout { 3668 MALI_SAMPLE_LAYOUT_ORDERED_4X_GRID = 0, 3669 MALI_SAMPLE_LAYOUT_ROTATED_4X_GRID = 1, 3670 MALI_SAMPLE_LAYOUT_D3D_8X_GRID = 2, 3671 MALI_SAMPLE_LAYOUT_D3D_16X_GRID = 3, 3672}; 3673 3674static inline const char * 3675mali_sample_layout_as_str(enum mali_sample_layout imm) 3676{ 3677 switch (imm) { 3678 case MALI_SAMPLE_LAYOUT_ORDERED_4X_GRID: return "Ordered 4x Grid"; 3679 case MALI_SAMPLE_LAYOUT_ROTATED_4X_GRID: return "Rotated 4x Grid"; 3680 case MALI_SAMPLE_LAYOUT_D3D_8X_GRID: return "D3D 8x Grid"; 3681 case MALI_SAMPLE_LAYOUT_D3D_16X_GRID: return "D3D 16x Grid"; 3682 default: return "XXX: INVALID"; 3683 } 3684} 3685 3686enum mali_zs_format { 3687 MALI_ZS_FORMAT_D16 = 1, 3688 MALI_ZS_FORMAT_D24 = 2, 3689 MALI_ZS_FORMAT_D24X8 = 4, 3690 MALI_ZS_FORMAT_D24S8 = 5, 3691 MALI_ZS_FORMAT_X8D24 = 6, 3692 MALI_ZS_FORMAT_S8D24 = 7, 3693 MALI_ZS_FORMAT_D32_X8X24 = 13, 3694 MALI_ZS_FORMAT_D32 = 14, 3695 MALI_ZS_FORMAT_D32_S8X24 = 15, 3696}; 3697 3698static inline const char * 3699mali_zs_format_as_str(enum mali_zs_format imm) 3700{ 3701 switch (imm) { 3702 case MALI_ZS_FORMAT_D16: return "D16"; 3703 case MALI_ZS_FORMAT_D24: return "D24"; 3704 case MALI_ZS_FORMAT_D24X8: return "D24X8"; 3705 case MALI_ZS_FORMAT_D24S8: return "D24S8"; 3706 case MALI_ZS_FORMAT_X8D24: return "X8D24"; 3707 case MALI_ZS_FORMAT_S8D24: return "S8D24"; 3708 case MALI_ZS_FORMAT_D32_X8X24: return "D32_X8X24"; 3709 case MALI_ZS_FORMAT_D32: return "D32"; 3710 case MALI_ZS_FORMAT_D32_S8X24: return "D32_S8X24"; 3711 default: return "XXX: INVALID"; 3712 } 3713} 3714 3715enum mali_zs_preload_format { 3716 MALI_ZS_PRELOAD_FORMAT_D32_S8X24 = 4, 3717}; 3718 3719static inline const char * 3720mali_zs_preload_format_as_str(enum mali_zs_preload_format imm) 3721{ 3722 switch (imm) { 3723 case MALI_ZS_PRELOAD_FORMAT_D32_S8X24: return "D32_S8X24"; 3724 default: return "XXX: INVALID"; 3725 } 3726} 3727 3728enum mali_s_format { 3729 MALI_S_FORMAT_S8 = 1, 3730 MALI_S_FORMAT_S8X8 = 2, 3731 MALI_S_FORMAT_S8X24 = 3, 3732 MALI_S_FORMAT_X24S8 = 4, 3733 MALI_S_FORMAT_X8S8 = 5, 3734 MALI_S_FORMAT_X32_S8X24 = 6, 3735}; 3736 3737static inline const char * 3738mali_s_format_as_str(enum mali_s_format imm) 3739{ 3740 switch (imm) { 3741 case MALI_S_FORMAT_S8: return "S8"; 3742 case MALI_S_FORMAT_S8X8: return "S8X8"; 3743 case MALI_S_FORMAT_S8X24: return "S8X24"; 3744 case MALI_S_FORMAT_X24S8: return "X24S8"; 3745 case MALI_S_FORMAT_X8S8: return "X8S8"; 3746 case MALI_S_FORMAT_X32_S8X24: return "X32_S8X24"; 3747 default: return "XXX: INVALID"; 3748 } 3749} 3750 3751enum mali_tie_break_rule { 3752 MALI_TIE_BREAK_RULE_0_IN_180_OUT = 0, 3753 MALI_TIE_BREAK_RULE_0_OUT_180_IN = 1, 3754 MALI_TIE_BREAK_RULE_MINUS_180_IN_0_OUT = 2, 3755 MALI_TIE_BREAK_RULE_MINUS_180_OUT_0_IN = 3, 3756 MALI_TIE_BREAK_RULE_90_IN_270_OUT = 4, 3757 MALI_TIE_BREAK_RULE_90_OUT_270_IN = 5, 3758 MALI_TIE_BREAK_RULE_MINUS_90_IN_90_OUT = 6, 3759 MALI_TIE_BREAK_RULE_MINUS_90_OUT_90_IN = 7, 3760}; 3761 3762static inline const char * 3763mali_tie_break_rule_as_str(enum mali_tie_break_rule imm) 3764{ 3765 switch (imm) { 3766 case MALI_TIE_BREAK_RULE_0_IN_180_OUT: return "0_IN_180_OUT"; 3767 case MALI_TIE_BREAK_RULE_0_OUT_180_IN: return "0_OUT_180_IN"; 3768 case MALI_TIE_BREAK_RULE_MINUS_180_IN_0_OUT: return "MINUS_180_IN_0_OUT"; 3769 case MALI_TIE_BREAK_RULE_MINUS_180_OUT_0_IN: return "MINUS_180_OUT_0_IN"; 3770 case MALI_TIE_BREAK_RULE_90_IN_270_OUT: return "90_IN_270_OUT"; 3771 case MALI_TIE_BREAK_RULE_90_OUT_270_IN: return "90_OUT_270_IN"; 3772 case MALI_TIE_BREAK_RULE_MINUS_90_IN_90_OUT: return "MINUS_90_IN_90_OUT"; 3773 case MALI_TIE_BREAK_RULE_MINUS_90_OUT_90_IN: return "MINUS_90_OUT_90_IN"; 3774 default: return "XXX: INVALID"; 3775 } 3776} 3777 3778struct MALI_RT_BUFFER { 3779 uint64_t base; 3780 uint32_t row_stride; 3781 uint32_t surface_stride; 3782}; 3783 3784#define MALI_RT_BUFFER_header \ 3785 0 3786 3787static inline void 3788MALI_RT_BUFFER_pack(uint32_t * restrict cl, 3789 const struct MALI_RT_BUFFER * restrict values) 3790{ 3791 cl[ 0] = __gen_uint(values->base, 0, 63); 3792 cl[ 1] = __gen_uint(values->base, 0, 63) >> 32; 3793 cl[ 2] = __gen_uint(values->row_stride, 0, 31); 3794 cl[ 3] = __gen_uint(values->surface_stride, 0, 31); 3795} 3796 3797 3798#define MALI_RT_BUFFER_LENGTH 16 3799struct mali_rt_buffer_packed { uint32_t opaque[4]; }; 3800static inline void 3801MALI_RT_BUFFER_unpack(const uint8_t * restrict cl, 3802 struct MALI_RT_BUFFER * restrict values) 3803{ 3804 values->base = __gen_unpack_uint(cl, 0, 63); 3805 values->row_stride = __gen_unpack_uint(cl, 64, 95); 3806 values->surface_stride = __gen_unpack_uint(cl, 96, 127); 3807} 3808 3809static inline void 3810MALI_RT_BUFFER_print(FILE *fp, const struct MALI_RT_BUFFER * values, unsigned indent) 3811{ 3812 fprintf(fp, "%*sBase: 0x%" PRIx64 "\n", indent, "", values->base); 3813 fprintf(fp, "%*sRow Stride: %u\n", indent, "", values->row_stride); 3814 fprintf(fp, "%*sSurface Stride: %u\n", indent, "", values->surface_stride); 3815} 3816 3817enum mali_sample_pattern { 3818 MALI_SAMPLE_PATTERN_SINGLE_SAMPLED = 0, 3819 MALI_SAMPLE_PATTERN_ORDERED_4X_GRID = 1, 3820 MALI_SAMPLE_PATTERN_ROTATED_4X_GRID = 2, 3821 MALI_SAMPLE_PATTERN_D3D_8X_GRID = 3, 3822 MALI_SAMPLE_PATTERN_D3D_16X_GRID = 4, 3823}; 3824 3825static inline const char * 3826mali_sample_pattern_as_str(enum mali_sample_pattern imm) 3827{ 3828 switch (imm) { 3829 case MALI_SAMPLE_PATTERN_SINGLE_SAMPLED: return "Single-sampled"; 3830 case MALI_SAMPLE_PATTERN_ORDERED_4X_GRID: return "Ordered 4x Grid"; 3831 case MALI_SAMPLE_PATTERN_ROTATED_4X_GRID: return "Rotated 4x Grid"; 3832 case MALI_SAMPLE_PATTERN_D3D_8X_GRID: return "D3D 8x Grid"; 3833 case MALI_SAMPLE_PATTERN_D3D_16X_GRID: return "D3D 16x Grid"; 3834 default: return "XXX: INVALID"; 3835 } 3836} 3837 3838enum mali_z_internal_format { 3839 MALI_Z_INTERNAL_FORMAT_D16 = 0, 3840 MALI_Z_INTERNAL_FORMAT_D24 = 1, 3841 MALI_Z_INTERNAL_FORMAT_D32 = 2, 3842}; 3843 3844static inline const char * 3845mali_z_internal_format_as_str(enum mali_z_internal_format imm) 3846{ 3847 switch (imm) { 3848 case MALI_Z_INTERNAL_FORMAT_D16: return "D16"; 3849 case MALI_Z_INTERNAL_FORMAT_D24: return "D24"; 3850 case MALI_Z_INTERNAL_FORMAT_D32: return "D32"; 3851 default: return "XXX: INVALID"; 3852 } 3853} 3854 3855enum mali_fbd_tag { 3856 MALI_FBD_TAG_IS_MFBD = 1, 3857 MALI_FBD_TAG_HAS_ZS_RT = 2, 3858 MALI_FBD_TAG_MASK = 63, 3859}; 3860 3861static inline const char * 3862mali_fbd_tag_as_str(enum mali_fbd_tag imm) 3863{ 3864 switch (imm) { 3865 case MALI_FBD_TAG_IS_MFBD: return "IS_MFBD"; 3866 case MALI_FBD_TAG_HAS_ZS_RT: return "HAS_ZS_RT"; 3867 case MALI_FBD_TAG_MASK: return "MASK"; 3868 default: return "XXX: INVALID"; 3869 } 3870} 3871 3872enum mali_pre_post_frame_shader_mode { 3873 MALI_PRE_POST_FRAME_SHADER_MODE_NEVER = 0, 3874 MALI_PRE_POST_FRAME_SHADER_MODE_ALWAYS = 1, 3875 MALI_PRE_POST_FRAME_SHADER_MODE_INTERSECT = 2, 3876 MALI_PRE_POST_FRAME_SHADER_MODE_EARLY_ZS_ALWAYS = 3, 3877}; 3878 3879static inline const char * 3880mali_pre_post_frame_shader_mode_as_str(enum mali_pre_post_frame_shader_mode imm) 3881{ 3882 switch (imm) { 3883 case MALI_PRE_POST_FRAME_SHADER_MODE_NEVER: return "Never"; 3884 case MALI_PRE_POST_FRAME_SHADER_MODE_ALWAYS: return "Always"; 3885 case MALI_PRE_POST_FRAME_SHADER_MODE_INTERSECT: return "Intersect"; 3886 case MALI_PRE_POST_FRAME_SHADER_MODE_EARLY_ZS_ALWAYS: return "Early ZS always"; 3887 default: return "XXX: INVALID"; 3888 } 3889} 3890 3891struct MALI_FRAMEBUFFER_PARAMETERS { 3892 enum mali_pre_post_frame_shader_mode pre_frame_0; 3893 enum mali_pre_post_frame_shader_mode pre_frame_1; 3894 enum mali_pre_post_frame_shader_mode post_frame; 3895 uint64_t sample_locations; 3896 uint64_t frame_shader_dcds; 3897 uint32_t width; 3898 uint32_t height; 3899 uint32_t bound_min_x; 3900 uint32_t bound_min_y; 3901 uint32_t bound_max_x; 3902 uint32_t bound_max_y; 3903 uint32_t sample_count; 3904 enum mali_sample_pattern sample_pattern; 3905 enum mali_tie_break_rule tie_break_rule; 3906 uint32_t effective_tile_size; 3907 uint32_t x_downsampling_scale; 3908 uint32_t y_downsampling_scale; 3909 uint32_t render_target_count; 3910 uint32_t color_buffer_allocation; 3911 uint32_t s_clear; 3912 bool s_write_enable; 3913 bool s_preload_enable; 3914 bool s_unload_enable; 3915 enum mali_z_internal_format z_internal_format; 3916 bool z_write_enable; 3917 bool z_preload_enable; 3918 bool z_unload_enable; 3919 bool has_zs_crc_extension; 3920 bool crc_read_enable; 3921 bool crc_write_enable; 3922 float z_clear; 3923 uint64_t tiler; 3924}; 3925 3926#define MALI_FRAMEBUFFER_PARAMETERS_header \ 3927 .sample_count = 1 3928 3929static inline void 3930MALI_FRAMEBUFFER_PARAMETERS_pack(uint32_t * restrict cl, 3931 const struct MALI_FRAMEBUFFER_PARAMETERS * restrict values) 3932{ 3933 assert(values->width >= 1); 3934 assert(values->height >= 1); 3935 assert(util_is_power_of_two_nonzero(values->sample_count)); 3936 assert(util_is_power_of_two_nonzero(values->effective_tile_size)); 3937 assert(values->render_target_count >= 1); 3938 assert((values->color_buffer_allocation & 0x3ff) == 0); 3939 cl[ 0] = __gen_uint(values->pre_frame_0, 0, 2) | 3940 __gen_uint(values->pre_frame_1, 3, 5) | 3941 __gen_uint(values->post_frame, 6, 8); 3942 cl[ 1] = 0; 3943 cl[ 2] = 0; 3944 cl[ 3] = 0; 3945 cl[ 4] = __gen_uint(values->sample_locations, 0, 63); 3946 cl[ 5] = __gen_uint(values->sample_locations, 0, 63) >> 32; 3947 cl[ 6] = __gen_uint(values->frame_shader_dcds, 0, 63); 3948 cl[ 7] = __gen_uint(values->frame_shader_dcds, 0, 63) >> 32; 3949 cl[ 8] = __gen_uint(values->width - 1, 0, 15) | 3950 __gen_uint(values->height - 1, 16, 31); 3951 cl[ 9] = __gen_uint(values->bound_min_x, 0, 15) | 3952 __gen_uint(values->bound_min_y, 16, 31); 3953 cl[10] = __gen_uint(values->bound_max_x, 0, 15) | 3954 __gen_uint(values->bound_max_y, 16, 31); 3955 cl[11] = __gen_uint(util_logbase2(values->sample_count), 0, 2) | 3956 __gen_uint(values->sample_pattern, 3, 5) | 3957 __gen_uint(values->tie_break_rule, 6, 8) | 3958 __gen_uint(util_logbase2(values->effective_tile_size), 9, 12) | 3959 __gen_uint(values->x_downsampling_scale, 13, 15) | 3960 __gen_uint(values->y_downsampling_scale, 16, 18) | 3961 __gen_uint(values->render_target_count - 1, 19, 22) | 3962 __gen_uint(values->color_buffer_allocation >> 10, 24, 31); 3963 cl[12] = __gen_uint(values->s_clear, 0, 7) | 3964 __gen_uint(values->s_write_enable, 8, 8) | 3965 __gen_uint(values->s_preload_enable, 9, 9) | 3966 __gen_uint(values->s_unload_enable, 10, 10) | 3967 __gen_uint(values->z_internal_format, 16, 17) | 3968 __gen_uint(values->z_write_enable, 18, 18) | 3969 __gen_uint(values->z_preload_enable, 19, 19) | 3970 __gen_uint(values->z_unload_enable, 20, 20) | 3971 __gen_uint(values->has_zs_crc_extension, 21, 21) | 3972 __gen_uint(values->crc_read_enable, 30, 30) | 3973 __gen_uint(values->crc_write_enable, 31, 31); 3974 cl[13] = __gen_uint(fui(values->z_clear), 0, 32); 3975 cl[14] = __gen_uint(values->tiler, 0, 63); 3976 cl[15] = __gen_uint(values->tiler, 0, 63) >> 32; 3977} 3978 3979 3980#define MALI_FRAMEBUFFER_PARAMETERS_LENGTH 64 3981struct mali_framebuffer_parameters_packed { uint32_t opaque[16]; }; 3982static inline void 3983MALI_FRAMEBUFFER_PARAMETERS_unpack(const uint8_t * restrict cl, 3984 struct MALI_FRAMEBUFFER_PARAMETERS * restrict values) 3985{ 3986 if (((const uint32_t *) cl)[0] & 0xfffffe00) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 0\n"); 3987 if (((const uint32_t *) cl)[1] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 1\n"); 3988 if (((const uint32_t *) cl)[2] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 2\n"); 3989 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 3\n"); 3990 if (((const uint32_t *) cl)[11] & 0x800000) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 11\n"); 3991 if (((const uint32_t *) cl)[12] & 0x3fc0f800) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 12\n"); 3992 values->pre_frame_0 = (enum mali_pre_post_frame_shader_mode)__gen_unpack_uint(cl, 0, 2); 3993 values->pre_frame_1 = (enum mali_pre_post_frame_shader_mode)__gen_unpack_uint(cl, 3, 5); 3994 values->post_frame = (enum mali_pre_post_frame_shader_mode)__gen_unpack_uint(cl, 6, 8); 3995 values->sample_locations = __gen_unpack_uint(cl, 128, 191); 3996 values->frame_shader_dcds = __gen_unpack_uint(cl, 192, 255); 3997 values->width = __gen_unpack_uint(cl, 256, 271) + 1; 3998 values->height = __gen_unpack_uint(cl, 272, 287) + 1; 3999 values->bound_min_x = __gen_unpack_uint(cl, 288, 303); 4000 values->bound_min_y = __gen_unpack_uint(cl, 304, 319); 4001 values->bound_max_x = __gen_unpack_uint(cl, 320, 335); 4002 values->bound_max_y = __gen_unpack_uint(cl, 336, 351); 4003 values->sample_count = 1U << __gen_unpack_uint(cl, 352, 354); 4004 values->sample_pattern = (enum mali_sample_pattern)__gen_unpack_uint(cl, 355, 357); 4005 values->tie_break_rule = (enum mali_tie_break_rule)__gen_unpack_uint(cl, 358, 360); 4006 values->effective_tile_size = 1U << __gen_unpack_uint(cl, 361, 364); 4007 values->x_downsampling_scale = __gen_unpack_uint(cl, 365, 367); 4008 values->y_downsampling_scale = __gen_unpack_uint(cl, 368, 370); 4009 values->render_target_count = __gen_unpack_uint(cl, 371, 374) + 1; 4010 values->color_buffer_allocation = __gen_unpack_uint(cl, 376, 383) << 10; 4011 values->s_clear = __gen_unpack_uint(cl, 384, 391); 4012 values->s_write_enable = __gen_unpack_uint(cl, 392, 392); 4013 values->s_preload_enable = __gen_unpack_uint(cl, 393, 393); 4014 values->s_unload_enable = __gen_unpack_uint(cl, 394, 394); 4015 values->z_internal_format = (enum mali_z_internal_format)__gen_unpack_uint(cl, 400, 401); 4016 values->z_write_enable = __gen_unpack_uint(cl, 402, 402); 4017 values->z_preload_enable = __gen_unpack_uint(cl, 403, 403); 4018 values->z_unload_enable = __gen_unpack_uint(cl, 404, 404); 4019 values->has_zs_crc_extension = __gen_unpack_uint(cl, 405, 405); 4020 values->crc_read_enable = __gen_unpack_uint(cl, 414, 414); 4021 values->crc_write_enable = __gen_unpack_uint(cl, 415, 415); 4022 values->z_clear = __gen_unpack_float(cl, 416, 447); 4023 values->tiler = __gen_unpack_uint(cl, 448, 511); 4024} 4025 4026static inline void 4027MALI_FRAMEBUFFER_PARAMETERS_print(FILE *fp, const struct MALI_FRAMEBUFFER_PARAMETERS * values, unsigned indent) 4028{ 4029 fprintf(fp, "%*sPre Frame 0: %s\n", indent, "", mali_pre_post_frame_shader_mode_as_str(values->pre_frame_0)); 4030 fprintf(fp, "%*sPre Frame 1: %s\n", indent, "", mali_pre_post_frame_shader_mode_as_str(values->pre_frame_1)); 4031 fprintf(fp, "%*sPost Frame: %s\n", indent, "", mali_pre_post_frame_shader_mode_as_str(values->post_frame)); 4032 fprintf(fp, "%*sSample Locations: 0x%" PRIx64 "\n", indent, "", values->sample_locations); 4033 fprintf(fp, "%*sFrame Shader DCDs: 0x%" PRIx64 "\n", indent, "", values->frame_shader_dcds); 4034 fprintf(fp, "%*sWidth: %u\n", indent, "", values->width); 4035 fprintf(fp, "%*sHeight: %u\n", indent, "", values->height); 4036 fprintf(fp, "%*sBound Min X: %u\n", indent, "", values->bound_min_x); 4037 fprintf(fp, "%*sBound Min Y: %u\n", indent, "", values->bound_min_y); 4038 fprintf(fp, "%*sBound Max X: %u\n", indent, "", values->bound_max_x); 4039 fprintf(fp, "%*sBound Max Y: %u\n", indent, "", values->bound_max_y); 4040 fprintf(fp, "%*sSample Count: %u\n", indent, "", values->sample_count); 4041 fprintf(fp, "%*sSample Pattern: %s\n", indent, "", mali_sample_pattern_as_str(values->sample_pattern)); 4042 fprintf(fp, "%*sTie-Break Rule: %s\n", indent, "", mali_tie_break_rule_as_str(values->tie_break_rule)); 4043 fprintf(fp, "%*sEffective Tile Size: %u\n", indent, "", values->effective_tile_size); 4044 fprintf(fp, "%*sX Downsampling Scale: %u\n", indent, "", values->x_downsampling_scale); 4045 fprintf(fp, "%*sY Downsampling Scale: %u\n", indent, "", values->y_downsampling_scale); 4046 fprintf(fp, "%*sRender Target Count: %u\n", indent, "", values->render_target_count); 4047 fprintf(fp, "%*sColor Buffer Allocation: %u\n", indent, "", values->color_buffer_allocation); 4048 fprintf(fp, "%*sS Clear: %u\n", indent, "", values->s_clear); 4049 fprintf(fp, "%*sS Write Enable: %s\n", indent, "", values->s_write_enable ? "true" : "false"); 4050 fprintf(fp, "%*sS Preload Enable: %s\n", indent, "", values->s_preload_enable ? "true" : "false"); 4051 fprintf(fp, "%*sS Unload Enable: %s\n", indent, "", values->s_unload_enable ? "true" : "false"); 4052 fprintf(fp, "%*sZ Internal Format: %s\n", indent, "", mali_z_internal_format_as_str(values->z_internal_format)); 4053 fprintf(fp, "%*sZ Write Enable: %s\n", indent, "", values->z_write_enable ? "true" : "false"); 4054 fprintf(fp, "%*sZ Preload Enable: %s\n", indent, "", values->z_preload_enable ? "true" : "false"); 4055 fprintf(fp, "%*sZ Unload Enable: %s\n", indent, "", values->z_unload_enable ? "true" : "false"); 4056 fprintf(fp, "%*sHas ZS CRC Extension: %s\n", indent, "", values->has_zs_crc_extension ? "true" : "false"); 4057 fprintf(fp, "%*sCRC Read Enable: %s\n", indent, "", values->crc_read_enable ? "true" : "false"); 4058 fprintf(fp, "%*sCRC Write Enable: %s\n", indent, "", values->crc_write_enable ? "true" : "false"); 4059 fprintf(fp, "%*sZ Clear: %f\n", indent, "", values->z_clear); 4060 fprintf(fp, "%*sTiler: 0x%" PRIx64 "\n", indent, "", values->tiler); 4061} 4062 4063struct MALI_ZS_CRC_EXTENSION { 4064 uint64_t crc_base; 4065 uint32_t crc_row_stride; 4066 enum mali_zs_format zs_write_format; 4067 enum mali_block_format zs_block_format; 4068 enum mali_msaa zs_msaa; 4069 bool zs_big_endian; 4070 bool zs_clean_pixel_write_enable; 4071 enum mali_s_format s_write_format; 4072 enum mali_block_format s_block_format; 4073 enum mali_msaa s_msaa; 4074 uint64_t zs_writeback_base; 4075 uint32_t zs_writeback_row_stride; 4076 uint32_t zs_writeback_surface_stride; 4077 uint64_t s_writeback_base; 4078 uint32_t s_writeback_row_stride; 4079 uint32_t s_writeback_surface_stride; 4080 uint64_t zs_afbc_header; 4081 uint32_t zs_afbc_row_stride; 4082 uint64_t zs_afbc_body; 4083}; 4084 4085#define MALI_ZS_CRC_EXTENSION_header \ 4086 .zs_msaa = MALI_MSAA_SINGLE, \ 4087 .s_msaa = MALI_MSAA_SINGLE 4088 4089static inline void 4090MALI_ZS_CRC_EXTENSION_pack(uint32_t * restrict cl, 4091 const struct MALI_ZS_CRC_EXTENSION * restrict values) 4092{ 4093 cl[ 0] = __gen_uint(values->crc_base, 0, 63); 4094 cl[ 1] = __gen_uint(values->crc_base, 0, 63) >> 32; 4095 cl[ 2] = __gen_uint(values->crc_row_stride, 0, 31); 4096 cl[ 3] = __gen_uint(values->zs_write_format, 0, 3) | 4097 __gen_uint(values->zs_block_format, 4, 5) | 4098 __gen_uint(values->zs_msaa, 6, 7) | 4099 __gen_uint(values->zs_big_endian, 8, 8) | 4100 __gen_uint(values->zs_clean_pixel_write_enable, 10, 10) | 4101 __gen_uint(values->s_write_format, 16, 19) | 4102 __gen_uint(values->s_block_format, 20, 21) | 4103 __gen_uint(values->s_msaa, 22, 23); 4104 cl[ 4] = __gen_uint(values->zs_writeback_base, 0, 63) | 4105 __gen_uint(values->zs_afbc_header, 0, 63); 4106 cl[ 5] = __gen_uint(values->zs_writeback_base, 0, 63) >> 32 | 4107 __gen_uint(values->zs_afbc_header, 0, 63) >> 32; 4108 cl[ 6] = __gen_uint(values->zs_writeback_row_stride, 0, 31) | 4109 __gen_uint(values->zs_afbc_row_stride, 0, 12); 4110 cl[ 7] = __gen_uint(values->zs_writeback_surface_stride, 0, 31); 4111 cl[ 8] = __gen_uint(values->s_writeback_base, 0, 63) | 4112 __gen_uint(values->zs_afbc_body, 0, 63); 4113 cl[ 9] = __gen_uint(values->s_writeback_base, 0, 63) >> 32 | 4114 __gen_uint(values->zs_afbc_body, 0, 63) >> 32; 4115 cl[10] = __gen_uint(values->s_writeback_row_stride, 0, 31); 4116 cl[11] = __gen_uint(values->s_writeback_surface_stride, 0, 31); 4117 cl[12] = 0; 4118 cl[13] = 0; 4119 cl[14] = 0; 4120 cl[15] = 0; 4121} 4122 4123 4124#define MALI_ZS_CRC_EXTENSION_LENGTH 64 4125#define MALI_ZS_CRC_EXTENSION_ALIGN 64 4126struct mali_zs_crc_extension_packed { uint32_t opaque[16]; }; 4127static inline void 4128MALI_ZS_CRC_EXTENSION_unpack(const uint8_t * restrict cl, 4129 struct MALI_ZS_CRC_EXTENSION * restrict values) 4130{ 4131 if (((const uint32_t *) cl)[3] & 0xff00fa00) fprintf(stderr, "XXX: Invalid field of ZS CRC Extension unpacked at word 3\n"); 4132 if (((const uint32_t *) cl)[12] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of ZS CRC Extension unpacked at word 12\n"); 4133 if (((const uint32_t *) cl)[13] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of ZS CRC Extension unpacked at word 13\n"); 4134 if (((const uint32_t *) cl)[14] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of ZS CRC Extension unpacked at word 14\n"); 4135 if (((const uint32_t *) cl)[15] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of ZS CRC Extension unpacked at word 15\n"); 4136 values->crc_base = __gen_unpack_uint(cl, 0, 63); 4137 values->crc_row_stride = __gen_unpack_uint(cl, 64, 95); 4138 values->zs_write_format = (enum mali_zs_format)__gen_unpack_uint(cl, 96, 99); 4139 values->zs_block_format = (enum mali_block_format)__gen_unpack_uint(cl, 100, 101); 4140 values->zs_msaa = (enum mali_msaa)__gen_unpack_uint(cl, 102, 103); 4141 values->zs_big_endian = __gen_unpack_uint(cl, 104, 104); 4142 values->zs_clean_pixel_write_enable = __gen_unpack_uint(cl, 106, 106); 4143 values->s_write_format = (enum mali_s_format)__gen_unpack_uint(cl, 112, 115); 4144 values->s_block_format = (enum mali_block_format)__gen_unpack_uint(cl, 116, 117); 4145 values->s_msaa = (enum mali_msaa)__gen_unpack_uint(cl, 118, 119); 4146 values->zs_writeback_base = __gen_unpack_uint(cl, 128, 191); 4147 values->zs_writeback_row_stride = __gen_unpack_uint(cl, 192, 223); 4148 values->zs_writeback_surface_stride = __gen_unpack_uint(cl, 224, 255); 4149 values->s_writeback_base = __gen_unpack_uint(cl, 256, 319); 4150 values->s_writeback_row_stride = __gen_unpack_uint(cl, 320, 351); 4151 values->s_writeback_surface_stride = __gen_unpack_uint(cl, 352, 383); 4152 values->zs_afbc_header = __gen_unpack_uint(cl, 128, 191); 4153 values->zs_afbc_row_stride = __gen_unpack_uint(cl, 192, 204); 4154 values->zs_afbc_body = __gen_unpack_uint(cl, 256, 319); 4155} 4156 4157static inline void 4158MALI_ZS_CRC_EXTENSION_print(FILE *fp, const struct MALI_ZS_CRC_EXTENSION * values, unsigned indent) 4159{ 4160 fprintf(fp, "%*sCRC Base: 0x%" PRIx64 "\n", indent, "", values->crc_base); 4161 fprintf(fp, "%*sCRC Row Stride: %u\n", indent, "", values->crc_row_stride); 4162 fprintf(fp, "%*sZS Write Format: %s\n", indent, "", mali_zs_format_as_str(values->zs_write_format)); 4163 fprintf(fp, "%*sZS Block Format: %s\n", indent, "", mali_block_format_as_str(values->zs_block_format)); 4164 fprintf(fp, "%*sZS MSAA: %s\n", indent, "", mali_msaa_as_str(values->zs_msaa)); 4165 fprintf(fp, "%*sZS Big Endian: %s\n", indent, "", values->zs_big_endian ? "true" : "false"); 4166 fprintf(fp, "%*sZS Clean Pixel Write Enable: %s\n", indent, "", values->zs_clean_pixel_write_enable ? "true" : "false"); 4167 fprintf(fp, "%*sS Write Format: %s\n", indent, "", mali_s_format_as_str(values->s_write_format)); 4168 fprintf(fp, "%*sS Block Format: %s\n", indent, "", mali_block_format_as_str(values->s_block_format)); 4169 fprintf(fp, "%*sS MSAA: %s\n", indent, "", mali_msaa_as_str(values->s_msaa)); 4170 fprintf(fp, "%*sZS Writeback Base: 0x%" PRIx64 "\n", indent, "", values->zs_writeback_base); 4171 fprintf(fp, "%*sZS Writeback Row Stride: %u\n", indent, "", values->zs_writeback_row_stride); 4172 fprintf(fp, "%*sZS Writeback Surface Stride: %u\n", indent, "", values->zs_writeback_surface_stride); 4173 fprintf(fp, "%*sS Writeback Base: 0x%" PRIx64 "\n", indent, "", values->s_writeback_base); 4174 fprintf(fp, "%*sS Writeback Row Stride: %u\n", indent, "", values->s_writeback_row_stride); 4175 fprintf(fp, "%*sS Writeback Surface Stride: %u\n", indent, "", values->s_writeback_surface_stride); 4176 fprintf(fp, "%*sZS AFBC Header: 0x%" PRIx64 "\n", indent, "", values->zs_afbc_header); 4177 fprintf(fp, "%*sZS AFBC Row Stride: %u\n", indent, "", values->zs_afbc_row_stride); 4178 fprintf(fp, "%*sZS AFBC Body: 0x%" PRIx64 "\n", indent, "", values->zs_afbc_body); 4179} 4180 4181enum mali_rt_endianness { 4182 MALI_RT_ENDIANNESS_LITTLE_ENDIAN = 0, 4183 MALI_RT_ENDIANNESS_BIG_ENDIAN_2B = 1, 4184 MALI_RT_ENDIANNESS_BIG_ENDIAN_4B = 2, 4185 MALI_RT_ENDIANNESS_BIG_ENDIAN_8B = 3, 4186}; 4187 4188static inline const char * 4189mali_rt_endianness_as_str(enum mali_rt_endianness imm) 4190{ 4191 switch (imm) { 4192 case MALI_RT_ENDIANNESS_LITTLE_ENDIAN: return "Little Endian"; 4193 case MALI_RT_ENDIANNESS_BIG_ENDIAN_2B: return "Big Endian 2B"; 4194 case MALI_RT_ENDIANNESS_BIG_ENDIAN_4B: return "Big Endian 4B"; 4195 case MALI_RT_ENDIANNESS_BIG_ENDIAN_8B: return "Big Endian 8B"; 4196 default: return "XXX: INVALID"; 4197 } 4198} 4199 4200enum mali_yuv_conv_k6 { 4201 MALI_YUV_CONV_K6_0 = 0, 4202 MALI_YUV_CONV_K6_16 = 1, 4203}; 4204 4205static inline const char * 4206mali_yuv_conv_k6_as_str(enum mali_yuv_conv_k6 imm) 4207{ 4208 switch (imm) { 4209 case MALI_YUV_CONV_K6_0: return "0"; 4210 case MALI_YUV_CONV_K6_16: return "16"; 4211 default: return "XXX: INVALID"; 4212 } 4213} 4214 4215enum mali_yuv_conv_k7_clamp { 4216 MALI_YUV_CONV_K7_CLAMP_MINUS_128_TO_127 = 0, 4217 MALI_YUV_CONV_K7_CLAMP_MINUS_112_TO_111 = 1, 4218 MALI_YUV_CONV_K7_CLAMP_0_TO_255 = 2, 4219 MALI_YUV_CONV_K7_CLAMP_16_TO_239 = 3, 4220}; 4221 4222static inline const char * 4223mali_yuv_conv_k7_clamp_as_str(enum mali_yuv_conv_k7_clamp imm) 4224{ 4225 switch (imm) { 4226 case MALI_YUV_CONV_K7_CLAMP_MINUS_128_TO_127: return "MINUS_128_TO_127"; 4227 case MALI_YUV_CONV_K7_CLAMP_MINUS_112_TO_111: return "MINUS_112_TO_111"; 4228 case MALI_YUV_CONV_K7_CLAMP_0_TO_255: return "0_TO_255"; 4229 case MALI_YUV_CONV_K7_CLAMP_16_TO_239: return "16_TO_239"; 4230 default: return "XXX: INVALID"; 4231 } 4232} 4233 4234enum mali_yuv_conv_k8 { 4235 MALI_YUV_CONV_K8_220 = 0, 4236 MALI_YUV_CONV_K8_256 = 1, 4237}; 4238 4239static inline const char * 4240mali_yuv_conv_k8_as_str(enum mali_yuv_conv_k8 imm) 4241{ 4242 switch (imm) { 4243 case MALI_YUV_CONV_K8_220: return "220"; 4244 case MALI_YUV_CONV_K8_256: return "256"; 4245 default: return "XXX: INVALID"; 4246 } 4247} 4248 4249struct MALI_RENDER_TARGET_YUV_OVERLAY { 4250 enum mali_yuv_swizzle swizzle; 4251 bool full_range; 4252 enum mali_yuv_conversion_mode conversion_mode; 4253 enum mali_yuv_cr_siting cr_siting; 4254 bool unsigned_cr_range; 4255 uint64_t plane_0_base; 4256 uint64_t plane_1_base; 4257 uint64_t plane_2_base; 4258 uint32_t plane_0_stride; 4259 uint32_t plane_1_2_stride; 4260}; 4261 4262#define MALI_RENDER_TARGET_YUV_OVERLAY_header \ 4263 0 4264 4265static inline void 4266MALI_RENDER_TARGET_YUV_OVERLAY_pack(uint32_t * restrict cl, 4267 const struct MALI_RENDER_TARGET_YUV_OVERLAY * restrict values) 4268{ 4269 cl[ 0] = 0; 4270 cl[ 1] = 0; 4271 cl[ 2] = __gen_uint(values->swizzle, 16, 18) | 4272 __gen_uint(values->full_range, 20, 20) | 4273 __gen_uint(values->conversion_mode, 21, 24) | 4274 __gen_uint(values->cr_siting, 25, 27) | 4275 __gen_uint(values->unsigned_cr_range, 28, 28); 4276 cl[ 3] = 0; 4277 cl[ 4] = __gen_uint(values->plane_0_base, 0, 63); 4278 cl[ 5] = __gen_uint(values->plane_0_base, 0, 63) >> 32; 4279 cl[ 6] = __gen_uint(values->plane_1_base, 0, 63); 4280 cl[ 7] = __gen_uint(values->plane_1_base, 0, 63) >> 32; 4281 cl[ 8] = __gen_uint(values->plane_2_base, 0, 63); 4282 cl[ 9] = __gen_uint(values->plane_2_base, 0, 63) >> 32; 4283 cl[10] = __gen_uint(values->plane_0_stride, 0, 31); 4284 cl[11] = __gen_uint(values->plane_1_2_stride, 0, 31); 4285 cl[12] = 0; 4286 cl[13] = 0; 4287 cl[14] = 0; 4288 cl[15] = 0; 4289} 4290 4291 4292#define MALI_RENDER_TARGET_YUV_OVERLAY_LENGTH 64 4293struct mali_render_target_yuv_overlay_packed { uint32_t opaque[16]; }; 4294static inline void 4295MALI_RENDER_TARGET_YUV_OVERLAY_unpack(const uint8_t * restrict cl, 4296 struct MALI_RENDER_TARGET_YUV_OVERLAY * restrict values) 4297{ 4298 if (((const uint32_t *) cl)[0] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target YUV Overlay unpacked at word 0\n"); 4299 if (((const uint32_t *) cl)[1] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target YUV Overlay unpacked at word 1\n"); 4300 if (((const uint32_t *) cl)[2] & 0xe008ffff) fprintf(stderr, "XXX: Invalid field of Render Target YUV Overlay unpacked at word 2\n"); 4301 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target YUV Overlay unpacked at word 3\n"); 4302 if (((const uint32_t *) cl)[12] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target YUV Overlay unpacked at word 12\n"); 4303 if (((const uint32_t *) cl)[13] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target YUV Overlay unpacked at word 13\n"); 4304 if (((const uint32_t *) cl)[14] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target YUV Overlay unpacked at word 14\n"); 4305 if (((const uint32_t *) cl)[15] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target YUV Overlay unpacked at word 15\n"); 4306 values->swizzle = (enum mali_yuv_swizzle)__gen_unpack_uint(cl, 80, 82); 4307 values->full_range = __gen_unpack_uint(cl, 84, 84); 4308 values->conversion_mode = (enum mali_yuv_conversion_mode)__gen_unpack_uint(cl, 85, 88); 4309 values->cr_siting = (enum mali_yuv_cr_siting)__gen_unpack_uint(cl, 89, 91); 4310 values->unsigned_cr_range = __gen_unpack_uint(cl, 92, 92); 4311 values->plane_0_base = __gen_unpack_uint(cl, 128, 191); 4312 values->plane_1_base = __gen_unpack_uint(cl, 192, 255); 4313 values->plane_2_base = __gen_unpack_uint(cl, 256, 319); 4314 values->plane_0_stride = __gen_unpack_uint(cl, 320, 351); 4315 values->plane_1_2_stride = __gen_unpack_uint(cl, 352, 383); 4316} 4317 4318static inline void 4319MALI_RENDER_TARGET_YUV_OVERLAY_print(FILE *fp, const struct MALI_RENDER_TARGET_YUV_OVERLAY * values, unsigned indent) 4320{ 4321 fprintf(fp, "%*sSwizzle: %s\n", indent, "", mali_yuv_swizzle_as_str(values->swizzle)); 4322 fprintf(fp, "%*sFull Range: %s\n", indent, "", values->full_range ? "true" : "false"); 4323 fprintf(fp, "%*sConversion Mode: %s\n", indent, "", mali_yuv_conversion_mode_as_str(values->conversion_mode)); 4324 fprintf(fp, "%*sCr Siting: %s\n", indent, "", mali_yuv_cr_siting_as_str(values->cr_siting)); 4325 fprintf(fp, "%*sUnsigned Cr Range: %s\n", indent, "", values->unsigned_cr_range ? "true" : "false"); 4326 fprintf(fp, "%*sPlane 0 Base: 0x%" PRIx64 "\n", indent, "", values->plane_0_base); 4327 fprintf(fp, "%*sPlane 1 Base: 0x%" PRIx64 "\n", indent, "", values->plane_1_base); 4328 fprintf(fp, "%*sPlane 2 Base: 0x%" PRIx64 "\n", indent, "", values->plane_2_base); 4329 fprintf(fp, "%*sPlane 0 Stride: %u\n", indent, "", values->plane_0_stride); 4330 fprintf(fp, "%*sPlane 1 2 Stride: %u\n", indent, "", values->plane_1_2_stride); 4331} 4332 4333struct MALI_RENDER_TARGET_AFBC_OVERLAY { 4334 uint64_t header; 4335 uint32_t row_stride; 4336 uint32_t chunk_size; 4337 bool afbc_split_block_enable; 4338 bool afbc_wide_block_enable; 4339 bool reverse_issue_order; 4340 bool yuv_transform_enable; 4341 uint64_t body; 4342 uint32_t body_size; 4343}; 4344 4345#define MALI_RENDER_TARGET_AFBC_OVERLAY_header \ 4346 0 4347 4348static inline void 4349MALI_RENDER_TARGET_AFBC_OVERLAY_pack(uint32_t * restrict cl, 4350 const struct MALI_RENDER_TARGET_AFBC_OVERLAY * restrict values) 4351{ 4352 cl[ 0] = 0; 4353 cl[ 1] = 0; 4354 cl[ 2] = 0; 4355 cl[ 3] = 0; 4356 cl[ 4] = __gen_uint(values->header, 0, 63); 4357 cl[ 5] = __gen_uint(values->header, 0, 63) >> 32; 4358 cl[ 6] = __gen_uint(values->row_stride, 0, 12); 4359 cl[ 7] = __gen_uint(values->chunk_size, 0, 11) | 4360 __gen_uint(values->afbc_split_block_enable, 18, 18) | 4361 __gen_uint(values->afbc_wide_block_enable, 19, 19) | 4362 __gen_uint(values->reverse_issue_order, 20, 20) | 4363 __gen_uint(values->yuv_transform_enable, 17, 17); 4364 cl[ 8] = __gen_uint(values->body, 0, 63); 4365 cl[ 9] = __gen_uint(values->body, 0, 63) >> 32; 4366 cl[10] = __gen_uint(values->body_size, 0, 31); 4367 cl[11] = 0; 4368 cl[12] = 0; 4369 cl[13] = 0; 4370 cl[14] = 0; 4371 cl[15] = 0; 4372} 4373 4374 4375#define MALI_RENDER_TARGET_AFBC_OVERLAY_LENGTH 64 4376struct mali_render_target_afbc_overlay_packed { uint32_t opaque[16]; }; 4377static inline void 4378MALI_RENDER_TARGET_AFBC_OVERLAY_unpack(const uint8_t * restrict cl, 4379 struct MALI_RENDER_TARGET_AFBC_OVERLAY * restrict values) 4380{ 4381 if (((const uint32_t *) cl)[0] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target AFBC Overlay unpacked at word 0\n"); 4382 if (((const uint32_t *) cl)[1] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target AFBC Overlay unpacked at word 1\n"); 4383 if (((const uint32_t *) cl)[2] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target AFBC Overlay unpacked at word 2\n"); 4384 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target AFBC Overlay unpacked at word 3\n"); 4385 if (((const uint32_t *) cl)[6] & 0xffffe000) fprintf(stderr, "XXX: Invalid field of Render Target AFBC Overlay unpacked at word 6\n"); 4386 if (((const uint32_t *) cl)[7] & 0xffe1f000) fprintf(stderr, "XXX: Invalid field of Render Target AFBC Overlay unpacked at word 7\n"); 4387 if (((const uint32_t *) cl)[11] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target AFBC Overlay unpacked at word 11\n"); 4388 if (((const uint32_t *) cl)[12] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target AFBC Overlay unpacked at word 12\n"); 4389 if (((const uint32_t *) cl)[13] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target AFBC Overlay unpacked at word 13\n"); 4390 if (((const uint32_t *) cl)[14] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target AFBC Overlay unpacked at word 14\n"); 4391 if (((const uint32_t *) cl)[15] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target AFBC Overlay unpacked at word 15\n"); 4392 values->header = __gen_unpack_uint(cl, 128, 191); 4393 values->row_stride = __gen_unpack_uint(cl, 192, 204); 4394 values->chunk_size = __gen_unpack_uint(cl, 224, 235); 4395 values->afbc_split_block_enable = __gen_unpack_uint(cl, 242, 242); 4396 values->afbc_wide_block_enable = __gen_unpack_uint(cl, 243, 243); 4397 values->reverse_issue_order = __gen_unpack_uint(cl, 244, 244); 4398 values->yuv_transform_enable = __gen_unpack_uint(cl, 241, 241); 4399 values->body = __gen_unpack_uint(cl, 256, 319); 4400 values->body_size = __gen_unpack_uint(cl, 320, 351); 4401} 4402 4403static inline void 4404MALI_RENDER_TARGET_AFBC_OVERLAY_print(FILE *fp, const struct MALI_RENDER_TARGET_AFBC_OVERLAY * values, unsigned indent) 4405{ 4406 fprintf(fp, "%*sHeader: 0x%" PRIx64 "\n", indent, "", values->header); 4407 fprintf(fp, "%*sRow Stride: %u\n", indent, "", values->row_stride); 4408 fprintf(fp, "%*sChunk Size: %u\n", indent, "", values->chunk_size); 4409 fprintf(fp, "%*sAFBC Split Block Enable: %s\n", indent, "", values->afbc_split_block_enable ? "true" : "false"); 4410 fprintf(fp, "%*sAFBC Wide Block Enable: %s\n", indent, "", values->afbc_wide_block_enable ? "true" : "false"); 4411 fprintf(fp, "%*sReverse Issue Order: %s\n", indent, "", values->reverse_issue_order ? "true" : "false"); 4412 fprintf(fp, "%*sYUV Transform Enable: %s\n", indent, "", values->yuv_transform_enable ? "true" : "false"); 4413 fprintf(fp, "%*sBody: 0x%" PRIx64 "\n", indent, "", values->body); 4414 fprintf(fp, "%*sBody Size: %u\n", indent, "", values->body_size); 4415} 4416 4417struct MALI_RT_CLEAR { 4418 uint32_t color_0; 4419 uint32_t color_1; 4420 uint32_t color_2; 4421 uint32_t color_3; 4422}; 4423 4424#define MALI_RT_CLEAR_header \ 4425 0 4426 4427static inline void 4428MALI_RT_CLEAR_pack(uint32_t * restrict cl, 4429 const struct MALI_RT_CLEAR * restrict values) 4430{ 4431 cl[ 0] = __gen_uint(values->color_0, 0, 31); 4432 cl[ 1] = __gen_uint(values->color_1, 0, 31); 4433 cl[ 2] = __gen_uint(values->color_2, 0, 31); 4434 cl[ 3] = __gen_uint(values->color_3, 0, 31); 4435} 4436 4437 4438#define MALI_RT_CLEAR_LENGTH 16 4439struct mali_rt_clear_packed { uint32_t opaque[4]; }; 4440static inline void 4441MALI_RT_CLEAR_unpack(const uint8_t * restrict cl, 4442 struct MALI_RT_CLEAR * restrict values) 4443{ 4444 values->color_0 = __gen_unpack_uint(cl, 0, 31); 4445 values->color_1 = __gen_unpack_uint(cl, 32, 63); 4446 values->color_2 = __gen_unpack_uint(cl, 64, 95); 4447 values->color_3 = __gen_unpack_uint(cl, 96, 127); 4448} 4449 4450static inline void 4451MALI_RT_CLEAR_print(FILE *fp, const struct MALI_RT_CLEAR * values, unsigned indent) 4452{ 4453 fprintf(fp, "%*sColor 0: %u\n", indent, "", values->color_0); 4454 fprintf(fp, "%*sColor 1: %u\n", indent, "", values->color_1); 4455 fprintf(fp, "%*sColor 2: %u\n", indent, "", values->color_2); 4456 fprintf(fp, "%*sColor 3: %u\n", indent, "", values->color_3); 4457} 4458 4459struct MALI_RENDER_TARGET { 4460 struct MALI_RENDER_TARGET_YUV_OVERLAY yuv; 4461 struct MALI_RENDER_TARGET_AFBC_OVERLAY afbc; 4462 uint32_t internal_buffer_offset; 4463 bool yuv_enable; 4464 bool dithered_clear; 4465 enum mali_color_buffer_internal_format internal_format; 4466 bool write_enable; 4467 enum mali_color_format writeback_format; 4468 enum mali_rt_endianness writeback_endianness; 4469 enum mali_block_format writeback_block_format; 4470 enum mali_msaa writeback_msaa; 4471 bool srgb; 4472 bool dithering_enable; 4473 uint32_t swizzle; 4474 bool clean_pixel_write_enable; 4475 struct MALI_RT_BUFFER rgb; 4476 struct MALI_RT_CLEAR clear; 4477}; 4478 4479#define MALI_RENDER_TARGET_header \ 4480 .yuv = { MALI_RENDER_TARGET_YUV_OVERLAY_header }, \ 4481 .afbc = { MALI_RENDER_TARGET_AFBC_OVERLAY_header }, \ 4482 .rgb = { MALI_RT_BUFFER_header }, \ 4483 .clear = { MALI_RT_CLEAR_header } 4484 4485static inline void 4486MALI_RENDER_TARGET_pack(uint32_t * restrict cl, 4487 const struct MALI_RENDER_TARGET * restrict values) 4488{ 4489 assert((values->internal_buffer_offset & 0xf) == 0); 4490 cl[ 0] = __gen_uint(values->internal_buffer_offset >> 4, 4, 15) | 4491 __gen_uint(values->yuv_enable, 24, 24) | 4492 __gen_uint(values->dithered_clear, 25, 25) | 4493 __gen_uint(values->internal_format, 26, 31); 4494 cl[ 1] = __gen_uint(values->write_enable, 0, 0) | 4495 __gen_uint(values->writeback_format, 3, 7) | 4496 __gen_uint(values->writeback_endianness, 8, 9) | 4497 __gen_uint(values->writeback_block_format, 10, 11) | 4498 __gen_uint(values->writeback_msaa, 12, 13) | 4499 __gen_uint(values->srgb, 14, 14) | 4500 __gen_uint(values->dithering_enable, 15, 15) | 4501 __gen_uint(values->swizzle, 16, 27) | 4502 __gen_uint(values->clean_pixel_write_enable, 31, 31); 4503 cl[ 2] = __gen_uint(values->yuv.swizzle, 16, 18) | 4504 __gen_uint(values->yuv.full_range, 20, 20) | 4505 __gen_uint(values->yuv.conversion_mode, 21, 24) | 4506 __gen_uint(values->yuv.cr_siting, 25, 27) | 4507 __gen_uint(values->yuv.unsigned_cr_range, 28, 28); 4508 cl[ 3] = 0; 4509 cl[ 4] = __gen_uint(values->yuv.plane_0_base, 0, 63) | 4510 __gen_uint(values->afbc.header, 0, 63); 4511 cl[ 5] = __gen_uint(values->yuv.plane_0_base, 0, 63) >> 32 | 4512 __gen_uint(values->afbc.header, 0, 63) >> 32; 4513 cl[ 6] = __gen_uint(values->yuv.plane_1_base, 0, 63) | 4514 __gen_uint(values->afbc.row_stride, 0, 12); 4515 cl[ 7] = __gen_uint(values->yuv.plane_1_base, 0, 63) >> 32 | 4516 __gen_uint(values->afbc.chunk_size, 0, 11) | 4517 __gen_uint(values->afbc.afbc_split_block_enable, 18, 18) | 4518 __gen_uint(values->afbc.afbc_wide_block_enable, 19, 19) | 4519 __gen_uint(values->afbc.reverse_issue_order, 20, 20) | 4520 __gen_uint(values->afbc.yuv_transform_enable, 17, 17); 4521 cl[ 8] = __gen_uint(values->yuv.plane_2_base, 0, 63) | 4522 __gen_uint(values->afbc.body, 0, 63) | 4523 __gen_uint(values->rgb.base, 0, 63); 4524 cl[ 9] = __gen_uint(values->yuv.plane_2_base, 0, 63) >> 32 | 4525 __gen_uint(values->afbc.body, 0, 63) >> 32 | 4526 __gen_uint(values->rgb.base, 0, 63) >> 32; 4527 cl[10] = __gen_uint(values->yuv.plane_0_stride, 0, 31) | 4528 __gen_uint(values->afbc.body_size, 0, 31) | 4529 __gen_uint(values->rgb.row_stride, 0, 31); 4530 cl[11] = __gen_uint(values->yuv.plane_1_2_stride, 0, 31) | 4531 __gen_uint(values->rgb.surface_stride, 0, 31); 4532 cl[12] = __gen_uint(values->clear.color_0, 0, 31); 4533 cl[13] = __gen_uint(values->clear.color_1, 0, 31); 4534 cl[14] = __gen_uint(values->clear.color_2, 0, 31); 4535 cl[15] = __gen_uint(values->clear.color_3, 0, 31); 4536} 4537 4538 4539#define MALI_RENDER_TARGET_LENGTH 64 4540#define MALI_RENDER_TARGET_ALIGN 64 4541struct mali_render_target_packed { uint32_t opaque[16]; }; 4542static inline void 4543MALI_RENDER_TARGET_unpack(const uint8_t * restrict cl, 4544 struct MALI_RENDER_TARGET * restrict values) 4545{ 4546 if (((const uint32_t *) cl)[0] & 0xff000f) fprintf(stderr, "XXX: Invalid field of Render Target unpacked at word 0\n"); 4547 if (((const uint32_t *) cl)[1] & 0x70000006) fprintf(stderr, "XXX: Invalid field of Render Target unpacked at word 1\n"); 4548 if (((const uint32_t *) cl)[2] & 0xe008ffff) fprintf(stderr, "XXX: Invalid field of Render Target unpacked at word 2\n"); 4549 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Render Target unpacked at word 3\n"); 4550 values->yuv.swizzle = (enum mali_yuv_swizzle)__gen_unpack_uint(cl, 80, 82); 4551 values->yuv.full_range = __gen_unpack_uint(cl, 84, 84); 4552 values->yuv.conversion_mode = (enum mali_yuv_conversion_mode)__gen_unpack_uint(cl, 85, 88); 4553 values->yuv.cr_siting = (enum mali_yuv_cr_siting)__gen_unpack_uint(cl, 89, 91); 4554 values->yuv.unsigned_cr_range = __gen_unpack_uint(cl, 92, 92); 4555 values->yuv.plane_0_base = __gen_unpack_uint(cl, 128, 191); 4556 values->yuv.plane_1_base = __gen_unpack_uint(cl, 192, 255); 4557 values->yuv.plane_2_base = __gen_unpack_uint(cl, 256, 319); 4558 values->yuv.plane_0_stride = __gen_unpack_uint(cl, 320, 351); 4559 values->yuv.plane_1_2_stride = __gen_unpack_uint(cl, 352, 383); 4560 values->afbc.header = __gen_unpack_uint(cl, 128, 191); 4561 values->afbc.row_stride = __gen_unpack_uint(cl, 192, 204); 4562 values->afbc.chunk_size = __gen_unpack_uint(cl, 224, 235); 4563 values->afbc.afbc_split_block_enable = __gen_unpack_uint(cl, 242, 242); 4564 values->afbc.afbc_wide_block_enable = __gen_unpack_uint(cl, 243, 243); 4565 values->afbc.reverse_issue_order = __gen_unpack_uint(cl, 244, 244); 4566 values->afbc.yuv_transform_enable = __gen_unpack_uint(cl, 241, 241); 4567 values->afbc.body = __gen_unpack_uint(cl, 256, 319); 4568 values->afbc.body_size = __gen_unpack_uint(cl, 320, 351); 4569 values->internal_buffer_offset = __gen_unpack_uint(cl, 4, 15) << 4; 4570 values->yuv_enable = __gen_unpack_uint(cl, 24, 24); 4571 values->dithered_clear = __gen_unpack_uint(cl, 25, 25); 4572 values->internal_format = (enum mali_color_buffer_internal_format)__gen_unpack_uint(cl, 26, 31); 4573 values->write_enable = __gen_unpack_uint(cl, 32, 32); 4574 values->writeback_format = (enum mali_color_format)__gen_unpack_uint(cl, 35, 39); 4575 values->writeback_endianness = (enum mali_rt_endianness)__gen_unpack_uint(cl, 40, 41); 4576 values->writeback_block_format = (enum mali_block_format)__gen_unpack_uint(cl, 42, 43); 4577 values->writeback_msaa = (enum mali_msaa)__gen_unpack_uint(cl, 44, 45); 4578 values->srgb = __gen_unpack_uint(cl, 46, 46); 4579 values->dithering_enable = __gen_unpack_uint(cl, 47, 47); 4580 values->swizzle = __gen_unpack_uint(cl, 48, 59); 4581 values->clean_pixel_write_enable = __gen_unpack_uint(cl, 63, 63); 4582 values->rgb.base = __gen_unpack_uint(cl, 256, 319); 4583 values->rgb.row_stride = __gen_unpack_uint(cl, 320, 351); 4584 values->rgb.surface_stride = __gen_unpack_uint(cl, 352, 383); 4585 values->clear.color_0 = __gen_unpack_uint(cl, 384, 415); 4586 values->clear.color_1 = __gen_unpack_uint(cl, 416, 447); 4587 values->clear.color_2 = __gen_unpack_uint(cl, 448, 479); 4588 values->clear.color_3 = __gen_unpack_uint(cl, 480, 511); 4589} 4590 4591static inline void 4592MALI_RENDER_TARGET_print(FILE *fp, const struct MALI_RENDER_TARGET * values, unsigned indent) 4593{ 4594 fprintf(fp, "%*sYUV:\n", indent, ""); 4595 MALI_RENDER_TARGET_YUV_OVERLAY_print(fp, &values->yuv, indent + 2); 4596 fprintf(fp, "%*sAFBC:\n", indent, ""); 4597 MALI_RENDER_TARGET_AFBC_OVERLAY_print(fp, &values->afbc, indent + 2); 4598 fprintf(fp, "%*sInternal Buffer Offset: %u\n", indent, "", values->internal_buffer_offset); 4599 fprintf(fp, "%*sYUV Enable: %s\n", indent, "", values->yuv_enable ? "true" : "false"); 4600 fprintf(fp, "%*sDithered Clear: %s\n", indent, "", values->dithered_clear ? "true" : "false"); 4601 fprintf(fp, "%*sInternal Format: %s\n", indent, "", mali_color_buffer_internal_format_as_str(values->internal_format)); 4602 fprintf(fp, "%*sWrite Enable: %s\n", indent, "", values->write_enable ? "true" : "false"); 4603 fprintf(fp, "%*sWriteback Format: %s\n", indent, "", mali_color_format_as_str(values->writeback_format)); 4604 fprintf(fp, "%*sWriteback Endianness: %s\n", indent, "", mali_rt_endianness_as_str(values->writeback_endianness)); 4605 fprintf(fp, "%*sWriteback Block Format: %s\n", indent, "", mali_block_format_as_str(values->writeback_block_format)); 4606 fprintf(fp, "%*sWriteback MSAA: %s\n", indent, "", mali_msaa_as_str(values->writeback_msaa)); 4607 fprintf(fp, "%*ssRGB: %s\n", indent, "", values->srgb ? "true" : "false"); 4608 fprintf(fp, "%*sDithering Enable: %s\n", indent, "", values->dithering_enable ? "true" : "false"); 4609 fprintf(fp, "%*sSwizzle: %u\n", indent, "", values->swizzle); 4610 fprintf(fp, "%*sClean Pixel Write Enable: %s\n", indent, "", values->clean_pixel_write_enable ? "true" : "false"); 4611 fprintf(fp, "%*sRGB:\n", indent, ""); 4612 MALI_RT_BUFFER_print(fp, &values->rgb, indent + 2); 4613 fprintf(fp, "%*sClear:\n", indent, ""); 4614 MALI_RT_CLEAR_print(fp, &values->clear, indent + 2); 4615} 4616 4617struct MALI_TILER_HEAP { 4618 uint32_t size; 4619 uint64_t base; 4620 uint64_t bottom; 4621 uint64_t top; 4622}; 4623 4624#define MALI_TILER_HEAP_header \ 4625 0 4626 4627static inline void 4628MALI_TILER_HEAP_pack(uint32_t * restrict cl, 4629 const struct MALI_TILER_HEAP * restrict values) 4630{ 4631 cl[ 0] = 0; 4632 cl[ 1] = __gen_uint(ALIGN_POT(values->size, 4096), 0, 31); 4633 cl[ 2] = __gen_uint(values->base, 0, 63); 4634 cl[ 3] = __gen_uint(values->base, 0, 63) >> 32; 4635 cl[ 4] = __gen_uint(values->bottom, 0, 63); 4636 cl[ 5] = __gen_uint(values->bottom, 0, 63) >> 32; 4637 cl[ 6] = __gen_uint(values->top, 0, 63); 4638 cl[ 7] = __gen_uint(values->top, 0, 63) >> 32; 4639} 4640 4641 4642#define MALI_TILER_HEAP_LENGTH 32 4643#define MALI_TILER_HEAP_ALIGN 64 4644struct mali_tiler_heap_packed { uint32_t opaque[8]; }; 4645static inline void 4646MALI_TILER_HEAP_unpack(const uint8_t * restrict cl, 4647 struct MALI_TILER_HEAP * restrict values) 4648{ 4649 if (((const uint32_t *) cl)[0] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Heap unpacked at word 0\n"); 4650 values->size = __gen_unpack_uint(cl, 32, 63); 4651 assert(!(values->size & 0xfff)); 4652 values->base = __gen_unpack_uint(cl, 64, 127); 4653 values->bottom = __gen_unpack_uint(cl, 128, 191); 4654 values->top = __gen_unpack_uint(cl, 192, 255); 4655} 4656 4657static inline void 4658MALI_TILER_HEAP_print(FILE *fp, const struct MALI_TILER_HEAP * values, unsigned indent) 4659{ 4660 fprintf(fp, "%*sSize: %u\n", indent, "", values->size); 4661 fprintf(fp, "%*sBase: 0x%" PRIx64 "\n", indent, "", values->base); 4662 fprintf(fp, "%*sBottom: 0x%" PRIx64 "\n", indent, "", values->bottom); 4663 fprintf(fp, "%*sTop: 0x%" PRIx64 "\n", indent, "", values->top); 4664} 4665 4666struct MALI_TILER_WEIGHTS { 4667 uint32_t weight0; 4668 uint32_t weight1; 4669 uint32_t weight2; 4670 uint32_t weight3; 4671 uint32_t weight4; 4672 uint32_t weight5; 4673 uint32_t weight6; 4674 uint32_t weight7; 4675}; 4676 4677#define MALI_TILER_WEIGHTS_header \ 4678 0 4679 4680static inline void 4681MALI_TILER_WEIGHTS_pack(uint32_t * restrict cl, 4682 const struct MALI_TILER_WEIGHTS * restrict values) 4683{ 4684 cl[ 0] = __gen_uint(values->weight0, 16, 31); 4685 cl[ 1] = __gen_uint(values->weight1, 16, 31); 4686 cl[ 2] = __gen_uint(values->weight2, 16, 31); 4687 cl[ 3] = __gen_uint(values->weight3, 16, 31); 4688 cl[ 4] = __gen_uint(values->weight4, 16, 31); 4689 cl[ 5] = __gen_uint(values->weight5, 16, 31); 4690 cl[ 6] = __gen_uint(values->weight6, 16, 31); 4691 cl[ 7] = __gen_uint(values->weight7, 16, 31); 4692} 4693 4694 4695#define MALI_TILER_WEIGHTS_LENGTH 32 4696struct mali_tiler_weights_packed { uint32_t opaque[8]; }; 4697static inline void 4698MALI_TILER_WEIGHTS_unpack(const uint8_t * restrict cl, 4699 struct MALI_TILER_WEIGHTS * restrict values) 4700{ 4701 if (((const uint32_t *) cl)[0] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Weights unpacked at word 0\n"); 4702 if (((const uint32_t *) cl)[1] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Weights unpacked at word 1\n"); 4703 if (((const uint32_t *) cl)[2] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Weights unpacked at word 2\n"); 4704 if (((const uint32_t *) cl)[3] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Weights unpacked at word 3\n"); 4705 if (((const uint32_t *) cl)[4] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Weights unpacked at word 4\n"); 4706 if (((const uint32_t *) cl)[5] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Weights unpacked at word 5\n"); 4707 if (((const uint32_t *) cl)[6] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Weights unpacked at word 6\n"); 4708 if (((const uint32_t *) cl)[7] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Weights unpacked at word 7\n"); 4709 values->weight0 = __gen_unpack_uint(cl, 16, 31); 4710 values->weight1 = __gen_unpack_uint(cl, 48, 63); 4711 values->weight2 = __gen_unpack_uint(cl, 80, 95); 4712 values->weight3 = __gen_unpack_uint(cl, 112, 127); 4713 values->weight4 = __gen_unpack_uint(cl, 144, 159); 4714 values->weight5 = __gen_unpack_uint(cl, 176, 191); 4715 values->weight6 = __gen_unpack_uint(cl, 208, 223); 4716 values->weight7 = __gen_unpack_uint(cl, 240, 255); 4717} 4718 4719static inline void 4720MALI_TILER_WEIGHTS_print(FILE *fp, const struct MALI_TILER_WEIGHTS * values, unsigned indent) 4721{ 4722 fprintf(fp, "%*sWeight0: %u\n", indent, "", values->weight0); 4723 fprintf(fp, "%*sWeight1: %u\n", indent, "", values->weight1); 4724 fprintf(fp, "%*sWeight2: %u\n", indent, "", values->weight2); 4725 fprintf(fp, "%*sWeight3: %u\n", indent, "", values->weight3); 4726 fprintf(fp, "%*sWeight4: %u\n", indent, "", values->weight4); 4727 fprintf(fp, "%*sWeight5: %u\n", indent, "", values->weight5); 4728 fprintf(fp, "%*sWeight6: %u\n", indent, "", values->weight6); 4729 fprintf(fp, "%*sWeight7: %u\n", indent, "", values->weight7); 4730} 4731 4732struct MALI_TILER_STATE { 4733 uint32_t word0; 4734 uint32_t word1; 4735 uint32_t word2; 4736 uint32_t word3; 4737 uint32_t word4; 4738 uint32_t word5; 4739 uint32_t word6; 4740 uint32_t word7; 4741 uint32_t word8; 4742 uint32_t word9; 4743 uint32_t word10; 4744 uint32_t word11; 4745 uint32_t word12; 4746 uint32_t word13; 4747 uint32_t word14; 4748 uint32_t word15; 4749}; 4750 4751#define MALI_TILER_STATE_header \ 4752 0 4753 4754static inline void 4755MALI_TILER_STATE_pack(uint32_t * restrict cl, 4756 const struct MALI_TILER_STATE * restrict values) 4757{ 4758 cl[ 0] = __gen_uint(values->word0, 0, 31); 4759 cl[ 1] = __gen_uint(values->word1, 0, 31); 4760 cl[ 2] = __gen_uint(values->word2, 0, 31); 4761 cl[ 3] = __gen_uint(values->word3, 0, 31); 4762 cl[ 4] = __gen_uint(values->word4, 0, 31); 4763 cl[ 5] = __gen_uint(values->word5, 0, 31); 4764 cl[ 6] = __gen_uint(values->word6, 0, 31); 4765 cl[ 7] = __gen_uint(values->word7, 0, 31); 4766 cl[ 8] = __gen_uint(values->word8, 0, 31); 4767 cl[ 9] = __gen_uint(values->word9, 0, 31); 4768 cl[10] = __gen_uint(values->word10, 0, 31); 4769 cl[11] = __gen_uint(values->word11, 0, 31); 4770 cl[12] = __gen_uint(values->word12, 0, 31); 4771 cl[13] = __gen_uint(values->word13, 0, 31); 4772 cl[14] = __gen_uint(values->word14, 0, 31); 4773 cl[15] = __gen_uint(values->word15, 0, 31); 4774} 4775 4776 4777#define MALI_TILER_STATE_LENGTH 64 4778struct mali_tiler_state_packed { uint32_t opaque[16]; }; 4779static inline void 4780MALI_TILER_STATE_unpack(const uint8_t * restrict cl, 4781 struct MALI_TILER_STATE * restrict values) 4782{ 4783 values->word0 = __gen_unpack_uint(cl, 0, 31); 4784 values->word1 = __gen_unpack_uint(cl, 32, 63); 4785 values->word2 = __gen_unpack_uint(cl, 64, 95); 4786 values->word3 = __gen_unpack_uint(cl, 96, 127); 4787 values->word4 = __gen_unpack_uint(cl, 128, 159); 4788 values->word5 = __gen_unpack_uint(cl, 160, 191); 4789 values->word6 = __gen_unpack_uint(cl, 192, 223); 4790 values->word7 = __gen_unpack_uint(cl, 224, 255); 4791 values->word8 = __gen_unpack_uint(cl, 256, 287); 4792 values->word9 = __gen_unpack_uint(cl, 288, 319); 4793 values->word10 = __gen_unpack_uint(cl, 320, 351); 4794 values->word11 = __gen_unpack_uint(cl, 352, 383); 4795 values->word12 = __gen_unpack_uint(cl, 384, 415); 4796 values->word13 = __gen_unpack_uint(cl, 416, 447); 4797 values->word14 = __gen_unpack_uint(cl, 448, 479); 4798 values->word15 = __gen_unpack_uint(cl, 480, 511); 4799} 4800 4801static inline void 4802MALI_TILER_STATE_print(FILE *fp, const struct MALI_TILER_STATE * values, unsigned indent) 4803{ 4804 fprintf(fp, "%*sWord0: %u\n", indent, "", values->word0); 4805 fprintf(fp, "%*sWord1: %u\n", indent, "", values->word1); 4806 fprintf(fp, "%*sWord2: %u\n", indent, "", values->word2); 4807 fprintf(fp, "%*sWord3: %u\n", indent, "", values->word3); 4808 fprintf(fp, "%*sWord4: %u\n", indent, "", values->word4); 4809 fprintf(fp, "%*sWord5: %u\n", indent, "", values->word5); 4810 fprintf(fp, "%*sWord6: %u\n", indent, "", values->word6); 4811 fprintf(fp, "%*sWord7: %u\n", indent, "", values->word7); 4812 fprintf(fp, "%*sWord8: %u\n", indent, "", values->word8); 4813 fprintf(fp, "%*sWord9: %u\n", indent, "", values->word9); 4814 fprintf(fp, "%*sWord10: %u\n", indent, "", values->word10); 4815 fprintf(fp, "%*sWord11: %u\n", indent, "", values->word11); 4816 fprintf(fp, "%*sWord12: %u\n", indent, "", values->word12); 4817 fprintf(fp, "%*sWord13: %u\n", indent, "", values->word13); 4818 fprintf(fp, "%*sWord14: %u\n", indent, "", values->word14); 4819 fprintf(fp, "%*sWord15: %u\n", indent, "", values->word15); 4820} 4821 4822struct MALI_TILER_CONTEXT { 4823 uint64_t polygon_list; 4824 uint32_t hierarchy_mask; 4825 enum mali_sample_pattern sample_pattern; 4826 bool update_cost_table; 4827 uint32_t fb_width; 4828 uint32_t fb_height; 4829 uint64_t heap; 4830 struct MALI_TILER_WEIGHTS weights; 4831 struct MALI_TILER_STATE state; 4832}; 4833 4834#define MALI_TILER_CONTEXT_header \ 4835 .weights = { MALI_TILER_WEIGHTS_header }, \ 4836 .state = { MALI_TILER_STATE_header } 4837 4838static inline void 4839MALI_TILER_CONTEXT_pack(uint32_t * restrict cl, 4840 const struct MALI_TILER_CONTEXT * restrict values) 4841{ 4842 assert(values->fb_width >= 1); 4843 assert(values->fb_height >= 1); 4844 cl[ 0] = __gen_uint(values->polygon_list, 0, 63); 4845 cl[ 1] = __gen_uint(values->polygon_list, 0, 63) >> 32; 4846 cl[ 2] = __gen_uint(values->hierarchy_mask, 0, 12) | 4847 __gen_uint(values->sample_pattern, 13, 15) | 4848 __gen_uint(values->update_cost_table, 16, 16); 4849 cl[ 3] = __gen_uint(values->fb_width - 1, 0, 15) | 4850 __gen_uint(values->fb_height - 1, 16, 31); 4851 cl[ 4] = 0; 4852 cl[ 5] = 0; 4853 cl[ 6] = __gen_uint(values->heap, 0, 63); 4854 cl[ 7] = __gen_uint(values->heap, 0, 63) >> 32; 4855 cl[ 8] = __gen_uint(values->weights.weight0, 16, 31); 4856 cl[ 9] = __gen_uint(values->weights.weight1, 16, 31); 4857 cl[10] = __gen_uint(values->weights.weight2, 16, 31); 4858 cl[11] = __gen_uint(values->weights.weight3, 16, 31); 4859 cl[12] = __gen_uint(values->weights.weight4, 16, 31); 4860 cl[13] = __gen_uint(values->weights.weight5, 16, 31); 4861 cl[14] = __gen_uint(values->weights.weight6, 16, 31); 4862 cl[15] = __gen_uint(values->weights.weight7, 16, 31); 4863 cl[16] = 0; 4864 cl[17] = 0; 4865 cl[18] = 0; 4866 cl[19] = 0; 4867 cl[20] = 0; 4868 cl[21] = 0; 4869 cl[22] = 0; 4870 cl[23] = 0; 4871 cl[24] = 0; 4872 cl[25] = 0; 4873 cl[26] = 0; 4874 cl[27] = 0; 4875 cl[28] = 0; 4876 cl[29] = 0; 4877 cl[30] = 0; 4878 cl[31] = 0; 4879 cl[32] = __gen_uint(values->state.word0, 0, 31); 4880 cl[33] = __gen_uint(values->state.word1, 0, 31); 4881 cl[34] = __gen_uint(values->state.word2, 0, 31); 4882 cl[35] = __gen_uint(values->state.word3, 0, 31); 4883 cl[36] = __gen_uint(values->state.word4, 0, 31); 4884 cl[37] = __gen_uint(values->state.word5, 0, 31); 4885 cl[38] = __gen_uint(values->state.word6, 0, 31); 4886 cl[39] = __gen_uint(values->state.word7, 0, 31); 4887 cl[40] = __gen_uint(values->state.word8, 0, 31); 4888 cl[41] = __gen_uint(values->state.word9, 0, 31); 4889 cl[42] = __gen_uint(values->state.word10, 0, 31); 4890 cl[43] = __gen_uint(values->state.word11, 0, 31); 4891 cl[44] = __gen_uint(values->state.word12, 0, 31); 4892 cl[45] = __gen_uint(values->state.word13, 0, 31); 4893 cl[46] = __gen_uint(values->state.word14, 0, 31); 4894 cl[47] = __gen_uint(values->state.word15, 0, 31); 4895} 4896 4897 4898#define MALI_TILER_CONTEXT_LENGTH 192 4899#define MALI_TILER_CONTEXT_ALIGN 64 4900struct mali_tiler_context_packed { uint32_t opaque[48]; }; 4901static inline void 4902MALI_TILER_CONTEXT_unpack(const uint8_t * restrict cl, 4903 struct MALI_TILER_CONTEXT * restrict values) 4904{ 4905 if (((const uint32_t *) cl)[2] & 0xfffe0000) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 2\n"); 4906 if (((const uint32_t *) cl)[4] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 4\n"); 4907 if (((const uint32_t *) cl)[5] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 5\n"); 4908 if (((const uint32_t *) cl)[8] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 8\n"); 4909 if (((const uint32_t *) cl)[9] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 9\n"); 4910 if (((const uint32_t *) cl)[10] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 10\n"); 4911 if (((const uint32_t *) cl)[11] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 11\n"); 4912 if (((const uint32_t *) cl)[12] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 12\n"); 4913 if (((const uint32_t *) cl)[13] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 13\n"); 4914 if (((const uint32_t *) cl)[14] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 14\n"); 4915 if (((const uint32_t *) cl)[15] & 0xffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 15\n"); 4916 if (((const uint32_t *) cl)[16] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 16\n"); 4917 if (((const uint32_t *) cl)[17] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 17\n"); 4918 if (((const uint32_t *) cl)[18] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 18\n"); 4919 if (((const uint32_t *) cl)[19] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 19\n"); 4920 if (((const uint32_t *) cl)[20] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 20\n"); 4921 if (((const uint32_t *) cl)[21] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 21\n"); 4922 if (((const uint32_t *) cl)[22] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 22\n"); 4923 if (((const uint32_t *) cl)[23] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 23\n"); 4924 if (((const uint32_t *) cl)[24] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 24\n"); 4925 if (((const uint32_t *) cl)[25] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 25\n"); 4926 if (((const uint32_t *) cl)[26] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 26\n"); 4927 if (((const uint32_t *) cl)[27] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 27\n"); 4928 if (((const uint32_t *) cl)[28] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 28\n"); 4929 if (((const uint32_t *) cl)[29] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 29\n"); 4930 if (((const uint32_t *) cl)[30] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 30\n"); 4931 if (((const uint32_t *) cl)[31] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 31\n"); 4932 values->polygon_list = __gen_unpack_uint(cl, 0, 63); 4933 values->hierarchy_mask = __gen_unpack_uint(cl, 64, 76); 4934 values->sample_pattern = (enum mali_sample_pattern)__gen_unpack_uint(cl, 77, 79); 4935 values->update_cost_table = __gen_unpack_uint(cl, 80, 80); 4936 values->fb_width = __gen_unpack_uint(cl, 96, 111) + 1; 4937 values->fb_height = __gen_unpack_uint(cl, 112, 127) + 1; 4938 values->heap = __gen_unpack_uint(cl, 192, 255); 4939 values->weights.weight0 = __gen_unpack_uint(cl, 272, 287); 4940 values->weights.weight1 = __gen_unpack_uint(cl, 304, 319); 4941 values->weights.weight2 = __gen_unpack_uint(cl, 336, 351); 4942 values->weights.weight3 = __gen_unpack_uint(cl, 368, 383); 4943 values->weights.weight4 = __gen_unpack_uint(cl, 400, 415); 4944 values->weights.weight5 = __gen_unpack_uint(cl, 432, 447); 4945 values->weights.weight6 = __gen_unpack_uint(cl, 464, 479); 4946 values->weights.weight7 = __gen_unpack_uint(cl, 496, 511); 4947 values->state.word0 = __gen_unpack_uint(cl, 1024, 1055); 4948 values->state.word1 = __gen_unpack_uint(cl, 1056, 1087); 4949 values->state.word2 = __gen_unpack_uint(cl, 1088, 1119); 4950 values->state.word3 = __gen_unpack_uint(cl, 1120, 1151); 4951 values->state.word4 = __gen_unpack_uint(cl, 1152, 1183); 4952 values->state.word5 = __gen_unpack_uint(cl, 1184, 1215); 4953 values->state.word6 = __gen_unpack_uint(cl, 1216, 1247); 4954 values->state.word7 = __gen_unpack_uint(cl, 1248, 1279); 4955 values->state.word8 = __gen_unpack_uint(cl, 1280, 1311); 4956 values->state.word9 = __gen_unpack_uint(cl, 1312, 1343); 4957 values->state.word10 = __gen_unpack_uint(cl, 1344, 1375); 4958 values->state.word11 = __gen_unpack_uint(cl, 1376, 1407); 4959 values->state.word12 = __gen_unpack_uint(cl, 1408, 1439); 4960 values->state.word13 = __gen_unpack_uint(cl, 1440, 1471); 4961 values->state.word14 = __gen_unpack_uint(cl, 1472, 1503); 4962 values->state.word15 = __gen_unpack_uint(cl, 1504, 1535); 4963} 4964 4965static inline void 4966MALI_TILER_CONTEXT_print(FILE *fp, const struct MALI_TILER_CONTEXT * values, unsigned indent) 4967{ 4968 fprintf(fp, "%*sPolygon List: 0x%" PRIx64 "\n", indent, "", values->polygon_list); 4969 fprintf(fp, "%*sHierarchy Mask: %u\n", indent, "", values->hierarchy_mask); 4970 fprintf(fp, "%*sSample Pattern: %s\n", indent, "", mali_sample_pattern_as_str(values->sample_pattern)); 4971 fprintf(fp, "%*sUpdate Cost Table: %s\n", indent, "", values->update_cost_table ? "true" : "false"); 4972 fprintf(fp, "%*sFB Width: %u\n", indent, "", values->fb_width); 4973 fprintf(fp, "%*sFB Height: %u\n", indent, "", values->fb_height); 4974 fprintf(fp, "%*sHeap: 0x%" PRIx64 "\n", indent, "", values->heap); 4975 fprintf(fp, "%*sWeights:\n", indent, ""); 4976 MALI_TILER_WEIGHTS_print(fp, &values->weights, indent + 2); 4977 fprintf(fp, "%*sState:\n", indent, ""); 4978 MALI_TILER_STATE_print(fp, &values->state, indent + 2); 4979} 4980 4981struct MALI_FRAMEBUFFER_PADDING { 4982 int dummy; 4983}; 4984 4985#define MALI_FRAMEBUFFER_PADDING_header \ 4986 0 4987 4988static inline void 4989MALI_FRAMEBUFFER_PADDING_pack(uint32_t * restrict cl, 4990 const struct MALI_FRAMEBUFFER_PADDING * restrict values) 4991{ 4992 cl[ 0] = 0; 4993 cl[ 1] = 0; 4994 cl[ 2] = 0; 4995 cl[ 3] = 0; 4996 cl[ 4] = 0; 4997 cl[ 5] = 0; 4998 cl[ 6] = 0; 4999 cl[ 7] = 0; 5000 cl[ 8] = 0; 5001 cl[ 9] = 0; 5002 cl[10] = 0; 5003 cl[11] = 0; 5004 cl[12] = 0; 5005 cl[13] = 0; 5006 cl[14] = 0; 5007 cl[15] = 0; 5008} 5009 5010 5011#define MALI_FRAMEBUFFER_PADDING_LENGTH 64 5012struct mali_framebuffer_padding_packed { uint32_t opaque[16]; }; 5013static inline void 5014MALI_FRAMEBUFFER_PADDING_unpack(const uint8_t * restrict cl, 5015 struct MALI_FRAMEBUFFER_PADDING * restrict values) 5016{ 5017 if (((const uint32_t *) cl)[0] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 0\n"); 5018 if (((const uint32_t *) cl)[1] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 1\n"); 5019 if (((const uint32_t *) cl)[2] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 2\n"); 5020 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 3\n"); 5021 if (((const uint32_t *) cl)[4] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 4\n"); 5022 if (((const uint32_t *) cl)[5] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 5\n"); 5023 if (((const uint32_t *) cl)[6] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 6\n"); 5024 if (((const uint32_t *) cl)[7] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 7\n"); 5025 if (((const uint32_t *) cl)[8] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 8\n"); 5026 if (((const uint32_t *) cl)[9] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 9\n"); 5027 if (((const uint32_t *) cl)[10] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 10\n"); 5028 if (((const uint32_t *) cl)[11] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 11\n"); 5029 if (((const uint32_t *) cl)[12] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 12\n"); 5030 if (((const uint32_t *) cl)[13] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 13\n"); 5031 if (((const uint32_t *) cl)[14] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 14\n"); 5032 if (((const uint32_t *) cl)[15] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding unpacked at word 15\n"); 5033} 5034 5035static inline void 5036MALI_FRAMEBUFFER_PADDING_print(FILE *fp, const struct MALI_FRAMEBUFFER_PADDING * values, unsigned indent) 5037{ 5038} 5039 5040struct mali_framebuffer_packed { 5041 uint32_t opaque[32]; 5042}; 5043 5044#define MALI_FRAMEBUFFER_LENGTH 128 5045#define MALI_FRAMEBUFFER_ALIGN 64 5046#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_TYPE struct MALI_FRAMEBUFFER_PARAMETERS 5047#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_header MALI_FRAMEBUFFER_PARAMETERS_header 5048#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_pack MALI_FRAMEBUFFER_PARAMETERS_pack 5049#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_unpack MALI_FRAMEBUFFER_PARAMETERS_unpack 5050#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_print MALI_FRAMEBUFFER_PARAMETERS_print 5051#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_OFFSET 0 5052#define MALI_FRAMEBUFFER_SECTION_PADDING_TYPE struct MALI_FRAMEBUFFER_PADDING 5053#define MALI_FRAMEBUFFER_SECTION_PADDING_header MALI_FRAMEBUFFER_PADDING_header 5054#define MALI_FRAMEBUFFER_SECTION_PADDING_pack MALI_FRAMEBUFFER_PADDING_pack 5055#define MALI_FRAMEBUFFER_SECTION_PADDING_unpack MALI_FRAMEBUFFER_PADDING_unpack 5056#define MALI_FRAMEBUFFER_SECTION_PADDING_print MALI_FRAMEBUFFER_PADDING_print 5057#define MALI_FRAMEBUFFER_SECTION_PADDING_OFFSET 64 5058 5059struct MALI_JOB_HEADER { 5060 uint32_t exception_status; 5061 uint32_t first_incomplete_task; 5062 uint64_t fault_pointer; 5063 bool is_64b; 5064 enum mali_job_type type; 5065 bool barrier; 5066 bool invalidate_cache; 5067 bool suppress_prefetch; 5068 bool enable_texture_mapper; 5069 bool relax_dependency_1; 5070 bool relax_dependency_2; 5071 uint32_t index; 5072 uint32_t dependency_1; 5073 uint32_t dependency_2; 5074 uint64_t next; 5075}; 5076 5077#define MALI_JOB_HEADER_header \ 5078 .is_64b = true 5079 5080static inline void 5081MALI_JOB_HEADER_pack(uint32_t * restrict cl, 5082 const struct MALI_JOB_HEADER * restrict values) 5083{ 5084 cl[ 0] = __gen_uint(values->exception_status, 0, 31); 5085 cl[ 1] = __gen_uint(values->first_incomplete_task, 0, 31); 5086 cl[ 2] = __gen_uint(values->fault_pointer, 0, 63); 5087 cl[ 3] = __gen_uint(values->fault_pointer, 0, 63) >> 32; 5088 cl[ 4] = __gen_uint(values->is_64b, 0, 0) | 5089 __gen_uint(values->type, 1, 7) | 5090 __gen_uint(values->barrier, 8, 8) | 5091 __gen_uint(values->invalidate_cache, 9, 9) | 5092 __gen_uint(values->suppress_prefetch, 11, 11) | 5093 __gen_uint(values->enable_texture_mapper, 12, 12) | 5094 __gen_uint(values->relax_dependency_1, 14, 14) | 5095 __gen_uint(values->relax_dependency_2, 15, 15) | 5096 __gen_uint(values->index, 16, 31); 5097 cl[ 5] = __gen_uint(values->dependency_1, 0, 15) | 5098 __gen_uint(values->dependency_2, 16, 31); 5099 cl[ 6] = __gen_uint(values->next, 0, 63); 5100 cl[ 7] = __gen_uint(values->next, 0, 63) >> 32; 5101} 5102 5103 5104#define MALI_JOB_HEADER_LENGTH 32 5105#define MALI_JOB_HEADER_ALIGN 64 5106struct mali_job_header_packed { uint32_t opaque[8]; }; 5107static inline void 5108MALI_JOB_HEADER_unpack(const uint8_t * restrict cl, 5109 struct MALI_JOB_HEADER * restrict values) 5110{ 5111 if (((const uint32_t *) cl)[4] & 0x2400) fprintf(stderr, "XXX: Invalid field of Job Header unpacked at word 4\n"); 5112 values->exception_status = __gen_unpack_uint(cl, 0, 31); 5113 values->first_incomplete_task = __gen_unpack_uint(cl, 32, 63); 5114 values->fault_pointer = __gen_unpack_uint(cl, 64, 127); 5115 values->is_64b = __gen_unpack_uint(cl, 128, 128); 5116 values->type = (enum mali_job_type)__gen_unpack_uint(cl, 129, 135); 5117 values->barrier = __gen_unpack_uint(cl, 136, 136); 5118 values->invalidate_cache = __gen_unpack_uint(cl, 137, 137); 5119 values->suppress_prefetch = __gen_unpack_uint(cl, 139, 139); 5120 values->enable_texture_mapper = __gen_unpack_uint(cl, 140, 140); 5121 values->relax_dependency_1 = __gen_unpack_uint(cl, 142, 142); 5122 values->relax_dependency_2 = __gen_unpack_uint(cl, 143, 143); 5123 values->index = __gen_unpack_uint(cl, 144, 159); 5124 values->dependency_1 = __gen_unpack_uint(cl, 160, 175); 5125 values->dependency_2 = __gen_unpack_uint(cl, 176, 191); 5126 values->next = __gen_unpack_uint(cl, 192, 255); 5127} 5128 5129static inline void 5130MALI_JOB_HEADER_print(FILE *fp, const struct MALI_JOB_HEADER * values, unsigned indent) 5131{ 5132 fprintf(fp, "%*sException Status: %u\n", indent, "", values->exception_status); 5133 fprintf(fp, "%*sFirst Incomplete Task: %u\n", indent, "", values->first_incomplete_task); 5134 fprintf(fp, "%*sFault Pointer: 0x%" PRIx64 "\n", indent, "", values->fault_pointer); 5135 fprintf(fp, "%*sIs 64b: %s\n", indent, "", values->is_64b ? "true" : "false"); 5136 fprintf(fp, "%*sType: %s\n", indent, "", mali_job_type_as_str(values->type)); 5137 fprintf(fp, "%*sBarrier: %s\n", indent, "", values->barrier ? "true" : "false"); 5138 fprintf(fp, "%*sInvalidate Cache: %s\n", indent, "", values->invalidate_cache ? "true" : "false"); 5139 fprintf(fp, "%*sSuppress Prefetch: %s\n", indent, "", values->suppress_prefetch ? "true" : "false"); 5140 fprintf(fp, "%*sEnable Texture Mapper: %s\n", indent, "", values->enable_texture_mapper ? "true" : "false"); 5141 fprintf(fp, "%*sRelax Dependency 1: %s\n", indent, "", values->relax_dependency_1 ? "true" : "false"); 5142 fprintf(fp, "%*sRelax Dependency 2: %s\n", indent, "", values->relax_dependency_2 ? "true" : "false"); 5143 fprintf(fp, "%*sIndex: %u\n", indent, "", values->index); 5144 fprintf(fp, "%*sDependency 1: %u\n", indent, "", values->dependency_1); 5145 fprintf(fp, "%*sDependency 2: %u\n", indent, "", values->dependency_2); 5146 fprintf(fp, "%*sNext: 0x%" PRIx64 "\n", indent, "", values->next); 5147} 5148 5149struct MALI_FRAGMENT_JOB_PAYLOAD { 5150 uint32_t bound_min_x; 5151 uint32_t bound_min_y; 5152 uint32_t bound_max_x; 5153 uint32_t bound_max_y; 5154 bool has_tile_enable_map; 5155 uint64_t framebuffer; 5156 uint64_t tile_enable_map; 5157 uint32_t tile_enable_map_row_stride; 5158}; 5159 5160#define MALI_FRAGMENT_JOB_PAYLOAD_header \ 5161 0 5162 5163static inline void 5164MALI_FRAGMENT_JOB_PAYLOAD_pack(uint32_t * restrict cl, 5165 const struct MALI_FRAGMENT_JOB_PAYLOAD * restrict values) 5166{ 5167 cl[ 0] = __gen_uint(values->bound_min_x, 0, 11) | 5168 __gen_uint(values->bound_min_y, 16, 27); 5169 cl[ 1] = __gen_uint(values->bound_max_x, 0, 11) | 5170 __gen_uint(values->bound_max_y, 16, 27) | 5171 __gen_uint(values->has_tile_enable_map, 31, 31); 5172 cl[ 2] = __gen_uint(values->framebuffer, 0, 63); 5173 cl[ 3] = __gen_uint(values->framebuffer, 0, 63) >> 32; 5174 cl[ 4] = __gen_uint(values->tile_enable_map, 0, 63); 5175 cl[ 5] = __gen_uint(values->tile_enable_map, 0, 63) >> 32; 5176 cl[ 6] = __gen_uint(values->tile_enable_map_row_stride, 0, 7); 5177 cl[ 7] = 0; 5178} 5179 5180 5181#define MALI_FRAGMENT_JOB_PAYLOAD_LENGTH 32 5182struct mali_fragment_job_payload_packed { uint32_t opaque[8]; }; 5183static inline void 5184MALI_FRAGMENT_JOB_PAYLOAD_unpack(const uint8_t * restrict cl, 5185 struct MALI_FRAGMENT_JOB_PAYLOAD * restrict values) 5186{ 5187 if (((const uint32_t *) cl)[0] & 0xf000f000) fprintf(stderr, "XXX: Invalid field of Fragment Job Payload unpacked at word 0\n"); 5188 if (((const uint32_t *) cl)[1] & 0x7000f000) fprintf(stderr, "XXX: Invalid field of Fragment Job Payload unpacked at word 1\n"); 5189 if (((const uint32_t *) cl)[6] & 0xffffff00) fprintf(stderr, "XXX: Invalid field of Fragment Job Payload unpacked at word 6\n"); 5190 if (((const uint32_t *) cl)[7] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Fragment Job Payload unpacked at word 7\n"); 5191 values->bound_min_x = __gen_unpack_uint(cl, 0, 11); 5192 values->bound_min_y = __gen_unpack_uint(cl, 16, 27); 5193 values->bound_max_x = __gen_unpack_uint(cl, 32, 43); 5194 values->bound_max_y = __gen_unpack_uint(cl, 48, 59); 5195 values->has_tile_enable_map = __gen_unpack_uint(cl, 63, 63); 5196 values->framebuffer = __gen_unpack_uint(cl, 64, 127); 5197 values->tile_enable_map = __gen_unpack_uint(cl, 128, 191); 5198 values->tile_enable_map_row_stride = __gen_unpack_uint(cl, 192, 199); 5199} 5200 5201static inline void 5202MALI_FRAGMENT_JOB_PAYLOAD_print(FILE *fp, const struct MALI_FRAGMENT_JOB_PAYLOAD * values, unsigned indent) 5203{ 5204 fprintf(fp, "%*sBound Min X: %u\n", indent, "", values->bound_min_x); 5205 fprintf(fp, "%*sBound Min Y: %u\n", indent, "", values->bound_min_y); 5206 fprintf(fp, "%*sBound Max X: %u\n", indent, "", values->bound_max_x); 5207 fprintf(fp, "%*sBound Max Y: %u\n", indent, "", values->bound_max_y); 5208 fprintf(fp, "%*sHas Tile Enable Map: %s\n", indent, "", values->has_tile_enable_map ? "true" : "false"); 5209 fprintf(fp, "%*sFramebuffer: 0x%" PRIx64 "\n", indent, "", values->framebuffer); 5210 fprintf(fp, "%*sTile Enable Map: 0x%" PRIx64 "\n", indent, "", values->tile_enable_map); 5211 fprintf(fp, "%*sTile Enable Map Row Stride: %u\n", indent, "", values->tile_enable_map_row_stride); 5212} 5213 5214struct mali_fragment_job_packed { 5215 uint32_t opaque[16]; 5216}; 5217 5218#define MALI_FRAGMENT_JOB_LENGTH 64 5219#define MALI_FRAGMENT_JOB_ALIGN 64 5220#define MALI_FRAGMENT_JOB_SECTION_HEADER_TYPE struct MALI_JOB_HEADER 5221#define MALI_FRAGMENT_JOB_SECTION_HEADER_header MALI_JOB_HEADER_header 5222#define MALI_FRAGMENT_JOB_SECTION_HEADER_pack MALI_JOB_HEADER_pack 5223#define MALI_FRAGMENT_JOB_SECTION_HEADER_unpack MALI_JOB_HEADER_unpack 5224#define MALI_FRAGMENT_JOB_SECTION_HEADER_print MALI_JOB_HEADER_print 5225#define MALI_FRAGMENT_JOB_SECTION_HEADER_OFFSET 0 5226#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_TYPE struct MALI_FRAGMENT_JOB_PAYLOAD 5227#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_header MALI_FRAGMENT_JOB_PAYLOAD_header 5228#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_pack MALI_FRAGMENT_JOB_PAYLOAD_pack 5229#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_unpack MALI_FRAGMENT_JOB_PAYLOAD_unpack 5230#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_print MALI_FRAGMENT_JOB_PAYLOAD_print 5231#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_OFFSET 32 5232 5233enum mali_write_value_type { 5234 MALI_WRITE_VALUE_TYPE_CYCLE_COUNTER = 1, 5235 MALI_WRITE_VALUE_TYPE_SYSTEM_TIMESTAMP = 2, 5236 MALI_WRITE_VALUE_TYPE_ZERO = 3, 5237 MALI_WRITE_VALUE_TYPE_IMMEDIATE_8 = 4, 5238 MALI_WRITE_VALUE_TYPE_IMMEDIATE_16 = 5, 5239 MALI_WRITE_VALUE_TYPE_IMMEDIATE_32 = 6, 5240 MALI_WRITE_VALUE_TYPE_IMMEDIATE_64 = 7, 5241}; 5242 5243static inline const char * 5244mali_write_value_type_as_str(enum mali_write_value_type imm) 5245{ 5246 switch (imm) { 5247 case MALI_WRITE_VALUE_TYPE_CYCLE_COUNTER: return "Cycle Counter"; 5248 case MALI_WRITE_VALUE_TYPE_SYSTEM_TIMESTAMP: return "System Timestamp"; 5249 case MALI_WRITE_VALUE_TYPE_ZERO: return "Zero"; 5250 case MALI_WRITE_VALUE_TYPE_IMMEDIATE_8: return "Immediate 8"; 5251 case MALI_WRITE_VALUE_TYPE_IMMEDIATE_16: return "Immediate 16"; 5252 case MALI_WRITE_VALUE_TYPE_IMMEDIATE_32: return "Immediate 32"; 5253 case MALI_WRITE_VALUE_TYPE_IMMEDIATE_64: return "Immediate 64"; 5254 default: return "XXX: INVALID"; 5255 } 5256} 5257 5258struct MALI_WRITE_VALUE_JOB_PAYLOAD { 5259 uint64_t address; 5260 enum mali_write_value_type type; 5261 uint64_t immediate_value; 5262}; 5263 5264#define MALI_WRITE_VALUE_JOB_PAYLOAD_header \ 5265 0 5266 5267static inline void 5268MALI_WRITE_VALUE_JOB_PAYLOAD_pack(uint32_t * restrict cl, 5269 const struct MALI_WRITE_VALUE_JOB_PAYLOAD * restrict values) 5270{ 5271 cl[ 0] = __gen_uint(values->address, 0, 63); 5272 cl[ 1] = __gen_uint(values->address, 0, 63) >> 32; 5273 cl[ 2] = __gen_uint(values->type, 0, 31); 5274 cl[ 3] = 0; 5275 cl[ 4] = __gen_uint(values->immediate_value, 0, 63); 5276 cl[ 5] = __gen_uint(values->immediate_value, 0, 63) >> 32; 5277} 5278 5279 5280#define MALI_WRITE_VALUE_JOB_PAYLOAD_LENGTH 24 5281struct mali_write_value_job_payload_packed { uint32_t opaque[6]; }; 5282static inline void 5283MALI_WRITE_VALUE_JOB_PAYLOAD_unpack(const uint8_t * restrict cl, 5284 struct MALI_WRITE_VALUE_JOB_PAYLOAD * restrict values) 5285{ 5286 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Write Value Job Payload unpacked at word 3\n"); 5287 values->address = __gen_unpack_uint(cl, 0, 63); 5288 values->type = (enum mali_write_value_type)__gen_unpack_uint(cl, 64, 95); 5289 values->immediate_value = __gen_unpack_uint(cl, 128, 191); 5290} 5291 5292static inline void 5293MALI_WRITE_VALUE_JOB_PAYLOAD_print(FILE *fp, const struct MALI_WRITE_VALUE_JOB_PAYLOAD * values, unsigned indent) 5294{ 5295 fprintf(fp, "%*sAddress: 0x%" PRIx64 "\n", indent, "", values->address); 5296 fprintf(fp, "%*sType: %s\n", indent, "", mali_write_value_type_as_str(values->type)); 5297 fprintf(fp, "%*sImmediate Value: 0x%" PRIx64 "\n", indent, "", values->immediate_value); 5298} 5299 5300struct MALI_CACHE_FLUSH_JOB_PAYLOAD { 5301 bool clean_shader_core_ls; 5302 bool invalidate_shader_core_ls; 5303 bool invalidate_shader_core_other; 5304 bool job_manager_clean; 5305 bool job_manager_invalidate; 5306 bool tiler_clean; 5307 bool tiler_invalidate; 5308 bool l2_clean; 5309 bool l2_invalidate; 5310}; 5311 5312#define MALI_CACHE_FLUSH_JOB_PAYLOAD_header \ 5313 0 5314 5315static inline void 5316MALI_CACHE_FLUSH_JOB_PAYLOAD_pack(uint32_t * restrict cl, 5317 const struct MALI_CACHE_FLUSH_JOB_PAYLOAD * restrict values) 5318{ 5319 cl[ 0] = __gen_uint(values->clean_shader_core_ls, 0, 0) | 5320 __gen_uint(values->invalidate_shader_core_ls, 1, 1) | 5321 __gen_uint(values->invalidate_shader_core_other, 2, 2) | 5322 __gen_uint(values->job_manager_clean, 16, 16) | 5323 __gen_uint(values->job_manager_invalidate, 17, 17) | 5324 __gen_uint(values->tiler_clean, 24, 24) | 5325 __gen_uint(values->tiler_invalidate, 25, 25); 5326 cl[ 1] = __gen_uint(values->l2_clean, 0, 0) | 5327 __gen_uint(values->l2_invalidate, 1, 1); 5328} 5329 5330 5331#define MALI_CACHE_FLUSH_JOB_PAYLOAD_LENGTH 8 5332struct mali_cache_flush_job_payload_packed { uint32_t opaque[2]; }; 5333static inline void 5334MALI_CACHE_FLUSH_JOB_PAYLOAD_unpack(const uint8_t * restrict cl, 5335 struct MALI_CACHE_FLUSH_JOB_PAYLOAD * restrict values) 5336{ 5337 if (((const uint32_t *) cl)[0] & 0xfcfcfff8) fprintf(stderr, "XXX: Invalid field of Cache Flush Job Payload unpacked at word 0\n"); 5338 if (((const uint32_t *) cl)[1] & 0xfffffffc) fprintf(stderr, "XXX: Invalid field of Cache Flush Job Payload unpacked at word 1\n"); 5339 values->clean_shader_core_ls = __gen_unpack_uint(cl, 0, 0); 5340 values->invalidate_shader_core_ls = __gen_unpack_uint(cl, 1, 1); 5341 values->invalidate_shader_core_other = __gen_unpack_uint(cl, 2, 2); 5342 values->job_manager_clean = __gen_unpack_uint(cl, 16, 16); 5343 values->job_manager_invalidate = __gen_unpack_uint(cl, 17, 17); 5344 values->tiler_clean = __gen_unpack_uint(cl, 24, 24); 5345 values->tiler_invalidate = __gen_unpack_uint(cl, 25, 25); 5346 values->l2_clean = __gen_unpack_uint(cl, 32, 32); 5347 values->l2_invalidate = __gen_unpack_uint(cl, 33, 33); 5348} 5349 5350static inline void 5351MALI_CACHE_FLUSH_JOB_PAYLOAD_print(FILE *fp, const struct MALI_CACHE_FLUSH_JOB_PAYLOAD * values, unsigned indent) 5352{ 5353 fprintf(fp, "%*sClean Shader Core LS: %s\n", indent, "", values->clean_shader_core_ls ? "true" : "false"); 5354 fprintf(fp, "%*sInvalidate Shader Core LS: %s\n", indent, "", values->invalidate_shader_core_ls ? "true" : "false"); 5355 fprintf(fp, "%*sInvalidate Shader Core Other: %s\n", indent, "", values->invalidate_shader_core_other ? "true" : "false"); 5356 fprintf(fp, "%*sJob Manager Clean: %s\n", indent, "", values->job_manager_clean ? "true" : "false"); 5357 fprintf(fp, "%*sJob Manager Invalidate: %s\n", indent, "", values->job_manager_invalidate ? "true" : "false"); 5358 fprintf(fp, "%*sTiler Clean: %s\n", indent, "", values->tiler_clean ? "true" : "false"); 5359 fprintf(fp, "%*sTiler Invalidate: %s\n", indent, "", values->tiler_invalidate ? "true" : "false"); 5360 fprintf(fp, "%*sL2 Clean: %s\n", indent, "", values->l2_clean ? "true" : "false"); 5361 fprintf(fp, "%*sL2 Invalidate: %s\n", indent, "", values->l2_invalidate ? "true" : "false"); 5362} 5363 5364struct mali_write_value_job_packed { 5365 uint32_t opaque[14]; 5366}; 5367 5368#define MALI_WRITE_VALUE_JOB_LENGTH 56 5369#define MALI_WRITE_VALUE_JOB_ALIGN 64 5370#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_TYPE struct MALI_JOB_HEADER 5371#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_header MALI_JOB_HEADER_header 5372#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_pack MALI_JOB_HEADER_pack 5373#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_unpack MALI_JOB_HEADER_unpack 5374#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_print MALI_JOB_HEADER_print 5375#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_OFFSET 0 5376#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_TYPE struct MALI_WRITE_VALUE_JOB_PAYLOAD 5377#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_header MALI_WRITE_VALUE_JOB_PAYLOAD_header 5378#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_pack MALI_WRITE_VALUE_JOB_PAYLOAD_pack 5379#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_unpack MALI_WRITE_VALUE_JOB_PAYLOAD_unpack 5380#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_print MALI_WRITE_VALUE_JOB_PAYLOAD_print 5381#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_OFFSET 32 5382 5383struct mali_cache_flush_job_packed { 5384 uint32_t opaque[10]; 5385}; 5386 5387#define MALI_CACHE_FLUSH_JOB_LENGTH 40 5388#define MALI_CACHE_FLUSH_JOB_ALIGN 64 5389#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_TYPE struct MALI_JOB_HEADER 5390#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_header MALI_JOB_HEADER_header 5391#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_pack MALI_JOB_HEADER_pack 5392#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_unpack MALI_JOB_HEADER_unpack 5393#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_print MALI_JOB_HEADER_print 5394#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_OFFSET 0 5395#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_TYPE struct MALI_CACHE_FLUSH_JOB_PAYLOAD 5396#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_header MALI_CACHE_FLUSH_JOB_PAYLOAD_header 5397#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_pack MALI_CACHE_FLUSH_JOB_PAYLOAD_pack 5398#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_unpack MALI_CACHE_FLUSH_JOB_PAYLOAD_unpack 5399#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_print MALI_CACHE_FLUSH_JOB_PAYLOAD_print 5400#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_OFFSET 32 5401 5402struct MALI_COMPUTE_JOB_PARAMETERS { 5403 uint32_t job_task_split; 5404}; 5405 5406#define MALI_COMPUTE_JOB_PARAMETERS_header \ 5407 0 5408 5409static inline void 5410MALI_COMPUTE_JOB_PARAMETERS_pack(uint32_t * restrict cl, 5411 const struct MALI_COMPUTE_JOB_PARAMETERS * restrict values) 5412{ 5413 cl[ 0] = __gen_uint(values->job_task_split, 26, 29); 5414 cl[ 1] = 0; 5415 cl[ 2] = 0; 5416 cl[ 3] = 0; 5417 cl[ 4] = 0; 5418 cl[ 5] = 0; 5419} 5420 5421 5422#define MALI_COMPUTE_JOB_PARAMETERS_LENGTH 24 5423struct mali_compute_job_parameters_packed { uint32_t opaque[6]; }; 5424static inline void 5425MALI_COMPUTE_JOB_PARAMETERS_unpack(const uint8_t * restrict cl, 5426 struct MALI_COMPUTE_JOB_PARAMETERS * restrict values) 5427{ 5428 if (((const uint32_t *) cl)[0] & 0xc3ffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 0\n"); 5429 if (((const uint32_t *) cl)[1] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 1\n"); 5430 if (((const uint32_t *) cl)[2] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 2\n"); 5431 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 3\n"); 5432 if (((const uint32_t *) cl)[4] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 4\n"); 5433 if (((const uint32_t *) cl)[5] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 5\n"); 5434 values->job_task_split = __gen_unpack_uint(cl, 26, 29); 5435} 5436 5437static inline void 5438MALI_COMPUTE_JOB_PARAMETERS_print(FILE *fp, const struct MALI_COMPUTE_JOB_PARAMETERS * values, unsigned indent) 5439{ 5440 fprintf(fp, "%*sJob Task Split: %u\n", indent, "", values->job_task_split); 5441} 5442 5443struct mali_compute_job_packed { 5444 uint32_t opaque[48]; 5445}; 5446 5447#define MALI_COMPUTE_JOB_LENGTH 192 5448#define MALI_COMPUTE_JOB_ALIGN 64 5449#define MALI_COMPUTE_JOB_SECTION_HEADER_TYPE struct MALI_JOB_HEADER 5450#define MALI_COMPUTE_JOB_SECTION_HEADER_header MALI_JOB_HEADER_header 5451#define MALI_COMPUTE_JOB_SECTION_HEADER_pack MALI_JOB_HEADER_pack 5452#define MALI_COMPUTE_JOB_SECTION_HEADER_unpack MALI_JOB_HEADER_unpack 5453#define MALI_COMPUTE_JOB_SECTION_HEADER_print MALI_JOB_HEADER_print 5454#define MALI_COMPUTE_JOB_SECTION_HEADER_OFFSET 0 5455#define MALI_COMPUTE_JOB_SECTION_INVOCATION_TYPE struct MALI_INVOCATION 5456#define MALI_COMPUTE_JOB_SECTION_INVOCATION_header MALI_INVOCATION_header 5457#define MALI_COMPUTE_JOB_SECTION_INVOCATION_pack MALI_INVOCATION_pack 5458#define MALI_COMPUTE_JOB_SECTION_INVOCATION_unpack MALI_INVOCATION_unpack 5459#define MALI_COMPUTE_JOB_SECTION_INVOCATION_print MALI_INVOCATION_print 5460#define MALI_COMPUTE_JOB_SECTION_INVOCATION_OFFSET 32 5461#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_TYPE struct MALI_COMPUTE_JOB_PARAMETERS 5462#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_header MALI_COMPUTE_JOB_PARAMETERS_header 5463#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_pack MALI_COMPUTE_JOB_PARAMETERS_pack 5464#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_unpack MALI_COMPUTE_JOB_PARAMETERS_unpack 5465#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_print MALI_COMPUTE_JOB_PARAMETERS_print 5466#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_OFFSET 40 5467#define MALI_COMPUTE_JOB_SECTION_DRAW_TYPE struct MALI_DRAW 5468#define MALI_COMPUTE_JOB_SECTION_DRAW_header MALI_DRAW_header 5469#define MALI_COMPUTE_JOB_SECTION_DRAW_pack MALI_DRAW_pack 5470#define MALI_COMPUTE_JOB_SECTION_DRAW_unpack MALI_DRAW_unpack 5471#define MALI_COMPUTE_JOB_SECTION_DRAW_print MALI_DRAW_print 5472#define MALI_COMPUTE_JOB_SECTION_DRAW_OFFSET 64 5473 5474struct MALI_PRIMITIVE_SIZE { 5475 float constant; 5476 uint64_t size_array; 5477}; 5478 5479#define MALI_PRIMITIVE_SIZE_header \ 5480 0 5481 5482static inline void 5483MALI_PRIMITIVE_SIZE_pack(uint32_t * restrict cl, 5484 const struct MALI_PRIMITIVE_SIZE * restrict values) 5485{ 5486 cl[ 0] = __gen_uint(fui(values->constant), 0, 32) | 5487 __gen_uint(values->size_array, 0, 63); 5488 cl[ 1] = __gen_uint(values->size_array, 0, 63) >> 32; 5489} 5490 5491 5492#define MALI_PRIMITIVE_SIZE_LENGTH 8 5493struct mali_primitive_size_packed { uint32_t opaque[2]; }; 5494static inline void 5495MALI_PRIMITIVE_SIZE_unpack(const uint8_t * restrict cl, 5496 struct MALI_PRIMITIVE_SIZE * restrict values) 5497{ 5498 values->constant = __gen_unpack_float(cl, 0, 31); 5499 values->size_array = __gen_unpack_uint(cl, 0, 63); 5500} 5501 5502static inline void 5503MALI_PRIMITIVE_SIZE_print(FILE *fp, const struct MALI_PRIMITIVE_SIZE * values, unsigned indent) 5504{ 5505 fprintf(fp, "%*sConstant: %f\n", indent, "", values->constant); 5506 fprintf(fp, "%*sSize Array: 0x%" PRIx64 "\n", indent, "", values->size_array); 5507} 5508 5509struct MALI_TILER_POINTER { 5510 uint64_t address; 5511}; 5512 5513#define MALI_TILER_POINTER_header \ 5514 0 5515 5516static inline void 5517MALI_TILER_POINTER_pack(uint32_t * restrict cl, 5518 const struct MALI_TILER_POINTER * restrict values) 5519{ 5520 cl[ 0] = __gen_uint(values->address, 0, 63); 5521 cl[ 1] = __gen_uint(values->address, 0, 63) >> 32; 5522} 5523 5524 5525#define MALI_TILER_POINTER_LENGTH 8 5526struct mali_tiler_pointer_packed { uint32_t opaque[2]; }; 5527static inline void 5528MALI_TILER_POINTER_unpack(const uint8_t * restrict cl, 5529 struct MALI_TILER_POINTER * restrict values) 5530{ 5531 values->address = __gen_unpack_uint(cl, 0, 63); 5532} 5533 5534static inline void 5535MALI_TILER_POINTER_print(FILE *fp, const struct MALI_TILER_POINTER * values, unsigned indent) 5536{ 5537 fprintf(fp, "%*sAddress: 0x%" PRIx64 "\n", indent, "", values->address); 5538} 5539 5540struct MALI_TILER_JOB_PADDING { 5541 int dummy; 5542}; 5543 5544#define MALI_TILER_JOB_PADDING_header \ 5545 0 5546 5547static inline void 5548MALI_TILER_JOB_PADDING_pack(uint32_t * restrict cl, 5549 const struct MALI_TILER_JOB_PADDING * restrict values) 5550{ 5551 cl[ 0] = 0; 5552 cl[ 1] = 0; 5553 cl[ 2] = 0; 5554 cl[ 3] = 0; 5555 cl[ 4] = 0; 5556 cl[ 5] = 0; 5557 cl[ 6] = 0; 5558 cl[ 7] = 0; 5559 cl[ 8] = 0; 5560 cl[ 9] = 0; 5561 cl[10] = 0; 5562 cl[11] = 0; 5563} 5564 5565 5566#define MALI_TILER_JOB_PADDING_LENGTH 48 5567struct mali_tiler_job_padding_packed { uint32_t opaque[12]; }; 5568static inline void 5569MALI_TILER_JOB_PADDING_unpack(const uint8_t * restrict cl, 5570 struct MALI_TILER_JOB_PADDING * restrict values) 5571{ 5572 if (((const uint32_t *) cl)[0] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 0\n"); 5573 if (((const uint32_t *) cl)[1] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 1\n"); 5574 if (((const uint32_t *) cl)[2] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 2\n"); 5575 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 3\n"); 5576 if (((const uint32_t *) cl)[4] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 4\n"); 5577 if (((const uint32_t *) cl)[5] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 5\n"); 5578 if (((const uint32_t *) cl)[6] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 6\n"); 5579 if (((const uint32_t *) cl)[7] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 7\n"); 5580 if (((const uint32_t *) cl)[8] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 8\n"); 5581 if (((const uint32_t *) cl)[9] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 9\n"); 5582 if (((const uint32_t *) cl)[10] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 10\n"); 5583 if (((const uint32_t *) cl)[11] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Tiler Job Padding unpacked at word 11\n"); 5584} 5585 5586static inline void 5587MALI_TILER_JOB_PADDING_print(FILE *fp, const struct MALI_TILER_JOB_PADDING * values, unsigned indent) 5588{ 5589} 5590 5591struct mali_tiler_job_packed { 5592 uint32_t opaque[64]; 5593}; 5594 5595#define MALI_TILER_JOB_LENGTH 256 5596#define MALI_TILER_JOB_ALIGN 64 5597#define MALI_TILER_JOB_SECTION_HEADER_TYPE struct MALI_JOB_HEADER 5598#define MALI_TILER_JOB_SECTION_HEADER_header MALI_JOB_HEADER_header 5599#define MALI_TILER_JOB_SECTION_HEADER_pack MALI_JOB_HEADER_pack 5600#define MALI_TILER_JOB_SECTION_HEADER_unpack MALI_JOB_HEADER_unpack 5601#define MALI_TILER_JOB_SECTION_HEADER_print MALI_JOB_HEADER_print 5602#define MALI_TILER_JOB_SECTION_HEADER_OFFSET 0 5603#define MALI_TILER_JOB_SECTION_INVOCATION_TYPE struct MALI_INVOCATION 5604#define MALI_TILER_JOB_SECTION_INVOCATION_header MALI_INVOCATION_header 5605#define MALI_TILER_JOB_SECTION_INVOCATION_pack MALI_INVOCATION_pack 5606#define MALI_TILER_JOB_SECTION_INVOCATION_unpack MALI_INVOCATION_unpack 5607#define MALI_TILER_JOB_SECTION_INVOCATION_print MALI_INVOCATION_print 5608#define MALI_TILER_JOB_SECTION_INVOCATION_OFFSET 32 5609#define MALI_TILER_JOB_SECTION_PRIMITIVE_TYPE struct MALI_PRIMITIVE 5610#define MALI_TILER_JOB_SECTION_PRIMITIVE_header MALI_PRIMITIVE_header 5611#define MALI_TILER_JOB_SECTION_PRIMITIVE_pack MALI_PRIMITIVE_pack 5612#define MALI_TILER_JOB_SECTION_PRIMITIVE_unpack MALI_PRIMITIVE_unpack 5613#define MALI_TILER_JOB_SECTION_PRIMITIVE_print MALI_PRIMITIVE_print 5614#define MALI_TILER_JOB_SECTION_PRIMITIVE_OFFSET 40 5615#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_TYPE struct MALI_PRIMITIVE_SIZE 5616#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_header MALI_PRIMITIVE_SIZE_header 5617#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_pack MALI_PRIMITIVE_SIZE_pack 5618#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_unpack MALI_PRIMITIVE_SIZE_unpack 5619#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_print MALI_PRIMITIVE_SIZE_print 5620#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_OFFSET 64 5621#define MALI_TILER_JOB_SECTION_TILER_TYPE struct MALI_TILER_POINTER 5622#define MALI_TILER_JOB_SECTION_TILER_header MALI_TILER_POINTER_header 5623#define MALI_TILER_JOB_SECTION_TILER_pack MALI_TILER_POINTER_pack 5624#define MALI_TILER_JOB_SECTION_TILER_unpack MALI_TILER_POINTER_unpack 5625#define MALI_TILER_JOB_SECTION_TILER_print MALI_TILER_POINTER_print 5626#define MALI_TILER_JOB_SECTION_TILER_OFFSET 72 5627#define MALI_TILER_JOB_SECTION_PADDING_TYPE struct MALI_TILER_JOB_PADDING 5628#define MALI_TILER_JOB_SECTION_PADDING_header MALI_TILER_JOB_PADDING_header 5629#define MALI_TILER_JOB_SECTION_PADDING_pack MALI_TILER_JOB_PADDING_pack 5630#define MALI_TILER_JOB_SECTION_PADDING_unpack MALI_TILER_JOB_PADDING_unpack 5631#define MALI_TILER_JOB_SECTION_PADDING_print MALI_TILER_JOB_PADDING_print 5632#define MALI_TILER_JOB_SECTION_PADDING_OFFSET 80 5633#define MALI_TILER_JOB_SECTION_DRAW_TYPE struct MALI_DRAW 5634#define MALI_TILER_JOB_SECTION_DRAW_header MALI_DRAW_header 5635#define MALI_TILER_JOB_SECTION_DRAW_pack MALI_DRAW_pack 5636#define MALI_TILER_JOB_SECTION_DRAW_unpack MALI_DRAW_unpack 5637#define MALI_TILER_JOB_SECTION_DRAW_print MALI_DRAW_print 5638#define MALI_TILER_JOB_SECTION_DRAW_OFFSET 128 5639 5640struct mali_indexed_vertex_job_packed { 5641 uint32_t opaque[96]; 5642}; 5643 5644#define MALI_INDEXED_VERTEX_JOB_LENGTH 384 5645#define MALI_INDEXED_VERTEX_JOB_ALIGN 64 5646#define MALI_INDEXED_VERTEX_JOB_SECTION_HEADER_TYPE struct MALI_JOB_HEADER 5647#define MALI_INDEXED_VERTEX_JOB_SECTION_HEADER_header MALI_JOB_HEADER_header 5648#define MALI_INDEXED_VERTEX_JOB_SECTION_HEADER_pack MALI_JOB_HEADER_pack 5649#define MALI_INDEXED_VERTEX_JOB_SECTION_HEADER_unpack MALI_JOB_HEADER_unpack 5650#define MALI_INDEXED_VERTEX_JOB_SECTION_HEADER_print MALI_JOB_HEADER_print 5651#define MALI_INDEXED_VERTEX_JOB_SECTION_HEADER_OFFSET 0 5652#define MALI_INDEXED_VERTEX_JOB_SECTION_INVOCATION_TYPE struct MALI_INVOCATION 5653#define MALI_INDEXED_VERTEX_JOB_SECTION_INVOCATION_header MALI_INVOCATION_header 5654#define MALI_INDEXED_VERTEX_JOB_SECTION_INVOCATION_pack MALI_INVOCATION_pack 5655#define MALI_INDEXED_VERTEX_JOB_SECTION_INVOCATION_unpack MALI_INVOCATION_unpack 5656#define MALI_INDEXED_VERTEX_JOB_SECTION_INVOCATION_print MALI_INVOCATION_print 5657#define MALI_INDEXED_VERTEX_JOB_SECTION_INVOCATION_OFFSET 32 5658#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_TYPE struct MALI_PRIMITIVE 5659#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_header MALI_PRIMITIVE_header 5660#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_pack MALI_PRIMITIVE_pack 5661#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_unpack MALI_PRIMITIVE_unpack 5662#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_print MALI_PRIMITIVE_print 5663#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_OFFSET 40 5664#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_SIZE_TYPE struct MALI_PRIMITIVE_SIZE 5665#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_SIZE_header MALI_PRIMITIVE_SIZE_header 5666#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_SIZE_pack MALI_PRIMITIVE_SIZE_pack 5667#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_SIZE_unpack MALI_PRIMITIVE_SIZE_unpack 5668#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_SIZE_print MALI_PRIMITIVE_SIZE_print 5669#define MALI_INDEXED_VERTEX_JOB_SECTION_PRIMITIVE_SIZE_OFFSET 64 5670#define MALI_INDEXED_VERTEX_JOB_SECTION_TILER_TYPE struct MALI_TILER_POINTER 5671#define MALI_INDEXED_VERTEX_JOB_SECTION_TILER_header MALI_TILER_POINTER_header 5672#define MALI_INDEXED_VERTEX_JOB_SECTION_TILER_pack MALI_TILER_POINTER_pack 5673#define MALI_INDEXED_VERTEX_JOB_SECTION_TILER_unpack MALI_TILER_POINTER_unpack 5674#define MALI_INDEXED_VERTEX_JOB_SECTION_TILER_print MALI_TILER_POINTER_print 5675#define MALI_INDEXED_VERTEX_JOB_SECTION_TILER_OFFSET 72 5676#define MALI_INDEXED_VERTEX_JOB_SECTION_PADDING_TYPE struct MALI_TILER_JOB_PADDING 5677#define MALI_INDEXED_VERTEX_JOB_SECTION_PADDING_header MALI_TILER_JOB_PADDING_header 5678#define MALI_INDEXED_VERTEX_JOB_SECTION_PADDING_pack MALI_TILER_JOB_PADDING_pack 5679#define MALI_INDEXED_VERTEX_JOB_SECTION_PADDING_unpack MALI_TILER_JOB_PADDING_unpack 5680#define MALI_INDEXED_VERTEX_JOB_SECTION_PADDING_print MALI_TILER_JOB_PADDING_print 5681#define MALI_INDEXED_VERTEX_JOB_SECTION_PADDING_OFFSET 80 5682#define MALI_INDEXED_VERTEX_JOB_SECTION_FRAGMENT_DRAW_TYPE struct MALI_DRAW 5683#define MALI_INDEXED_VERTEX_JOB_SECTION_FRAGMENT_DRAW_header MALI_DRAW_header 5684#define MALI_INDEXED_VERTEX_JOB_SECTION_FRAGMENT_DRAW_pack MALI_DRAW_pack 5685#define MALI_INDEXED_VERTEX_JOB_SECTION_FRAGMENT_DRAW_unpack MALI_DRAW_unpack 5686#define MALI_INDEXED_VERTEX_JOB_SECTION_FRAGMENT_DRAW_print MALI_DRAW_print 5687#define MALI_INDEXED_VERTEX_JOB_SECTION_FRAGMENT_DRAW_OFFSET 128 5688#define MALI_INDEXED_VERTEX_JOB_SECTION_VERTEX_DRAW_TYPE struct MALI_DRAW 5689#define MALI_INDEXED_VERTEX_JOB_SECTION_VERTEX_DRAW_header MALI_DRAW_header 5690#define MALI_INDEXED_VERTEX_JOB_SECTION_VERTEX_DRAW_pack MALI_DRAW_pack 5691#define MALI_INDEXED_VERTEX_JOB_SECTION_VERTEX_DRAW_unpack MALI_DRAW_unpack 5692#define MALI_INDEXED_VERTEX_JOB_SECTION_VERTEX_DRAW_print MALI_DRAW_print 5693#define MALI_INDEXED_VERTEX_JOB_SECTION_VERTEX_DRAW_OFFSET 256 5694 5695#include "panfrost-job.h" 5696#endif 5697