v4_pack.h revision 96c5ddc4
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_attribute_special { 203 MALI_ATTRIBUTE_SPECIAL_VERTEX_ID = 34, 204 MALI_ATTRIBUTE_SPECIAL_INSTANCE_ID = 36, 205 MALI_ATTRIBUTE_SPECIAL_FRAG_COORD = 37, 206 MALI_ATTRIBUTE_SPECIAL_FRONT_FACING = 38, 207 MALI_ATTRIBUTE_SPECIAL_POINT_COORD = 97, 208}; 209 210static inline const char * 211mali_attribute_special_as_str(enum mali_attribute_special imm) 212{ 213 switch (imm) { 214 case MALI_ATTRIBUTE_SPECIAL_VERTEX_ID: return "Vertex ID"; 215 case MALI_ATTRIBUTE_SPECIAL_INSTANCE_ID: return "Instance ID"; 216 case MALI_ATTRIBUTE_SPECIAL_FRAG_COORD: return "Frag Coord"; 217 case MALI_ATTRIBUTE_SPECIAL_FRONT_FACING: return "Front Facing"; 218 case MALI_ATTRIBUTE_SPECIAL_POINT_COORD: return "Point Coord"; 219 default: return "XXX: INVALID"; 220 } 221} 222 223enum mali_channel { 224 MALI_CHANNEL_R = 0, 225 MALI_CHANNEL_G = 1, 226 MALI_CHANNEL_B = 2, 227 MALI_CHANNEL_A = 3, 228 MALI_CHANNEL_0 = 4, 229 MALI_CHANNEL_1 = 5, 230}; 231 232static inline const char * 233mali_channel_as_str(enum mali_channel imm) 234{ 235 switch (imm) { 236 case MALI_CHANNEL_R: return "R"; 237 case MALI_CHANNEL_G: return "G"; 238 case MALI_CHANNEL_B: return "B"; 239 case MALI_CHANNEL_A: return "A"; 240 case MALI_CHANNEL_0: return "0"; 241 case MALI_CHANNEL_1: return "1"; 242 default: return "XXX: INVALID"; 243 } 244} 245 246enum mali_depth_source { 247 MALI_DEPTH_SOURCE_MINIMUM = 0, 248 MALI_DEPTH_SOURCE_MAXIMUM = 1, 249 MALI_DEPTH_SOURCE_FIXED_FUNCTION = 2, 250 MALI_DEPTH_SOURCE_SHADER = 3, 251}; 252 253static inline const char * 254mali_depth_source_as_str(enum mali_depth_source imm) 255{ 256 switch (imm) { 257 case MALI_DEPTH_SOURCE_MINIMUM: return "Minimum"; 258 case MALI_DEPTH_SOURCE_MAXIMUM: return "Maximum"; 259 case MALI_DEPTH_SOURCE_FIXED_FUNCTION: return "Fixed function"; 260 case MALI_DEPTH_SOURCE_SHADER: return "Shader"; 261 default: return "XXX: INVALID"; 262 } 263} 264 265enum mali_job_type { 266 MALI_JOB_TYPE_NOT_STARTED = 0, 267 MALI_JOB_TYPE_NULL = 1, 268 MALI_JOB_TYPE_WRITE_VALUE = 2, 269 MALI_JOB_TYPE_CACHE_FLUSH = 3, 270 MALI_JOB_TYPE_COMPUTE = 4, 271 MALI_JOB_TYPE_VERTEX = 5, 272 MALI_JOB_TYPE_GEOMETRY = 6, 273 MALI_JOB_TYPE_TILER = 7, 274 MALI_JOB_TYPE_FUSED = 8, 275 MALI_JOB_TYPE_FRAGMENT = 9, 276}; 277 278static inline const char * 279mali_job_type_as_str(enum mali_job_type imm) 280{ 281 switch (imm) { 282 case MALI_JOB_TYPE_NOT_STARTED: return "Not started"; 283 case MALI_JOB_TYPE_NULL: return "Null"; 284 case MALI_JOB_TYPE_WRITE_VALUE: return "Write value"; 285 case MALI_JOB_TYPE_CACHE_FLUSH: return "Cache flush"; 286 case MALI_JOB_TYPE_COMPUTE: return "Compute"; 287 case MALI_JOB_TYPE_VERTEX: return "Vertex"; 288 case MALI_JOB_TYPE_GEOMETRY: return "Geometry"; 289 case MALI_JOB_TYPE_TILER: return "Tiler"; 290 case MALI_JOB_TYPE_FUSED: return "Fused"; 291 case MALI_JOB_TYPE_FRAGMENT: return "Fragment"; 292 default: return "XXX: INVALID"; 293 } 294} 295 296enum mali_draw_mode { 297 MALI_DRAW_MODE_POINTS = 1, 298 MALI_DRAW_MODE_LINES = 2, 299 MALI_DRAW_MODE_LINES_WITH_ADJACENCY = 3, 300 MALI_DRAW_MODE_LINE_STRIP = 4, 301 MALI_DRAW_MODE_LINE_STRIP_WITH_ADJACENCY = 5, 302 MALI_DRAW_MODE_LINE_LOOP = 6, 303 MALI_DRAW_MODE_TRIANGLES = 8, 304 MALI_DRAW_MODE_TRIANGLES_WITH_ADJACENCY = 9, 305 MALI_DRAW_MODE_TRIANGLE_STRIP = 10, 306 MALI_DRAW_MODE_TRIANGLE_STRIP_WITH_ADJACENCY = 11, 307 MALI_DRAW_MODE_TRIANGLE_FAN = 12, 308 MALI_DRAW_MODE_POLYGON = 13, 309 MALI_DRAW_MODE_QUADS = 14, 310 MALI_DRAW_MODE_QUAD_STRIP = 15, 311 MALI_DRAW_MODE_PARALLELOGRAM = 16, 312}; 313 314static inline const char * 315mali_draw_mode_as_str(enum mali_draw_mode imm) 316{ 317 switch (imm) { 318 case MALI_DRAW_MODE_POINTS: return "Points"; 319 case MALI_DRAW_MODE_LINES: return "Lines"; 320 case MALI_DRAW_MODE_LINES_WITH_ADJACENCY: return "Lines with adjacency"; 321 case MALI_DRAW_MODE_LINE_STRIP: return "Line strip"; 322 case MALI_DRAW_MODE_LINE_STRIP_WITH_ADJACENCY: return "Line strip with adjacency"; 323 case MALI_DRAW_MODE_LINE_LOOP: return "Line loop"; 324 case MALI_DRAW_MODE_TRIANGLES: return "Triangles"; 325 case MALI_DRAW_MODE_TRIANGLES_WITH_ADJACENCY: return "Triangles with adjacency"; 326 case MALI_DRAW_MODE_TRIANGLE_STRIP: return "Triangle strip"; 327 case MALI_DRAW_MODE_TRIANGLE_STRIP_WITH_ADJACENCY: return "Triangle strip with adjacency"; 328 case MALI_DRAW_MODE_TRIANGLE_FAN: return "Triangle fan"; 329 case MALI_DRAW_MODE_POLYGON: return "Polygon"; 330 case MALI_DRAW_MODE_QUADS: return "Quads"; 331 case MALI_DRAW_MODE_QUAD_STRIP: return "Quad strip"; 332 case MALI_DRAW_MODE_PARALLELOGRAM: return "Parallelogram"; 333 default: return "XXX: INVALID"; 334 } 335} 336 337enum mali_exception_access { 338 MALI_EXCEPTION_ACCESS_NONE = 0, 339 MALI_EXCEPTION_ACCESS_EXECUTE = 2, 340 MALI_EXCEPTION_ACCESS_READ = 1, 341 MALI_EXCEPTION_ACCESS_WRITE = 3, 342}; 343 344static inline const char * 345mali_exception_access_as_str(enum mali_exception_access imm) 346{ 347 switch (imm) { 348 case MALI_EXCEPTION_ACCESS_NONE: return "None"; 349 case MALI_EXCEPTION_ACCESS_EXECUTE: return "Execute"; 350 case MALI_EXCEPTION_ACCESS_READ: return "Read"; 351 case MALI_EXCEPTION_ACCESS_WRITE: return "Write"; 352 default: return "XXX: INVALID"; 353 } 354} 355 356enum mali_func { 357 MALI_FUNC_NEVER = 0, 358 MALI_FUNC_LESS = 1, 359 MALI_FUNC_EQUAL = 2, 360 MALI_FUNC_LEQUAL = 3, 361 MALI_FUNC_GREATER = 4, 362 MALI_FUNC_NOT_EQUAL = 5, 363 MALI_FUNC_GEQUAL = 6, 364 MALI_FUNC_ALWAYS = 7, 365}; 366 367static inline const char * 368mali_func_as_str(enum mali_func imm) 369{ 370 switch (imm) { 371 case MALI_FUNC_NEVER: return "Never"; 372 case MALI_FUNC_LESS: return "Less"; 373 case MALI_FUNC_EQUAL: return "Equal"; 374 case MALI_FUNC_LEQUAL: return "Lequal"; 375 case MALI_FUNC_GREATER: return "Greater"; 376 case MALI_FUNC_NOT_EQUAL: return "Not Equal"; 377 case MALI_FUNC_GEQUAL: return "Gequal"; 378 case MALI_FUNC_ALWAYS: return "Always"; 379 default: return "XXX: INVALID"; 380 } 381} 382 383enum mali_format { 384 MALI_ETC2_RGB8 = 1, 385 MALI_ETC2_R11_UNORM = 2, 386 MALI_ETC2_RGBA8 = 3, 387 MALI_ETC2_RG11_UNORM = 4, 388 MALI_NXR = 6, 389 MALI_BC1_UNORM = 7, 390 MALI_BC2_UNORM = 8, 391 MALI_BC3_UNORM = 9, 392 MALI_BC4_UNORM = 10, 393 MALI_BC4_SNORM = 11, 394 MALI_BC5_UNORM = 12, 395 MALI_BC5_SNORM = 13, 396 MALI_BC6H_UF16 = 14, 397 MALI_BC6H_SF16 = 15, 398 MALI_BC7_UNORM = 16, 399 MALI_ETC2_R11_SNORM = 17, 400 MALI_ETC2_RG11_SNORM = 18, 401 MALI_ETC2_RGB8A1 = 19, 402 MALI_RGB565 = 64, 403 MALI_RGB5_A1_UNORM = 65, 404 MALI_A1_BGR5_UNORM = 66, 405 MALI_RGB10_A2_UNORM = 67, 406 MALI_A2_BGR10_UNORM = 68, 407 MALI_RGB10_A2_SNORM = 69, 408 MALI_A2_BGR10_SNORM = 70, 409 MALI_RGB10_A2UI = 71, 410 MALI_A2_BGR10UI = 72, 411 MALI_RGB10_A2I = 73, 412 MALI_A2_BGR10I = 74, 413 MALI_RGB332_UNORM = 75, 414 MALI_BGR233_UNORM = 76, 415 MALI_Z24X8_UNORM = 77, 416 MALI_X8Z24 = 78, 417 MALI_X32_S8X24 = 79, 418 MALI_X24S8_X32 = 80, 419 MALI_R32_FIXED = 81, 420 MALI_RG32_FIXED = 82, 421 MALI_RGB32_FIXED = 83, 422 MALI_RGBA32_FIXED = 84, 423 MALI_TILEBUFFER_NATIVE = 85, 424 MALI_R11F_G11F_B10F = 89, 425 MALI_B10F_G11F_R11F = 90, 426 MALI_R9F_G9F_B9F_E5F = 91, 427 MALI_E5F_B9F_G9F_R9F = 92, 428 MALI_SNAP_2 = 93, 429 MALI_SNAP_4 = 94, 430 MALI_CONSTANT = 95, 431 MALI_R1_SNORM = 96, 432 MALI_R2_SNORM = 97, 433 MALI_R4_SNORM = 98, 434 MALI_R8_SNORM = 99, 435 MALI_R16_SNORM = 100, 436 MALI_R32_SNORM = 101, 437 MALI_R64_SNORM = 102, 438 MALI_RG1_SNORM = 104, 439 MALI_RG2_SNORM = 105, 440 MALI_RG4_SNORM = 106, 441 MALI_RG8_SNORM = 107, 442 MALI_RG16_SNORM = 108, 443 MALI_RG32_SNORM = 109, 444 MALI_RG64_SNORM = 110, 445 MALI_RGB1_SNORM = 112, 446 MALI_RGB2_SNORM = 113, 447 MALI_RGB4_SNORM = 114, 448 MALI_RGB8_SNORM = 115, 449 MALI_RGB16_SNORM = 116, 450 MALI_RGB32_SNORM = 117, 451 MALI_RGB64_SNORM = 118, 452 MALI_RGBA1_SNORM = 120, 453 MALI_RGBA2_SNORM = 121, 454 MALI_RGBA4_SNORM = 122, 455 MALI_RGBA8_SNORM = 123, 456 MALI_RGBA16_SNORM = 124, 457 MALI_RGBA32_SNORM = 125, 458 MALI_RGBA64_SNORM = 126, 459 MALI_R1UI = 128, 460 MALI_R2UI = 129, 461 MALI_R4UI = 130, 462 MALI_R8UI = 131, 463 MALI_R16UI = 132, 464 MALI_R32UI = 133, 465 MALI_R64UI = 134, 466 MALI_R64F = 135, 467 MALI_RG1UI = 136, 468 MALI_RG2UI = 137, 469 MALI_RG4UI = 138, 470 MALI_RG8UI = 139, 471 MALI_RG16UI = 140, 472 MALI_RG32UI = 141, 473 MALI_RG64UI = 142, 474 MALI_RG64F = 143, 475 MALI_RGB1UI = 144, 476 MALI_RGB2UI = 145, 477 MALI_RGB4UI = 146, 478 MALI_RGB8UI = 147, 479 MALI_RGB16UI = 148, 480 MALI_RGB32UI = 149, 481 MALI_RGB64UI = 150, 482 MALI_RGB64F = 151, 483 MALI_RGBA1UI = 152, 484 MALI_RGBA2UI = 153, 485 MALI_RGBA4UI = 154, 486 MALI_RGBA8UI = 155, 487 MALI_RGBA16UI = 156, 488 MALI_RGBA32UI = 157, 489 MALI_RGBA64UI = 158, 490 MALI_RGBA64F = 159, 491 MALI_R1_UNORM = 160, 492 MALI_R2_UNORM = 161, 493 MALI_R4_UNORM = 162, 494 MALI_R8_UNORM = 163, 495 MALI_R16_UNORM = 164, 496 MALI_R32_UNORM = 165, 497 MALI_R64_UNORM = 166, 498 MALI_R32F = 167, 499 MALI_RG1_UNORM = 168, 500 MALI_RG2_UNORM = 169, 501 MALI_RG4_UNORM = 170, 502 MALI_RG8_UNORM = 171, 503 MALI_RG16_UNORM = 172, 504 MALI_RG32_UNORM = 173, 505 MALI_RG64_UNORM = 174, 506 MALI_RG32F = 175, 507 MALI_RGB1_UNORM = 176, 508 MALI_RGB2_UNORM = 177, 509 MALI_RGB4_UNORM = 178, 510 MALI_RGB8_UNORM = 179, 511 MALI_RGB16_UNORM = 180, 512 MALI_RGB32_UNORM = 181, 513 MALI_RGB64_UNORM = 182, 514 MALI_RGB32F = 183, 515 MALI_RGBA1_UNORM = 184, 516 MALI_RGBA2_UNORM = 185, 517 MALI_RGBA4_UNORM = 186, 518 MALI_RGBA8_UNORM = 187, 519 MALI_RGBA16_UNORM = 188, 520 MALI_RGBA32_UNORM = 189, 521 MALI_RGBA64_UNORM = 190, 522 MALI_RGBA32F = 191, 523 MALI_R1I = 192, 524 MALI_R2I = 193, 525 MALI_R4I = 194, 526 MALI_R8I = 195, 527 MALI_R16I = 196, 528 MALI_R32I = 197, 529 MALI_R64I = 198, 530 MALI_R16F = 199, 531 MALI_RG1I = 200, 532 MALI_RG2I = 201, 533 MALI_RG4I = 202, 534 MALI_RG8I = 203, 535 MALI_RG16I = 204, 536 MALI_RG32I = 205, 537 MALI_RG64I = 206, 538 MALI_RG16F = 207, 539 MALI_RGB1I = 208, 540 MALI_RGB2I = 209, 541 MALI_RGB4I = 210, 542 MALI_RGB8I = 211, 543 MALI_RGB16I = 212, 544 MALI_RGB32I = 213, 545 MALI_RGB64I = 214, 546 MALI_RGB16F = 215, 547 MALI_RGBA1I = 216, 548 MALI_RGBA2I = 217, 549 MALI_RGBA4I = 218, 550 MALI_RGBA8I = 219, 551 MALI_RGBA16I = 220, 552 MALI_RGBA32I = 221, 553 MALI_RGBA64I = 222, 554 MALI_RGBA16F = 223, 555}; 556 557static inline const char * 558mali_format_as_str(enum mali_format imm) 559{ 560 switch (imm) { 561 case MALI_ETC2_RGB8: return "ETC2 RGB8"; 562 case MALI_ETC2_R11_UNORM: return "ETC2 R11 UNORM"; 563 case MALI_ETC2_RGBA8: return "ETC2 RGBA8"; 564 case MALI_ETC2_RG11_UNORM: return "ETC2 RG11 UNORM"; 565 case MALI_NXR: return "NXR"; 566 case MALI_BC1_UNORM: return "BC1 UNORM"; 567 case MALI_BC2_UNORM: return "BC2 UNORM"; 568 case MALI_BC3_UNORM: return "BC3 UNORM"; 569 case MALI_BC4_UNORM: return "BC4 UNORM"; 570 case MALI_BC4_SNORM: return "BC4 SNORM"; 571 case MALI_BC5_UNORM: return "BC5 UNORM"; 572 case MALI_BC5_SNORM: return "BC5 SNORM"; 573 case MALI_BC6H_UF16: return "BC6H UF16"; 574 case MALI_BC6H_SF16: return "BC6H SF16"; 575 case MALI_BC7_UNORM: return "BC7 UNORM"; 576 case MALI_ETC2_R11_SNORM: return "ETC2 R11 SNORM"; 577 case MALI_ETC2_RG11_SNORM: return "ETC2 RG11 SNORM"; 578 case MALI_ETC2_RGB8A1: return "ETC2 RGB8A1"; 579 case MALI_RGB565: return "RGB565"; 580 case MALI_RGB5_A1_UNORM: return "RGB5 A1 UNORM"; 581 case MALI_A1_BGR5_UNORM: return "A1 BGR5 UNORM"; 582 case MALI_RGB10_A2_UNORM: return "RGB10 A2 UNORM"; 583 case MALI_A2_BGR10_UNORM: return "A2 BGR10 UNORM"; 584 case MALI_RGB10_A2_SNORM: return "RGB10 A2 SNORM"; 585 case MALI_A2_BGR10_SNORM: return "A2 BGR10 SNORM"; 586 case MALI_RGB10_A2UI: return "RGB10 A2UI"; 587 case MALI_A2_BGR10UI: return "A2 BGR10UI"; 588 case MALI_RGB10_A2I: return "RGB10 A2I"; 589 case MALI_A2_BGR10I: return "A2 BGR10I"; 590 case MALI_RGB332_UNORM: return "RGB332 UNORM"; 591 case MALI_BGR233_UNORM: return "BGR233 UNORM"; 592 case MALI_Z24X8_UNORM: return "Z24X8 UNORM"; 593 case MALI_X8Z24: return "X8Z24"; 594 case MALI_X32_S8X24: return "X32 S8X24"; 595 case MALI_X24S8_X32: return "X24S8 X32"; 596 case MALI_R32_FIXED: return "R32 FIXED"; 597 case MALI_RG32_FIXED: return "RG32 FIXED"; 598 case MALI_RGB32_FIXED: return "RGB32 FIXED"; 599 case MALI_RGBA32_FIXED: return "RGBA32 FIXED"; 600 case MALI_TILEBUFFER_NATIVE: return "Tilebuffer Native"; 601 case MALI_R11F_G11F_B10F: return "R11F G11F B10F"; 602 case MALI_B10F_G11F_R11F: return "B10F G11F R11F"; 603 case MALI_R9F_G9F_B9F_E5F: return "R9F G9F B9F E5F"; 604 case MALI_E5F_B9F_G9F_R9F: return "E5F B9F G9F R9F"; 605 case MALI_SNAP_2: return "Snap 2"; 606 case MALI_SNAP_4: return "Snap 4"; 607 case MALI_CONSTANT: return "Constant"; 608 case MALI_R1_SNORM: return "R1 SNORM"; 609 case MALI_R2_SNORM: return "R2 SNORM"; 610 case MALI_R4_SNORM: return "R4 SNORM"; 611 case MALI_R8_SNORM: return "R8 SNORM"; 612 case MALI_R16_SNORM: return "R16 SNORM"; 613 case MALI_R32_SNORM: return "R32 SNORM"; 614 case MALI_R64_SNORM: return "R64 SNORM"; 615 case MALI_RG1_SNORM: return "RG1 SNORM"; 616 case MALI_RG2_SNORM: return "RG2 SNORM"; 617 case MALI_RG4_SNORM: return "RG4 SNORM"; 618 case MALI_RG8_SNORM: return "RG8 SNORM"; 619 case MALI_RG16_SNORM: return "RG16 SNORM"; 620 case MALI_RG32_SNORM: return "RG32 SNORM"; 621 case MALI_RG64_SNORM: return "RG64 SNORM"; 622 case MALI_RGB1_SNORM: return "RGB1 SNORM"; 623 case MALI_RGB2_SNORM: return "RGB2 SNORM"; 624 case MALI_RGB4_SNORM: return "RGB4 SNORM"; 625 case MALI_RGB8_SNORM: return "RGB8 SNORM"; 626 case MALI_RGB16_SNORM: return "RGB16 SNORM"; 627 case MALI_RGB32_SNORM: return "RGB32 SNORM"; 628 case MALI_RGB64_SNORM: return "RGB64 SNORM"; 629 case MALI_RGBA1_SNORM: return "RGBA1 SNORM"; 630 case MALI_RGBA2_SNORM: return "RGBA2 SNORM"; 631 case MALI_RGBA4_SNORM: return "RGBA4 SNORM"; 632 case MALI_RGBA8_SNORM: return "RGBA8 SNORM"; 633 case MALI_RGBA16_SNORM: return "RGBA16 SNORM"; 634 case MALI_RGBA32_SNORM: return "RGBA32 SNORM"; 635 case MALI_RGBA64_SNORM: return "RGBA64 SNORM"; 636 case MALI_R1UI: return "R1UI"; 637 case MALI_R2UI: return "R2UI"; 638 case MALI_R4UI: return "R4UI"; 639 case MALI_R8UI: return "R8UI"; 640 case MALI_R16UI: return "R16UI"; 641 case MALI_R32UI: return "R32UI"; 642 case MALI_R64UI: return "R64UI"; 643 case MALI_R64F: return "R64F"; 644 case MALI_RG1UI: return "RG1UI"; 645 case MALI_RG2UI: return "RG2UI"; 646 case MALI_RG4UI: return "RG4UI"; 647 case MALI_RG8UI: return "RG8UI"; 648 case MALI_RG16UI: return "RG16UI"; 649 case MALI_RG32UI: return "RG32UI"; 650 case MALI_RG64UI: return "RG64UI"; 651 case MALI_RG64F: return "RG64F"; 652 case MALI_RGB1UI: return "RGB1UI"; 653 case MALI_RGB2UI: return "RGB2UI"; 654 case MALI_RGB4UI: return "RGB4UI"; 655 case MALI_RGB8UI: return "RGB8UI"; 656 case MALI_RGB16UI: return "RGB16UI"; 657 case MALI_RGB32UI: return "RGB32UI"; 658 case MALI_RGB64UI: return "RGB64UI"; 659 case MALI_RGB64F: return "RGB64F"; 660 case MALI_RGBA1UI: return "RGBA1UI"; 661 case MALI_RGBA2UI: return "RGBA2UI"; 662 case MALI_RGBA4UI: return "RGBA4UI"; 663 case MALI_RGBA8UI: return "RGBA8UI"; 664 case MALI_RGBA16UI: return "RGBA16UI"; 665 case MALI_RGBA32UI: return "RGBA32UI"; 666 case MALI_RGBA64UI: return "RGBA64UI"; 667 case MALI_RGBA64F: return "RGBA64F"; 668 case MALI_R1_UNORM: return "R1 UNORM"; 669 case MALI_R2_UNORM: return "R2 UNORM"; 670 case MALI_R4_UNORM: return "R4 UNORM"; 671 case MALI_R8_UNORM: return "R8 UNORM"; 672 case MALI_R16_UNORM: return "R16 UNORM"; 673 case MALI_R32_UNORM: return "R32 UNORM"; 674 case MALI_R64_UNORM: return "R64 UNORM"; 675 case MALI_R32F: return "R32F"; 676 case MALI_RG1_UNORM: return "RG1 UNORM"; 677 case MALI_RG2_UNORM: return "RG2 UNORM"; 678 case MALI_RG4_UNORM: return "RG4 UNORM"; 679 case MALI_RG8_UNORM: return "RG8 UNORM"; 680 case MALI_RG16_UNORM: return "RG16 UNORM"; 681 case MALI_RG32_UNORM: return "RG32 UNORM"; 682 case MALI_RG64_UNORM: return "RG64 UNORM"; 683 case MALI_RG32F: return "RG32F"; 684 case MALI_RGB1_UNORM: return "RGB1 UNORM"; 685 case MALI_RGB2_UNORM: return "RGB2 UNORM"; 686 case MALI_RGB4_UNORM: return "RGB4 UNORM"; 687 case MALI_RGB8_UNORM: return "RGB8 UNORM"; 688 case MALI_RGB16_UNORM: return "RGB16 UNORM"; 689 case MALI_RGB32_UNORM: return "RGB32 UNORM"; 690 case MALI_RGB64_UNORM: return "RGB64 UNORM"; 691 case MALI_RGB32F: return "RGB32F"; 692 case MALI_RGBA1_UNORM: return "RGBA1 UNORM"; 693 case MALI_RGBA2_UNORM: return "RGBA2 UNORM"; 694 case MALI_RGBA4_UNORM: return "RGBA4 UNORM"; 695 case MALI_RGBA8_UNORM: return "RGBA8 UNORM"; 696 case MALI_RGBA16_UNORM: return "RGBA16 UNORM"; 697 case MALI_RGBA32_UNORM: return "RGBA32 UNORM"; 698 case MALI_RGBA64_UNORM: return "RGBA64 UNORM"; 699 case MALI_RGBA32F: return "RGBA32F"; 700 case MALI_R1I: return "R1I"; 701 case MALI_R2I: return "R2I"; 702 case MALI_R4I: return "R4I"; 703 case MALI_R8I: return "R8I"; 704 case MALI_R16I: return "R16I"; 705 case MALI_R32I: return "R32I"; 706 case MALI_R64I: return "R64I"; 707 case MALI_R16F: return "R16F"; 708 case MALI_RG1I: return "RG1I"; 709 case MALI_RG2I: return "RG2I"; 710 case MALI_RG4I: return "RG4I"; 711 case MALI_RG8I: return "RG8I"; 712 case MALI_RG16I: return "RG16I"; 713 case MALI_RG32I: return "RG32I"; 714 case MALI_RG64I: return "RG64I"; 715 case MALI_RG16F: return "RG16F"; 716 case MALI_RGB1I: return "RGB1I"; 717 case MALI_RGB2I: return "RGB2I"; 718 case MALI_RGB4I: return "RGB4I"; 719 case MALI_RGB8I: return "RGB8I"; 720 case MALI_RGB16I: return "RGB16I"; 721 case MALI_RGB32I: return "RGB32I"; 722 case MALI_RGB64I: return "RGB64I"; 723 case MALI_RGB16F: return "RGB16F"; 724 case MALI_RGBA1I: return "RGBA1I"; 725 case MALI_RGBA2I: return "RGBA2I"; 726 case MALI_RGBA4I: return "RGBA4I"; 727 case MALI_RGBA8I: return "RGBA8I"; 728 case MALI_RGBA16I: return "RGBA16I"; 729 case MALI_RGBA32I: return "RGBA32I"; 730 case MALI_RGBA64I: return "RGBA64I"; 731 case MALI_RGBA16F: return "RGBA16F"; 732 default: return "XXX: INVALID"; 733 } 734} 735 736enum mali_yuv_swizzle { 737 MALI_YUV_SWIZZLE_YUVA = 0, 738 MALI_YUV_SWIZZLE_YVUA = 1, 739 MALI_YUV_SWIZZLE_UYVA = 2, 740 MALI_YUV_SWIZZLE_UVYA = 3, 741 MALI_YUV_SWIZZLE_VUYA = 4, 742 MALI_YUV_SWIZZLE_VYUA = 5, 743 MALI_YUV_SWIZZLE_Y00A = 6, 744 MALI_YUV_SWIZZLE_YXXA = 7, 745}; 746 747static inline const char * 748mali_yuv_swizzle_as_str(enum mali_yuv_swizzle imm) 749{ 750 switch (imm) { 751 case MALI_YUV_SWIZZLE_YUVA: return "YUVA"; 752 case MALI_YUV_SWIZZLE_YVUA: return "YVUA"; 753 case MALI_YUV_SWIZZLE_UYVA: return "UYVA"; 754 case MALI_YUV_SWIZZLE_UVYA: return "UVYA"; 755 case MALI_YUV_SWIZZLE_VUYA: return "VUYA"; 756 case MALI_YUV_SWIZZLE_VYUA: return "VYUA"; 757 case MALI_YUV_SWIZZLE_Y00A: return "Y00A"; 758 case MALI_YUV_SWIZZLE_YXXA: return "YXXA"; 759 default: return "XXX: INVALID"; 760 } 761} 762 763enum mali_yuv_conversion_mode { 764 MALI_YUV_CONVERSION_MODE_NO_CONVERSION = 0, 765 MALI_YUV_CONVERSION_MODE_BT_601 = 3, 766 MALI_YUV_CONVERSION_MODE_BT_709 = 4, 767 MALI_YUV_CONVERSION_MODE_BT_2020 = 6, 768}; 769 770static inline const char * 771mali_yuv_conversion_mode_as_str(enum mali_yuv_conversion_mode imm) 772{ 773 switch (imm) { 774 case MALI_YUV_CONVERSION_MODE_NO_CONVERSION: return "No Conversion"; 775 case MALI_YUV_CONVERSION_MODE_BT_601: return "BT 601"; 776 case MALI_YUV_CONVERSION_MODE_BT_709: return "BT 709"; 777 case MALI_YUV_CONVERSION_MODE_BT_2020: return "BT 2020"; 778 default: return "XXX: INVALID"; 779 } 780} 781 782enum mali_yuv_cr_siting { 783 MALI_YUV_CR_SITING_CO_SITED = 0, 784 MALI_YUV_CR_SITING_CENTER_Y = 1, 785 MALI_YUV_CR_SITING_CENTER_X = 2, 786 MALI_YUV_CR_SITING_CENTER = 3, 787 MALI_YUV_CR_SITING_ONE_QUARTER = 4, 788 MALI_YUV_CR_SITING_THREE_QUARTERS = 5, 789 MALI_YUV_CR_SITING_REPLICATED = 7, 790}; 791 792static inline const char * 793mali_yuv_cr_siting_as_str(enum mali_yuv_cr_siting imm) 794{ 795 switch (imm) { 796 case MALI_YUV_CR_SITING_CO_SITED: return "Co-Sited"; 797 case MALI_YUV_CR_SITING_CENTER_Y: return "Center Y"; 798 case MALI_YUV_CR_SITING_CENTER_X: return "Center X"; 799 case MALI_YUV_CR_SITING_CENTER: return "Center"; 800 case MALI_YUV_CR_SITING_ONE_QUARTER: return "One Quarter"; 801 case MALI_YUV_CR_SITING_THREE_QUARTERS: return "Three Quarters"; 802 case MALI_YUV_CR_SITING_REPLICATED: return "Replicated"; 803 default: return "XXX: INVALID"; 804 } 805} 806 807enum mali_block_format { 808 MALI_BLOCK_FORMAT_TILED_U_INTERLEAVED = 0, 809 MALI_BLOCK_FORMAT_TILED_LINEAR = 1, 810 MALI_BLOCK_FORMAT_LINEAR = 2, 811}; 812 813static inline const char * 814mali_block_format_as_str(enum mali_block_format imm) 815{ 816 switch (imm) { 817 case MALI_BLOCK_FORMAT_TILED_U_INTERLEAVED: return "Tiled U-Interleaved"; 818 case MALI_BLOCK_FORMAT_TILED_LINEAR: return "Tiled Linear"; 819 case MALI_BLOCK_FORMAT_LINEAR: return "Linear"; 820 default: return "XXX: INVALID"; 821 } 822} 823 824enum mali_mipmap_mode { 825 MALI_MIPMAP_MODE_NEAREST = 0, 826 MALI_MIPMAP_MODE_PERFORMANCE_TRILINEAR = 2, 827 MALI_MIPMAP_MODE_TRILINEAR = 3, 828}; 829 830static inline const char * 831mali_mipmap_mode_as_str(enum mali_mipmap_mode imm) 832{ 833 switch (imm) { 834 case MALI_MIPMAP_MODE_NEAREST: return "Nearest"; 835 case MALI_MIPMAP_MODE_PERFORMANCE_TRILINEAR: return "Performance Trilinear"; 836 case MALI_MIPMAP_MODE_TRILINEAR: return "Trilinear"; 837 default: return "XXX: INVALID"; 838 } 839} 840 841enum mali_msaa { 842 MALI_MSAA_SINGLE = 0, 843 MALI_MSAA_AVERAGE = 1, 844 MALI_MSAA_MULTIPLE = 2, 845 MALI_MSAA_LAYERED = 3, 846}; 847 848static inline const char * 849mali_msaa_as_str(enum mali_msaa imm) 850{ 851 switch (imm) { 852 case MALI_MSAA_SINGLE: return "Single"; 853 case MALI_MSAA_AVERAGE: return "Average"; 854 case MALI_MSAA_MULTIPLE: return "Multiple"; 855 case MALI_MSAA_LAYERED: return "Layered"; 856 default: return "XXX: INVALID"; 857 } 858} 859 860enum mali_index_type { 861 MALI_INDEX_TYPE_NONE = 0, 862 MALI_INDEX_TYPE_UINT8 = 1, 863 MALI_INDEX_TYPE_UINT16 = 2, 864 MALI_INDEX_TYPE_UINT32 = 3, 865}; 866 867static inline const char * 868mali_index_type_as_str(enum mali_index_type imm) 869{ 870 switch (imm) { 871 case MALI_INDEX_TYPE_NONE: return "None"; 872 case MALI_INDEX_TYPE_UINT8: return "UINT8"; 873 case MALI_INDEX_TYPE_UINT16: return "UINT16"; 874 case MALI_INDEX_TYPE_UINT32: return "UINT32"; 875 default: return "XXX: INVALID"; 876 } 877} 878 879enum mali_occlusion_mode { 880 MALI_OCCLUSION_MODE_DISABLED = 0, 881 MALI_OCCLUSION_MODE_PREDICATE = 1, 882 MALI_OCCLUSION_MODE_COUNTER = 3, 883}; 884 885static inline const char * 886mali_occlusion_mode_as_str(enum mali_occlusion_mode imm) 887{ 888 switch (imm) { 889 case MALI_OCCLUSION_MODE_DISABLED: return "Disabled"; 890 case MALI_OCCLUSION_MODE_PREDICATE: return "Predicate"; 891 case MALI_OCCLUSION_MODE_COUNTER: return "Counter"; 892 default: return "XXX: INVALID"; 893 } 894} 895 896enum mali_stencil_op { 897 MALI_STENCIL_OP_KEEP = 0, 898 MALI_STENCIL_OP_REPLACE = 1, 899 MALI_STENCIL_OP_ZERO = 2, 900 MALI_STENCIL_OP_INVERT = 3, 901 MALI_STENCIL_OP_INCR_WRAP = 4, 902 MALI_STENCIL_OP_DECR_WRAP = 5, 903 MALI_STENCIL_OP_INCR_SAT = 6, 904 MALI_STENCIL_OP_DECR_SAT = 7, 905}; 906 907static inline const char * 908mali_stencil_op_as_str(enum mali_stencil_op imm) 909{ 910 switch (imm) { 911 case MALI_STENCIL_OP_KEEP: return "Keep"; 912 case MALI_STENCIL_OP_REPLACE: return "Replace"; 913 case MALI_STENCIL_OP_ZERO: return "Zero"; 914 case MALI_STENCIL_OP_INVERT: return "Invert"; 915 case MALI_STENCIL_OP_INCR_WRAP: return "Incr Wrap"; 916 case MALI_STENCIL_OP_DECR_WRAP: return "Decr Wrap"; 917 case MALI_STENCIL_OP_INCR_SAT: return "Incr Sat"; 918 case MALI_STENCIL_OP_DECR_SAT: return "Decr Sat"; 919 default: return "XXX: INVALID"; 920 } 921} 922 923enum mali_texture_dimension { 924 MALI_TEXTURE_DIMENSION_CUBE = 0, 925 MALI_TEXTURE_DIMENSION_1D = 1, 926 MALI_TEXTURE_DIMENSION_2D = 2, 927 MALI_TEXTURE_DIMENSION_3D = 3, 928}; 929 930static inline const char * 931mali_texture_dimension_as_str(enum mali_texture_dimension imm) 932{ 933 switch (imm) { 934 case MALI_TEXTURE_DIMENSION_CUBE: return "Cube"; 935 case MALI_TEXTURE_DIMENSION_1D: return "1D"; 936 case MALI_TEXTURE_DIMENSION_2D: return "2D"; 937 case MALI_TEXTURE_DIMENSION_3D: return "3D"; 938 default: return "XXX: INVALID"; 939 } 940} 941 942enum mali_texture_layout { 943 MALI_TEXTURE_LAYOUT_TILED = 1, 944 MALI_TEXTURE_LAYOUT_LINEAR = 2, 945 MALI_TEXTURE_LAYOUT_AFBC = 12, 946}; 947 948static inline const char * 949mali_texture_layout_as_str(enum mali_texture_layout imm) 950{ 951 switch (imm) { 952 case MALI_TEXTURE_LAYOUT_TILED: return "Tiled"; 953 case MALI_TEXTURE_LAYOUT_LINEAR: return "Linear"; 954 case MALI_TEXTURE_LAYOUT_AFBC: return "AFBC"; 955 default: return "XXX: INVALID"; 956 } 957} 958 959enum mali_afbc_surface_flag { 960 MALI_AFBC_SURFACE_FLAG_YTR = 1, 961}; 962 963static inline const char * 964mali_afbc_surface_flag_as_str(enum mali_afbc_surface_flag imm) 965{ 966 switch (imm) { 967 case MALI_AFBC_SURFACE_FLAG_YTR: return "YTR"; 968 default: return "XXX: INVALID"; 969 } 970} 971 972enum mali_wrap_mode { 973 MALI_WRAP_MODE_REPEAT = 8, 974 MALI_WRAP_MODE_CLAMP_TO_EDGE = 9, 975 MALI_WRAP_MODE_CLAMP = 10, 976 MALI_WRAP_MODE_CLAMP_TO_BORDER = 11, 977 MALI_WRAP_MODE_MIRRORED_REPEAT = 12, 978 MALI_WRAP_MODE_MIRRORED_CLAMP_TO_EDGE = 13, 979 MALI_WRAP_MODE_MIRRORED_CLAMP = 14, 980 MALI_WRAP_MODE_MIRRORED_CLAMP_TO_BORDER = 15, 981}; 982 983static inline const char * 984mali_wrap_mode_as_str(enum mali_wrap_mode imm) 985{ 986 switch (imm) { 987 case MALI_WRAP_MODE_REPEAT: return "Repeat"; 988 case MALI_WRAP_MODE_CLAMP_TO_EDGE: return "Clamp to Edge"; 989 case MALI_WRAP_MODE_CLAMP: return "Clamp"; 990 case MALI_WRAP_MODE_CLAMP_TO_BORDER: return "Clamp to Border"; 991 case MALI_WRAP_MODE_MIRRORED_REPEAT: return "Mirrored Repeat"; 992 case MALI_WRAP_MODE_MIRRORED_CLAMP_TO_EDGE: return "Mirrored Clamp to Edge"; 993 case MALI_WRAP_MODE_MIRRORED_CLAMP: return "Mirrored Clamp"; 994 case MALI_WRAP_MODE_MIRRORED_CLAMP_TO_BORDER: return "Mirrored Clamp to Border"; 995 default: return "XXX: INVALID"; 996 } 997} 998 999struct MALI_ATTRIBUTE { 1000 uint32_t buffer_index; 1001 bool offset_enable; 1002 uint32_t format; 1003 int32_t offset; 1004}; 1005 1006#define MALI_ATTRIBUTE_header \ 1007 .offset_enable = true 1008 1009static inline void 1010MALI_ATTRIBUTE_pack(uint32_t * restrict cl, 1011 const struct MALI_ATTRIBUTE * restrict values) 1012{ 1013 cl[ 0] = __gen_uint(values->buffer_index, 0, 8) | 1014 __gen_uint(values->offset_enable, 9, 9) | 1015 __gen_uint(values->format, 10, 31); 1016 cl[ 1] = __gen_sint(values->offset, 0, 31); 1017} 1018 1019 1020#define MALI_ATTRIBUTE_LENGTH 8 1021#define MALI_ATTRIBUTE_ALIGN 8 1022struct mali_attribute_packed { uint32_t opaque[2]; }; 1023static inline void 1024MALI_ATTRIBUTE_unpack(const uint8_t * restrict cl, 1025 struct MALI_ATTRIBUTE * restrict values) 1026{ 1027 values->buffer_index = __gen_unpack_uint(cl, 0, 8); 1028 values->offset_enable = __gen_unpack_uint(cl, 9, 9); 1029 values->format = __gen_unpack_uint(cl, 10, 31); 1030 values->offset = __gen_unpack_sint(cl, 32, 63); 1031} 1032 1033static inline void 1034MALI_ATTRIBUTE_print(FILE *fp, const struct MALI_ATTRIBUTE * values, unsigned indent) 1035{ 1036 fprintf(fp, "%*sBuffer index: %u\n", indent, "", values->buffer_index); 1037 fprintf(fp, "%*sOffset enable: %s\n", indent, "", values->offset_enable ? "true" : "false"); 1038 mali_pixel_format_print(fp, values->format); 1039 fprintf(fp, "%*sOffset: %d\n", indent, "", values->offset); 1040} 1041 1042struct MALI_ATTRIBUTE_VERTEX_ID { 1043 enum mali_attribute_special type; 1044 uint32_t divisor_r; 1045 uint32_t divisor_p; 1046 int32_t offset; 1047}; 1048 1049#define MALI_ATTRIBUTE_VERTEX_ID_header \ 1050 .type = MALI_ATTRIBUTE_SPECIAL_VERTEX_ID 1051 1052static inline void 1053MALI_ATTRIBUTE_VERTEX_ID_pack(uint32_t * restrict cl, 1054 const struct MALI_ATTRIBUTE_VERTEX_ID * restrict values) 1055{ 1056 cl[ 0] = __gen_uint(values->type, 0, 7); 1057 cl[ 1] = __gen_uint(values->divisor_r, 24, 28) | 1058 __gen_uint(values->divisor_p, 29, 31); 1059 cl[ 2] = 0; 1060 cl[ 3] = __gen_sint(values->offset, 0, 31); 1061} 1062 1063 1064#define MALI_ATTRIBUTE_VERTEX_ID_LENGTH 16 1065#define MALI_ATTRIBUTE_VERTEX_ID_ALIGN 32 1066struct mali_attribute_vertex_id_packed { uint32_t opaque[4]; }; 1067static inline void 1068MALI_ATTRIBUTE_VERTEX_ID_unpack(const uint8_t * restrict cl, 1069 struct MALI_ATTRIBUTE_VERTEX_ID * restrict values) 1070{ 1071 if (((const uint32_t *) cl)[0] & 0xffffff00) fprintf(stderr, "XXX: Invalid field of Attribute Vertex ID unpacked at word 0\n"); 1072 if (((const uint32_t *) cl)[1] & 0xffffff) fprintf(stderr, "XXX: Invalid field of Attribute Vertex ID unpacked at word 1\n"); 1073 if (((const uint32_t *) cl)[2] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Attribute Vertex ID unpacked at word 2\n"); 1074 values->type = (enum mali_attribute_special)__gen_unpack_uint(cl, 0, 7); 1075 values->divisor_r = __gen_unpack_uint(cl, 56, 60); 1076 values->divisor_p = __gen_unpack_uint(cl, 61, 63); 1077 values->offset = __gen_unpack_sint(cl, 96, 127); 1078} 1079 1080static inline void 1081MALI_ATTRIBUTE_VERTEX_ID_print(FILE *fp, const struct MALI_ATTRIBUTE_VERTEX_ID * values, unsigned indent) 1082{ 1083 fprintf(fp, "%*sType: %s\n", indent, "", mali_attribute_special_as_str(values->type)); 1084 fprintf(fp, "%*sDivisor R: %u\n", indent, "", values->divisor_r); 1085 fprintf(fp, "%*sDivisor P: %u\n", indent, "", values->divisor_p); 1086 fprintf(fp, "%*sOffset: %d\n", indent, "", values->offset); 1087} 1088 1089struct MALI_ATTRIBUTE_INSTANCE_ID { 1090 enum mali_attribute_special type; 1091 uint32_t divisor_r; 1092 uint32_t divisor_e; 1093 uint32_t divisor_p; 1094 int32_t offset; 1095}; 1096 1097#define MALI_ATTRIBUTE_INSTANCE_ID_header \ 1098 .type = MALI_ATTRIBUTE_SPECIAL_INSTANCE_ID 1099 1100static inline void 1101MALI_ATTRIBUTE_INSTANCE_ID_pack(uint32_t * restrict cl, 1102 const struct MALI_ATTRIBUTE_INSTANCE_ID * restrict values) 1103{ 1104 cl[ 0] = __gen_uint(values->type, 0, 7); 1105 cl[ 1] = __gen_uint(values->divisor_r, 24, 28) | 1106 __gen_uint(values->divisor_e, 29, 29); 1107 cl[ 2] = __gen_uint(values->divisor_p, 0, 31); 1108 cl[ 3] = __gen_sint(values->offset, 0, 31); 1109} 1110 1111 1112#define MALI_ATTRIBUTE_INSTANCE_ID_LENGTH 16 1113#define MALI_ATTRIBUTE_INSTANCE_ID_ALIGN 32 1114struct mali_attribute_instance_id_packed { uint32_t opaque[4]; }; 1115static inline void 1116MALI_ATTRIBUTE_INSTANCE_ID_unpack(const uint8_t * restrict cl, 1117 struct MALI_ATTRIBUTE_INSTANCE_ID * restrict values) 1118{ 1119 if (((const uint32_t *) cl)[0] & 0xffffff00) fprintf(stderr, "XXX: Invalid field of Attribute Instance ID unpacked at word 0\n"); 1120 if (((const uint32_t *) cl)[1] & 0xc0ffffff) fprintf(stderr, "XXX: Invalid field of Attribute Instance ID unpacked at word 1\n"); 1121 values->type = (enum mali_attribute_special)__gen_unpack_uint(cl, 0, 7); 1122 values->divisor_r = __gen_unpack_uint(cl, 56, 60); 1123 values->divisor_e = __gen_unpack_uint(cl, 61, 61); 1124 values->divisor_p = __gen_unpack_uint(cl, 64, 95); 1125 values->offset = __gen_unpack_sint(cl, 96, 127); 1126} 1127 1128static inline void 1129MALI_ATTRIBUTE_INSTANCE_ID_print(FILE *fp, const struct MALI_ATTRIBUTE_INSTANCE_ID * values, unsigned indent) 1130{ 1131 fprintf(fp, "%*sType: %s\n", indent, "", mali_attribute_special_as_str(values->type)); 1132 fprintf(fp, "%*sDivisor R: %u\n", indent, "", values->divisor_r); 1133 fprintf(fp, "%*sDivisor E: %u\n", indent, "", values->divisor_e); 1134 fprintf(fp, "%*sDivisor P: %u\n", indent, "", values->divisor_p); 1135 fprintf(fp, "%*sOffset: %d\n", indent, "", values->offset); 1136} 1137 1138struct MALI_ATTRIBUTE_BUFFER { 1139 enum mali_attribute_special special; 1140 enum mali_attribute_type type; 1141 uint64_t pointer; 1142 uint32_t stride; 1143 uint32_t size; 1144 uint32_t divisor; 1145 uint32_t divisor_r; 1146 uint32_t divisor_p; 1147 uint32_t divisor_e; 1148}; 1149 1150#define MALI_ATTRIBUTE_BUFFER_header \ 1151 .type = MALI_ATTRIBUTE_TYPE_1D, \ 1152 .divisor = 1 1153 1154static inline void 1155MALI_ATTRIBUTE_BUFFER_pack(uint32_t * restrict cl, 1156 const struct MALI_ATTRIBUTE_BUFFER * restrict values) 1157{ 1158 assert((values->pointer & 0x3f) == 0); 1159 cl[ 0] = __gen_uint(values->special, 0, 7) | 1160 __gen_uint(values->type, 0, 5) | 1161 __gen_uint(values->pointer >> 6, 6, 55); 1162 cl[ 1] = __gen_uint(values->pointer >> 6, 6, 55) >> 32 | 1163 __gen_padded(values->divisor, 24, 31) | 1164 __gen_uint(values->divisor_r, 24, 28) | 1165 __gen_uint(values->divisor_p, 29, 31) | 1166 __gen_uint(values->divisor_e, 29, 29); 1167 cl[ 2] = __gen_uint(values->stride, 0, 31); 1168 cl[ 3] = __gen_uint(values->size, 0, 31); 1169} 1170 1171 1172#define MALI_ATTRIBUTE_BUFFER_LENGTH 16 1173#define MALI_ATTRIBUTE_BUFFER_ALIGN 32 1174struct mali_attribute_buffer_packed { uint32_t opaque[4]; }; 1175static inline void 1176MALI_ATTRIBUTE_BUFFER_unpack(const uint8_t * restrict cl, 1177 struct MALI_ATTRIBUTE_BUFFER * restrict values) 1178{ 1179 values->special = (enum mali_attribute_special)__gen_unpack_uint(cl, 0, 7); 1180 values->type = (enum mali_attribute_type)__gen_unpack_uint(cl, 0, 5); 1181 values->pointer = __gen_unpack_uint(cl, 6, 55) << 6; 1182 values->stride = __gen_unpack_uint(cl, 64, 95); 1183 values->size = __gen_unpack_uint(cl, 96, 127); 1184 values->divisor = __gen_unpack_padded(cl, 56, 63); 1185 values->divisor_r = __gen_unpack_uint(cl, 56, 60); 1186 values->divisor_p = __gen_unpack_uint(cl, 61, 63); 1187 values->divisor_e = __gen_unpack_uint(cl, 61, 61); 1188} 1189 1190static inline void 1191MALI_ATTRIBUTE_BUFFER_print(FILE *fp, const struct MALI_ATTRIBUTE_BUFFER * values, unsigned indent) 1192{ 1193 fprintf(fp, "%*sSpecial: %s\n", indent, "", mali_attribute_special_as_str(values->special)); 1194 fprintf(fp, "%*sType: %s\n", indent, "", mali_attribute_type_as_str(values->type)); 1195 fprintf(fp, "%*sPointer: 0x%" PRIx64 "\n", indent, "", values->pointer); 1196 fprintf(fp, "%*sStride: %u\n", indent, "", values->stride); 1197 fprintf(fp, "%*sSize: %u\n", indent, "", values->size); 1198 fprintf(fp, "%*sDivisor: %u\n", indent, "", values->divisor); 1199 fprintf(fp, "%*sDivisor R: %u\n", indent, "", values->divisor_r); 1200 fprintf(fp, "%*sDivisor P: %u\n", indent, "", values->divisor_p); 1201 fprintf(fp, "%*sDivisor E: %u\n", indent, "", values->divisor_e); 1202} 1203 1204struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT { 1205 enum mali_attribute_type type; 1206 uint32_t divisor_numerator; 1207 uint32_t divisor; 1208}; 1209 1210#define MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_header\ 1211 .type = MALI_ATTRIBUTE_TYPE_CONTINUATION 1212 1213static inline void 1214MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_pack(uint32_t * restrict cl, 1215 const struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT * restrict values) 1216{ 1217 cl[ 0] = __gen_uint(values->type, 0, 5); 1218 cl[ 1] = __gen_uint(values->divisor_numerator, 0, 31); 1219 cl[ 2] = 0; 1220 cl[ 3] = __gen_uint(values->divisor, 0, 31); 1221} 1222 1223 1224#define MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_LENGTH 16 1225struct mali_attribute_buffer_continuation_npot_packed { uint32_t opaque[4]; }; 1226static inline void 1227MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_unpack(const uint8_t * restrict cl, 1228 struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT * restrict values) 1229{ 1230 if (((const uint32_t *) cl)[0] & 0xffffffc0) fprintf(stderr, "XXX: Invalid field of Attribute Buffer Continuation NPOT unpacked at word 0\n"); 1231 if (((const uint32_t *) cl)[2] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Attribute Buffer Continuation NPOT unpacked at word 2\n"); 1232 values->type = (enum mali_attribute_type)__gen_unpack_uint(cl, 0, 5); 1233 values->divisor_numerator = __gen_unpack_uint(cl, 32, 63); 1234 values->divisor = __gen_unpack_uint(cl, 96, 127); 1235} 1236 1237static inline void 1238MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_print(FILE *fp, const struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT * values, unsigned indent) 1239{ 1240 fprintf(fp, "%*sType: %s\n", indent, "", mali_attribute_type_as_str(values->type)); 1241 fprintf(fp, "%*sDivisor Numerator: %u\n", indent, "", values->divisor_numerator); 1242 fprintf(fp, "%*sDivisor: %u\n", indent, "", values->divisor); 1243} 1244 1245struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D { 1246 enum mali_attribute_type type; 1247 uint32_t s_dimension; 1248 uint32_t t_dimension; 1249 uint32_t r_dimension; 1250 uint32_t row_stride; 1251 uint32_t slice_stride; 1252}; 1253 1254#define MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D_header\ 1255 .type = MALI_ATTRIBUTE_TYPE_CONTINUATION 1256 1257static inline void 1258MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D_pack(uint32_t * restrict cl, 1259 const struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D * restrict values) 1260{ 1261 assert(values->s_dimension >= 1); 1262 assert(values->t_dimension >= 1); 1263 assert(values->r_dimension >= 1); 1264 cl[ 0] = __gen_uint(values->type, 0, 5) | 1265 __gen_uint(values->s_dimension - 1, 16, 31); 1266 cl[ 1] = __gen_uint(values->t_dimension - 1, 0, 15) | 1267 __gen_uint(values->r_dimension - 1, 16, 31); 1268 cl[ 2] = __gen_uint(values->row_stride, 0, 31); 1269 cl[ 3] = __gen_uint(values->slice_stride, 0, 31); 1270} 1271 1272 1273#define MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D_LENGTH 16 1274struct mali_attribute_buffer_continuation_3d_packed { uint32_t opaque[4]; }; 1275static inline void 1276MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D_unpack(const uint8_t * restrict cl, 1277 struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D * restrict values) 1278{ 1279 if (((const uint32_t *) cl)[0] & 0xffc0) fprintf(stderr, "XXX: Invalid field of Attribute Buffer Continuation 3D unpacked at word 0\n"); 1280 values->type = (enum mali_attribute_type)__gen_unpack_uint(cl, 0, 5); 1281 values->s_dimension = __gen_unpack_uint(cl, 16, 31) + 1; 1282 values->t_dimension = __gen_unpack_uint(cl, 32, 47) + 1; 1283 values->r_dimension = __gen_unpack_uint(cl, 48, 63) + 1; 1284 values->row_stride = __gen_unpack_uint(cl, 64, 95); 1285 values->slice_stride = __gen_unpack_uint(cl, 96, 127); 1286} 1287 1288static inline void 1289MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D_print(FILE *fp, const struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_3D * values, unsigned indent) 1290{ 1291 fprintf(fp, "%*sType: %s\n", indent, "", mali_attribute_type_as_str(values->type)); 1292 fprintf(fp, "%*sS dimension: %u\n", indent, "", values->s_dimension); 1293 fprintf(fp, "%*sT dimension: %u\n", indent, "", values->t_dimension); 1294 fprintf(fp, "%*sR dimension: %u\n", indent, "", values->r_dimension); 1295 fprintf(fp, "%*sRow Stride: %u\n", indent, "", values->row_stride); 1296 fprintf(fp, "%*sSlice Stride: %u\n", indent, "", values->slice_stride); 1297} 1298 1299enum mali_blend_operand_a { 1300 MALI_BLEND_OPERAND_A_ZERO = 1, 1301 MALI_BLEND_OPERAND_A_SRC = 2, 1302 MALI_BLEND_OPERAND_A_DEST = 3, 1303}; 1304 1305static inline const char * 1306mali_blend_operand_a_as_str(enum mali_blend_operand_a imm) 1307{ 1308 switch (imm) { 1309 case MALI_BLEND_OPERAND_A_ZERO: return "Zero"; 1310 case MALI_BLEND_OPERAND_A_SRC: return "Src"; 1311 case MALI_BLEND_OPERAND_A_DEST: return "Dest"; 1312 default: return "XXX: INVALID"; 1313 } 1314} 1315 1316enum mali_blend_operand_b { 1317 MALI_BLEND_OPERAND_B_SRC_MINUS_DEST = 0, 1318 MALI_BLEND_OPERAND_B_SRC_PLUS_DEST = 1, 1319 MALI_BLEND_OPERAND_B_SRC = 2, 1320 MALI_BLEND_OPERAND_B_DEST = 3, 1321}; 1322 1323static inline const char * 1324mali_blend_operand_b_as_str(enum mali_blend_operand_b imm) 1325{ 1326 switch (imm) { 1327 case MALI_BLEND_OPERAND_B_SRC_MINUS_DEST: return "Src Minus Dest"; 1328 case MALI_BLEND_OPERAND_B_SRC_PLUS_DEST: return "Src Plus Dest"; 1329 case MALI_BLEND_OPERAND_B_SRC: return "Src"; 1330 case MALI_BLEND_OPERAND_B_DEST: return "Dest"; 1331 default: return "XXX: INVALID"; 1332 } 1333} 1334 1335enum mali_blend_operand_c { 1336 MALI_BLEND_OPERAND_C_ZERO = 1, 1337 MALI_BLEND_OPERAND_C_SRC = 2, 1338 MALI_BLEND_OPERAND_C_DEST = 3, 1339 MALI_BLEND_OPERAND_C_SRC_X_2 = 4, 1340 MALI_BLEND_OPERAND_C_SRC_ALPHA = 5, 1341 MALI_BLEND_OPERAND_C_DEST_ALPHA = 6, 1342 MALI_BLEND_OPERAND_C_CONSTANT = 7, 1343}; 1344 1345static inline const char * 1346mali_blend_operand_c_as_str(enum mali_blend_operand_c imm) 1347{ 1348 switch (imm) { 1349 case MALI_BLEND_OPERAND_C_ZERO: return "Zero"; 1350 case MALI_BLEND_OPERAND_C_SRC: return "Src"; 1351 case MALI_BLEND_OPERAND_C_DEST: return "Dest"; 1352 case MALI_BLEND_OPERAND_C_SRC_X_2: return "Src x 2"; 1353 case MALI_BLEND_OPERAND_C_SRC_ALPHA: return "Src Alpha"; 1354 case MALI_BLEND_OPERAND_C_DEST_ALPHA: return "Dest Alpha"; 1355 case MALI_BLEND_OPERAND_C_CONSTANT: return "Constant"; 1356 default: return "XXX: INVALID"; 1357 } 1358} 1359 1360struct MALI_BLEND_FUNCTION { 1361 enum mali_blend_operand_a a; 1362 bool negate_a; 1363 enum mali_blend_operand_b b; 1364 bool negate_b; 1365 enum mali_blend_operand_c c; 1366 bool invert_c; 1367}; 1368 1369#define MALI_BLEND_FUNCTION_header \ 1370 0 1371 1372static inline void 1373MALI_BLEND_FUNCTION_print(FILE *fp, const struct MALI_BLEND_FUNCTION * values, unsigned indent) 1374{ 1375 fprintf(fp, "%*sA: %s\n", indent, "", mali_blend_operand_a_as_str(values->a)); 1376 fprintf(fp, "%*sNegate A: %s\n", indent, "", values->negate_a ? "true" : "false"); 1377 fprintf(fp, "%*sB: %s\n", indent, "", mali_blend_operand_b_as_str(values->b)); 1378 fprintf(fp, "%*sNegate B: %s\n", indent, "", values->negate_b ? "true" : "false"); 1379 fprintf(fp, "%*sC: %s\n", indent, "", mali_blend_operand_c_as_str(values->c)); 1380 fprintf(fp, "%*sInvert C: %s\n", indent, "", values->invert_c ? "true" : "false"); 1381} 1382 1383struct MALI_BLEND_EQUATION { 1384 struct MALI_BLEND_FUNCTION rgb; 1385 struct MALI_BLEND_FUNCTION alpha; 1386 uint32_t color_mask; 1387}; 1388 1389#define MALI_BLEND_EQUATION_header \ 1390 .rgb = { MALI_BLEND_FUNCTION_header }, \ 1391 .alpha = { MALI_BLEND_FUNCTION_header } 1392 1393static inline void 1394MALI_BLEND_EQUATION_pack(uint32_t * restrict cl, 1395 const struct MALI_BLEND_EQUATION * restrict values) 1396{ 1397 cl[ 0] = __gen_uint(values->rgb.a, 0, 1) | 1398 __gen_uint(values->rgb.negate_a, 3, 3) | 1399 __gen_uint(values->rgb.b, 4, 5) | 1400 __gen_uint(values->rgb.negate_b, 7, 7) | 1401 __gen_uint(values->rgb.c, 8, 10) | 1402 __gen_uint(values->rgb.invert_c, 11, 11) | 1403 __gen_uint(values->alpha.a, 12, 13) | 1404 __gen_uint(values->alpha.negate_a, 15, 15) | 1405 __gen_uint(values->alpha.b, 16, 17) | 1406 __gen_uint(values->alpha.negate_b, 19, 19) | 1407 __gen_uint(values->alpha.c, 20, 22) | 1408 __gen_uint(values->alpha.invert_c, 23, 23) | 1409 __gen_uint(values->color_mask, 28, 31); 1410} 1411 1412 1413#define MALI_BLEND_EQUATION_LENGTH 4 1414struct mali_blend_equation_packed { uint32_t opaque[1]; }; 1415static inline void 1416MALI_BLEND_EQUATION_unpack(const uint8_t * restrict cl, 1417 struct MALI_BLEND_EQUATION * restrict values) 1418{ 1419 if (((const uint32_t *) cl)[0] & 0xf044044) fprintf(stderr, "XXX: Invalid field of Blend Equation unpacked at word 0\n"); 1420 values->rgb.a = (enum mali_blend_operand_a)__gen_unpack_uint(cl, 0, 1); 1421 values->rgb.negate_a = __gen_unpack_uint(cl, 3, 3); 1422 values->rgb.b = (enum mali_blend_operand_b)__gen_unpack_uint(cl, 4, 5); 1423 values->rgb.negate_b = __gen_unpack_uint(cl, 7, 7); 1424 values->rgb.c = (enum mali_blend_operand_c)__gen_unpack_uint(cl, 8, 10); 1425 values->rgb.invert_c = __gen_unpack_uint(cl, 11, 11); 1426 values->alpha.a = (enum mali_blend_operand_a)__gen_unpack_uint(cl, 12, 13); 1427 values->alpha.negate_a = __gen_unpack_uint(cl, 15, 15); 1428 values->alpha.b = (enum mali_blend_operand_b)__gen_unpack_uint(cl, 16, 17); 1429 values->alpha.negate_b = __gen_unpack_uint(cl, 19, 19); 1430 values->alpha.c = (enum mali_blend_operand_c)__gen_unpack_uint(cl, 20, 22); 1431 values->alpha.invert_c = __gen_unpack_uint(cl, 23, 23); 1432 values->color_mask = __gen_unpack_uint(cl, 28, 31); 1433} 1434 1435static inline void 1436MALI_BLEND_EQUATION_print(FILE *fp, const struct MALI_BLEND_EQUATION * values, unsigned indent) 1437{ 1438 fprintf(fp, "%*sRGB:\n", indent, ""); 1439 MALI_BLEND_FUNCTION_print(fp, &values->rgb, indent + 2); 1440 fprintf(fp, "%*sAlpha:\n", indent, ""); 1441 MALI_BLEND_FUNCTION_print(fp, &values->alpha, indent + 2); 1442 fprintf(fp, "%*sColor Mask: %u\n", indent, "", values->color_mask); 1443} 1444 1445struct MALI_BLEND { 1446 bool load_destination; 1447 bool blend_shader; 1448 bool blend_shader_contains_discard; 1449 bool alpha_to_one; 1450 bool enable; 1451 bool srgb; 1452 bool round_to_fb_precision; 1453 uint64_t shader_pc; 1454 struct MALI_BLEND_EQUATION equation; 1455 float constant; 1456}; 1457 1458#define MALI_BLEND_header \ 1459 .load_destination = false, \ 1460 .blend_shader = false, \ 1461 .blend_shader_contains_discard = false, \ 1462 .enable = true, \ 1463 .srgb = false, \ 1464 .round_to_fb_precision = false, \ 1465 .equation = { MALI_BLEND_EQUATION_header } 1466 1467static inline void 1468MALI_BLEND_pack(uint32_t * restrict cl, 1469 const struct MALI_BLEND * restrict values) 1470{ 1471 cl[ 0] = __gen_uint(values->load_destination, 0, 0) | 1472 __gen_uint(values->blend_shader, 1, 1) | 1473 __gen_uint(values->blend_shader_contains_discard, 2, 2) | 1474 __gen_uint(values->alpha_to_one, 8, 8) | 1475 __gen_uint(values->enable, 9, 9) | 1476 __gen_uint(values->srgb, 10, 10) | 1477 __gen_uint(values->round_to_fb_precision, 11, 11); 1478 cl[ 1] = 0; 1479 cl[ 2] = __gen_uint(values->shader_pc, 0, 63) | 1480 __gen_uint(values->equation.rgb.a, 0, 1) | 1481 __gen_uint(values->equation.rgb.negate_a, 3, 3) | 1482 __gen_uint(values->equation.rgb.b, 4, 5) | 1483 __gen_uint(values->equation.rgb.negate_b, 7, 7) | 1484 __gen_uint(values->equation.rgb.c, 8, 10) | 1485 __gen_uint(values->equation.rgb.invert_c, 11, 11) | 1486 __gen_uint(values->equation.alpha.a, 12, 13) | 1487 __gen_uint(values->equation.alpha.negate_a, 15, 15) | 1488 __gen_uint(values->equation.alpha.b, 16, 17) | 1489 __gen_uint(values->equation.alpha.negate_b, 19, 19) | 1490 __gen_uint(values->equation.alpha.c, 20, 22) | 1491 __gen_uint(values->equation.alpha.invert_c, 23, 23) | 1492 __gen_uint(values->equation.color_mask, 28, 31); 1493 cl[ 3] = __gen_uint(values->shader_pc, 0, 63) >> 32 | 1494 __gen_uint(fui(values->constant), 0, 32); 1495} 1496 1497 1498#define MALI_BLEND_LENGTH 16 1499#define MALI_BLEND_ALIGN 16 1500struct mali_blend_packed { uint32_t opaque[4]; }; 1501static inline void 1502MALI_BLEND_unpack(const uint8_t * restrict cl, 1503 struct MALI_BLEND * restrict values) 1504{ 1505 if (((const uint32_t *) cl)[0] & 0xfffff0f8) fprintf(stderr, "XXX: Invalid field of Blend unpacked at word 0\n"); 1506 if (((const uint32_t *) cl)[1] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Blend unpacked at word 1\n"); 1507 values->load_destination = __gen_unpack_uint(cl, 0, 0); 1508 values->blend_shader = __gen_unpack_uint(cl, 1, 1); 1509 values->blend_shader_contains_discard = __gen_unpack_uint(cl, 2, 2); 1510 values->alpha_to_one = __gen_unpack_uint(cl, 8, 8); 1511 values->enable = __gen_unpack_uint(cl, 9, 9); 1512 values->srgb = __gen_unpack_uint(cl, 10, 10); 1513 values->round_to_fb_precision = __gen_unpack_uint(cl, 11, 11); 1514 values->shader_pc = __gen_unpack_uint(cl, 64, 127); 1515 values->equation.rgb.a = (enum mali_blend_operand_a)__gen_unpack_uint(cl, 64, 65); 1516 values->equation.rgb.negate_a = __gen_unpack_uint(cl, 67, 67); 1517 values->equation.rgb.b = (enum mali_blend_operand_b)__gen_unpack_uint(cl, 68, 69); 1518 values->equation.rgb.negate_b = __gen_unpack_uint(cl, 71, 71); 1519 values->equation.rgb.c = (enum mali_blend_operand_c)__gen_unpack_uint(cl, 72, 74); 1520 values->equation.rgb.invert_c = __gen_unpack_uint(cl, 75, 75); 1521 values->equation.alpha.a = (enum mali_blend_operand_a)__gen_unpack_uint(cl, 76, 77); 1522 values->equation.alpha.negate_a = __gen_unpack_uint(cl, 79, 79); 1523 values->equation.alpha.b = (enum mali_blend_operand_b)__gen_unpack_uint(cl, 80, 81); 1524 values->equation.alpha.negate_b = __gen_unpack_uint(cl, 83, 83); 1525 values->equation.alpha.c = (enum mali_blend_operand_c)__gen_unpack_uint(cl, 84, 86); 1526 values->equation.alpha.invert_c = __gen_unpack_uint(cl, 87, 87); 1527 values->equation.color_mask = __gen_unpack_uint(cl, 92, 95); 1528 values->constant = __gen_unpack_float(cl, 96, 127); 1529} 1530 1531static inline void 1532MALI_BLEND_print(FILE *fp, const struct MALI_BLEND * values, unsigned indent) 1533{ 1534 fprintf(fp, "%*sLoad Destination: %s\n", indent, "", values->load_destination ? "true" : "false"); 1535 fprintf(fp, "%*sBlend Shader: %s\n", indent, "", values->blend_shader ? "true" : "false"); 1536 fprintf(fp, "%*sBlend Shader Contains Discard: %s\n", indent, "", values->blend_shader_contains_discard ? "true" : "false"); 1537 fprintf(fp, "%*sAlpha To One: %s\n", indent, "", values->alpha_to_one ? "true" : "false"); 1538 fprintf(fp, "%*sEnable: %s\n", indent, "", values->enable ? "true" : "false"); 1539 fprintf(fp, "%*ssRGB: %s\n", indent, "", values->srgb ? "true" : "false"); 1540 fprintf(fp, "%*sRound to FB precision: %s\n", indent, "", values->round_to_fb_precision ? "true" : "false"); 1541 fprintf(fp, "%*sShader PC: 0x%" PRIx64 "\n", indent, "", values->shader_pc); 1542 fprintf(fp, "%*sEquation:\n", indent, ""); 1543 MALI_BLEND_EQUATION_print(fp, &values->equation, indent + 2); 1544 fprintf(fp, "%*sConstant: %f\n", indent, "", values->constant); 1545} 1546 1547struct MALI_INVOCATION { 1548 uint32_t invocations; 1549 uint32_t size_y_shift; 1550 uint32_t size_z_shift; 1551 uint32_t workgroups_x_shift; 1552 uint32_t workgroups_y_shift; 1553 uint32_t workgroups_z_shift; 1554 uint32_t thread_group_split; 1555#define MALI_SPLIT_MIN_EFFICIENT 2 1556}; 1557 1558#define MALI_INVOCATION_header \ 1559 0 1560 1561static inline void 1562MALI_INVOCATION_pack(uint32_t * restrict cl, 1563 const struct MALI_INVOCATION * restrict values) 1564{ 1565 cl[ 0] = __gen_uint(values->invocations, 0, 31); 1566 cl[ 1] = __gen_uint(values->size_y_shift, 0, 4) | 1567 __gen_uint(values->size_z_shift, 5, 9) | 1568 __gen_uint(values->workgroups_x_shift, 10, 15) | 1569 __gen_uint(values->workgroups_y_shift, 16, 21) | 1570 __gen_uint(values->workgroups_z_shift, 22, 27) | 1571 __gen_uint(values->thread_group_split, 28, 31); 1572} 1573 1574 1575#define MALI_INVOCATION_LENGTH 8 1576struct mali_invocation_packed { uint32_t opaque[2]; }; 1577static inline void 1578MALI_INVOCATION_unpack(const uint8_t * restrict cl, 1579 struct MALI_INVOCATION * restrict values) 1580{ 1581 values->invocations = __gen_unpack_uint(cl, 0, 31); 1582 values->size_y_shift = __gen_unpack_uint(cl, 32, 36); 1583 values->size_z_shift = __gen_unpack_uint(cl, 37, 41); 1584 values->workgroups_x_shift = __gen_unpack_uint(cl, 42, 47); 1585 values->workgroups_y_shift = __gen_unpack_uint(cl, 48, 53); 1586 values->workgroups_z_shift = __gen_unpack_uint(cl, 54, 59); 1587 values->thread_group_split = __gen_unpack_uint(cl, 60, 63); 1588} 1589 1590static inline void 1591MALI_INVOCATION_print(FILE *fp, const struct MALI_INVOCATION * values, unsigned indent) 1592{ 1593 fprintf(fp, "%*sInvocations: %u\n", indent, "", values->invocations); 1594 fprintf(fp, "%*sSize Y shift: %u\n", indent, "", values->size_y_shift); 1595 fprintf(fp, "%*sSize Z shift: %u\n", indent, "", values->size_z_shift); 1596 fprintf(fp, "%*sWorkgroups X shift: %u\n", indent, "", values->workgroups_x_shift); 1597 fprintf(fp, "%*sWorkgroups Y shift: %u\n", indent, "", values->workgroups_y_shift); 1598 fprintf(fp, "%*sWorkgroups Z shift: %u\n", indent, "", values->workgroups_z_shift); 1599 fprintf(fp, "%*sThread group split: %u\n", indent, "", values->thread_group_split); 1600} 1601 1602enum mali_point_size_array_format { 1603 MALI_POINT_SIZE_ARRAY_FORMAT_NONE = 0, 1604 MALI_POINT_SIZE_ARRAY_FORMAT_FP16 = 2, 1605 MALI_POINT_SIZE_ARRAY_FORMAT_FP32 = 3, 1606}; 1607 1608static inline const char * 1609mali_point_size_array_format_as_str(enum mali_point_size_array_format imm) 1610{ 1611 switch (imm) { 1612 case MALI_POINT_SIZE_ARRAY_FORMAT_NONE: return "None"; 1613 case MALI_POINT_SIZE_ARRAY_FORMAT_FP16: return "FP16"; 1614 case MALI_POINT_SIZE_ARRAY_FORMAT_FP32: return "FP32"; 1615 default: return "XXX: INVALID"; 1616 } 1617} 1618 1619enum mali_primitive_restart { 1620 MALI_PRIMITIVE_RESTART_NONE = 0, 1621 MALI_PRIMITIVE_RESTART_IMPLICIT = 2, 1622 MALI_PRIMITIVE_RESTART_EXPLICIT = 3, 1623}; 1624 1625static inline const char * 1626mali_primitive_restart_as_str(enum mali_primitive_restart imm) 1627{ 1628 switch (imm) { 1629 case MALI_PRIMITIVE_RESTART_NONE: return "None"; 1630 case MALI_PRIMITIVE_RESTART_IMPLICIT: return "Implicit"; 1631 case MALI_PRIMITIVE_RESTART_EXPLICIT: return "Explicit"; 1632 default: return "XXX: INVALID"; 1633 } 1634} 1635 1636struct MALI_PRIMITIVE { 1637 enum mali_draw_mode draw_mode; 1638 enum mali_index_type index_type; 1639 enum mali_point_size_array_format point_size_array_format; 1640 bool primitive_index_enable; 1641 bool primitive_index_writeback; 1642 bool first_provoking_vertex; 1643 bool low_depth_cull; 1644 bool high_depth_cull; 1645 enum mali_primitive_restart primitive_restart; 1646 uint32_t job_task_split; 1647 uint32_t base_vertex_offset; 1648 uint32_t primitive_restart_index; 1649 uint32_t index_count; 1650 uint64_t indices; 1651}; 1652 1653#define MALI_PRIMITIVE_header \ 1654 .index_type = MALI_INDEX_TYPE_NONE, \ 1655 .first_provoking_vertex = true, \ 1656 .low_depth_cull = true, \ 1657 .high_depth_cull = true 1658 1659static inline void 1660MALI_PRIMITIVE_pack(uint32_t * restrict cl, 1661 const struct MALI_PRIMITIVE * restrict values) 1662{ 1663 assert(values->index_count >= 1); 1664 cl[ 0] = __gen_uint(values->draw_mode, 0, 7) | 1665 __gen_uint(values->index_type, 8, 10) | 1666 __gen_uint(values->point_size_array_format, 11, 12) | 1667 __gen_uint(values->primitive_index_enable, 13, 13) | 1668 __gen_uint(values->primitive_index_writeback, 14, 14) | 1669 __gen_uint(values->first_provoking_vertex, 15, 15) | 1670 __gen_uint(values->low_depth_cull, 16, 16) | 1671 __gen_uint(values->high_depth_cull, 17, 17) | 1672 __gen_uint(values->primitive_restart, 19, 20) | 1673 __gen_uint(values->job_task_split, 26, 31); 1674 cl[ 1] = __gen_uint(values->base_vertex_offset, 0, 31); 1675 cl[ 2] = __gen_uint(values->primitive_restart_index, 0, 31); 1676 cl[ 3] = __gen_uint(values->index_count - 1, 0, 31); 1677 cl[ 4] = __gen_uint(values->indices, 0, 63); 1678 cl[ 5] = __gen_uint(values->indices, 0, 63) >> 32; 1679} 1680 1681 1682#define MALI_PRIMITIVE_LENGTH 24 1683struct mali_primitive_packed { uint32_t opaque[6]; }; 1684static inline void 1685MALI_PRIMITIVE_unpack(const uint8_t * restrict cl, 1686 struct MALI_PRIMITIVE * restrict values) 1687{ 1688 if (((const uint32_t *) cl)[0] & 0x3e40000) fprintf(stderr, "XXX: Invalid field of Primitive unpacked at word 0\n"); 1689 values->draw_mode = (enum mali_draw_mode)__gen_unpack_uint(cl, 0, 7); 1690 values->index_type = (enum mali_index_type)__gen_unpack_uint(cl, 8, 10); 1691 values->point_size_array_format = (enum mali_point_size_array_format)__gen_unpack_uint(cl, 11, 12); 1692 values->primitive_index_enable = __gen_unpack_uint(cl, 13, 13); 1693 values->primitive_index_writeback = __gen_unpack_uint(cl, 14, 14); 1694 values->first_provoking_vertex = __gen_unpack_uint(cl, 15, 15); 1695 values->low_depth_cull = __gen_unpack_uint(cl, 16, 16); 1696 values->high_depth_cull = __gen_unpack_uint(cl, 17, 17); 1697 values->primitive_restart = (enum mali_primitive_restart)__gen_unpack_uint(cl, 19, 20); 1698 values->job_task_split = __gen_unpack_uint(cl, 26, 31); 1699 values->base_vertex_offset = __gen_unpack_uint(cl, 32, 63); 1700 values->primitive_restart_index = __gen_unpack_uint(cl, 64, 95); 1701 values->index_count = __gen_unpack_uint(cl, 96, 127) + 1; 1702 values->indices = __gen_unpack_uint(cl, 128, 191); 1703} 1704 1705static inline void 1706MALI_PRIMITIVE_print(FILE *fp, const struct MALI_PRIMITIVE * values, unsigned indent) 1707{ 1708 fprintf(fp, "%*sDraw mode: %s\n", indent, "", mali_draw_mode_as_str(values->draw_mode)); 1709 fprintf(fp, "%*sIndex type: %s\n", indent, "", mali_index_type_as_str(values->index_type)); 1710 fprintf(fp, "%*sPoint size array format: %s\n", indent, "", mali_point_size_array_format_as_str(values->point_size_array_format)); 1711 fprintf(fp, "%*sPrimitive Index Enable: %s\n", indent, "", values->primitive_index_enable ? "true" : "false"); 1712 fprintf(fp, "%*sPrimitive Index Writeback: %s\n", indent, "", values->primitive_index_writeback ? "true" : "false"); 1713 fprintf(fp, "%*sFirst provoking vertex: %s\n", indent, "", values->first_provoking_vertex ? "true" : "false"); 1714 fprintf(fp, "%*sLow Depth Cull: %s\n", indent, "", values->low_depth_cull ? "true" : "false"); 1715 fprintf(fp, "%*sHigh Depth Cull: %s\n", indent, "", values->high_depth_cull ? "true" : "false"); 1716 fprintf(fp, "%*sPrimitive restart: %s\n", indent, "", mali_primitive_restart_as_str(values->primitive_restart)); 1717 fprintf(fp, "%*sJob Task Split: %u\n", indent, "", values->job_task_split); 1718 fprintf(fp, "%*sBase vertex offset: %u\n", indent, "", values->base_vertex_offset); 1719 fprintf(fp, "%*sPrimitive Restart Index: %u\n", indent, "", values->primitive_restart_index); 1720 fprintf(fp, "%*sIndex count: %u\n", indent, "", values->index_count); 1721 fprintf(fp, "%*sIndices: 0x%" PRIx64 "\n", indent, "", values->indices); 1722} 1723 1724struct MALI_DRAW { 1725 bool four_components_per_vertex; 1726 bool draw_descriptor_is_64b; 1727 bool texture_descriptor_is_64b; 1728 enum mali_occlusion_mode occlusion_query; 1729 bool front_face_ccw; 1730 bool cull_front_face; 1731 bool cull_back_face; 1732 uint32_t flat_shading_vertex; 1733 bool primitive_barrier; 1734 bool clean_fragment_write; 1735 uint32_t instance_size; 1736 uint32_t instance_primitive_size; 1737 uint32_t offset_start; 1738 uint32_t primitive_index_base; 1739 uint64_t position; 1740 uint64_t uniform_buffers; 1741 uint64_t textures; 1742 uint64_t samplers; 1743 uint64_t push_uniforms; 1744 uint64_t state; 1745 uint64_t attribute_buffers; 1746 uint64_t attributes; 1747 uint64_t varying_buffers; 1748 uint64_t varyings; 1749 uint64_t viewport; 1750 uint64_t occlusion; 1751 uint64_t thread_storage; 1752 uint64_t fbd; 1753}; 1754 1755#define MALI_DRAW_header \ 1756 .texture_descriptor_is_64b = true, \ 1757 .occlusion_query = MALI_OCCLUSION_MODE_DISABLED, \ 1758 .instance_size = 1, \ 1759 .instance_primitive_size = 1 1760 1761static inline void 1762MALI_DRAW_pack(uint32_t * restrict cl, 1763 const struct MALI_DRAW * restrict values) 1764{ 1765 cl[ 0] = __gen_uint(values->four_components_per_vertex, 0, 0) | 1766 __gen_uint(values->draw_descriptor_is_64b, 1, 1) | 1767 __gen_uint(values->texture_descriptor_is_64b, 2, 2) | 1768 __gen_uint(values->occlusion_query, 3, 4) | 1769 __gen_uint(values->front_face_ccw, 5, 5) | 1770 __gen_uint(values->cull_front_face, 6, 6) | 1771 __gen_uint(values->cull_back_face, 7, 7) | 1772 __gen_uint(values->flat_shading_vertex, 8, 8) | 1773 __gen_uint(values->primitive_barrier, 10, 10) | 1774 __gen_uint(values->clean_fragment_write, 11, 11) | 1775 __gen_padded(values->instance_size, 16, 23) | 1776 __gen_padded(values->instance_primitive_size, 24, 31); 1777 cl[ 1] = __gen_uint(values->offset_start, 0, 31); 1778 cl[ 2] = __gen_uint(values->primitive_index_base, 0, 31); 1779 cl[ 3] = 0; 1780 cl[ 4] = __gen_uint(values->position, 0, 63); 1781 cl[ 5] = __gen_uint(values->position, 0, 63) >> 32; 1782 cl[ 6] = __gen_uint(values->uniform_buffers, 0, 63); 1783 cl[ 7] = __gen_uint(values->uniform_buffers, 0, 63) >> 32; 1784 cl[ 8] = __gen_uint(values->textures, 0, 63); 1785 cl[ 9] = __gen_uint(values->textures, 0, 63) >> 32; 1786 cl[10] = __gen_uint(values->samplers, 0, 63); 1787 cl[11] = __gen_uint(values->samplers, 0, 63) >> 32; 1788 cl[12] = __gen_uint(values->push_uniforms, 0, 63); 1789 cl[13] = __gen_uint(values->push_uniforms, 0, 63) >> 32; 1790 cl[14] = __gen_uint(values->state, 0, 63); 1791 cl[15] = __gen_uint(values->state, 0, 63) >> 32; 1792 cl[16] = __gen_uint(values->attribute_buffers, 0, 63); 1793 cl[17] = __gen_uint(values->attribute_buffers, 0, 63) >> 32; 1794 cl[18] = __gen_uint(values->attributes, 0, 63); 1795 cl[19] = __gen_uint(values->attributes, 0, 63) >> 32; 1796 cl[20] = __gen_uint(values->varying_buffers, 0, 63); 1797 cl[21] = __gen_uint(values->varying_buffers, 0, 63) >> 32; 1798 cl[22] = __gen_uint(values->varyings, 0, 63); 1799 cl[23] = __gen_uint(values->varyings, 0, 63) >> 32; 1800 cl[24] = __gen_uint(values->viewport, 0, 63); 1801 cl[25] = __gen_uint(values->viewport, 0, 63) >> 32; 1802 cl[26] = __gen_uint(values->occlusion, 0, 63); 1803 cl[27] = __gen_uint(values->occlusion, 0, 63) >> 32; 1804 cl[28] = __gen_uint(values->thread_storage, 0, 63) | 1805 __gen_uint(values->fbd, 0, 63); 1806 cl[29] = __gen_uint(values->thread_storage, 0, 63) >> 32 | 1807 __gen_uint(values->fbd, 0, 63) >> 32; 1808} 1809 1810 1811#define MALI_DRAW_LENGTH 120 1812#define MALI_DRAW_ALIGN 64 1813struct mali_draw_packed { uint32_t opaque[30]; }; 1814static inline void 1815MALI_DRAW_unpack(const uint8_t * restrict cl, 1816 struct MALI_DRAW * restrict values) 1817{ 1818 if (((const uint32_t *) cl)[0] & 0xf200) fprintf(stderr, "XXX: Invalid field of Draw unpacked at word 0\n"); 1819 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Draw unpacked at word 3\n"); 1820 values->four_components_per_vertex = __gen_unpack_uint(cl, 0, 0); 1821 values->draw_descriptor_is_64b = __gen_unpack_uint(cl, 1, 1); 1822 values->texture_descriptor_is_64b = __gen_unpack_uint(cl, 2, 2); 1823 values->occlusion_query = (enum mali_occlusion_mode)__gen_unpack_uint(cl, 3, 4); 1824 values->front_face_ccw = __gen_unpack_uint(cl, 5, 5); 1825 values->cull_front_face = __gen_unpack_uint(cl, 6, 6); 1826 values->cull_back_face = __gen_unpack_uint(cl, 7, 7); 1827 values->flat_shading_vertex = __gen_unpack_uint(cl, 8, 8); 1828 values->primitive_barrier = __gen_unpack_uint(cl, 10, 10); 1829 values->clean_fragment_write = __gen_unpack_uint(cl, 11, 11); 1830 values->instance_size = __gen_unpack_padded(cl, 16, 23); 1831 values->instance_primitive_size = __gen_unpack_padded(cl, 24, 31); 1832 values->offset_start = __gen_unpack_uint(cl, 32, 63); 1833 values->primitive_index_base = __gen_unpack_uint(cl, 64, 95); 1834 values->position = __gen_unpack_uint(cl, 128, 191); 1835 values->uniform_buffers = __gen_unpack_uint(cl, 192, 255); 1836 values->textures = __gen_unpack_uint(cl, 256, 319); 1837 values->samplers = __gen_unpack_uint(cl, 320, 383); 1838 values->push_uniforms = __gen_unpack_uint(cl, 384, 447); 1839 values->state = __gen_unpack_uint(cl, 448, 511); 1840 values->attribute_buffers = __gen_unpack_uint(cl, 512, 575); 1841 values->attributes = __gen_unpack_uint(cl, 576, 639); 1842 values->varying_buffers = __gen_unpack_uint(cl, 640, 703); 1843 values->varyings = __gen_unpack_uint(cl, 704, 767); 1844 values->viewport = __gen_unpack_uint(cl, 768, 831); 1845 values->occlusion = __gen_unpack_uint(cl, 832, 895); 1846 values->thread_storage = __gen_unpack_uint(cl, 896, 959); 1847 values->fbd = __gen_unpack_uint(cl, 896, 959); 1848} 1849 1850static inline void 1851MALI_DRAW_print(FILE *fp, const struct MALI_DRAW * values, unsigned indent) 1852{ 1853 fprintf(fp, "%*sFour Components Per Vertex: %s\n", indent, "", values->four_components_per_vertex ? "true" : "false"); 1854 fprintf(fp, "%*sDraw Descriptor Is 64b: %s\n", indent, "", values->draw_descriptor_is_64b ? "true" : "false"); 1855 fprintf(fp, "%*sTexture Descriptor Is 64b: %s\n", indent, "", values->texture_descriptor_is_64b ? "true" : "false"); 1856 fprintf(fp, "%*sOcclusion query: %s\n", indent, "", mali_occlusion_mode_as_str(values->occlusion_query)); 1857 fprintf(fp, "%*sFront face CCW: %s\n", indent, "", values->front_face_ccw ? "true" : "false"); 1858 fprintf(fp, "%*sCull front face: %s\n", indent, "", values->cull_front_face ? "true" : "false"); 1859 fprintf(fp, "%*sCull back face: %s\n", indent, "", values->cull_back_face ? "true" : "false"); 1860 fprintf(fp, "%*sFlat Shading Vertex: %u\n", indent, "", values->flat_shading_vertex); 1861 fprintf(fp, "%*sPrimitive Barrier: %s\n", indent, "", values->primitive_barrier ? "true" : "false"); 1862 fprintf(fp, "%*sClean Fragment Write: %s\n", indent, "", values->clean_fragment_write ? "true" : "false"); 1863 fprintf(fp, "%*sInstance Size: %u\n", indent, "", values->instance_size); 1864 fprintf(fp, "%*sInstance Primitive Size: %u\n", indent, "", values->instance_primitive_size); 1865 fprintf(fp, "%*sOffset start: %u\n", indent, "", values->offset_start); 1866 fprintf(fp, "%*sPrimitive Index Base: %u\n", indent, "", values->primitive_index_base); 1867 fprintf(fp, "%*sPosition: 0x%" PRIx64 "\n", indent, "", values->position); 1868 fprintf(fp, "%*sUniform buffers: 0x%" PRIx64 "\n", indent, "", values->uniform_buffers); 1869 fprintf(fp, "%*sTextures: 0x%" PRIx64 "\n", indent, "", values->textures); 1870 fprintf(fp, "%*sSamplers: 0x%" PRIx64 "\n", indent, "", values->samplers); 1871 fprintf(fp, "%*sPush uniforms: 0x%" PRIx64 "\n", indent, "", values->push_uniforms); 1872 fprintf(fp, "%*sState: 0x%" PRIx64 "\n", indent, "", values->state); 1873 fprintf(fp, "%*sAttribute buffers: 0x%" PRIx64 "\n", indent, "", values->attribute_buffers); 1874 fprintf(fp, "%*sAttributes: 0x%" PRIx64 "\n", indent, "", values->attributes); 1875 fprintf(fp, "%*sVarying buffers: 0x%" PRIx64 "\n", indent, "", values->varying_buffers); 1876 fprintf(fp, "%*sVaryings: 0x%" PRIx64 "\n", indent, "", values->varyings); 1877 fprintf(fp, "%*sViewport: 0x%" PRIx64 "\n", indent, "", values->viewport); 1878 fprintf(fp, "%*sOcclusion: 0x%" PRIx64 "\n", indent, "", values->occlusion); 1879 fprintf(fp, "%*sThread Storage: 0x%" PRIx64 "\n", indent, "", values->thread_storage); 1880 fprintf(fp, "%*sFBD: 0x%" PRIx64 "\n", indent, "", values->fbd); 1881} 1882 1883struct MALI_SURFACE { 1884 uint64_t pointer; 1885}; 1886 1887#define MALI_SURFACE_header \ 1888 0 1889 1890static inline void 1891MALI_SURFACE_pack(uint32_t * restrict cl, 1892 const struct MALI_SURFACE * restrict values) 1893{ 1894 cl[ 0] = __gen_uint(values->pointer, 0, 63); 1895 cl[ 1] = __gen_uint(values->pointer, 0, 63) >> 32; 1896} 1897 1898 1899#define MALI_SURFACE_LENGTH 8 1900#define MALI_SURFACE_ALIGN 8 1901struct mali_surface_packed { uint32_t opaque[2]; }; 1902static inline void 1903MALI_SURFACE_unpack(const uint8_t * restrict cl, 1904 struct MALI_SURFACE * restrict values) 1905{ 1906 values->pointer = __gen_unpack_uint(cl, 0, 63); 1907} 1908 1909static inline void 1910MALI_SURFACE_print(FILE *fp, const struct MALI_SURFACE * values, unsigned indent) 1911{ 1912 fprintf(fp, "%*sPointer: 0x%" PRIx64 "\n", indent, "", values->pointer); 1913} 1914 1915struct MALI_SURFACE_WITH_STRIDE { 1916 uint64_t pointer; 1917 int32_t row_stride; 1918 int32_t surface_stride; 1919}; 1920 1921#define MALI_SURFACE_WITH_STRIDE_header \ 1922 0 1923 1924static inline void 1925MALI_SURFACE_WITH_STRIDE_pack(uint32_t * restrict cl, 1926 const struct MALI_SURFACE_WITH_STRIDE * restrict values) 1927{ 1928 cl[ 0] = __gen_uint(values->pointer, 0, 63); 1929 cl[ 1] = __gen_uint(values->pointer, 0, 63) >> 32; 1930 cl[ 2] = __gen_sint(values->row_stride, 0, 31); 1931 cl[ 3] = __gen_sint(values->surface_stride, 0, 31); 1932} 1933 1934 1935#define MALI_SURFACE_WITH_STRIDE_LENGTH 16 1936#define MALI_SURFACE_WITH_STRIDE_ALIGN 8 1937struct mali_surface_with_stride_packed { uint32_t opaque[4]; }; 1938static inline void 1939MALI_SURFACE_WITH_STRIDE_unpack(const uint8_t * restrict cl, 1940 struct MALI_SURFACE_WITH_STRIDE * restrict values) 1941{ 1942 values->pointer = __gen_unpack_uint(cl, 0, 63); 1943 values->row_stride = __gen_unpack_sint(cl, 64, 95); 1944 values->surface_stride = __gen_unpack_sint(cl, 96, 127); 1945} 1946 1947static inline void 1948MALI_SURFACE_WITH_STRIDE_print(FILE *fp, const struct MALI_SURFACE_WITH_STRIDE * values, unsigned indent) 1949{ 1950 fprintf(fp, "%*sPointer: 0x%" PRIx64 "\n", indent, "", values->pointer); 1951 fprintf(fp, "%*sRow stride: %d\n", indent, "", values->row_stride); 1952 fprintf(fp, "%*sSurface stride: %d\n", indent, "", values->surface_stride); 1953} 1954 1955struct MALI_SAMPLER { 1956 bool magnify_nearest; 1957 bool minify_nearest; 1958 enum mali_mipmap_mode mipmap_mode; 1959 bool normalized_coordinates; 1960 bool isotropic_lod; 1961 int32_t lod_bias; 1962 uint32_t minimum_lod; 1963 uint32_t maximum_lod; 1964 enum mali_wrap_mode wrap_mode_s; 1965 enum mali_wrap_mode wrap_mode_t; 1966 enum mali_wrap_mode wrap_mode_r; 1967 enum mali_func compare_function; 1968 bool seamless_cube_map; 1969 uint32_t border_color_r; 1970 uint32_t border_color_g; 1971 uint32_t border_color_b; 1972 uint32_t border_color_a; 1973}; 1974 1975#define MALI_SAMPLER_header \ 1976 .magnify_nearest = true, \ 1977 .minify_nearest = true, \ 1978 .mipmap_mode = MALI_MIPMAP_MODE_NEAREST, \ 1979 .normalized_coordinates = true, \ 1980 .lod_bias = 0, \ 1981 .minimum_lod = 0, \ 1982 .maximum_lod = 1, \ 1983 .wrap_mode_s = MALI_WRAP_MODE_CLAMP_TO_EDGE, \ 1984 .wrap_mode_t = MALI_WRAP_MODE_CLAMP_TO_EDGE, \ 1985 .wrap_mode_r = MALI_WRAP_MODE_CLAMP_TO_EDGE, \ 1986 .compare_function = MALI_FUNC_NEVER, \ 1987 .seamless_cube_map = true, \ 1988 .border_color_r = 0.0, \ 1989 .border_color_g = 0.0, \ 1990 .border_color_b = 0.0, \ 1991 .border_color_a = 0.0 1992 1993static inline void 1994MALI_SAMPLER_pack(uint32_t * restrict cl, 1995 const struct MALI_SAMPLER * restrict values) 1996{ 1997 cl[ 0] = __gen_uint(values->magnify_nearest, 0, 0) | 1998 __gen_uint(values->minify_nearest, 1, 1) | 1999 __gen_uint(values->mipmap_mode, 3, 4) | 2000 __gen_uint(values->normalized_coordinates, 5, 5) | 2001 __gen_uint(values->isotropic_lod, 6, 6) | 2002 __gen_sint(values->lod_bias, 16, 31); 2003 cl[ 1] = __gen_uint(values->minimum_lod, 0, 15) | 2004 __gen_uint(values->maximum_lod, 16, 31); 2005 cl[ 2] = __gen_uint(values->wrap_mode_s, 0, 3) | 2006 __gen_uint(values->wrap_mode_t, 4, 7) | 2007 __gen_uint(values->wrap_mode_r, 8, 11) | 2008 __gen_uint(values->compare_function, 12, 14) | 2009 __gen_uint(values->seamless_cube_map, 15, 15); 2010 cl[ 3] = 0; 2011 cl[ 4] = __gen_uint(values->border_color_r, 0, 31); 2012 cl[ 5] = __gen_uint(values->border_color_g, 0, 31); 2013 cl[ 6] = __gen_uint(values->border_color_b, 0, 31); 2014 cl[ 7] = __gen_uint(values->border_color_a, 0, 31); 2015} 2016 2017 2018#define MALI_SAMPLER_LENGTH 32 2019#define MALI_SAMPLER_ALIGN 32 2020struct mali_sampler_packed { uint32_t opaque[8]; }; 2021static inline void 2022MALI_SAMPLER_unpack(const uint8_t * restrict cl, 2023 struct MALI_SAMPLER * restrict values) 2024{ 2025 if (((const uint32_t *) cl)[0] & 0xff84) fprintf(stderr, "XXX: Invalid field of Sampler unpacked at word 0\n"); 2026 if (((const uint32_t *) cl)[2] & 0xffff0000) fprintf(stderr, "XXX: Invalid field of Sampler unpacked at word 2\n"); 2027 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Sampler unpacked at word 3\n"); 2028 values->magnify_nearest = __gen_unpack_uint(cl, 0, 0); 2029 values->minify_nearest = __gen_unpack_uint(cl, 1, 1); 2030 values->mipmap_mode = (enum mali_mipmap_mode)__gen_unpack_uint(cl, 3, 4); 2031 values->normalized_coordinates = __gen_unpack_uint(cl, 5, 5); 2032 values->isotropic_lod = __gen_unpack_uint(cl, 6, 6); 2033 values->lod_bias = __gen_unpack_sint(cl, 16, 31); 2034 values->minimum_lod = __gen_unpack_uint(cl, 32, 47); 2035 values->maximum_lod = __gen_unpack_uint(cl, 48, 63); 2036 values->wrap_mode_s = (enum mali_wrap_mode)__gen_unpack_uint(cl, 64, 67); 2037 values->wrap_mode_t = (enum mali_wrap_mode)__gen_unpack_uint(cl, 68, 71); 2038 values->wrap_mode_r = (enum mali_wrap_mode)__gen_unpack_uint(cl, 72, 75); 2039 values->compare_function = (enum mali_func)__gen_unpack_uint(cl, 76, 78); 2040 values->seamless_cube_map = __gen_unpack_uint(cl, 79, 79); 2041 values->border_color_r = __gen_unpack_uint(cl, 128, 159); 2042 values->border_color_g = __gen_unpack_uint(cl, 160, 191); 2043 values->border_color_b = __gen_unpack_uint(cl, 192, 223); 2044 values->border_color_a = __gen_unpack_uint(cl, 224, 255); 2045} 2046 2047static inline void 2048MALI_SAMPLER_print(FILE *fp, const struct MALI_SAMPLER * values, unsigned indent) 2049{ 2050 fprintf(fp, "%*sMagnify Nearest: %s\n", indent, "", values->magnify_nearest ? "true" : "false"); 2051 fprintf(fp, "%*sMinify Nearest: %s\n", indent, "", values->minify_nearest ? "true" : "false"); 2052 fprintf(fp, "%*sMipmap Mode: %s\n", indent, "", mali_mipmap_mode_as_str(values->mipmap_mode)); 2053 fprintf(fp, "%*sNormalized Coordinates: %s\n", indent, "", values->normalized_coordinates ? "true" : "false"); 2054 fprintf(fp, "%*sIsotropic LOD: %s\n", indent, "", values->isotropic_lod ? "true" : "false"); 2055 fprintf(fp, "%*sLOD Bias: %d\n", indent, "", values->lod_bias); 2056 fprintf(fp, "%*sMinimum LOD: %u\n", indent, "", values->minimum_lod); 2057 fprintf(fp, "%*sMaximum LOD: %u\n", indent, "", values->maximum_lod); 2058 fprintf(fp, "%*sWrap Mode S: %s\n", indent, "", mali_wrap_mode_as_str(values->wrap_mode_s)); 2059 fprintf(fp, "%*sWrap Mode T: %s\n", indent, "", mali_wrap_mode_as_str(values->wrap_mode_t)); 2060 fprintf(fp, "%*sWrap Mode R: %s\n", indent, "", mali_wrap_mode_as_str(values->wrap_mode_r)); 2061 fprintf(fp, "%*sCompare Function: %s\n", indent, "", mali_func_as_str(values->compare_function)); 2062 fprintf(fp, "%*sSeamless Cube Map: %s\n", indent, "", values->seamless_cube_map ? "true" : "false"); 2063 fprintf(fp, "%*sBorder Color R: 0x%X (%f)\n", indent, "", values->border_color_r, uif(values->border_color_r)); 2064 fprintf(fp, "%*sBorder Color G: 0x%X (%f)\n", indent, "", values->border_color_g, uif(values->border_color_g)); 2065 fprintf(fp, "%*sBorder Color B: 0x%X (%f)\n", indent, "", values->border_color_b, uif(values->border_color_b)); 2066 fprintf(fp, "%*sBorder Color A: 0x%X (%f)\n", indent, "", values->border_color_a, uif(values->border_color_a)); 2067} 2068 2069struct MALI_TEXTURE { 2070 uint32_t width; 2071 uint32_t height; 2072 uint32_t depth; 2073 uint32_t sample_count; 2074 uint32_t array_size; 2075 uint32_t format; 2076 enum mali_texture_dimension dimension; 2077 enum mali_texture_layout texel_ordering; 2078 bool surface_pointer_is_64b; 2079 bool manual_stride; 2080 uint32_t levels; 2081 uint32_t swizzle; 2082}; 2083 2084#define MALI_TEXTURE_header \ 2085 .depth = 1, \ 2086 .sample_count = 1, \ 2087 .surface_pointer_is_64b = true, \ 2088 .manual_stride = false, \ 2089 .levels = 1 2090 2091static inline void 2092MALI_TEXTURE_pack(uint32_t * restrict cl, 2093 const struct MALI_TEXTURE * restrict values) 2094{ 2095 assert(values->width >= 1); 2096 assert(values->height >= 1); 2097 assert(values->depth >= 1); 2098 assert(values->sample_count >= 1); 2099 assert(values->array_size >= 1); 2100 assert(values->levels >= 1); 2101 cl[ 0] = __gen_uint(values->width - 1, 0, 15) | 2102 __gen_uint(values->height - 1, 16, 31); 2103 cl[ 1] = __gen_uint(values->depth - 1, 0, 15) | 2104 __gen_uint(values->sample_count - 1, 0, 15) | 2105 __gen_uint(values->array_size - 1, 16, 31); 2106 cl[ 2] = __gen_uint(values->format, 0, 21) | 2107 __gen_uint(values->dimension, 22, 23) | 2108 __gen_uint(values->texel_ordering, 24, 27) | 2109 __gen_uint(values->surface_pointer_is_64b, 28, 28) | 2110 __gen_uint(values->manual_stride, 29, 29); 2111 cl[ 3] = __gen_uint(values->levels - 1, 24, 31); 2112 cl[ 4] = __gen_uint(values->swizzle, 0, 11); 2113 cl[ 5] = 0; 2114 cl[ 6] = 0; 2115 cl[ 7] = 0; 2116} 2117 2118 2119#define MALI_TEXTURE_LENGTH 32 2120#define MALI_TEXTURE_ALIGN 64 2121struct mali_texture_packed { uint32_t opaque[8]; }; 2122static inline void 2123MALI_TEXTURE_unpack(const uint8_t * restrict cl, 2124 struct MALI_TEXTURE * restrict values) 2125{ 2126 if (((const uint32_t *) cl)[2] & 0xc0000000) fprintf(stderr, "XXX: Invalid field of Texture unpacked at word 2\n"); 2127 if (((const uint32_t *) cl)[3] & 0xffffff) fprintf(stderr, "XXX: Invalid field of Texture unpacked at word 3\n"); 2128 if (((const uint32_t *) cl)[4] & 0xfffff000) fprintf(stderr, "XXX: Invalid field of Texture unpacked at word 4\n"); 2129 if (((const uint32_t *) cl)[5] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Texture unpacked at word 5\n"); 2130 if (((const uint32_t *) cl)[6] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Texture unpacked at word 6\n"); 2131 if (((const uint32_t *) cl)[7] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Texture unpacked at word 7\n"); 2132 values->width = __gen_unpack_uint(cl, 0, 15) + 1; 2133 values->height = __gen_unpack_uint(cl, 16, 31) + 1; 2134 values->depth = __gen_unpack_uint(cl, 32, 47) + 1; 2135 values->sample_count = __gen_unpack_uint(cl, 32, 47) + 1; 2136 values->array_size = __gen_unpack_uint(cl, 48, 63) + 1; 2137 values->format = __gen_unpack_uint(cl, 64, 85); 2138 values->dimension = (enum mali_texture_dimension)__gen_unpack_uint(cl, 86, 87); 2139 values->texel_ordering = (enum mali_texture_layout)__gen_unpack_uint(cl, 88, 91); 2140 values->surface_pointer_is_64b = __gen_unpack_uint(cl, 92, 92); 2141 values->manual_stride = __gen_unpack_uint(cl, 93, 93); 2142 values->levels = __gen_unpack_uint(cl, 120, 127) + 1; 2143 values->swizzle = __gen_unpack_uint(cl, 128, 139); 2144} 2145 2146static inline void 2147MALI_TEXTURE_print(FILE *fp, const struct MALI_TEXTURE * values, unsigned indent) 2148{ 2149 fprintf(fp, "%*sWidth: %u\n", indent, "", values->width); 2150 fprintf(fp, "%*sHeight: %u\n", indent, "", values->height); 2151 fprintf(fp, "%*sDepth: %u\n", indent, "", values->depth); 2152 fprintf(fp, "%*sSample count: %u\n", indent, "", values->sample_count); 2153 fprintf(fp, "%*sArray size: %u\n", indent, "", values->array_size); 2154 mali_pixel_format_print(fp, values->format); 2155 fprintf(fp, "%*sDimension: %s\n", indent, "", mali_texture_dimension_as_str(values->dimension)); 2156 fprintf(fp, "%*sTexel ordering: %s\n", indent, "", mali_texture_layout_as_str(values->texel_ordering)); 2157 fprintf(fp, "%*sSurface pointer is 64b: %s\n", indent, "", values->surface_pointer_is_64b ? "true" : "false"); 2158 fprintf(fp, "%*sManual stride: %s\n", indent, "", values->manual_stride ? "true" : "false"); 2159 fprintf(fp, "%*sLevels: %u\n", indent, "", values->levels); 2160 fprintf(fp, "%*sSwizzle: %u\n", indent, "", values->swizzle); 2161} 2162 2163enum mali_fp_mode { 2164 MALI_FP_MODE_GL_INF_NAN_ALLOWED = 0, 2165 MALI_FP_MODE_GL_INF_NAN_SUPPRESSED = 1, 2166 MALI_FP_MODE_CL = 2, 2167 MALI_FP_MODE_D3D11 = 3, 2168}; 2169 2170static inline const char * 2171mali_fp_mode_as_str(enum mali_fp_mode imm) 2172{ 2173 switch (imm) { 2174 case MALI_FP_MODE_GL_INF_NAN_ALLOWED: return "GL Inf/NaN Allowed"; 2175 case MALI_FP_MODE_GL_INF_NAN_SUPPRESSED: return "GL Inf/NaN Suppressed"; 2176 case MALI_FP_MODE_CL: return "CL"; 2177 case MALI_FP_MODE_D3D11: return "D3D11"; 2178 default: return "XXX: INVALID"; 2179 } 2180} 2181 2182struct MALI_RENDERER_PROPERTIES { 2183 uint32_t uniform_buffer_count; 2184 enum mali_depth_source depth_source; 2185 bool shader_contains_barrier; 2186 bool force_early_z; 2187 bool shader_contains_discard; 2188 bool shader_has_side_effects; 2189 bool shader_reads_tilebuffer; 2190 bool forward_pixel_kill; 2191 uint32_t work_register_count; 2192 uint32_t uniform_count; 2193 bool stencil_from_shader; 2194 enum mali_fp_mode fp_mode; 2195}; 2196 2197#define MALI_RENDERER_PROPERTIES_header \ 2198 .depth_source = MALI_DEPTH_SOURCE_MINIMUM 2199 2200static inline void 2201MALI_RENDERER_PROPERTIES_pack(uint32_t * restrict cl, 2202 const struct MALI_RENDERER_PROPERTIES * restrict values) 2203{ 2204 cl[ 0] = __gen_uint(values->uniform_buffer_count, 0, 7) | 2205 __gen_uint(values->depth_source, 8, 9) | 2206 __gen_uint(values->shader_contains_barrier, 11, 11) | 2207 __gen_uint(values->force_early_z, 10, 10) | 2208 __gen_uint(values->shader_contains_discard, 12, 12) | 2209 __gen_uint(values->shader_has_side_effects, 13, 13) | 2210 __gen_uint(values->shader_reads_tilebuffer, 14, 14) | 2211 __gen_uint(values->forward_pixel_kill, 15, 15) | 2212 __gen_uint(values->work_register_count, 16, 20) | 2213 __gen_uint(values->uniform_count, 21, 25) | 2214 __gen_uint(values->stencil_from_shader, 28, 28) | 2215 __gen_uint(values->fp_mode, 29, 31); 2216} 2217 2218 2219#define MALI_RENDERER_PROPERTIES_LENGTH 4 2220struct mali_renderer_properties_packed { uint32_t opaque[1]; }; 2221static inline void 2222MALI_RENDERER_PROPERTIES_unpack(const uint8_t * restrict cl, 2223 struct MALI_RENDERER_PROPERTIES * restrict values) 2224{ 2225 if (((const uint32_t *) cl)[0] & 0xc000000) fprintf(stderr, "XXX: Invalid field of Renderer Properties unpacked at word 0\n"); 2226 values->uniform_buffer_count = __gen_unpack_uint(cl, 0, 7); 2227 values->depth_source = (enum mali_depth_source)__gen_unpack_uint(cl, 8, 9); 2228 values->shader_contains_barrier = __gen_unpack_uint(cl, 11, 11); 2229 values->force_early_z = __gen_unpack_uint(cl, 10, 10); 2230 values->shader_contains_discard = __gen_unpack_uint(cl, 12, 12); 2231 values->shader_has_side_effects = __gen_unpack_uint(cl, 13, 13); 2232 values->shader_reads_tilebuffer = __gen_unpack_uint(cl, 14, 14); 2233 values->forward_pixel_kill = __gen_unpack_uint(cl, 15, 15); 2234 values->work_register_count = __gen_unpack_uint(cl, 16, 20); 2235 values->uniform_count = __gen_unpack_uint(cl, 21, 25); 2236 values->stencil_from_shader = __gen_unpack_uint(cl, 28, 28); 2237 values->fp_mode = (enum mali_fp_mode)__gen_unpack_uint(cl, 29, 31); 2238} 2239 2240static inline void 2241MALI_RENDERER_PROPERTIES_print(FILE *fp, const struct MALI_RENDERER_PROPERTIES * values, unsigned indent) 2242{ 2243 fprintf(fp, "%*sUniform buffer count: %u\n", indent, "", values->uniform_buffer_count); 2244 fprintf(fp, "%*sDepth source: %s\n", indent, "", mali_depth_source_as_str(values->depth_source)); 2245 fprintf(fp, "%*sShader contains barrier: %s\n", indent, "", values->shader_contains_barrier ? "true" : "false"); 2246 fprintf(fp, "%*sForce early-z: %s\n", indent, "", values->force_early_z ? "true" : "false"); 2247 fprintf(fp, "%*sShader contains discard: %s\n", indent, "", values->shader_contains_discard ? "true" : "false"); 2248 fprintf(fp, "%*sShader has side-effects: %s\n", indent, "", values->shader_has_side_effects ? "true" : "false"); 2249 fprintf(fp, "%*sShader reads tilebuffer: %s\n", indent, "", values->shader_reads_tilebuffer ? "true" : "false"); 2250 fprintf(fp, "%*sForward pixel kill: %s\n", indent, "", values->forward_pixel_kill ? "true" : "false"); 2251 fprintf(fp, "%*sWork register count: %u\n", indent, "", values->work_register_count); 2252 fprintf(fp, "%*sUniform count: %u\n", indent, "", values->uniform_count); 2253 fprintf(fp, "%*sStencil from shader: %s\n", indent, "", values->stencil_from_shader ? "true" : "false"); 2254 fprintf(fp, "%*sFP mode: %s\n", indent, "", mali_fp_mode_as_str(values->fp_mode)); 2255} 2256 2257struct MALI_SHADER { 2258 uint64_t shader; 2259 uint32_t sampler_count; 2260 uint32_t texture_count; 2261 uint32_t attribute_count; 2262 uint32_t varying_count; 2263}; 2264 2265#define MALI_SHADER_header \ 2266 0 2267 2268static inline void 2269MALI_SHADER_pack(uint32_t * restrict cl, 2270 const struct MALI_SHADER * restrict values) 2271{ 2272 cl[ 0] = __gen_uint(values->shader, 0, 63); 2273 cl[ 1] = __gen_uint(values->shader, 0, 63) >> 32; 2274 cl[ 2] = __gen_uint(values->sampler_count, 0, 15) | 2275 __gen_uint(values->texture_count, 16, 31); 2276 cl[ 3] = __gen_uint(values->attribute_count, 0, 15) | 2277 __gen_uint(values->varying_count, 16, 31); 2278} 2279 2280 2281#define MALI_SHADER_LENGTH 16 2282struct mali_shader_packed { uint32_t opaque[4]; }; 2283static inline void 2284MALI_SHADER_unpack(const uint8_t * restrict cl, 2285 struct MALI_SHADER * restrict values) 2286{ 2287 values->shader = __gen_unpack_uint(cl, 0, 63); 2288 values->sampler_count = __gen_unpack_uint(cl, 64, 79); 2289 values->texture_count = __gen_unpack_uint(cl, 80, 95); 2290 values->attribute_count = __gen_unpack_uint(cl, 96, 111); 2291 values->varying_count = __gen_unpack_uint(cl, 112, 127); 2292} 2293 2294static inline void 2295MALI_SHADER_print(FILE *fp, const struct MALI_SHADER * values, unsigned indent) 2296{ 2297 fprintf(fp, "%*sShader: 0x%" PRIx64 "\n", indent, "", values->shader); 2298 fprintf(fp, "%*sSampler count: %u\n", indent, "", values->sampler_count); 2299 fprintf(fp, "%*sTexture count: %u\n", indent, "", values->texture_count); 2300 fprintf(fp, "%*sAttribute count: %u\n", indent, "", values->attribute_count); 2301 fprintf(fp, "%*sVarying count: %u\n", indent, "", values->varying_count); 2302} 2303 2304struct MALI_MULTISAMPLE_MISC { 2305 uint32_t sample_mask; 2306 bool multisample_enable; 2307 bool multisample_late_coverage; 2308 bool evaluate_per_sample; 2309 bool fixed_function_depth_range_fixed; 2310 bool shader_depth_range_fixed; 2311 bool load_destination; 2312 bool blend_shader; 2313 bool blend_shader_discard; 2314 enum mali_func depth_function; 2315 bool depth_write_mask; 2316 bool fixed_function_near_discard; 2317 bool fixed_function_far_discard; 2318 bool fragment_near_discard; 2319 bool fragment_far_discard; 2320}; 2321 2322#define MALI_MULTISAMPLE_MISC_header \ 2323 0 2324 2325static inline void 2326MALI_MULTISAMPLE_MISC_pack(uint32_t * restrict cl, 2327 const struct MALI_MULTISAMPLE_MISC * restrict values) 2328{ 2329 cl[ 0] = __gen_uint(values->sample_mask, 0, 15) | 2330 __gen_uint(values->multisample_enable, 16, 16) | 2331 __gen_uint(values->multisample_late_coverage, 17, 17) | 2332 __gen_uint(values->evaluate_per_sample, 18, 18) | 2333 __gen_uint(values->fixed_function_depth_range_fixed, 19, 19) | 2334 __gen_uint(values->shader_depth_range_fixed, 20, 20) | 2335 __gen_uint(values->load_destination, 21, 21) | 2336 __gen_uint(values->blend_shader, 22, 22) | 2337 __gen_uint(values->blend_shader_discard, 23, 23) | 2338 __gen_uint(values->depth_function, 24, 26) | 2339 __gen_uint(values->depth_write_mask, 27, 27) | 2340 __gen_uint(values->fixed_function_near_discard, 28, 28) | 2341 __gen_uint(values->fixed_function_far_discard, 29, 29) | 2342 __gen_uint(values->fragment_near_discard, 30, 30) | 2343 __gen_uint(values->fragment_far_discard, 31, 31); 2344} 2345 2346 2347#define MALI_MULTISAMPLE_MISC_LENGTH 4 2348struct mali_multisample_misc_packed { uint32_t opaque[1]; }; 2349static inline void 2350MALI_MULTISAMPLE_MISC_unpack(const uint8_t * restrict cl, 2351 struct MALI_MULTISAMPLE_MISC * restrict values) 2352{ 2353 values->sample_mask = __gen_unpack_uint(cl, 0, 15); 2354 values->multisample_enable = __gen_unpack_uint(cl, 16, 16); 2355 values->multisample_late_coverage = __gen_unpack_uint(cl, 17, 17); 2356 values->evaluate_per_sample = __gen_unpack_uint(cl, 18, 18); 2357 values->fixed_function_depth_range_fixed = __gen_unpack_uint(cl, 19, 19); 2358 values->shader_depth_range_fixed = __gen_unpack_uint(cl, 20, 20); 2359 values->load_destination = __gen_unpack_uint(cl, 21, 21); 2360 values->blend_shader = __gen_unpack_uint(cl, 22, 22); 2361 values->blend_shader_discard = __gen_unpack_uint(cl, 23, 23); 2362 values->depth_function = (enum mali_func)__gen_unpack_uint(cl, 24, 26); 2363 values->depth_write_mask = __gen_unpack_uint(cl, 27, 27); 2364 values->fixed_function_near_discard = __gen_unpack_uint(cl, 28, 28); 2365 values->fixed_function_far_discard = __gen_unpack_uint(cl, 29, 29); 2366 values->fragment_near_discard = __gen_unpack_uint(cl, 30, 30); 2367 values->fragment_far_discard = __gen_unpack_uint(cl, 31, 31); 2368} 2369 2370static inline void 2371MALI_MULTISAMPLE_MISC_print(FILE *fp, const struct MALI_MULTISAMPLE_MISC * values, unsigned indent) 2372{ 2373 fprintf(fp, "%*sSample mask: %u\n", indent, "", values->sample_mask); 2374 fprintf(fp, "%*sMultisample enable: %s\n", indent, "", values->multisample_enable ? "true" : "false"); 2375 fprintf(fp, "%*sMultisample late coverage: %s\n", indent, "", values->multisample_late_coverage ? "true" : "false"); 2376 fprintf(fp, "%*sEvaluate per-sample: %s\n", indent, "", values->evaluate_per_sample ? "true" : "false"); 2377 fprintf(fp, "%*sFixed-function depth range fixed: %s\n", indent, "", values->fixed_function_depth_range_fixed ? "true" : "false"); 2378 fprintf(fp, "%*sShader depth range fixed: %s\n", indent, "", values->shader_depth_range_fixed ? "true" : "false"); 2379 fprintf(fp, "%*sLoad destination: %s\n", indent, "", values->load_destination ? "true" : "false"); 2380 fprintf(fp, "%*sBlend shader: %s\n", indent, "", values->blend_shader ? "true" : "false"); 2381 fprintf(fp, "%*sBlend shader discard: %s\n", indent, "", values->blend_shader_discard ? "true" : "false"); 2382 fprintf(fp, "%*sDepth function: %s\n", indent, "", mali_func_as_str(values->depth_function)); 2383 fprintf(fp, "%*sDepth write mask: %s\n", indent, "", values->depth_write_mask ? "true" : "false"); 2384 fprintf(fp, "%*sFixed-function near discard: %s\n", indent, "", values->fixed_function_near_discard ? "true" : "false"); 2385 fprintf(fp, "%*sFixed-function far discard: %s\n", indent, "", values->fixed_function_far_discard ? "true" : "false"); 2386 fprintf(fp, "%*sFragment near discard: %s\n", indent, "", values->fragment_near_discard ? "true" : "false"); 2387 fprintf(fp, "%*sFragment far discard: %s\n", indent, "", values->fragment_far_discard ? "true" : "false"); 2388} 2389 2390struct MALI_STENCIL_MASK_MISC { 2391 uint32_t stencil_mask_front; 2392 uint32_t stencil_mask_back; 2393 bool stencil_enable; 2394 bool alpha_to_coverage; 2395 bool alpha_to_coverage_invert; 2396 bool alpha_to_one; 2397 bool write_enable; 2398 enum mali_func alpha_test_compare_function; 2399 bool srgb; 2400 bool dither_disable; 2401 bool force_seamless_cubemaps; 2402 bool depth_range_1; 2403 bool depth_range_2; 2404 bool single_sampled_lines; 2405 bool point_snap; 2406}; 2407 2408#define MALI_STENCIL_MASK_MISC_header \ 2409 0 2410 2411static inline void 2412MALI_STENCIL_MASK_MISC_pack(uint32_t * restrict cl, 2413 const struct MALI_STENCIL_MASK_MISC * restrict values) 2414{ 2415 cl[ 0] = __gen_uint(values->stencil_mask_front, 0, 7) | 2416 __gen_uint(values->stencil_mask_back, 8, 15) | 2417 __gen_uint(values->stencil_enable, 16, 16) | 2418 __gen_uint(values->alpha_to_coverage, 17, 17) | 2419 __gen_uint(values->alpha_to_coverage_invert, 18, 18) | 2420 __gen_uint(values->alpha_to_one, 19, 19) | 2421 __gen_uint(values->write_enable, 20, 20) | 2422 __gen_uint(values->alpha_test_compare_function, 21, 23) | 2423 __gen_uint(values->srgb, 24, 24) | 2424 __gen_uint(values->dither_disable, 25, 25) | 2425 __gen_uint(values->force_seamless_cubemaps, 26, 26) | 2426 __gen_uint(values->depth_range_1, 28, 28) | 2427 __gen_uint(values->depth_range_2, 29, 29) | 2428 __gen_uint(values->single_sampled_lines, 30, 30) | 2429 __gen_uint(values->point_snap, 31, 31); 2430} 2431 2432 2433#define MALI_STENCIL_MASK_MISC_LENGTH 4 2434struct mali_stencil_mask_misc_packed { uint32_t opaque[1]; }; 2435static inline void 2436MALI_STENCIL_MASK_MISC_unpack(const uint8_t * restrict cl, 2437 struct MALI_STENCIL_MASK_MISC * restrict values) 2438{ 2439 if (((const uint32_t *) cl)[0] & 0x8000000) fprintf(stderr, "XXX: Invalid field of Stencil Mask, Misc unpacked at word 0\n"); 2440 values->stencil_mask_front = __gen_unpack_uint(cl, 0, 7); 2441 values->stencil_mask_back = __gen_unpack_uint(cl, 8, 15); 2442 values->stencil_enable = __gen_unpack_uint(cl, 16, 16); 2443 values->alpha_to_coverage = __gen_unpack_uint(cl, 17, 17); 2444 values->alpha_to_coverage_invert = __gen_unpack_uint(cl, 18, 18); 2445 values->alpha_to_one = __gen_unpack_uint(cl, 19, 19); 2446 values->write_enable = __gen_unpack_uint(cl, 20, 20); 2447 values->alpha_test_compare_function = (enum mali_func)__gen_unpack_uint(cl, 21, 23); 2448 values->srgb = __gen_unpack_uint(cl, 24, 24); 2449 values->dither_disable = __gen_unpack_uint(cl, 25, 25); 2450 values->force_seamless_cubemaps = __gen_unpack_uint(cl, 26, 26); 2451 values->depth_range_1 = __gen_unpack_uint(cl, 28, 28); 2452 values->depth_range_2 = __gen_unpack_uint(cl, 29, 29); 2453 values->single_sampled_lines = __gen_unpack_uint(cl, 30, 30); 2454 values->point_snap = __gen_unpack_uint(cl, 31, 31); 2455} 2456 2457static inline void 2458MALI_STENCIL_MASK_MISC_print(FILE *fp, const struct MALI_STENCIL_MASK_MISC * values, unsigned indent) 2459{ 2460 fprintf(fp, "%*sStencil mask front: %u\n", indent, "", values->stencil_mask_front); 2461 fprintf(fp, "%*sStencil mask back: %u\n", indent, "", values->stencil_mask_back); 2462 fprintf(fp, "%*sStencil enable: %s\n", indent, "", values->stencil_enable ? "true" : "false"); 2463 fprintf(fp, "%*sAlpha-to-coverage: %s\n", indent, "", values->alpha_to_coverage ? "true" : "false"); 2464 fprintf(fp, "%*sAlpha-to-coverage Invert: %s\n", indent, "", values->alpha_to_coverage_invert ? "true" : "false"); 2465 fprintf(fp, "%*sAlpha to one: %s\n", indent, "", values->alpha_to_one ? "true" : "false"); 2466 fprintf(fp, "%*sWrite enable: %s\n", indent, "", values->write_enable ? "true" : "false"); 2467 fprintf(fp, "%*sAlpha test compare function: %s\n", indent, "", mali_func_as_str(values->alpha_test_compare_function)); 2468 fprintf(fp, "%*ssRGB: %s\n", indent, "", values->srgb ? "true" : "false"); 2469 fprintf(fp, "%*sDither disable: %s\n", indent, "", values->dither_disable ? "true" : "false"); 2470 fprintf(fp, "%*sForce seamless cubemaps: %s\n", indent, "", values->force_seamless_cubemaps ? "true" : "false"); 2471 fprintf(fp, "%*sDepth Range 1: %s\n", indent, "", values->depth_range_1 ? "true" : "false"); 2472 fprintf(fp, "%*sDepth Range 2: %s\n", indent, "", values->depth_range_2 ? "true" : "false"); 2473 fprintf(fp, "%*sSingle-sampled lines: %s\n", indent, "", values->single_sampled_lines ? "true" : "false"); 2474 fprintf(fp, "%*sPoint snap: %s\n", indent, "", values->point_snap ? "true" : "false"); 2475} 2476 2477struct MALI_STENCIL { 2478 uint32_t reference_value; 2479 uint32_t mask; 2480 enum mali_func compare_function; 2481 enum mali_stencil_op stencil_fail; 2482 enum mali_stencil_op depth_fail; 2483 enum mali_stencil_op depth_pass; 2484}; 2485 2486#define MALI_STENCIL_header \ 2487 0 2488 2489static inline void 2490MALI_STENCIL_pack(uint32_t * restrict cl, 2491 const struct MALI_STENCIL * restrict values) 2492{ 2493 cl[ 0] = __gen_uint(values->reference_value, 0, 7) | 2494 __gen_uint(values->mask, 8, 15) | 2495 __gen_uint(values->compare_function, 16, 18) | 2496 __gen_uint(values->stencil_fail, 19, 21) | 2497 __gen_uint(values->depth_fail, 22, 24) | 2498 __gen_uint(values->depth_pass, 25, 27); 2499} 2500 2501 2502#define MALI_STENCIL_LENGTH 4 2503struct mali_stencil_packed { uint32_t opaque[1]; }; 2504static inline void 2505MALI_STENCIL_unpack(const uint8_t * restrict cl, 2506 struct MALI_STENCIL * restrict values) 2507{ 2508 if (((const uint32_t *) cl)[0] & 0xf0000000) fprintf(stderr, "XXX: Invalid field of Stencil unpacked at word 0\n"); 2509 values->reference_value = __gen_unpack_uint(cl, 0, 7); 2510 values->mask = __gen_unpack_uint(cl, 8, 15); 2511 values->compare_function = (enum mali_func)__gen_unpack_uint(cl, 16, 18); 2512 values->stencil_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 19, 21); 2513 values->depth_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 22, 24); 2514 values->depth_pass = (enum mali_stencil_op)__gen_unpack_uint(cl, 25, 27); 2515} 2516 2517static inline void 2518MALI_STENCIL_print(FILE *fp, const struct MALI_STENCIL * values, unsigned indent) 2519{ 2520 fprintf(fp, "%*sReference Value: %u\n", indent, "", values->reference_value); 2521 fprintf(fp, "%*sMask: %u\n", indent, "", values->mask); 2522 fprintf(fp, "%*sCompare Function: %s\n", indent, "", mali_func_as_str(values->compare_function)); 2523 fprintf(fp, "%*sStencil Fail: %s\n", indent, "", mali_stencil_op_as_str(values->stencil_fail)); 2524 fprintf(fp, "%*sDepth Fail: %s\n", indent, "", mali_stencil_op_as_str(values->depth_fail)); 2525 fprintf(fp, "%*sDepth Pass: %s\n", indent, "", mali_stencil_op_as_str(values->depth_pass)); 2526} 2527 2528struct MALI_RENDERER_STATE { 2529 struct MALI_SHADER shader; 2530 struct MALI_RENDERER_PROPERTIES properties; 2531 float depth_units; 2532 float depth_factor; 2533 float depth_bias_clamp; 2534 struct MALI_MULTISAMPLE_MISC multisample_misc; 2535 struct MALI_STENCIL_MASK_MISC stencil_mask_misc; 2536 struct MALI_STENCIL stencil_front; 2537 struct MALI_STENCIL stencil_back; 2538 float alpha_reference; 2539 uint32_t thread_balancing; 2540 uint64_t blend_shader; 2541 struct MALI_BLEND_EQUATION blend_equation; 2542 float blend_constant; 2543}; 2544 2545#define MALI_RENDERER_STATE_header \ 2546 .shader = { MALI_SHADER_header }, \ 2547 .properties = { MALI_RENDERER_PROPERTIES_header }, \ 2548 .multisample_misc = { MALI_MULTISAMPLE_MISC_header }, \ 2549 .stencil_mask_misc = { MALI_STENCIL_MASK_MISC_header }, \ 2550 .stencil_front = { MALI_STENCIL_header }, \ 2551 .stencil_back = { MALI_STENCIL_header }, \ 2552 .blend_equation = { MALI_BLEND_EQUATION_header } 2553 2554static inline void 2555MALI_RENDERER_STATE_pack(uint32_t * restrict cl, 2556 const struct MALI_RENDERER_STATE * restrict values) 2557{ 2558 cl[ 0] = __gen_uint(values->shader.shader, 0, 63); 2559 cl[ 1] = __gen_uint(values->shader.shader, 0, 63) >> 32; 2560 cl[ 2] = __gen_uint(values->shader.sampler_count, 0, 15) | 2561 __gen_uint(values->shader.texture_count, 16, 31); 2562 cl[ 3] = __gen_uint(values->shader.attribute_count, 0, 15) | 2563 __gen_uint(values->shader.varying_count, 16, 31); 2564 cl[ 4] = __gen_uint(values->properties.uniform_buffer_count, 0, 7) | 2565 __gen_uint(values->properties.depth_source, 8, 9) | 2566 __gen_uint(values->properties.shader_contains_barrier, 11, 11) | 2567 __gen_uint(values->properties.force_early_z, 10, 10) | 2568 __gen_uint(values->properties.shader_contains_discard, 12, 12) | 2569 __gen_uint(values->properties.shader_has_side_effects, 13, 13) | 2570 __gen_uint(values->properties.shader_reads_tilebuffer, 14, 14) | 2571 __gen_uint(values->properties.forward_pixel_kill, 15, 15) | 2572 __gen_uint(values->properties.work_register_count, 16, 20) | 2573 __gen_uint(values->properties.uniform_count, 21, 25) | 2574 __gen_uint(values->properties.stencil_from_shader, 28, 28) | 2575 __gen_uint(values->properties.fp_mode, 29, 31); 2576 cl[ 5] = __gen_uint(fui(values->depth_units), 0, 32); 2577 cl[ 6] = __gen_uint(fui(values->depth_factor), 0, 32); 2578 cl[ 7] = __gen_uint(fui(values->depth_bias_clamp), 0, 32); 2579 cl[ 8] = __gen_uint(values->multisample_misc.sample_mask, 0, 15) | 2580 __gen_uint(values->multisample_misc.multisample_enable, 16, 16) | 2581 __gen_uint(values->multisample_misc.multisample_late_coverage, 17, 17) | 2582 __gen_uint(values->multisample_misc.evaluate_per_sample, 18, 18) | 2583 __gen_uint(values->multisample_misc.fixed_function_depth_range_fixed, 19, 19) | 2584 __gen_uint(values->multisample_misc.shader_depth_range_fixed, 20, 20) | 2585 __gen_uint(values->multisample_misc.load_destination, 21, 21) | 2586 __gen_uint(values->multisample_misc.blend_shader, 22, 22) | 2587 __gen_uint(values->multisample_misc.blend_shader_discard, 23, 23) | 2588 __gen_uint(values->multisample_misc.depth_function, 24, 26) | 2589 __gen_uint(values->multisample_misc.depth_write_mask, 27, 27) | 2590 __gen_uint(values->multisample_misc.fixed_function_near_discard, 28, 28) | 2591 __gen_uint(values->multisample_misc.fixed_function_far_discard, 29, 29) | 2592 __gen_uint(values->multisample_misc.fragment_near_discard, 30, 30) | 2593 __gen_uint(values->multisample_misc.fragment_far_discard, 31, 31); 2594 cl[ 9] = __gen_uint(values->stencil_mask_misc.stencil_mask_front, 0, 7) | 2595 __gen_uint(values->stencil_mask_misc.stencil_mask_back, 8, 15) | 2596 __gen_uint(values->stencil_mask_misc.stencil_enable, 16, 16) | 2597 __gen_uint(values->stencil_mask_misc.alpha_to_coverage, 17, 17) | 2598 __gen_uint(values->stencil_mask_misc.alpha_to_coverage_invert, 18, 18) | 2599 __gen_uint(values->stencil_mask_misc.alpha_to_one, 19, 19) | 2600 __gen_uint(values->stencil_mask_misc.write_enable, 20, 20) | 2601 __gen_uint(values->stencil_mask_misc.alpha_test_compare_function, 21, 23) | 2602 __gen_uint(values->stencil_mask_misc.srgb, 24, 24) | 2603 __gen_uint(values->stencil_mask_misc.dither_disable, 25, 25) | 2604 __gen_uint(values->stencil_mask_misc.force_seamless_cubemaps, 26, 26) | 2605 __gen_uint(values->stencil_mask_misc.depth_range_1, 28, 28) | 2606 __gen_uint(values->stencil_mask_misc.depth_range_2, 29, 29) | 2607 __gen_uint(values->stencil_mask_misc.single_sampled_lines, 30, 30) | 2608 __gen_uint(values->stencil_mask_misc.point_snap, 31, 31); 2609 cl[10] = __gen_uint(values->stencil_front.reference_value, 0, 7) | 2610 __gen_uint(values->stencil_front.mask, 8, 15) | 2611 __gen_uint(values->stencil_front.compare_function, 16, 18) | 2612 __gen_uint(values->stencil_front.stencil_fail, 19, 21) | 2613 __gen_uint(values->stencil_front.depth_fail, 22, 24) | 2614 __gen_uint(values->stencil_front.depth_pass, 25, 27); 2615 cl[11] = __gen_uint(values->stencil_back.reference_value, 0, 7) | 2616 __gen_uint(values->stencil_back.mask, 8, 15) | 2617 __gen_uint(values->stencil_back.compare_function, 16, 18) | 2618 __gen_uint(values->stencil_back.stencil_fail, 19, 21) | 2619 __gen_uint(values->stencil_back.depth_fail, 22, 24) | 2620 __gen_uint(values->stencil_back.depth_pass, 25, 27); 2621 cl[12] = __gen_uint(fui(values->alpha_reference), 0, 32); 2622 cl[13] = __gen_uint(values->thread_balancing, 0, 15); 2623 cl[14] = __gen_uint(values->blend_shader, 0, 63) | 2624 __gen_uint(values->blend_equation.rgb.a, 0, 1) | 2625 __gen_uint(values->blend_equation.rgb.negate_a, 3, 3) | 2626 __gen_uint(values->blend_equation.rgb.b, 4, 5) | 2627 __gen_uint(values->blend_equation.rgb.negate_b, 7, 7) | 2628 __gen_uint(values->blend_equation.rgb.c, 8, 10) | 2629 __gen_uint(values->blend_equation.rgb.invert_c, 11, 11) | 2630 __gen_uint(values->blend_equation.alpha.a, 12, 13) | 2631 __gen_uint(values->blend_equation.alpha.negate_a, 15, 15) | 2632 __gen_uint(values->blend_equation.alpha.b, 16, 17) | 2633 __gen_uint(values->blend_equation.alpha.negate_b, 19, 19) | 2634 __gen_uint(values->blend_equation.alpha.c, 20, 22) | 2635 __gen_uint(values->blend_equation.alpha.invert_c, 23, 23) | 2636 __gen_uint(values->blend_equation.color_mask, 28, 31); 2637 cl[15] = __gen_uint(values->blend_shader, 0, 63) >> 32 | 2638 __gen_uint(fui(values->blend_constant), 0, 32); 2639} 2640 2641 2642#define MALI_RENDERER_STATE_LENGTH 64 2643#define MALI_RENDERER_STATE_ALIGN 64 2644struct mali_renderer_state_packed { uint32_t opaque[16]; }; 2645static inline void 2646MALI_RENDERER_STATE_unpack(const uint8_t * restrict cl, 2647 struct MALI_RENDERER_STATE * restrict values) 2648{ 2649 if (((const uint32_t *) cl)[4] & 0xc000000) fprintf(stderr, "XXX: Invalid field of Renderer State unpacked at word 4\n"); 2650 if (((const uint32_t *) cl)[9] & 0x8000000) fprintf(stderr, "XXX: Invalid field of Renderer State unpacked at word 9\n"); 2651 if (((const uint32_t *) cl)[10] & 0xf0000000) fprintf(stderr, "XXX: Invalid field of Renderer State unpacked at word 10\n"); 2652 if (((const uint32_t *) cl)[11] & 0xf0000000) fprintf(stderr, "XXX: Invalid field of Renderer State unpacked at word 11\n"); 2653 if (((const uint32_t *) cl)[13] & 0xffff0000) fprintf(stderr, "XXX: Invalid field of Renderer State unpacked at word 13\n"); 2654 values->shader.shader = __gen_unpack_uint(cl, 0, 63); 2655 values->shader.sampler_count = __gen_unpack_uint(cl, 64, 79); 2656 values->shader.texture_count = __gen_unpack_uint(cl, 80, 95); 2657 values->shader.attribute_count = __gen_unpack_uint(cl, 96, 111); 2658 values->shader.varying_count = __gen_unpack_uint(cl, 112, 127); 2659 values->properties.uniform_buffer_count = __gen_unpack_uint(cl, 128, 135); 2660 values->properties.depth_source = (enum mali_depth_source)__gen_unpack_uint(cl, 136, 137); 2661 values->properties.shader_contains_barrier = __gen_unpack_uint(cl, 139, 139); 2662 values->properties.force_early_z = __gen_unpack_uint(cl, 138, 138); 2663 values->properties.shader_contains_discard = __gen_unpack_uint(cl, 140, 140); 2664 values->properties.shader_has_side_effects = __gen_unpack_uint(cl, 141, 141); 2665 values->properties.shader_reads_tilebuffer = __gen_unpack_uint(cl, 142, 142); 2666 values->properties.forward_pixel_kill = __gen_unpack_uint(cl, 143, 143); 2667 values->properties.work_register_count = __gen_unpack_uint(cl, 144, 148); 2668 values->properties.uniform_count = __gen_unpack_uint(cl, 149, 153); 2669 values->properties.stencil_from_shader = __gen_unpack_uint(cl, 156, 156); 2670 values->properties.fp_mode = (enum mali_fp_mode)__gen_unpack_uint(cl, 157, 159); 2671 values->depth_units = __gen_unpack_float(cl, 160, 191); 2672 values->depth_factor = __gen_unpack_float(cl, 192, 223); 2673 values->depth_bias_clamp = __gen_unpack_float(cl, 224, 255); 2674 values->multisample_misc.sample_mask = __gen_unpack_uint(cl, 256, 271); 2675 values->multisample_misc.multisample_enable = __gen_unpack_uint(cl, 272, 272); 2676 values->multisample_misc.multisample_late_coverage = __gen_unpack_uint(cl, 273, 273); 2677 values->multisample_misc.evaluate_per_sample = __gen_unpack_uint(cl, 274, 274); 2678 values->multisample_misc.fixed_function_depth_range_fixed = __gen_unpack_uint(cl, 275, 275); 2679 values->multisample_misc.shader_depth_range_fixed = __gen_unpack_uint(cl, 276, 276); 2680 values->multisample_misc.load_destination = __gen_unpack_uint(cl, 277, 277); 2681 values->multisample_misc.blend_shader = __gen_unpack_uint(cl, 278, 278); 2682 values->multisample_misc.blend_shader_discard = __gen_unpack_uint(cl, 279, 279); 2683 values->multisample_misc.depth_function = (enum mali_func)__gen_unpack_uint(cl, 280, 282); 2684 values->multisample_misc.depth_write_mask = __gen_unpack_uint(cl, 283, 283); 2685 values->multisample_misc.fixed_function_near_discard = __gen_unpack_uint(cl, 284, 284); 2686 values->multisample_misc.fixed_function_far_discard = __gen_unpack_uint(cl, 285, 285); 2687 values->multisample_misc.fragment_near_discard = __gen_unpack_uint(cl, 286, 286); 2688 values->multisample_misc.fragment_far_discard = __gen_unpack_uint(cl, 287, 287); 2689 values->stencil_mask_misc.stencil_mask_front = __gen_unpack_uint(cl, 288, 295); 2690 values->stencil_mask_misc.stencil_mask_back = __gen_unpack_uint(cl, 296, 303); 2691 values->stencil_mask_misc.stencil_enable = __gen_unpack_uint(cl, 304, 304); 2692 values->stencil_mask_misc.alpha_to_coverage = __gen_unpack_uint(cl, 305, 305); 2693 values->stencil_mask_misc.alpha_to_coverage_invert = __gen_unpack_uint(cl, 306, 306); 2694 values->stencil_mask_misc.alpha_to_one = __gen_unpack_uint(cl, 307, 307); 2695 values->stencil_mask_misc.write_enable = __gen_unpack_uint(cl, 308, 308); 2696 values->stencil_mask_misc.alpha_test_compare_function = (enum mali_func)__gen_unpack_uint(cl, 309, 311); 2697 values->stencil_mask_misc.srgb = __gen_unpack_uint(cl, 312, 312); 2698 values->stencil_mask_misc.dither_disable = __gen_unpack_uint(cl, 313, 313); 2699 values->stencil_mask_misc.force_seamless_cubemaps = __gen_unpack_uint(cl, 314, 314); 2700 values->stencil_mask_misc.depth_range_1 = __gen_unpack_uint(cl, 316, 316); 2701 values->stencil_mask_misc.depth_range_2 = __gen_unpack_uint(cl, 317, 317); 2702 values->stencil_mask_misc.single_sampled_lines = __gen_unpack_uint(cl, 318, 318); 2703 values->stencil_mask_misc.point_snap = __gen_unpack_uint(cl, 319, 319); 2704 values->stencil_front.reference_value = __gen_unpack_uint(cl, 320, 327); 2705 values->stencil_front.mask = __gen_unpack_uint(cl, 328, 335); 2706 values->stencil_front.compare_function = (enum mali_func)__gen_unpack_uint(cl, 336, 338); 2707 values->stencil_front.stencil_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 339, 341); 2708 values->stencil_front.depth_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 342, 344); 2709 values->stencil_front.depth_pass = (enum mali_stencil_op)__gen_unpack_uint(cl, 345, 347); 2710 values->stencil_back.reference_value = __gen_unpack_uint(cl, 352, 359); 2711 values->stencil_back.mask = __gen_unpack_uint(cl, 360, 367); 2712 values->stencil_back.compare_function = (enum mali_func)__gen_unpack_uint(cl, 368, 370); 2713 values->stencil_back.stencil_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 371, 373); 2714 values->stencil_back.depth_fail = (enum mali_stencil_op)__gen_unpack_uint(cl, 374, 376); 2715 values->stencil_back.depth_pass = (enum mali_stencil_op)__gen_unpack_uint(cl, 377, 379); 2716 values->alpha_reference = __gen_unpack_float(cl, 384, 415); 2717 values->thread_balancing = __gen_unpack_uint(cl, 416, 431); 2718 values->blend_shader = __gen_unpack_uint(cl, 448, 511); 2719 values->blend_equation.rgb.a = (enum mali_blend_operand_a)__gen_unpack_uint(cl, 448, 449); 2720 values->blend_equation.rgb.negate_a = __gen_unpack_uint(cl, 451, 451); 2721 values->blend_equation.rgb.b = (enum mali_blend_operand_b)__gen_unpack_uint(cl, 452, 453); 2722 values->blend_equation.rgb.negate_b = __gen_unpack_uint(cl, 455, 455); 2723 values->blend_equation.rgb.c = (enum mali_blend_operand_c)__gen_unpack_uint(cl, 456, 458); 2724 values->blend_equation.rgb.invert_c = __gen_unpack_uint(cl, 459, 459); 2725 values->blend_equation.alpha.a = (enum mali_blend_operand_a)__gen_unpack_uint(cl, 460, 461); 2726 values->blend_equation.alpha.negate_a = __gen_unpack_uint(cl, 463, 463); 2727 values->blend_equation.alpha.b = (enum mali_blend_operand_b)__gen_unpack_uint(cl, 464, 465); 2728 values->blend_equation.alpha.negate_b = __gen_unpack_uint(cl, 467, 467); 2729 values->blend_equation.alpha.c = (enum mali_blend_operand_c)__gen_unpack_uint(cl, 468, 470); 2730 values->blend_equation.alpha.invert_c = __gen_unpack_uint(cl, 471, 471); 2731 values->blend_equation.color_mask = __gen_unpack_uint(cl, 476, 479); 2732 values->blend_constant = __gen_unpack_float(cl, 480, 511); 2733} 2734 2735static inline void 2736MALI_RENDERER_STATE_print(FILE *fp, const struct MALI_RENDERER_STATE * values, unsigned indent) 2737{ 2738 fprintf(fp, "%*sShader:\n", indent, ""); 2739 MALI_SHADER_print(fp, &values->shader, indent + 2); 2740 fprintf(fp, "%*sProperties:\n", indent, ""); 2741 MALI_RENDERER_PROPERTIES_print(fp, &values->properties, indent + 2); 2742 fprintf(fp, "%*sDepth units: %f\n", indent, "", values->depth_units); 2743 fprintf(fp, "%*sDepth factor: %f\n", indent, "", values->depth_factor); 2744 fprintf(fp, "%*sDepth bias clamp: %f\n", indent, "", values->depth_bias_clamp); 2745 fprintf(fp, "%*sMultisample, Misc:\n", indent, ""); 2746 MALI_MULTISAMPLE_MISC_print(fp, &values->multisample_misc, indent + 2); 2747 fprintf(fp, "%*sStencil Mask, Misc:\n", indent, ""); 2748 MALI_STENCIL_MASK_MISC_print(fp, &values->stencil_mask_misc, indent + 2); 2749 fprintf(fp, "%*sStencil front:\n", indent, ""); 2750 MALI_STENCIL_print(fp, &values->stencil_front, indent + 2); 2751 fprintf(fp, "%*sStencil back:\n", indent, ""); 2752 MALI_STENCIL_print(fp, &values->stencil_back, indent + 2); 2753 fprintf(fp, "%*sAlpha reference: %f\n", indent, "", values->alpha_reference); 2754 fprintf(fp, "%*sThread Balancing: %u\n", indent, "", values->thread_balancing); 2755 fprintf(fp, "%*sBlend Shader: 0x%" PRIx64 "\n", indent, "", values->blend_shader); 2756 fprintf(fp, "%*sBlend Equation:\n", indent, ""); 2757 MALI_BLEND_EQUATION_print(fp, &values->blend_equation, indent + 2); 2758 fprintf(fp, "%*sBlend Constant: %f\n", indent, "", values->blend_constant); 2759} 2760 2761struct MALI_UNIFORM_BUFFER { 2762 uint32_t entries; 2763 uint64_t pointer; 2764}; 2765 2766#define MALI_UNIFORM_BUFFER_header \ 2767 0 2768 2769static inline void 2770MALI_UNIFORM_BUFFER_pack(uint32_t * restrict cl, 2771 const struct MALI_UNIFORM_BUFFER * restrict values) 2772{ 2773 assert(values->entries >= 1); 2774 assert((values->pointer & 0xf) == 0); 2775 cl[ 0] = __gen_uint(values->entries - 1, 0, 11) | 2776 __gen_uint(values->pointer >> 4, 12, 63); 2777 cl[ 1] = __gen_uint(values->pointer >> 4, 12, 63) >> 32; 2778} 2779 2780 2781#define MALI_UNIFORM_BUFFER_LENGTH 8 2782#define MALI_UNIFORM_BUFFER_ALIGN 8 2783struct mali_uniform_buffer_packed { uint32_t opaque[2]; }; 2784static inline void 2785MALI_UNIFORM_BUFFER_unpack(const uint8_t * restrict cl, 2786 struct MALI_UNIFORM_BUFFER * restrict values) 2787{ 2788 values->entries = __gen_unpack_uint(cl, 0, 11) + 1; 2789 values->pointer = __gen_unpack_uint(cl, 12, 63) << 4; 2790} 2791 2792static inline void 2793MALI_UNIFORM_BUFFER_print(FILE *fp, const struct MALI_UNIFORM_BUFFER * values, unsigned indent) 2794{ 2795 fprintf(fp, "%*sEntries: %u\n", indent, "", values->entries); 2796 fprintf(fp, "%*sPointer: 0x%" PRIx64 "\n", indent, "", values->pointer); 2797} 2798 2799struct MALI_VIEWPORT { 2800 float minimum_x; 2801 float minimum_y; 2802 float maximum_x; 2803 float maximum_y; 2804 float minimum_z; 2805 float maximum_z; 2806 uint32_t scissor_minimum_x; 2807 uint32_t scissor_minimum_y; 2808 uint32_t scissor_maximum_x; 2809 uint32_t scissor_maximum_y; 2810}; 2811 2812#define MALI_VIEWPORT_header \ 2813 .minimum_x = -INFINITY, \ 2814 .minimum_y = -INFINITY, \ 2815 .maximum_x = +INFINITY, \ 2816 .maximum_y = +INFINITY, \ 2817 .minimum_z = 0.0, \ 2818 .maximum_z = 1.0, \ 2819 .scissor_minimum_x = 0, \ 2820 .scissor_minimum_y = 0 2821 2822static inline void 2823MALI_VIEWPORT_pack(uint32_t * restrict cl, 2824 const struct MALI_VIEWPORT * restrict values) 2825{ 2826 cl[ 0] = __gen_uint(fui(values->minimum_x), 0, 32); 2827 cl[ 1] = __gen_uint(fui(values->minimum_y), 0, 32); 2828 cl[ 2] = __gen_uint(fui(values->maximum_x), 0, 32); 2829 cl[ 3] = __gen_uint(fui(values->maximum_y), 0, 32); 2830 cl[ 4] = __gen_uint(fui(values->minimum_z), 0, 32); 2831 cl[ 5] = __gen_uint(fui(values->maximum_z), 0, 32); 2832 cl[ 6] = __gen_uint(values->scissor_minimum_x, 0, 15) | 2833 __gen_uint(values->scissor_minimum_y, 16, 31); 2834 cl[ 7] = __gen_uint(values->scissor_maximum_x, 0, 15) | 2835 __gen_uint(values->scissor_maximum_y, 16, 31); 2836} 2837 2838 2839#define MALI_VIEWPORT_LENGTH 32 2840#define MALI_VIEWPORT_ALIGN 32 2841struct mali_viewport_packed { uint32_t opaque[8]; }; 2842static inline void 2843MALI_VIEWPORT_unpack(const uint8_t * restrict cl, 2844 struct MALI_VIEWPORT * restrict values) 2845{ 2846 values->minimum_x = __gen_unpack_float(cl, 0, 31); 2847 values->minimum_y = __gen_unpack_float(cl, 32, 63); 2848 values->maximum_x = __gen_unpack_float(cl, 64, 95); 2849 values->maximum_y = __gen_unpack_float(cl, 96, 127); 2850 values->minimum_z = __gen_unpack_float(cl, 128, 159); 2851 values->maximum_z = __gen_unpack_float(cl, 160, 191); 2852 values->scissor_minimum_x = __gen_unpack_uint(cl, 192, 207); 2853 values->scissor_minimum_y = __gen_unpack_uint(cl, 208, 223); 2854 values->scissor_maximum_x = __gen_unpack_uint(cl, 224, 239); 2855 values->scissor_maximum_y = __gen_unpack_uint(cl, 240, 255); 2856} 2857 2858static inline void 2859MALI_VIEWPORT_print(FILE *fp, const struct MALI_VIEWPORT * values, unsigned indent) 2860{ 2861 fprintf(fp, "%*sMinimum X: %f\n", indent, "", values->minimum_x); 2862 fprintf(fp, "%*sMinimum Y: %f\n", indent, "", values->minimum_y); 2863 fprintf(fp, "%*sMaximum X: %f\n", indent, "", values->maximum_x); 2864 fprintf(fp, "%*sMaximum Y: %f\n", indent, "", values->maximum_y); 2865 fprintf(fp, "%*sMinimum Z: %f\n", indent, "", values->minimum_z); 2866 fprintf(fp, "%*sMaximum Z: %f\n", indent, "", values->maximum_z); 2867 fprintf(fp, "%*sScissor Minimum X: %u\n", indent, "", values->scissor_minimum_x); 2868 fprintf(fp, "%*sScissor Minimum Y: %u\n", indent, "", values->scissor_minimum_y); 2869 fprintf(fp, "%*sScissor Maximum X: %u\n", indent, "", values->scissor_maximum_x); 2870 fprintf(fp, "%*sScissor Maximum Y: %u\n", indent, "", values->scissor_maximum_y); 2871} 2872 2873struct MALI_LOCAL_STORAGE { 2874 uint32_t tls_size; 2875 uint32_t tls_initial_stack_pointer_offset; 2876 uint32_t wls_instances; 2877#define MALI_LOCAL_STORAGE_NO_WORKGROUP_MEM 2147483648 2878 uint32_t wls_size_base; 2879 uint32_t wls_size_scale; 2880 uint64_t tls_base_pointer; 2881 uint64_t wls_base_pointer; 2882}; 2883 2884#define MALI_LOCAL_STORAGE_header \ 2885 .wls_instances = MALI_LOCAL_STORAGE_NO_WORKGROUP_MEM 2886 2887static inline void 2888MALI_LOCAL_STORAGE_pack(uint32_t * restrict cl, 2889 const struct MALI_LOCAL_STORAGE * restrict values) 2890{ 2891 assert(util_is_power_of_two_nonzero(values->wls_instances)); 2892 cl[ 0] = __gen_uint(values->tls_size, 0, 4) | 2893 __gen_uint(values->tls_initial_stack_pointer_offset, 5, 31); 2894 cl[ 1] = __gen_uint(util_logbase2(values->wls_instances), 0, 4) | 2895 __gen_uint(values->wls_size_base, 5, 6) | 2896 __gen_uint(values->wls_size_scale, 8, 12); 2897 cl[ 2] = __gen_uint(values->tls_base_pointer, 0, 63); 2898 cl[ 3] = __gen_uint(values->tls_base_pointer, 0, 63) >> 32; 2899 cl[ 4] = __gen_uint(values->wls_base_pointer, 0, 63); 2900 cl[ 5] = __gen_uint(values->wls_base_pointer, 0, 63) >> 32; 2901 cl[ 6] = 0; 2902 cl[ 7] = 0; 2903} 2904 2905 2906#define MALI_LOCAL_STORAGE_LENGTH 32 2907#define MALI_LOCAL_STORAGE_ALIGN 64 2908struct mali_local_storage_packed { uint32_t opaque[8]; }; 2909static inline void 2910MALI_LOCAL_STORAGE_unpack(const uint8_t * restrict cl, 2911 struct MALI_LOCAL_STORAGE * restrict values) 2912{ 2913 if (((const uint32_t *) cl)[1] & 0xffffe080) fprintf(stderr, "XXX: Invalid field of Local Storage unpacked at word 1\n"); 2914 if (((const uint32_t *) cl)[6] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Local Storage unpacked at word 6\n"); 2915 if (((const uint32_t *) cl)[7] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Local Storage unpacked at word 7\n"); 2916 values->tls_size = __gen_unpack_uint(cl, 0, 4); 2917 values->tls_initial_stack_pointer_offset = __gen_unpack_uint(cl, 5, 31); 2918 values->wls_instances = 1U << __gen_unpack_uint(cl, 32, 36); 2919 values->wls_size_base = __gen_unpack_uint(cl, 37, 38); 2920 values->wls_size_scale = __gen_unpack_uint(cl, 40, 44); 2921 values->tls_base_pointer = __gen_unpack_uint(cl, 64, 127); 2922 values->wls_base_pointer = __gen_unpack_uint(cl, 128, 191); 2923} 2924 2925static inline void 2926MALI_LOCAL_STORAGE_print(FILE *fp, const struct MALI_LOCAL_STORAGE * values, unsigned indent) 2927{ 2928 fprintf(fp, "%*sTLS Size: %u\n", indent, "", values->tls_size); 2929 fprintf(fp, "%*sTLS Initial Stack Pointer Offset: %u\n", indent, "", values->tls_initial_stack_pointer_offset); 2930 fprintf(fp, "%*sWLS Instances: %u\n", indent, "", values->wls_instances); 2931 fprintf(fp, "%*sWLS Size Base: %u\n", indent, "", values->wls_size_base); 2932 fprintf(fp, "%*sWLS Size Scale: %u\n", indent, "", values->wls_size_scale); 2933 fprintf(fp, "%*sTLS Base Pointer: 0x%" PRIx64 "\n", indent, "", values->tls_base_pointer); 2934 fprintf(fp, "%*sWLS Base Pointer: 0x%" PRIx64 "\n", indent, "", values->wls_base_pointer); 2935} 2936 2937struct MALI_TILER_CONTEXT { 2938 uint32_t polygon_list_size; 2939#define MALI_MIDGARD_TILER_MINIMUM_HEADER_SIZE 512 2940 uint32_t hierarchy_mask; 2941#define MALI_MIDGARD_TILER_DISABLED 4096 2942#define MALI_MIDGARD_TILER_USER 4095 2943#define MALI_MIDGARD_TILER_HIERARCHY_MASK 511 2944 uint64_t polygon_list; 2945 uint64_t polygon_list_body; 2946 uint64_t heap_start; 2947 uint64_t heap_end; 2948}; 2949 2950#define MALI_TILER_CONTEXT_header \ 2951 0 2952 2953static inline void 2954MALI_TILER_CONTEXT_pack(uint32_t * restrict cl, 2955 const struct MALI_TILER_CONTEXT * restrict values) 2956{ 2957 cl[ 0] = __gen_uint(values->polygon_list_size, 0, 31); 2958 cl[ 1] = __gen_uint(values->hierarchy_mask, 0, 15); 2959 cl[ 2] = __gen_uint(values->polygon_list, 0, 63); 2960 cl[ 3] = __gen_uint(values->polygon_list, 0, 63) >> 32; 2961 cl[ 4] = __gen_uint(values->polygon_list_body, 0, 63); 2962 cl[ 5] = __gen_uint(values->polygon_list_body, 0, 63) >> 32; 2963 cl[ 6] = __gen_uint(values->heap_start, 0, 63); 2964 cl[ 7] = __gen_uint(values->heap_start, 0, 63) >> 32; 2965 cl[ 8] = __gen_uint(values->heap_end, 0, 63); 2966 cl[ 9] = __gen_uint(values->heap_end, 0, 63) >> 32; 2967} 2968 2969 2970#define MALI_TILER_CONTEXT_LENGTH 40 2971struct mali_tiler_context_packed { uint32_t opaque[10]; }; 2972static inline void 2973MALI_TILER_CONTEXT_unpack(const uint8_t * restrict cl, 2974 struct MALI_TILER_CONTEXT * restrict values) 2975{ 2976 if (((const uint32_t *) cl)[1] & 0xffff0000) fprintf(stderr, "XXX: Invalid field of Tiler Context unpacked at word 1\n"); 2977 values->polygon_list_size = __gen_unpack_uint(cl, 0, 31); 2978 values->hierarchy_mask = __gen_unpack_uint(cl, 32, 47); 2979 values->polygon_list = __gen_unpack_uint(cl, 64, 127); 2980 values->polygon_list_body = __gen_unpack_uint(cl, 128, 191); 2981 values->heap_start = __gen_unpack_uint(cl, 192, 255); 2982 values->heap_end = __gen_unpack_uint(cl, 256, 319); 2983} 2984 2985static inline void 2986MALI_TILER_CONTEXT_print(FILE *fp, const struct MALI_TILER_CONTEXT * values, unsigned indent) 2987{ 2988 fprintf(fp, "%*sPolygon List Size: %u\n", indent, "", values->polygon_list_size); 2989 fprintf(fp, "%*sHierarchy Mask: %u\n", indent, "", values->hierarchy_mask); 2990 fprintf(fp, "%*sPolygon List: 0x%" PRIx64 "\n", indent, "", values->polygon_list); 2991 fprintf(fp, "%*sPolygon List Body: 0x%" PRIx64 "\n", indent, "", values->polygon_list_body); 2992 fprintf(fp, "%*sHeap Start: 0x%" PRIx64 "\n", indent, "", values->heap_start); 2993 fprintf(fp, "%*sHeap End: 0x%" PRIx64 "\n", indent, "", values->heap_end); 2994} 2995 2996struct MALI_TILER_WEIGHTS { 2997 uint32_t weight0; 2998 uint32_t weight1; 2999 uint32_t weight2; 3000 uint32_t weight3; 3001 uint32_t weight4; 3002 uint32_t weight5; 3003 uint32_t weight6; 3004 uint32_t weight7; 3005}; 3006 3007#define MALI_TILER_WEIGHTS_header \ 3008 0 3009 3010static inline void 3011MALI_TILER_WEIGHTS_pack(uint32_t * restrict cl, 3012 const struct MALI_TILER_WEIGHTS * restrict values) 3013{ 3014 cl[ 0] = __gen_uint(values->weight0, 0, 31); 3015 cl[ 1] = __gen_uint(values->weight1, 0, 31); 3016 cl[ 2] = __gen_uint(values->weight2, 0, 31); 3017 cl[ 3] = __gen_uint(values->weight3, 0, 31); 3018 cl[ 4] = __gen_uint(values->weight4, 0, 31); 3019 cl[ 5] = __gen_uint(values->weight5, 0, 31); 3020 cl[ 6] = __gen_uint(values->weight6, 0, 31); 3021 cl[ 7] = __gen_uint(values->weight7, 0, 31); 3022} 3023 3024 3025#define MALI_TILER_WEIGHTS_LENGTH 32 3026struct mali_tiler_weights_packed { uint32_t opaque[8]; }; 3027static inline void 3028MALI_TILER_WEIGHTS_unpack(const uint8_t * restrict cl, 3029 struct MALI_TILER_WEIGHTS * restrict values) 3030{ 3031 values->weight0 = __gen_unpack_uint(cl, 0, 31); 3032 values->weight1 = __gen_unpack_uint(cl, 32, 63); 3033 values->weight2 = __gen_unpack_uint(cl, 64, 95); 3034 values->weight3 = __gen_unpack_uint(cl, 96, 127); 3035 values->weight4 = __gen_unpack_uint(cl, 128, 159); 3036 values->weight5 = __gen_unpack_uint(cl, 160, 191); 3037 values->weight6 = __gen_unpack_uint(cl, 192, 223); 3038 values->weight7 = __gen_unpack_uint(cl, 224, 255); 3039} 3040 3041static inline void 3042MALI_TILER_WEIGHTS_print(FILE *fp, const struct MALI_TILER_WEIGHTS * values, unsigned indent) 3043{ 3044 fprintf(fp, "%*sWeight0: %u\n", indent, "", values->weight0); 3045 fprintf(fp, "%*sWeight1: %u\n", indent, "", values->weight1); 3046 fprintf(fp, "%*sWeight2: %u\n", indent, "", values->weight2); 3047 fprintf(fp, "%*sWeight3: %u\n", indent, "", values->weight3); 3048 fprintf(fp, "%*sWeight4: %u\n", indent, "", values->weight4); 3049 fprintf(fp, "%*sWeight5: %u\n", indent, "", values->weight5); 3050 fprintf(fp, "%*sWeight6: %u\n", indent, "", values->weight6); 3051 fprintf(fp, "%*sWeight7: %u\n", indent, "", values->weight7); 3052} 3053 3054enum mali_color_buffer_internal_format { 3055 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW_VALUE = 0, 3056 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R8G8B8A8 = 1, 3057 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R10G10B10A2 = 2, 3058 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R8G8B8A2 = 3, 3059 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R4G4B4A4 = 4, 3060 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R5G6B5A0 = 5, 3061 MALI_COLOR_BUFFER_INTERNAL_FORMAT_R5G5B5A1 = 6, 3062 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW8 = 32, 3063 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW16 = 33, 3064 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW32 = 34, 3065 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW64 = 35, 3066 MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW128 = 36, 3067}; 3068 3069static inline const char * 3070mali_color_buffer_internal_format_as_str(enum mali_color_buffer_internal_format imm) 3071{ 3072 switch (imm) { 3073 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW_VALUE: return "Raw Value"; 3074 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R8G8B8A8: return "R8G8B8A8"; 3075 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R10G10B10A2: return "R10G10B10A2"; 3076 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R8G8B8A2: return "R8G8B8A2"; 3077 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R4G4B4A4: return "R4G4B4A4"; 3078 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R5G6B5A0: return "R5G6B5A0"; 3079 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R5G5B5A1: return "R5G5B5A1"; 3080 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW8: return "RAW8"; 3081 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW16: return "RAW16"; 3082 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW32: return "RAW32"; 3083 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW64: return "RAW64"; 3084 case MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW128: return "RAW128"; 3085 default: return "XXX: INVALID"; 3086 } 3087} 3088 3089enum mali_color_format { 3090 MALI_COLOR_FORMAT_4_32B_CHANNELS = 0, 3091 MALI_COLOR_FORMAT_3_32B_CHANNELS = 1, 3092 MALI_COLOR_FORMAT_2_32B_CHANNELS = 2, 3093 MALI_COLOR_FORMAT_1_32B_CHANNEL = 3, 3094 MALI_COLOR_FORMAT_4_16B_CHANNELS = 4, 3095 MALI_COLOR_FORMAT_3_16B_CHANNELS = 5, 3096 MALI_COLOR_FORMAT_2_16B_CHANNELS = 6, 3097 MALI_COLOR_FORMAT_1_16B_CHANNEL = 7, 3098 MALI_COLOR_FORMAT_R8 = 16, 3099 MALI_COLOR_FORMAT_R8G8 = 17, 3100 MALI_COLOR_FORMAT_R8G8B8 = 18, 3101 MALI_COLOR_FORMAT_R8G8B8A8 = 19, 3102 MALI_COLOR_FORMAT_R4G4B4A4 = 20, 3103 MALI_COLOR_FORMAT_R5G6B5 = 21, 3104 MALI_COLOR_FORMAT_R8G8B8_FROM_R8G8B8A2 = 22, 3105 MALI_COLOR_FORMAT_R10G10B10A2 = 24, 3106 MALI_COLOR_FORMAT_A2B10G10R10 = 25, 3107 MALI_COLOR_FORMAT_R5G5B5A1 = 28, 3108 MALI_COLOR_FORMAT_A1B5G5R5 = 29, 3109}; 3110 3111static inline const char * 3112mali_color_format_as_str(enum mali_color_format imm) 3113{ 3114 switch (imm) { 3115 case MALI_COLOR_FORMAT_4_32B_CHANNELS: return "4_32B_CHANNELS"; 3116 case MALI_COLOR_FORMAT_3_32B_CHANNELS: return "3_32B_CHANNELS"; 3117 case MALI_COLOR_FORMAT_2_32B_CHANNELS: return "2_32B_CHANNELS"; 3118 case MALI_COLOR_FORMAT_1_32B_CHANNEL: return "1_32B_CHANNEL"; 3119 case MALI_COLOR_FORMAT_4_16B_CHANNELS: return "4_16B_CHANNELS"; 3120 case MALI_COLOR_FORMAT_3_16B_CHANNELS: return "3_16B_CHANNELS"; 3121 case MALI_COLOR_FORMAT_2_16B_CHANNELS: return "2_16B_CHANNELS"; 3122 case MALI_COLOR_FORMAT_1_16B_CHANNEL: return "1_16B_CHANNEL"; 3123 case MALI_COLOR_FORMAT_R8: return "R8"; 3124 case MALI_COLOR_FORMAT_R8G8: return "R8G8"; 3125 case MALI_COLOR_FORMAT_R8G8B8: return "R8G8B8"; 3126 case MALI_COLOR_FORMAT_R8G8B8A8: return "R8G8B8A8"; 3127 case MALI_COLOR_FORMAT_R4G4B4A4: return "R4G4B4A4"; 3128 case MALI_COLOR_FORMAT_R5G6B5: return "R5G6B5"; 3129 case MALI_COLOR_FORMAT_R8G8B8_FROM_R8G8B8A2: return "R8G8B8_FROM_R8G8B8A2"; 3130 case MALI_COLOR_FORMAT_R10G10B10A2: return "R10G10B10A2"; 3131 case MALI_COLOR_FORMAT_A2B10G10R10: return "A2B10G10R10"; 3132 case MALI_COLOR_FORMAT_R5G5B5A1: return "R5G5B5A1"; 3133 case MALI_COLOR_FORMAT_A1B5G5R5: return "A1B5G5R5"; 3134 default: return "XXX: INVALID"; 3135 } 3136} 3137 3138enum mali_downsampling_accumulation_mode { 3139 MALI_DOWNSAMPLING_ACCUMULATION_MODE_UNSIGNED_NORMALIZED_INTEGER = 0, 3140 MALI_DOWNSAMPLING_ACCUMULATION_MODE_SIGNED_NORMALIZED_INTEGER = 1, 3141}; 3142 3143static inline const char * 3144mali_downsampling_accumulation_mode_as_str(enum mali_downsampling_accumulation_mode imm) 3145{ 3146 switch (imm) { 3147 case MALI_DOWNSAMPLING_ACCUMULATION_MODE_UNSIGNED_NORMALIZED_INTEGER: return "Unsigned normalized integer"; 3148 case MALI_DOWNSAMPLING_ACCUMULATION_MODE_SIGNED_NORMALIZED_INTEGER: return "Signed normalized integer"; 3149 default: return "XXX: INVALID"; 3150 } 3151} 3152 3153enum mali_sample_layout { 3154 MALI_SAMPLE_LAYOUT_ORDERED_4X_GRID = 0, 3155 MALI_SAMPLE_LAYOUT_ROTATED_4X_GRID = 1, 3156 MALI_SAMPLE_LAYOUT_D3D_8X_GRID = 2, 3157 MALI_SAMPLE_LAYOUT_D3D_16X_GRID = 3, 3158}; 3159 3160static inline const char * 3161mali_sample_layout_as_str(enum mali_sample_layout imm) 3162{ 3163 switch (imm) { 3164 case MALI_SAMPLE_LAYOUT_ORDERED_4X_GRID: return "Ordered 4x Grid"; 3165 case MALI_SAMPLE_LAYOUT_ROTATED_4X_GRID: return "Rotated 4x Grid"; 3166 case MALI_SAMPLE_LAYOUT_D3D_8X_GRID: return "D3D 8x Grid"; 3167 case MALI_SAMPLE_LAYOUT_D3D_16X_GRID: return "D3D 16x Grid"; 3168 default: return "XXX: INVALID"; 3169 } 3170} 3171 3172enum mali_zs_format { 3173 MALI_ZS_FORMAT_D16 = 1, 3174 MALI_ZS_FORMAT_D24 = 2, 3175 MALI_ZS_FORMAT_D24X8 = 4, 3176 MALI_ZS_FORMAT_D24S8 = 5, 3177 MALI_ZS_FORMAT_X8D24 = 6, 3178 MALI_ZS_FORMAT_S8D24 = 7, 3179 MALI_ZS_FORMAT_D32 = 14, 3180 MALI_ZS_FORMAT_D32_S8X24 = 15, 3181}; 3182 3183static inline const char * 3184mali_zs_format_as_str(enum mali_zs_format imm) 3185{ 3186 switch (imm) { 3187 case MALI_ZS_FORMAT_D16: return "D16"; 3188 case MALI_ZS_FORMAT_D24: return "D24"; 3189 case MALI_ZS_FORMAT_D24X8: return "D24X8"; 3190 case MALI_ZS_FORMAT_D24S8: return "D24S8"; 3191 case MALI_ZS_FORMAT_X8D24: return "X8D24"; 3192 case MALI_ZS_FORMAT_S8D24: return "S8D24"; 3193 case MALI_ZS_FORMAT_D32: return "D32"; 3194 case MALI_ZS_FORMAT_D32_S8X24: return "D32_S8X24"; 3195 default: return "XXX: INVALID"; 3196 } 3197} 3198 3199enum mali_zs_preload_format { 3200 MALI_ZS_PRELOAD_FORMAT_D32_S8X24 = 4, 3201}; 3202 3203static inline const char * 3204mali_zs_preload_format_as_str(enum mali_zs_preload_format imm) 3205{ 3206 switch (imm) { 3207 case MALI_ZS_PRELOAD_FORMAT_D32_S8X24: return "D32_S8X24"; 3208 default: return "XXX: INVALID"; 3209 } 3210} 3211 3212enum mali_s_format { 3213 MALI_S_FORMAT_S8 = 1, 3214 MALI_S_FORMAT_S8X8 = 2, 3215 MALI_S_FORMAT_S8X24 = 3, 3216 MALI_S_FORMAT_X24S8 = 4, 3217}; 3218 3219static inline const char * 3220mali_s_format_as_str(enum mali_s_format imm) 3221{ 3222 switch (imm) { 3223 case MALI_S_FORMAT_S8: return "S8"; 3224 case MALI_S_FORMAT_S8X8: return "S8X8"; 3225 case MALI_S_FORMAT_S8X24: return "S8X24"; 3226 case MALI_S_FORMAT_X24S8: return "X24S8"; 3227 default: return "XXX: INVALID"; 3228 } 3229} 3230 3231enum mali_tie_break_rule { 3232 MALI_TIE_BREAK_RULE_0_IN_180_OUT = 0, 3233 MALI_TIE_BREAK_RULE_0_OUT_180_IN = 1, 3234 MALI_TIE_BREAK_RULE_MINUS_180_IN_0_OUT = 2, 3235 MALI_TIE_BREAK_RULE_MINUS_180_OUT_0_IN = 3, 3236 MALI_TIE_BREAK_RULE_90_IN_270_OUT = 4, 3237 MALI_TIE_BREAK_RULE_90_OUT_270_IN = 5, 3238 MALI_TIE_BREAK_RULE_MINUS_90_IN_90_OUT = 6, 3239 MALI_TIE_BREAK_RULE_MINUS_90_OUT_90_IN = 7, 3240}; 3241 3242static inline const char * 3243mali_tie_break_rule_as_str(enum mali_tie_break_rule imm) 3244{ 3245 switch (imm) { 3246 case MALI_TIE_BREAK_RULE_0_IN_180_OUT: return "0_IN_180_OUT"; 3247 case MALI_TIE_BREAK_RULE_0_OUT_180_IN: return "0_OUT_180_IN"; 3248 case MALI_TIE_BREAK_RULE_MINUS_180_IN_0_OUT: return "MINUS_180_IN_0_OUT"; 3249 case MALI_TIE_BREAK_RULE_MINUS_180_OUT_0_IN: return "MINUS_180_OUT_0_IN"; 3250 case MALI_TIE_BREAK_RULE_90_IN_270_OUT: return "90_IN_270_OUT"; 3251 case MALI_TIE_BREAK_RULE_90_OUT_270_IN: return "90_OUT_270_IN"; 3252 case MALI_TIE_BREAK_RULE_MINUS_90_IN_90_OUT: return "MINUS_90_IN_90_OUT"; 3253 case MALI_TIE_BREAK_RULE_MINUS_90_OUT_90_IN: return "MINUS_90_OUT_90_IN"; 3254 default: return "XXX: INVALID"; 3255 } 3256} 3257 3258struct MALI_RT_BUFFER { 3259 uint64_t base; 3260 uint32_t row_stride; 3261 uint32_t surface_stride; 3262}; 3263 3264#define MALI_RT_BUFFER_header \ 3265 0 3266 3267static inline void 3268MALI_RT_BUFFER_pack(uint32_t * restrict cl, 3269 const struct MALI_RT_BUFFER * restrict values) 3270{ 3271 cl[ 0] = __gen_uint(values->base, 0, 63); 3272 cl[ 1] = __gen_uint(values->base, 0, 63) >> 32; 3273 cl[ 2] = __gen_uint(values->row_stride, 0, 31); 3274 cl[ 3] = __gen_uint(values->surface_stride, 0, 31); 3275} 3276 3277 3278#define MALI_RT_BUFFER_LENGTH 16 3279struct mali_rt_buffer_packed { uint32_t opaque[4]; }; 3280static inline void 3281MALI_RT_BUFFER_unpack(const uint8_t * restrict cl, 3282 struct MALI_RT_BUFFER * restrict values) 3283{ 3284 values->base = __gen_unpack_uint(cl, 0, 63); 3285 values->row_stride = __gen_unpack_uint(cl, 64, 95); 3286 values->surface_stride = __gen_unpack_uint(cl, 96, 127); 3287} 3288 3289static inline void 3290MALI_RT_BUFFER_print(FILE *fp, const struct MALI_RT_BUFFER * values, unsigned indent) 3291{ 3292 fprintf(fp, "%*sBase: 0x%" PRIx64 "\n", indent, "", values->base); 3293 fprintf(fp, "%*sRow Stride: %u\n", indent, "", values->row_stride); 3294 fprintf(fp, "%*sSurface Stride: %u\n", indent, "", values->surface_stride); 3295} 3296 3297struct MALI_FRAMEBUFFER_PARAMETERS { 3298 enum mali_color_buffer_internal_format internal_format; 3299 uint32_t sample_count; 3300 uint32_t swizzle; 3301 enum mali_color_format color_writeback_format; 3302 enum mali_msaa msaa; 3303 bool srgb; 3304 enum mali_block_format color_block_format; 3305 bool dithering_enable; 3306 bool clean_pixel_write_enable; 3307 bool color_preload_enable; 3308 bool color_write_enable; 3309 uint32_t x_downsampling_scale; 3310 uint32_t y_downsampling_scale; 3311 enum mali_downsampling_accumulation_mode downsampling_accumulation_mode; 3312 enum mali_sample_layout sample_layout; 3313 bool big_endian; 3314 enum mali_tie_break_rule tie_break_rule; 3315 bool crc_read_enable; 3316 bool crc_write_enable; 3317 enum mali_block_format zs_block_format; 3318 enum mali_zs_format zs_format; 3319 bool zs_preload_enable; 3320 bool zs_write_enable; 3321 enum mali_block_format s_block_format; 3322 enum mali_s_format s_format; 3323 bool s_write_enable; 3324 uint32_t bound_min_x; 3325 uint32_t bound_min_y; 3326 uint32_t bound_max_x; 3327 uint32_t bound_max_y; 3328 uint32_t dcd_offset; 3329 struct MALI_RT_BUFFER crc_buffer; 3330 struct MALI_RT_BUFFER color_writeback; 3331 struct MALI_RT_BUFFER zs_writeback; 3332 struct MALI_RT_BUFFER s_writeback; 3333 uint64_t color_load_address; 3334 uint32_t color_load_row_stride; 3335 uint32_t color_load_surface_stride; 3336 uint32_t clear_color_0; 3337 uint32_t clear_color_1; 3338 uint32_t clear_color_2; 3339 uint32_t clear_color_3; 3340 uint64_t zs_load_address; 3341 uint32_t zs_load_row_stride; 3342 uint32_t zs_load_surface_stride; 3343 float z_clear; 3344 uint32_t s_clear; 3345}; 3346 3347#define MALI_FRAMEBUFFER_PARAMETERS_header \ 3348 .internal_format = MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW_VALUE, \ 3349 .sample_count = 1, \ 3350 .color_writeback_format = MALI_COLOR_FORMAT_4_32B_CHANNELS, \ 3351 .msaa = MALI_MSAA_SINGLE, \ 3352 .zs_format = MALI_ZS_FORMAT_D24S8, \ 3353 .crc_buffer = { MALI_RT_BUFFER_header }, \ 3354 .color_writeback = { MALI_RT_BUFFER_header }, \ 3355 .zs_writeback = { MALI_RT_BUFFER_header }, \ 3356 .s_writeback = { MALI_RT_BUFFER_header } 3357 3358static inline void 3359MALI_FRAMEBUFFER_PARAMETERS_pack(uint32_t * restrict cl, 3360 const struct MALI_FRAMEBUFFER_PARAMETERS * restrict values) 3361{ 3362 assert(util_is_power_of_two_nonzero(values->sample_count)); 3363 cl[ 0] = __gen_uint(values->internal_format, 0, 2) | 3364 __gen_uint(util_logbase2(values->sample_count), 3, 5) | 3365 __gen_uint(values->swizzle, 6, 17) | 3366 __gen_uint(values->color_writeback_format, 18, 22) | 3367 __gen_uint(values->msaa, 23, 24) | 3368 __gen_uint(values->srgb, 25, 25) | 3369 __gen_uint(values->color_block_format, 26, 27) | 3370 __gen_uint(values->dithering_enable, 28, 28) | 3371 __gen_uint(values->clean_pixel_write_enable, 29, 29) | 3372 __gen_uint(values->color_preload_enable, 30, 30) | 3373 __gen_uint(values->color_write_enable, 31, 31); 3374 cl[ 1] = __gen_uint(values->x_downsampling_scale, 0, 2) | 3375 __gen_uint(values->y_downsampling_scale, 3, 5) | 3376 __gen_uint(values->downsampling_accumulation_mode, 6, 7) | 3377 __gen_uint(values->sample_layout, 8, 9) | 3378 __gen_uint(values->big_endian, 10, 10) | 3379 __gen_uint(values->tie_break_rule, 11, 13) | 3380 __gen_uint(values->crc_read_enable, 14, 14) | 3381 __gen_uint(values->crc_write_enable, 15, 15) | 3382 __gen_uint(values->zs_block_format, 16, 17) | 3383 __gen_uint(values->zs_format, 18, 21) | 3384 __gen_uint(values->zs_preload_enable, 22, 22) | 3385 __gen_uint(values->zs_write_enable, 23, 23) | 3386 __gen_uint(values->s_block_format, 24, 25) | 3387 __gen_uint(values->s_format, 26, 29) | 3388 __gen_uint(values->s_write_enable, 31, 31); 3389 cl[ 2] = __gen_uint(values->bound_min_x, 0, 15) | 3390 __gen_uint(values->bound_min_y, 16, 31); 3391 cl[ 3] = __gen_uint(values->bound_max_x, 0, 15) | 3392 __gen_uint(values->bound_max_y, 16, 31); 3393 cl[ 4] = __gen_uint(values->dcd_offset, 0, 31); 3394 cl[ 5] = 0; 3395 cl[ 6] = 0; 3396 cl[ 7] = 0; 3397 cl[ 8] = __gen_uint(values->crc_buffer.base, 0, 63); 3398 cl[ 9] = __gen_uint(values->crc_buffer.base, 0, 63) >> 32; 3399 cl[10] = __gen_uint(values->crc_buffer.row_stride, 0, 31); 3400 cl[11] = __gen_uint(values->crc_buffer.surface_stride, 0, 31); 3401 cl[12] = __gen_uint(values->color_writeback.base, 0, 63); 3402 cl[13] = __gen_uint(values->color_writeback.base, 0, 63) >> 32; 3403 cl[14] = __gen_uint(values->color_writeback.row_stride, 0, 31); 3404 cl[15] = __gen_uint(values->color_writeback.surface_stride, 0, 31); 3405 cl[16] = __gen_uint(values->zs_writeback.base, 0, 63); 3406 cl[17] = __gen_uint(values->zs_writeback.base, 0, 63) >> 32; 3407 cl[18] = __gen_uint(values->zs_writeback.row_stride, 0, 31); 3408 cl[19] = __gen_uint(values->zs_writeback.surface_stride, 0, 31); 3409 cl[20] = __gen_uint(values->s_writeback.base, 0, 63); 3410 cl[21] = __gen_uint(values->s_writeback.base, 0, 63) >> 32; 3411 cl[22] = __gen_uint(values->s_writeback.row_stride, 0, 31); 3412 cl[23] = __gen_uint(values->s_writeback.surface_stride, 0, 31); 3413 cl[24] = __gen_uint(values->color_load_address, 0, 63) | 3414 __gen_uint(values->clear_color_0, 0, 31); 3415 cl[25] = __gen_uint(values->color_load_address, 0, 63) >> 32 | 3416 __gen_uint(values->clear_color_1, 0, 31); 3417 cl[26] = __gen_uint(values->color_load_row_stride, 0, 31) | 3418 __gen_uint(values->clear_color_2, 0, 31); 3419 cl[27] = __gen_uint(values->color_load_surface_stride, 0, 31) | 3420 __gen_uint(values->clear_color_3, 0, 31); 3421 cl[28] = __gen_uint(values->zs_load_address, 0, 63) | 3422 __gen_uint(fui(values->z_clear), 0, 32); 3423 cl[29] = __gen_uint(values->zs_load_address, 0, 63) >> 32; 3424 cl[30] = __gen_uint(values->zs_load_row_stride, 0, 31); 3425 cl[31] = __gen_uint(values->zs_load_surface_stride, 0, 31); 3426 cl[32] = __gen_uint(values->s_clear, 0, 7); 3427 cl[33] = 0; 3428 cl[34] = 0; 3429 cl[35] = 0; 3430 cl[36] = 0; 3431 cl[37] = 0; 3432 cl[38] = 0; 3433 cl[39] = 0; 3434} 3435 3436 3437#define MALI_FRAMEBUFFER_PARAMETERS_LENGTH 160 3438struct mali_framebuffer_parameters_packed { uint32_t opaque[40]; }; 3439static inline void 3440MALI_FRAMEBUFFER_PARAMETERS_unpack(const uint8_t * restrict cl, 3441 struct MALI_FRAMEBUFFER_PARAMETERS * restrict values) 3442{ 3443 if (((const uint32_t *) cl)[1] & 0x40000000) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 1\n"); 3444 if (((const uint32_t *) cl)[5] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 5\n"); 3445 if (((const uint32_t *) cl)[6] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 6\n"); 3446 if (((const uint32_t *) cl)[7] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 7\n"); 3447 if (((const uint32_t *) cl)[32] & 0xffffff00) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 32\n"); 3448 if (((const uint32_t *) cl)[33] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 33\n"); 3449 if (((const uint32_t *) cl)[34] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 34\n"); 3450 if (((const uint32_t *) cl)[35] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 35\n"); 3451 if (((const uint32_t *) cl)[36] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 36\n"); 3452 if (((const uint32_t *) cl)[37] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 37\n"); 3453 if (((const uint32_t *) cl)[38] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 38\n"); 3454 if (((const uint32_t *) cl)[39] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Parameters unpacked at word 39\n"); 3455 values->internal_format = (enum mali_color_buffer_internal_format)__gen_unpack_uint(cl, 0, 2); 3456 values->sample_count = 1U << __gen_unpack_uint(cl, 3, 5); 3457 values->swizzle = __gen_unpack_uint(cl, 6, 17); 3458 values->color_writeback_format = (enum mali_color_format)__gen_unpack_uint(cl, 18, 22); 3459 values->msaa = (enum mali_msaa)__gen_unpack_uint(cl, 23, 24); 3460 values->srgb = __gen_unpack_uint(cl, 25, 25); 3461 values->color_block_format = (enum mali_block_format)__gen_unpack_uint(cl, 26, 27); 3462 values->dithering_enable = __gen_unpack_uint(cl, 28, 28); 3463 values->clean_pixel_write_enable = __gen_unpack_uint(cl, 29, 29); 3464 values->color_preload_enable = __gen_unpack_uint(cl, 30, 30); 3465 values->color_write_enable = __gen_unpack_uint(cl, 31, 31); 3466 values->x_downsampling_scale = __gen_unpack_uint(cl, 32, 34); 3467 values->y_downsampling_scale = __gen_unpack_uint(cl, 35, 37); 3468 values->downsampling_accumulation_mode = (enum mali_downsampling_accumulation_mode)__gen_unpack_uint(cl, 38, 39); 3469 values->sample_layout = (enum mali_sample_layout)__gen_unpack_uint(cl, 40, 41); 3470 values->big_endian = __gen_unpack_uint(cl, 42, 42); 3471 values->tie_break_rule = (enum mali_tie_break_rule)__gen_unpack_uint(cl, 43, 45); 3472 values->crc_read_enable = __gen_unpack_uint(cl, 46, 46); 3473 values->crc_write_enable = __gen_unpack_uint(cl, 47, 47); 3474 values->zs_block_format = (enum mali_block_format)__gen_unpack_uint(cl, 48, 49); 3475 values->zs_format = (enum mali_zs_format)__gen_unpack_uint(cl, 50, 53); 3476 values->zs_preload_enable = __gen_unpack_uint(cl, 54, 54); 3477 values->zs_write_enable = __gen_unpack_uint(cl, 55, 55); 3478 values->s_block_format = (enum mali_block_format)__gen_unpack_uint(cl, 56, 57); 3479 values->s_format = (enum mali_s_format)__gen_unpack_uint(cl, 58, 61); 3480 values->s_write_enable = __gen_unpack_uint(cl, 63, 63); 3481 values->bound_min_x = __gen_unpack_uint(cl, 64, 79); 3482 values->bound_min_y = __gen_unpack_uint(cl, 80, 95); 3483 values->bound_max_x = __gen_unpack_uint(cl, 96, 111); 3484 values->bound_max_y = __gen_unpack_uint(cl, 112, 127); 3485 values->dcd_offset = __gen_unpack_uint(cl, 128, 159); 3486 values->crc_buffer.base = __gen_unpack_uint(cl, 256, 319); 3487 values->crc_buffer.row_stride = __gen_unpack_uint(cl, 320, 351); 3488 values->crc_buffer.surface_stride = __gen_unpack_uint(cl, 352, 383); 3489 values->color_writeback.base = __gen_unpack_uint(cl, 384, 447); 3490 values->color_writeback.row_stride = __gen_unpack_uint(cl, 448, 479); 3491 values->color_writeback.surface_stride = __gen_unpack_uint(cl, 480, 511); 3492 values->zs_writeback.base = __gen_unpack_uint(cl, 512, 575); 3493 values->zs_writeback.row_stride = __gen_unpack_uint(cl, 576, 607); 3494 values->zs_writeback.surface_stride = __gen_unpack_uint(cl, 608, 639); 3495 values->s_writeback.base = __gen_unpack_uint(cl, 640, 703); 3496 values->s_writeback.row_stride = __gen_unpack_uint(cl, 704, 735); 3497 values->s_writeback.surface_stride = __gen_unpack_uint(cl, 736, 767); 3498 values->color_load_address = __gen_unpack_uint(cl, 768, 831); 3499 values->color_load_row_stride = __gen_unpack_uint(cl, 832, 863); 3500 values->color_load_surface_stride = __gen_unpack_uint(cl, 864, 895); 3501 values->clear_color_0 = __gen_unpack_uint(cl, 768, 799); 3502 values->clear_color_1 = __gen_unpack_uint(cl, 800, 831); 3503 values->clear_color_2 = __gen_unpack_uint(cl, 832, 863); 3504 values->clear_color_3 = __gen_unpack_uint(cl, 864, 895); 3505 values->zs_load_address = __gen_unpack_uint(cl, 896, 959); 3506 values->zs_load_row_stride = __gen_unpack_uint(cl, 960, 991); 3507 values->zs_load_surface_stride = __gen_unpack_uint(cl, 992, 1023); 3508 values->z_clear = __gen_unpack_float(cl, 896, 927); 3509 values->s_clear = __gen_unpack_uint(cl, 1024, 1031); 3510} 3511 3512static inline void 3513MALI_FRAMEBUFFER_PARAMETERS_print(FILE *fp, const struct MALI_FRAMEBUFFER_PARAMETERS * values, unsigned indent) 3514{ 3515 fprintf(fp, "%*sInternal Format: %s\n", indent, "", mali_color_buffer_internal_format_as_str(values->internal_format)); 3516 fprintf(fp, "%*sSample Count: %u\n", indent, "", values->sample_count); 3517 fprintf(fp, "%*sSwizzle: %u\n", indent, "", values->swizzle); 3518 fprintf(fp, "%*sColor Writeback Format: %s\n", indent, "", mali_color_format_as_str(values->color_writeback_format)); 3519 fprintf(fp, "%*sMSAA: %s\n", indent, "", mali_msaa_as_str(values->msaa)); 3520 fprintf(fp, "%*ssRGB: %s\n", indent, "", values->srgb ? "true" : "false"); 3521 fprintf(fp, "%*sColor Block Format: %s\n", indent, "", mali_block_format_as_str(values->color_block_format)); 3522 fprintf(fp, "%*sDithering Enable: %s\n", indent, "", values->dithering_enable ? "true" : "false"); 3523 fprintf(fp, "%*sClean Pixel Write Enable: %s\n", indent, "", values->clean_pixel_write_enable ? "true" : "false"); 3524 fprintf(fp, "%*sColor Preload Enable: %s\n", indent, "", values->color_preload_enable ? "true" : "false"); 3525 fprintf(fp, "%*sColor Write Enable: %s\n", indent, "", values->color_write_enable ? "true" : "false"); 3526 fprintf(fp, "%*sX Downsampling Scale: %u\n", indent, "", values->x_downsampling_scale); 3527 fprintf(fp, "%*sY Downsampling Scale: %u\n", indent, "", values->y_downsampling_scale); 3528 fprintf(fp, "%*sDownsampling Accumulation Mode: %s\n", indent, "", mali_downsampling_accumulation_mode_as_str(values->downsampling_accumulation_mode)); 3529 fprintf(fp, "%*sSample Layout: %s\n", indent, "", mali_sample_layout_as_str(values->sample_layout)); 3530 fprintf(fp, "%*sBig Endian: %s\n", indent, "", values->big_endian ? "true" : "false"); 3531 fprintf(fp, "%*sTie-Break Rule: %s\n", indent, "", mali_tie_break_rule_as_str(values->tie_break_rule)); 3532 fprintf(fp, "%*sCRC Read Enable: %s\n", indent, "", values->crc_read_enable ? "true" : "false"); 3533 fprintf(fp, "%*sCRC Write Enable: %s\n", indent, "", values->crc_write_enable ? "true" : "false"); 3534 fprintf(fp, "%*sZS Block Format: %s\n", indent, "", mali_block_format_as_str(values->zs_block_format)); 3535 fprintf(fp, "%*sZS Format: %s\n", indent, "", mali_zs_format_as_str(values->zs_format)); 3536 fprintf(fp, "%*sZS Preload Enable: %s\n", indent, "", values->zs_preload_enable ? "true" : "false"); 3537 fprintf(fp, "%*sZS Write Enable: %s\n", indent, "", values->zs_write_enable ? "true" : "false"); 3538 fprintf(fp, "%*sS Block Format: %s\n", indent, "", mali_block_format_as_str(values->s_block_format)); 3539 fprintf(fp, "%*sS Format: %s\n", indent, "", mali_s_format_as_str(values->s_format)); 3540 fprintf(fp, "%*sS Write Enable: %s\n", indent, "", values->s_write_enable ? "true" : "false"); 3541 fprintf(fp, "%*sBound Min X: %u\n", indent, "", values->bound_min_x); 3542 fprintf(fp, "%*sBound Min Y: %u\n", indent, "", values->bound_min_y); 3543 fprintf(fp, "%*sBound Max X: %u\n", indent, "", values->bound_max_x); 3544 fprintf(fp, "%*sBound Max Y: %u\n", indent, "", values->bound_max_y); 3545 fprintf(fp, "%*sDCD Offset: %u\n", indent, "", values->dcd_offset); 3546 fprintf(fp, "%*sCRC Buffer:\n", indent, ""); 3547 MALI_RT_BUFFER_print(fp, &values->crc_buffer, indent + 2); 3548 fprintf(fp, "%*sColor Writeback:\n", indent, ""); 3549 MALI_RT_BUFFER_print(fp, &values->color_writeback, indent + 2); 3550 fprintf(fp, "%*sZS Writeback:\n", indent, ""); 3551 MALI_RT_BUFFER_print(fp, &values->zs_writeback, indent + 2); 3552 fprintf(fp, "%*sS Writeback:\n", indent, ""); 3553 MALI_RT_BUFFER_print(fp, &values->s_writeback, indent + 2); 3554 fprintf(fp, "%*sColor Load Address: 0x%" PRIx64 "\n", indent, "", values->color_load_address); 3555 fprintf(fp, "%*sColor Load Row Stride: %u\n", indent, "", values->color_load_row_stride); 3556 fprintf(fp, "%*sColor Load Surface Stride: %u\n", indent, "", values->color_load_surface_stride); 3557 fprintf(fp, "%*sClear Color 0: %u\n", indent, "", values->clear_color_0); 3558 fprintf(fp, "%*sClear Color 1: %u\n", indent, "", values->clear_color_1); 3559 fprintf(fp, "%*sClear Color 2: %u\n", indent, "", values->clear_color_2); 3560 fprintf(fp, "%*sClear Color 3: %u\n", indent, "", values->clear_color_3); 3561 fprintf(fp, "%*sZS Load Address: 0x%" PRIx64 "\n", indent, "", values->zs_load_address); 3562 fprintf(fp, "%*sZS Load Row Stride: %u\n", indent, "", values->zs_load_row_stride); 3563 fprintf(fp, "%*sZS Load Surface Stride: %u\n", indent, "", values->zs_load_surface_stride); 3564 fprintf(fp, "%*sZ Clear: %f\n", indent, "", values->z_clear); 3565 fprintf(fp, "%*sS Clear: %u\n", indent, "", values->s_clear); 3566} 3567 3568struct MALI_FRAMEBUFFER_PADDING_1 { 3569 int dummy; 3570}; 3571 3572#define MALI_FRAMEBUFFER_PADDING_1_header \ 3573 0 3574 3575static inline void 3576MALI_FRAMEBUFFER_PADDING_1_pack(uint32_t * restrict cl, 3577 const struct MALI_FRAMEBUFFER_PADDING_1 * restrict values) 3578{ 3579 cl[ 0] = 0; 3580 cl[ 1] = 0; 3581 cl[ 2] = 0; 3582 cl[ 3] = 0; 3583 cl[ 4] = 0; 3584 cl[ 5] = 0; 3585} 3586 3587 3588#define MALI_FRAMEBUFFER_PADDING_1_LENGTH 24 3589struct mali_framebuffer_padding_1_packed { uint32_t opaque[6]; }; 3590static inline void 3591MALI_FRAMEBUFFER_PADDING_1_unpack(const uint8_t * restrict cl, 3592 struct MALI_FRAMEBUFFER_PADDING_1 * restrict values) 3593{ 3594 if (((const uint32_t *) cl)[0] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 1 unpacked at word 0\n"); 3595 if (((const uint32_t *) cl)[1] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 1 unpacked at word 1\n"); 3596 if (((const uint32_t *) cl)[2] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 1 unpacked at word 2\n"); 3597 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 1 unpacked at word 3\n"); 3598 if (((const uint32_t *) cl)[4] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 1 unpacked at word 4\n"); 3599 if (((const uint32_t *) cl)[5] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 1 unpacked at word 5\n"); 3600} 3601 3602static inline void 3603MALI_FRAMEBUFFER_PADDING_1_print(FILE *fp, const struct MALI_FRAMEBUFFER_PADDING_1 * values, unsigned indent) 3604{ 3605} 3606 3607struct MALI_FRAMEBUFFER_PADDING_2 { 3608 int dummy; 3609}; 3610 3611#define MALI_FRAMEBUFFER_PADDING_2_header \ 3612 0 3613 3614static inline void 3615MALI_FRAMEBUFFER_PADDING_2_pack(uint32_t * restrict cl, 3616 const struct MALI_FRAMEBUFFER_PADDING_2 * restrict values) 3617{ 3618 cl[ 0] = 0; 3619 cl[ 1] = 0; 3620 cl[ 2] = 0; 3621 cl[ 3] = 0; 3622 cl[ 4] = 0; 3623 cl[ 5] = 0; 3624 cl[ 6] = 0; 3625 cl[ 7] = 0; 3626} 3627 3628 3629#define MALI_FRAMEBUFFER_PADDING_2_LENGTH 32 3630struct mali_framebuffer_padding_2_packed { uint32_t opaque[8]; }; 3631static inline void 3632MALI_FRAMEBUFFER_PADDING_2_unpack(const uint8_t * restrict cl, 3633 struct MALI_FRAMEBUFFER_PADDING_2 * restrict values) 3634{ 3635 if (((const uint32_t *) cl)[0] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 2 unpacked at word 0\n"); 3636 if (((const uint32_t *) cl)[1] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 2 unpacked at word 1\n"); 3637 if (((const uint32_t *) cl)[2] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 2 unpacked at word 2\n"); 3638 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 2 unpacked at word 3\n"); 3639 if (((const uint32_t *) cl)[4] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 2 unpacked at word 4\n"); 3640 if (((const uint32_t *) cl)[5] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 2 unpacked at word 5\n"); 3641 if (((const uint32_t *) cl)[6] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 2 unpacked at word 6\n"); 3642 if (((const uint32_t *) cl)[7] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Framebuffer Padding 2 unpacked at word 7\n"); 3643} 3644 3645static inline void 3646MALI_FRAMEBUFFER_PADDING_2_print(FILE *fp, const struct MALI_FRAMEBUFFER_PADDING_2 * values, unsigned indent) 3647{ 3648} 3649 3650struct mali_framebuffer_packed { 3651 uint32_t opaque[80]; 3652}; 3653 3654#define MALI_FRAMEBUFFER_LENGTH 320 3655#define MALI_FRAMEBUFFER_ALIGN 64 3656#define MALI_FRAMEBUFFER_SECTION_LOCAL_STORAGE_TYPE struct MALI_LOCAL_STORAGE 3657#define MALI_FRAMEBUFFER_SECTION_LOCAL_STORAGE_header MALI_LOCAL_STORAGE_header 3658#define MALI_FRAMEBUFFER_SECTION_LOCAL_STORAGE_pack MALI_LOCAL_STORAGE_pack 3659#define MALI_FRAMEBUFFER_SECTION_LOCAL_STORAGE_unpack MALI_LOCAL_STORAGE_unpack 3660#define MALI_FRAMEBUFFER_SECTION_LOCAL_STORAGE_print MALI_LOCAL_STORAGE_print 3661#define MALI_FRAMEBUFFER_SECTION_LOCAL_STORAGE_OFFSET 0 3662#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_TYPE struct MALI_FRAMEBUFFER_PARAMETERS 3663#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_header MALI_FRAMEBUFFER_PARAMETERS_header 3664#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_pack MALI_FRAMEBUFFER_PARAMETERS_pack 3665#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_unpack MALI_FRAMEBUFFER_PARAMETERS_unpack 3666#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_print MALI_FRAMEBUFFER_PARAMETERS_print 3667#define MALI_FRAMEBUFFER_SECTION_PARAMETERS_OFFSET 32 3668#define MALI_FRAMEBUFFER_SECTION_TILER_TYPE struct MALI_TILER_CONTEXT 3669#define MALI_FRAMEBUFFER_SECTION_TILER_header MALI_TILER_CONTEXT_header 3670#define MALI_FRAMEBUFFER_SECTION_TILER_pack MALI_TILER_CONTEXT_pack 3671#define MALI_FRAMEBUFFER_SECTION_TILER_unpack MALI_TILER_CONTEXT_unpack 3672#define MALI_FRAMEBUFFER_SECTION_TILER_print MALI_TILER_CONTEXT_print 3673#define MALI_FRAMEBUFFER_SECTION_TILER_OFFSET 192 3674#define MALI_FRAMEBUFFER_SECTION_PADDING_1_TYPE struct MALI_FRAMEBUFFER_PADDING_1 3675#define MALI_FRAMEBUFFER_SECTION_PADDING_1_header MALI_FRAMEBUFFER_PADDING_1_header 3676#define MALI_FRAMEBUFFER_SECTION_PADDING_1_pack MALI_FRAMEBUFFER_PADDING_1_pack 3677#define MALI_FRAMEBUFFER_SECTION_PADDING_1_unpack MALI_FRAMEBUFFER_PADDING_1_unpack 3678#define MALI_FRAMEBUFFER_SECTION_PADDING_1_print MALI_FRAMEBUFFER_PADDING_1_print 3679#define MALI_FRAMEBUFFER_SECTION_PADDING_1_OFFSET 232 3680#define MALI_FRAMEBUFFER_SECTION_TILER_WEIGHTS_TYPE struct MALI_TILER_WEIGHTS 3681#define MALI_FRAMEBUFFER_SECTION_TILER_WEIGHTS_header MALI_TILER_WEIGHTS_header 3682#define MALI_FRAMEBUFFER_SECTION_TILER_WEIGHTS_pack MALI_TILER_WEIGHTS_pack 3683#define MALI_FRAMEBUFFER_SECTION_TILER_WEIGHTS_unpack MALI_TILER_WEIGHTS_unpack 3684#define MALI_FRAMEBUFFER_SECTION_TILER_WEIGHTS_print MALI_TILER_WEIGHTS_print 3685#define MALI_FRAMEBUFFER_SECTION_TILER_WEIGHTS_OFFSET 256 3686#define MALI_FRAMEBUFFER_SECTION_PADDING_2_TYPE struct MALI_FRAMEBUFFER_PADDING_2 3687#define MALI_FRAMEBUFFER_SECTION_PADDING_2_header MALI_FRAMEBUFFER_PADDING_2_header 3688#define MALI_FRAMEBUFFER_SECTION_PADDING_2_pack MALI_FRAMEBUFFER_PADDING_2_pack 3689#define MALI_FRAMEBUFFER_SECTION_PADDING_2_unpack MALI_FRAMEBUFFER_PADDING_2_unpack 3690#define MALI_FRAMEBUFFER_SECTION_PADDING_2_print MALI_FRAMEBUFFER_PADDING_2_print 3691#define MALI_FRAMEBUFFER_SECTION_PADDING_2_OFFSET 288 3692 3693enum mali_sample_pattern { 3694 MALI_SAMPLE_PATTERN_SINGLE_SAMPLED = 0, 3695 MALI_SAMPLE_PATTERN_ORDERED_4X_GRID = 1, 3696 MALI_SAMPLE_PATTERN_ROTATED_4X_GRID = 2, 3697 MALI_SAMPLE_PATTERN_D3D_8X_GRID = 3, 3698 MALI_SAMPLE_PATTERN_D3D_16X_GRID = 4, 3699}; 3700 3701static inline const char * 3702mali_sample_pattern_as_str(enum mali_sample_pattern imm) 3703{ 3704 switch (imm) { 3705 case MALI_SAMPLE_PATTERN_SINGLE_SAMPLED: return "Single-sampled"; 3706 case MALI_SAMPLE_PATTERN_ORDERED_4X_GRID: return "Ordered 4x Grid"; 3707 case MALI_SAMPLE_PATTERN_ROTATED_4X_GRID: return "Rotated 4x Grid"; 3708 case MALI_SAMPLE_PATTERN_D3D_8X_GRID: return "D3D 8x Grid"; 3709 case MALI_SAMPLE_PATTERN_D3D_16X_GRID: return "D3D 16x Grid"; 3710 default: return "XXX: INVALID"; 3711 } 3712} 3713 3714struct MALI_JOB_HEADER { 3715 uint32_t exception_status; 3716 uint32_t first_incomplete_task; 3717 uint64_t fault_pointer; 3718 bool is_64b; 3719 enum mali_job_type type; 3720 bool barrier; 3721 bool invalidate_cache; 3722 bool suppress_prefetch; 3723 bool enable_texture_mapper; 3724 bool relax_dependency_1; 3725 bool relax_dependency_2; 3726 uint32_t index; 3727 uint32_t dependency_1; 3728 uint32_t dependency_2; 3729 uint64_t next; 3730}; 3731 3732#define MALI_JOB_HEADER_header \ 3733 .is_64b = true 3734 3735static inline void 3736MALI_JOB_HEADER_pack(uint32_t * restrict cl, 3737 const struct MALI_JOB_HEADER * restrict values) 3738{ 3739 cl[ 0] = __gen_uint(values->exception_status, 0, 31); 3740 cl[ 1] = __gen_uint(values->first_incomplete_task, 0, 31); 3741 cl[ 2] = __gen_uint(values->fault_pointer, 0, 63); 3742 cl[ 3] = __gen_uint(values->fault_pointer, 0, 63) >> 32; 3743 cl[ 4] = __gen_uint(values->is_64b, 0, 0) | 3744 __gen_uint(values->type, 1, 7) | 3745 __gen_uint(values->barrier, 8, 8) | 3746 __gen_uint(values->invalidate_cache, 9, 9) | 3747 __gen_uint(values->suppress_prefetch, 11, 11) | 3748 __gen_uint(values->enable_texture_mapper, 12, 12) | 3749 __gen_uint(values->relax_dependency_1, 14, 14) | 3750 __gen_uint(values->relax_dependency_2, 15, 15) | 3751 __gen_uint(values->index, 16, 31); 3752 cl[ 5] = __gen_uint(values->dependency_1, 0, 15) | 3753 __gen_uint(values->dependency_2, 16, 31); 3754 cl[ 6] = __gen_uint(values->next, 0, 63); 3755 cl[ 7] = __gen_uint(values->next, 0, 63) >> 32; 3756} 3757 3758 3759#define MALI_JOB_HEADER_LENGTH 32 3760#define MALI_JOB_HEADER_ALIGN 64 3761struct mali_job_header_packed { uint32_t opaque[8]; }; 3762static inline void 3763MALI_JOB_HEADER_unpack(const uint8_t * restrict cl, 3764 struct MALI_JOB_HEADER * restrict values) 3765{ 3766 if (((const uint32_t *) cl)[4] & 0x2400) fprintf(stderr, "XXX: Invalid field of Job Header unpacked at word 4\n"); 3767 values->exception_status = __gen_unpack_uint(cl, 0, 31); 3768 values->first_incomplete_task = __gen_unpack_uint(cl, 32, 63); 3769 values->fault_pointer = __gen_unpack_uint(cl, 64, 127); 3770 values->is_64b = __gen_unpack_uint(cl, 128, 128); 3771 values->type = (enum mali_job_type)__gen_unpack_uint(cl, 129, 135); 3772 values->barrier = __gen_unpack_uint(cl, 136, 136); 3773 values->invalidate_cache = __gen_unpack_uint(cl, 137, 137); 3774 values->suppress_prefetch = __gen_unpack_uint(cl, 139, 139); 3775 values->enable_texture_mapper = __gen_unpack_uint(cl, 140, 140); 3776 values->relax_dependency_1 = __gen_unpack_uint(cl, 142, 142); 3777 values->relax_dependency_2 = __gen_unpack_uint(cl, 143, 143); 3778 values->index = __gen_unpack_uint(cl, 144, 159); 3779 values->dependency_1 = __gen_unpack_uint(cl, 160, 175); 3780 values->dependency_2 = __gen_unpack_uint(cl, 176, 191); 3781 values->next = __gen_unpack_uint(cl, 192, 255); 3782} 3783 3784static inline void 3785MALI_JOB_HEADER_print(FILE *fp, const struct MALI_JOB_HEADER * values, unsigned indent) 3786{ 3787 fprintf(fp, "%*sException Status: %u\n", indent, "", values->exception_status); 3788 fprintf(fp, "%*sFirst Incomplete Task: %u\n", indent, "", values->first_incomplete_task); 3789 fprintf(fp, "%*sFault Pointer: 0x%" PRIx64 "\n", indent, "", values->fault_pointer); 3790 fprintf(fp, "%*sIs 64b: %s\n", indent, "", values->is_64b ? "true" : "false"); 3791 fprintf(fp, "%*sType: %s\n", indent, "", mali_job_type_as_str(values->type)); 3792 fprintf(fp, "%*sBarrier: %s\n", indent, "", values->barrier ? "true" : "false"); 3793 fprintf(fp, "%*sInvalidate Cache: %s\n", indent, "", values->invalidate_cache ? "true" : "false"); 3794 fprintf(fp, "%*sSuppress Prefetch: %s\n", indent, "", values->suppress_prefetch ? "true" : "false"); 3795 fprintf(fp, "%*sEnable Texture Mapper: %s\n", indent, "", values->enable_texture_mapper ? "true" : "false"); 3796 fprintf(fp, "%*sRelax Dependency 1: %s\n", indent, "", values->relax_dependency_1 ? "true" : "false"); 3797 fprintf(fp, "%*sRelax Dependency 2: %s\n", indent, "", values->relax_dependency_2 ? "true" : "false"); 3798 fprintf(fp, "%*sIndex: %u\n", indent, "", values->index); 3799 fprintf(fp, "%*sDependency 1: %u\n", indent, "", values->dependency_1); 3800 fprintf(fp, "%*sDependency 2: %u\n", indent, "", values->dependency_2); 3801 fprintf(fp, "%*sNext: 0x%" PRIx64 "\n", indent, "", values->next); 3802} 3803 3804struct MALI_FRAGMENT_JOB_PAYLOAD { 3805 uint32_t bound_min_x; 3806 uint32_t bound_min_y; 3807 uint32_t bound_max_x; 3808 uint32_t bound_max_y; 3809 uint64_t framebuffer; 3810}; 3811 3812#define MALI_FRAGMENT_JOB_PAYLOAD_header \ 3813 0 3814 3815static inline void 3816MALI_FRAGMENT_JOB_PAYLOAD_pack(uint32_t * restrict cl, 3817 const struct MALI_FRAGMENT_JOB_PAYLOAD * restrict values) 3818{ 3819 cl[ 0] = __gen_uint(values->bound_min_x, 0, 11) | 3820 __gen_uint(values->bound_min_y, 16, 27); 3821 cl[ 1] = __gen_uint(values->bound_max_x, 0, 11) | 3822 __gen_uint(values->bound_max_y, 16, 27); 3823 cl[ 2] = __gen_uint(values->framebuffer, 0, 63); 3824 cl[ 3] = __gen_uint(values->framebuffer, 0, 63) >> 32; 3825} 3826 3827 3828#define MALI_FRAGMENT_JOB_PAYLOAD_LENGTH 16 3829struct mali_fragment_job_payload_packed { uint32_t opaque[4]; }; 3830static inline void 3831MALI_FRAGMENT_JOB_PAYLOAD_unpack(const uint8_t * restrict cl, 3832 struct MALI_FRAGMENT_JOB_PAYLOAD * restrict values) 3833{ 3834 if (((const uint32_t *) cl)[0] & 0xf000f000) fprintf(stderr, "XXX: Invalid field of Fragment Job Payload unpacked at word 0\n"); 3835 if (((const uint32_t *) cl)[1] & 0xf000f000) fprintf(stderr, "XXX: Invalid field of Fragment Job Payload unpacked at word 1\n"); 3836 values->bound_min_x = __gen_unpack_uint(cl, 0, 11); 3837 values->bound_min_y = __gen_unpack_uint(cl, 16, 27); 3838 values->bound_max_x = __gen_unpack_uint(cl, 32, 43); 3839 values->bound_max_y = __gen_unpack_uint(cl, 48, 59); 3840 values->framebuffer = __gen_unpack_uint(cl, 64, 127); 3841} 3842 3843static inline void 3844MALI_FRAGMENT_JOB_PAYLOAD_print(FILE *fp, const struct MALI_FRAGMENT_JOB_PAYLOAD * values, unsigned indent) 3845{ 3846 fprintf(fp, "%*sBound Min X: %u\n", indent, "", values->bound_min_x); 3847 fprintf(fp, "%*sBound Min Y: %u\n", indent, "", values->bound_min_y); 3848 fprintf(fp, "%*sBound Max X: %u\n", indent, "", values->bound_max_x); 3849 fprintf(fp, "%*sBound Max Y: %u\n", indent, "", values->bound_max_y); 3850 fprintf(fp, "%*sFramebuffer: 0x%" PRIx64 "\n", indent, "", values->framebuffer); 3851} 3852 3853struct mali_fragment_job_packed { 3854 uint32_t opaque[12]; 3855}; 3856 3857#define MALI_FRAGMENT_JOB_LENGTH 48 3858#define MALI_FRAGMENT_JOB_ALIGN 64 3859#define MALI_FRAGMENT_JOB_SECTION_HEADER_TYPE struct MALI_JOB_HEADER 3860#define MALI_FRAGMENT_JOB_SECTION_HEADER_header MALI_JOB_HEADER_header 3861#define MALI_FRAGMENT_JOB_SECTION_HEADER_pack MALI_JOB_HEADER_pack 3862#define MALI_FRAGMENT_JOB_SECTION_HEADER_unpack MALI_JOB_HEADER_unpack 3863#define MALI_FRAGMENT_JOB_SECTION_HEADER_print MALI_JOB_HEADER_print 3864#define MALI_FRAGMENT_JOB_SECTION_HEADER_OFFSET 0 3865#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_TYPE struct MALI_FRAGMENT_JOB_PAYLOAD 3866#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_header MALI_FRAGMENT_JOB_PAYLOAD_header 3867#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_pack MALI_FRAGMENT_JOB_PAYLOAD_pack 3868#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_unpack MALI_FRAGMENT_JOB_PAYLOAD_unpack 3869#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_print MALI_FRAGMENT_JOB_PAYLOAD_print 3870#define MALI_FRAGMENT_JOB_SECTION_PAYLOAD_OFFSET 32 3871 3872enum mali_write_value_type { 3873 MALI_WRITE_VALUE_TYPE_CYCLE_COUNTER = 1, 3874 MALI_WRITE_VALUE_TYPE_SYSTEM_TIMESTAMP = 2, 3875 MALI_WRITE_VALUE_TYPE_ZERO = 3, 3876}; 3877 3878static inline const char * 3879mali_write_value_type_as_str(enum mali_write_value_type imm) 3880{ 3881 switch (imm) { 3882 case MALI_WRITE_VALUE_TYPE_CYCLE_COUNTER: return "Cycle Counter"; 3883 case MALI_WRITE_VALUE_TYPE_SYSTEM_TIMESTAMP: return "System Timestamp"; 3884 case MALI_WRITE_VALUE_TYPE_ZERO: return "Zero"; 3885 default: return "XXX: INVALID"; 3886 } 3887} 3888 3889struct MALI_WRITE_VALUE_JOB_PAYLOAD { 3890 uint64_t address; 3891 enum mali_write_value_type type; 3892}; 3893 3894#define MALI_WRITE_VALUE_JOB_PAYLOAD_header \ 3895 0 3896 3897static inline void 3898MALI_WRITE_VALUE_JOB_PAYLOAD_pack(uint32_t * restrict cl, 3899 const struct MALI_WRITE_VALUE_JOB_PAYLOAD * restrict values) 3900{ 3901 cl[ 0] = __gen_uint(values->address, 0, 63); 3902 cl[ 1] = __gen_uint(values->address, 0, 63) >> 32; 3903 cl[ 2] = __gen_uint(values->type, 0, 31); 3904} 3905 3906 3907#define MALI_WRITE_VALUE_JOB_PAYLOAD_LENGTH 12 3908struct mali_write_value_job_payload_packed { uint32_t opaque[3]; }; 3909static inline void 3910MALI_WRITE_VALUE_JOB_PAYLOAD_unpack(const uint8_t * restrict cl, 3911 struct MALI_WRITE_VALUE_JOB_PAYLOAD * restrict values) 3912{ 3913 values->address = __gen_unpack_uint(cl, 0, 63); 3914 values->type = (enum mali_write_value_type)__gen_unpack_uint(cl, 64, 95); 3915} 3916 3917static inline void 3918MALI_WRITE_VALUE_JOB_PAYLOAD_print(FILE *fp, const struct MALI_WRITE_VALUE_JOB_PAYLOAD * values, unsigned indent) 3919{ 3920 fprintf(fp, "%*sAddress: 0x%" PRIx64 "\n", indent, "", values->address); 3921 fprintf(fp, "%*sType: %s\n", indent, "", mali_write_value_type_as_str(values->type)); 3922} 3923 3924struct MALI_CACHE_FLUSH_JOB_PAYLOAD { 3925 bool clean_shader_core_ls; 3926 bool invalidate_shader_core_ls; 3927 bool invalidate_shader_core_other; 3928 bool job_manager_clean; 3929 bool job_manager_invalidate; 3930 bool tiler_clean; 3931 bool tiler_invalidate; 3932 bool l2_clean; 3933 bool l2_invalidate; 3934}; 3935 3936#define MALI_CACHE_FLUSH_JOB_PAYLOAD_header \ 3937 0 3938 3939static inline void 3940MALI_CACHE_FLUSH_JOB_PAYLOAD_pack(uint32_t * restrict cl, 3941 const struct MALI_CACHE_FLUSH_JOB_PAYLOAD * restrict values) 3942{ 3943 cl[ 0] = __gen_uint(values->clean_shader_core_ls, 0, 0) | 3944 __gen_uint(values->invalidate_shader_core_ls, 1, 1) | 3945 __gen_uint(values->invalidate_shader_core_other, 2, 2) | 3946 __gen_uint(values->job_manager_clean, 16, 16) | 3947 __gen_uint(values->job_manager_invalidate, 17, 17) | 3948 __gen_uint(values->tiler_clean, 24, 24) | 3949 __gen_uint(values->tiler_invalidate, 25, 25); 3950 cl[ 1] = __gen_uint(values->l2_clean, 0, 0) | 3951 __gen_uint(values->l2_invalidate, 1, 1); 3952} 3953 3954 3955#define MALI_CACHE_FLUSH_JOB_PAYLOAD_LENGTH 8 3956struct mali_cache_flush_job_payload_packed { uint32_t opaque[2]; }; 3957static inline void 3958MALI_CACHE_FLUSH_JOB_PAYLOAD_unpack(const uint8_t * restrict cl, 3959 struct MALI_CACHE_FLUSH_JOB_PAYLOAD * restrict values) 3960{ 3961 if (((const uint32_t *) cl)[0] & 0xfcfcfff8) fprintf(stderr, "XXX: Invalid field of Cache Flush Job Payload unpacked at word 0\n"); 3962 if (((const uint32_t *) cl)[1] & 0xfffffffc) fprintf(stderr, "XXX: Invalid field of Cache Flush Job Payload unpacked at word 1\n"); 3963 values->clean_shader_core_ls = __gen_unpack_uint(cl, 0, 0); 3964 values->invalidate_shader_core_ls = __gen_unpack_uint(cl, 1, 1); 3965 values->invalidate_shader_core_other = __gen_unpack_uint(cl, 2, 2); 3966 values->job_manager_clean = __gen_unpack_uint(cl, 16, 16); 3967 values->job_manager_invalidate = __gen_unpack_uint(cl, 17, 17); 3968 values->tiler_clean = __gen_unpack_uint(cl, 24, 24); 3969 values->tiler_invalidate = __gen_unpack_uint(cl, 25, 25); 3970 values->l2_clean = __gen_unpack_uint(cl, 32, 32); 3971 values->l2_invalidate = __gen_unpack_uint(cl, 33, 33); 3972} 3973 3974static inline void 3975MALI_CACHE_FLUSH_JOB_PAYLOAD_print(FILE *fp, const struct MALI_CACHE_FLUSH_JOB_PAYLOAD * values, unsigned indent) 3976{ 3977 fprintf(fp, "%*sClean Shader Core LS: %s\n", indent, "", values->clean_shader_core_ls ? "true" : "false"); 3978 fprintf(fp, "%*sInvalidate Shader Core LS: %s\n", indent, "", values->invalidate_shader_core_ls ? "true" : "false"); 3979 fprintf(fp, "%*sInvalidate Shader Core Other: %s\n", indent, "", values->invalidate_shader_core_other ? "true" : "false"); 3980 fprintf(fp, "%*sJob Manager Clean: %s\n", indent, "", values->job_manager_clean ? "true" : "false"); 3981 fprintf(fp, "%*sJob Manager Invalidate: %s\n", indent, "", values->job_manager_invalidate ? "true" : "false"); 3982 fprintf(fp, "%*sTiler Clean: %s\n", indent, "", values->tiler_clean ? "true" : "false"); 3983 fprintf(fp, "%*sTiler Invalidate: %s\n", indent, "", values->tiler_invalidate ? "true" : "false"); 3984 fprintf(fp, "%*sL2 Clean: %s\n", indent, "", values->l2_clean ? "true" : "false"); 3985 fprintf(fp, "%*sL2 Invalidate: %s\n", indent, "", values->l2_invalidate ? "true" : "false"); 3986} 3987 3988struct mali_write_value_job_packed { 3989 uint32_t opaque[11]; 3990}; 3991 3992#define MALI_WRITE_VALUE_JOB_LENGTH 44 3993#define MALI_WRITE_VALUE_JOB_ALIGN 64 3994#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_TYPE struct MALI_JOB_HEADER 3995#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_header MALI_JOB_HEADER_header 3996#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_pack MALI_JOB_HEADER_pack 3997#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_unpack MALI_JOB_HEADER_unpack 3998#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_print MALI_JOB_HEADER_print 3999#define MALI_WRITE_VALUE_JOB_SECTION_HEADER_OFFSET 0 4000#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_TYPE struct MALI_WRITE_VALUE_JOB_PAYLOAD 4001#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_header MALI_WRITE_VALUE_JOB_PAYLOAD_header 4002#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_pack MALI_WRITE_VALUE_JOB_PAYLOAD_pack 4003#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_unpack MALI_WRITE_VALUE_JOB_PAYLOAD_unpack 4004#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_print MALI_WRITE_VALUE_JOB_PAYLOAD_print 4005#define MALI_WRITE_VALUE_JOB_SECTION_PAYLOAD_OFFSET 32 4006 4007struct mali_cache_flush_job_packed { 4008 uint32_t opaque[10]; 4009}; 4010 4011#define MALI_CACHE_FLUSH_JOB_LENGTH 40 4012#define MALI_CACHE_FLUSH_JOB_ALIGN 64 4013#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_TYPE struct MALI_JOB_HEADER 4014#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_header MALI_JOB_HEADER_header 4015#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_pack MALI_JOB_HEADER_pack 4016#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_unpack MALI_JOB_HEADER_unpack 4017#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_print MALI_JOB_HEADER_print 4018#define MALI_CACHE_FLUSH_JOB_SECTION_HEADER_OFFSET 0 4019#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_TYPE struct MALI_CACHE_FLUSH_JOB_PAYLOAD 4020#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_header MALI_CACHE_FLUSH_JOB_PAYLOAD_header 4021#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_pack MALI_CACHE_FLUSH_JOB_PAYLOAD_pack 4022#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_unpack MALI_CACHE_FLUSH_JOB_PAYLOAD_unpack 4023#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_print MALI_CACHE_FLUSH_JOB_PAYLOAD_print 4024#define MALI_CACHE_FLUSH_JOB_SECTION_PAYLOAD_OFFSET 32 4025 4026struct MALI_COMPUTE_JOB_PARAMETERS { 4027 uint32_t job_task_split; 4028}; 4029 4030#define MALI_COMPUTE_JOB_PARAMETERS_header \ 4031 0 4032 4033static inline void 4034MALI_COMPUTE_JOB_PARAMETERS_pack(uint32_t * restrict cl, 4035 const struct MALI_COMPUTE_JOB_PARAMETERS * restrict values) 4036{ 4037 cl[ 0] = __gen_uint(values->job_task_split, 26, 29); 4038 cl[ 1] = 0; 4039 cl[ 2] = 0; 4040 cl[ 3] = 0; 4041 cl[ 4] = 0; 4042 cl[ 5] = 0; 4043} 4044 4045 4046#define MALI_COMPUTE_JOB_PARAMETERS_LENGTH 24 4047struct mali_compute_job_parameters_packed { uint32_t opaque[6]; }; 4048static inline void 4049MALI_COMPUTE_JOB_PARAMETERS_unpack(const uint8_t * restrict cl, 4050 struct MALI_COMPUTE_JOB_PARAMETERS * restrict values) 4051{ 4052 if (((const uint32_t *) cl)[0] & 0xc3ffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 0\n"); 4053 if (((const uint32_t *) cl)[1] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 1\n"); 4054 if (((const uint32_t *) cl)[2] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 2\n"); 4055 if (((const uint32_t *) cl)[3] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 3\n"); 4056 if (((const uint32_t *) cl)[4] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 4\n"); 4057 if (((const uint32_t *) cl)[5] & 0xffffffff) fprintf(stderr, "XXX: Invalid field of Compute Job Parameters unpacked at word 5\n"); 4058 values->job_task_split = __gen_unpack_uint(cl, 26, 29); 4059} 4060 4061static inline void 4062MALI_COMPUTE_JOB_PARAMETERS_print(FILE *fp, const struct MALI_COMPUTE_JOB_PARAMETERS * values, unsigned indent) 4063{ 4064 fprintf(fp, "%*sJob Task Split: %u\n", indent, "", values->job_task_split); 4065} 4066 4067struct mali_compute_job_packed { 4068 uint32_t opaque[46]; 4069}; 4070 4071#define MALI_COMPUTE_JOB_LENGTH 184 4072#define MALI_COMPUTE_JOB_ALIGN 64 4073#define MALI_COMPUTE_JOB_SECTION_HEADER_TYPE struct MALI_JOB_HEADER 4074#define MALI_COMPUTE_JOB_SECTION_HEADER_header MALI_JOB_HEADER_header 4075#define MALI_COMPUTE_JOB_SECTION_HEADER_pack MALI_JOB_HEADER_pack 4076#define MALI_COMPUTE_JOB_SECTION_HEADER_unpack MALI_JOB_HEADER_unpack 4077#define MALI_COMPUTE_JOB_SECTION_HEADER_print MALI_JOB_HEADER_print 4078#define MALI_COMPUTE_JOB_SECTION_HEADER_OFFSET 0 4079#define MALI_COMPUTE_JOB_SECTION_INVOCATION_TYPE struct MALI_INVOCATION 4080#define MALI_COMPUTE_JOB_SECTION_INVOCATION_header MALI_INVOCATION_header 4081#define MALI_COMPUTE_JOB_SECTION_INVOCATION_pack MALI_INVOCATION_pack 4082#define MALI_COMPUTE_JOB_SECTION_INVOCATION_unpack MALI_INVOCATION_unpack 4083#define MALI_COMPUTE_JOB_SECTION_INVOCATION_print MALI_INVOCATION_print 4084#define MALI_COMPUTE_JOB_SECTION_INVOCATION_OFFSET 32 4085#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_TYPE struct MALI_COMPUTE_JOB_PARAMETERS 4086#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_header MALI_COMPUTE_JOB_PARAMETERS_header 4087#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_pack MALI_COMPUTE_JOB_PARAMETERS_pack 4088#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_unpack MALI_COMPUTE_JOB_PARAMETERS_unpack 4089#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_print MALI_COMPUTE_JOB_PARAMETERS_print 4090#define MALI_COMPUTE_JOB_SECTION_PARAMETERS_OFFSET 40 4091#define MALI_COMPUTE_JOB_SECTION_DRAW_TYPE struct MALI_DRAW 4092#define MALI_COMPUTE_JOB_SECTION_DRAW_header MALI_DRAW_header 4093#define MALI_COMPUTE_JOB_SECTION_DRAW_pack MALI_DRAW_pack 4094#define MALI_COMPUTE_JOB_SECTION_DRAW_unpack MALI_DRAW_unpack 4095#define MALI_COMPUTE_JOB_SECTION_DRAW_print MALI_DRAW_print 4096#define MALI_COMPUTE_JOB_SECTION_DRAW_OFFSET 64 4097 4098struct MALI_PRIMITIVE_SIZE { 4099 float constant; 4100 uint64_t size_array; 4101}; 4102 4103#define MALI_PRIMITIVE_SIZE_header \ 4104 0 4105 4106static inline void 4107MALI_PRIMITIVE_SIZE_pack(uint32_t * restrict cl, 4108 const struct MALI_PRIMITIVE_SIZE * restrict values) 4109{ 4110 cl[ 0] = __gen_uint(fui(values->constant), 0, 32) | 4111 __gen_uint(values->size_array, 0, 63); 4112 cl[ 1] = __gen_uint(values->size_array, 0, 63) >> 32; 4113} 4114 4115 4116#define MALI_PRIMITIVE_SIZE_LENGTH 8 4117struct mali_primitive_size_packed { uint32_t opaque[2]; }; 4118static inline void 4119MALI_PRIMITIVE_SIZE_unpack(const uint8_t * restrict cl, 4120 struct MALI_PRIMITIVE_SIZE * restrict values) 4121{ 4122 values->constant = __gen_unpack_float(cl, 0, 31); 4123 values->size_array = __gen_unpack_uint(cl, 0, 63); 4124} 4125 4126static inline void 4127MALI_PRIMITIVE_SIZE_print(FILE *fp, const struct MALI_PRIMITIVE_SIZE * values, unsigned indent) 4128{ 4129 fprintf(fp, "%*sConstant: %f\n", indent, "", values->constant); 4130 fprintf(fp, "%*sSize Array: 0x%" PRIx64 "\n", indent, "", values->size_array); 4131} 4132 4133struct mali_tiler_job_packed { 4134 uint32_t opaque[48]; 4135}; 4136 4137#define MALI_TILER_JOB_LENGTH 192 4138#define MALI_TILER_JOB_ALIGN 64 4139#define MALI_TILER_JOB_SECTION_HEADER_TYPE struct MALI_JOB_HEADER 4140#define MALI_TILER_JOB_SECTION_HEADER_header MALI_JOB_HEADER_header 4141#define MALI_TILER_JOB_SECTION_HEADER_pack MALI_JOB_HEADER_pack 4142#define MALI_TILER_JOB_SECTION_HEADER_unpack MALI_JOB_HEADER_unpack 4143#define MALI_TILER_JOB_SECTION_HEADER_print MALI_JOB_HEADER_print 4144#define MALI_TILER_JOB_SECTION_HEADER_OFFSET 0 4145#define MALI_TILER_JOB_SECTION_INVOCATION_TYPE struct MALI_INVOCATION 4146#define MALI_TILER_JOB_SECTION_INVOCATION_header MALI_INVOCATION_header 4147#define MALI_TILER_JOB_SECTION_INVOCATION_pack MALI_INVOCATION_pack 4148#define MALI_TILER_JOB_SECTION_INVOCATION_unpack MALI_INVOCATION_unpack 4149#define MALI_TILER_JOB_SECTION_INVOCATION_print MALI_INVOCATION_print 4150#define MALI_TILER_JOB_SECTION_INVOCATION_OFFSET 32 4151#define MALI_TILER_JOB_SECTION_PRIMITIVE_TYPE struct MALI_PRIMITIVE 4152#define MALI_TILER_JOB_SECTION_PRIMITIVE_header MALI_PRIMITIVE_header 4153#define MALI_TILER_JOB_SECTION_PRIMITIVE_pack MALI_PRIMITIVE_pack 4154#define MALI_TILER_JOB_SECTION_PRIMITIVE_unpack MALI_PRIMITIVE_unpack 4155#define MALI_TILER_JOB_SECTION_PRIMITIVE_print MALI_PRIMITIVE_print 4156#define MALI_TILER_JOB_SECTION_PRIMITIVE_OFFSET 40 4157#define MALI_TILER_JOB_SECTION_DRAW_TYPE struct MALI_DRAW 4158#define MALI_TILER_JOB_SECTION_DRAW_header MALI_DRAW_header 4159#define MALI_TILER_JOB_SECTION_DRAW_pack MALI_DRAW_pack 4160#define MALI_TILER_JOB_SECTION_DRAW_unpack MALI_DRAW_unpack 4161#define MALI_TILER_JOB_SECTION_DRAW_print MALI_DRAW_print 4162#define MALI_TILER_JOB_SECTION_DRAW_OFFSET 64 4163#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_TYPE struct MALI_PRIMITIVE_SIZE 4164#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_header MALI_PRIMITIVE_SIZE_header 4165#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_pack MALI_PRIMITIVE_SIZE_pack 4166#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_unpack MALI_PRIMITIVE_SIZE_unpack 4167#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_print MALI_PRIMITIVE_SIZE_print 4168#define MALI_TILER_JOB_SECTION_PRIMITIVE_SIZE_OFFSET 184 4169 4170#include "panfrost-job.h" 4171#endif 4172