mali-job.h 17.1 KB
Newer Older
1
/*
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
2
 * © Copyright 2017-2018 The Panfrost Community
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * This program is free software and is provided to you under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation, and any use by you of this program is subject to the terms
 * of such GNU licence.
 *
 * A copy of the licence is included with the program, and can also be obtained
 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 */

#ifndef __MALI_JOB_H__
#define __MALI_JOB_H__

#include <config.h>
#include <mali-ioctl.h>

21
#define MALI_SHORT_PTR_BITS (sizeof(uintptr_t)*8)
22 23 24

#define MALI_FBD_HIERARCHY_WEIGHTS 8

25 26
#define MALI_PAYLOAD_SIZE 256

27 28 29 30 31 32 33 34 35 36 37 38 39
enum mali_job_type {
	JOB_NOT_STARTED	= 0,
	JOB_TYPE_NULL = 1,
	JOB_TYPE_SET_VALUE = 2,
	JOB_TYPE_CACHE_FLUSH = 3,
	JOB_TYPE_COMPUTE = 4,
	JOB_TYPE_VERTEX = 5,
	JOB_TYPE_TILER = 7,
	JOB_TYPE_FUSED = 8,
	JOB_TYPE_FRAGMENT = 9,
};

enum mali_gl_mode {
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
40 41 42 43 44 45 46
	MALI_GL_POINTS         = 0x1,
	MALI_GL_LINES          = 0x2,
	MALI_GL_LINE_STRIP     = 0x4,
	MALI_GL_LINE_LOOP      = 0x6,
	MALI_GL_TRIANGLES      = 0x8,
	MALI_GL_TRIANGLE_STRIP = 0xA,
	MALI_GL_TRIANGLE_FAN   = 0xC,
47 48
};

49 50
#define MALI_GL_CULL_FACE_BACK  0x80
#define MALI_GL_CULL_FACE_FRONT 0x40
51

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
52 53 54 55
#define MALI_GL_FRONT_FACE(v) (v << 5)
#define MALI_GL_CCW (0)
#define MALI_GL_CW  (1)

56 57 58 59 60 61 62 63 64
/* TODO: Might this actually be a finer bitfield? */
#define MALI_DEPTH_STENCIL_ENABLE 0x6400

#define DS_ENABLE(field) \
	(field == MALI_DEPTH_STENCIL_ENABLE) \
	? "MALI_DEPTH_STENCIL_ENABLE" \
	: (field == 0) ? "0" \
	: "0 /* XXX: Unknown, check hexdump */"

65 66 67 68 69 70 71 72 73 74 75 76 77
/* Used in stencil and depth tests */

enum mali_func {
	MALI_FUNC_NEVER    = 0,
	MALI_FUNC_LESS     = 1,
	MALI_FUNC_EQUAL    = 2,
	MALI_FUNC_LEQUAL   = 3,
	MALI_FUNC_GREATER  = 4,
	MALI_FUNC_NOTEQUAL = 5,
	MALI_FUNC_GEQUAL   = 6,
	MALI_FUNC_ALWAYS   = 7
};

78 79 80 81 82 83 84 85 86 87 88 89 90
/* Same OpenGL, but mixed up. Why? Because forget me, that's why! */

enum mali_alt_func {
	MALI_ALT_FUNC_NEVER    = 0,
	MALI_ALT_FUNC_GREATER  = 1,
	MALI_ALT_FUNC_EQUAL    = 2,
	MALI_ALT_FUNC_GEQUAL   = 3,
	MALI_ALT_FUNC_LESS     = 4,
	MALI_ALT_FUNC_NOTEQUAL = 5,
	MALI_ALT_FUNC_LEQUAL   = 6,
	MALI_ALT_FUNC_ALWAYS   = 7
};

91
/* Flags apply to unknown2_3? */
92

93 94 95
#define MALI_HAS_MSAA		(1 << 0)
#define MALI_CAN_DISCARD 	(1 << 5)
#define MALI_HAS_BLEND_SHADER 	(1 << 6)
96 97

/* func is mali_func */
98 99
#define MALI_DEPTH_FUNC(func)	   (func << 8)
#define MALI_GET_DEPTH_FUNC(flags) ((flags >> 8) & 0x7)
100 101
#define MALI_DEPTH_FUNC_MASK	   MALI_DEPTH_FUNC(0x7)
 
102
#define MALI_DEPTH_TEST		(1 << 11)
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
103

104
/* Next flags to unknown2_4 */
105 106 107 108 109
#define MALI_STENCIL_TEST      	(1 << 16)

/* What?! */
#define MALI_SAMPLE_ALPHA_TO_COVERAGE_NO_BLEND_SHADER (1 << 17)

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
110
#define MALI_NO_DITHER		(1 << 25)
111 112 113
#define MALI_DEPTH_RANGE_A	(1 << 28)
#define MALI_DEPTH_RANGE_B	(1 << 29)
#define MALI_NO_MSAA		(1 << 30)
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
114

115 116 117 118 119 120 121 122 123
/* glStencilMask state plonked onto unknown2_4, a bit like glDepthFunc plonked
 * onto unknown2_3 */

#define MALI_STENCIL_MASK_FRONT(f) 	(f << 0)
#define MALI_STENCIL_MASK_BACK(f)  	(f << 8)
#define MALI_GET_STENCIL_MASK_FRONT(f) 	(f & 0xFF)
#define MALI_GET_STENCIL_MASK_BACK(f)  	((f >> 8) & 0xFF)
#define MALI_STENCIL_MASK_MASK     	0xFFFF

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
124 125
/* Stencil test state is all encoded in a single u32, just with a lot of
 * enums... */
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
126

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140
enum mali_stencil_op {
	MALI_STENCIL_KEEP 	= 0,
	MALI_STENCIL_REPLACE 	= 1,
	MALI_STENCIL_ZERO 	= 2,
	MALI_STENCIL_INVERT 	= 3,
	MALI_STENCIL_INCR_WRAP 	= 4,
	MALI_STENCIL_DECR_WRAP 	= 5,
	MALI_STENCIL_INCR 	= 6,
	MALI_STENCIL_DECR 	= 7
};

struct mali_stencil_test {
	unsigned ref  			: 8;
	unsigned mask 			: 8;
141
	enum mali_func func 		: 3;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
142 143 144 145 146 147
	enum mali_stencil_op sfail 	: 3;
	enum mali_stencil_op dpfail 	: 3;
	enum mali_stencil_op dppass 	: 3;
	unsigned zero			: 4;
} __attribute__((packed));

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
/* Blending is a mess, since anything fancy triggers a blend shader, and
 * -those- are not understood whatsover yet */

#define MALI_MASK_R (1 << 0)
#define MALI_MASK_G (1 << 1)
#define MALI_MASK_B (1 << 2)
#define MALI_MASK_A (1 << 3)

struct mali_blend_equation {
	unsigned unknown : 28;

	/* Corresponds to MALI_MASK_* above and glColorMask arguments */

	unsigned color_mask : 4;

	/* Probably doesn't actually exist, but keeps the union with mali_ptr
	 * from spilling and masking zero trips and other ugliness */
	unsigned zero    : 32;
};

168 169 170 171 172 173 174
/* Alpha coverage is encoded as 4-bits (from a clampf), with inversion
 * literally performing a bitwise invert. This function produces slightly wrong
 * results and I'm not sure why; some rounding issue I suppose... */

#define MALI_ALPHA_COVERAGE(clampf) ((uint16_t) (int) (clampf * 15.0f))
#define MALI_GET_ALPHA_COVERAGE(nibble) ((float) nibble / 15.0f)

175 176 177
/* Applies to unknown1 */
#define MALI_NO_ALPHA_TO_COVERAGE (1 << 10)

178
struct mali_shader_meta {
179
	mali_ptr shader;
180
	u32 zero1;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
181

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
182
	/* Counted as number of address slots (i.e. half-precision vec4's) */
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
183
	u16 attribute_count;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
184
	u16 varying_count;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
185

186
	/* 0x200 except MALI_NO_ALPHA_TO_COVERAGE */
187 188 189 190
	u16 unknown1; 

	 /* Whole number of uniform registers used, times two; whole number of
	  * work registers used (no scale). 
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
191 192
	 */

193 194 195
	unsigned work_count : 5;
	unsigned uniform_count : 5;
	unsigned unknown2 : 6;
196

197 198 199 200 201 202 203
	/* Depth factor is exactly as passed to glDepthOffset. Depth units is
	 * equal to the value passed to glDeptOhffset + 1.0f (use
	 * MALI_NEGATIVE) */

	float depth_units;
	float depth_factor;

204
	u32 unknown2_2;
205 206 207 208

	u16 alpha_coverage;
	u16 unknown2_3;

209
	u32 unknown2_4;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
210

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
211 212
	struct mali_stencil_test stencil_front;
	struct mali_stencil_test stencil_back;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
213

214 215
	u32 unknown2_7;
	u32 unknown2_8;
216 217 218 219 220

	/* Check for MALI_HAS_BLEND_SHADER to decide how to interpret */

	union {
		mali_ptr blend_shader;
221 222

		/* Exact format of this is not known yet */
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
223
		struct mali_blend_equation blend_equation;
224
	};
225
} __attribute__((packed));
226

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
227
/* This only concerns hardware jobs */
228

229 230
/* Possible values for job_descriptor_size */

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
231
#define MALI_JOB_32 0
232 233
#define MALI_JOB_64 1

234 235 236 237 238 239 240
struct mali_job_descriptor_header {
	u32 exception_status;
	u32 first_incomplete_task;
	u64 fault_pointer;
	u8 job_descriptor_size : 1;
	enum mali_job_type job_type : 7;
	u8 job_barrier : 1;
241
	u8 unknown_flags : 7;
242 243 244
	u16 job_index;
	u16 job_dependency_index_1;
	u16 job_dependency_index_2;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
245 246 247 248 249
	
	union {
		u64 next_job_64;
		u32 next_job_32;
	};
250 251 252 253 254 255 256 257
} __attribute__((packed));

struct mali_payload_set_value {
	u64 out;
	u64 unknown;
} __attribute__((packed));

struct mali_attr {
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
258
	mali_ptr elements;
259 260 261 262
	u32 stride;
	u32 size;
} __attribute__((packed));

263 264 265
/* TODO: I'm pretty sure this isn't really right in the presence of more
 * complicated metadata, like matrices or varyings */

266 267
struct mali_attr_meta {
	u8 index;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
268 269 270 271 272 273 274 275 276 277 278
	u64 unknown1 :14;

	/* Part of the type specifier, anyway:
	 * 1: packed (with other encoding weirdness)
	 * 3: byte
	 * 4: short
	 * 5: int
	 * 7: half, float, packed
	 */

	unsigned type : 3;
279 280 281 282

	/* After MALI_POSITIVE, 4 for vec4, 1 for scalar, etc */
	unsigned nr_components : 2;

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
283
	/* Somewhat correlated to the opposite of not_normalised, or the opposite of is_half_float? */
284 285
	unsigned unknown2 : 1;

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
286 287
	/* If the type is a signed integer, is_int_signed is set. If the type
	 * is a half-float, it's also set. Otherwise, it is clear. */
288 289 290

	unsigned is_int_signed : 1;

291 292 293 294
	/* if `normalized` passed to VertexAttribPointer is clear */
	unsigned not_normalised : 1;

	u64 unknown3 :34;
295 296 297 298 299 300 301 302 303
} __attribute__((packed));
ASSERT_SIZEOF_TYPE(struct mali_attr_meta,
		   sizeof(u64), sizeof(u64));

enum mali_fbd_type {
	MALI_SFBD = 0,
	MALI_MFBD = 1,
};

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
304 305
#define FBD_TYPE (1)
#define FBD_MASK (~0x3f)
306

307
struct mali_payload_vertex_tiler {
308 309 310
	/* Exactly as passed to glLineWidth */
	float line_width;

311 312 313
	/* Off by one */
	u32 vertex_count; 

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
314
	u32 unk1; // 0x28000000
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
315
	u32 draw_mode; 
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
316
	u32 zero0;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
317
	u32 zero1;
318 319 320 321 322 323 324 325 326

	/* Like many other strictly nonzero quantities, index_count is
	 * subtracted by one. For an indexed cube, this is equal to 35 = 6
	 * faces * 2 triangles/per face * 3 vertices/per triangle - 1. For
	 * non-indexed draws, equal to vertex_count. */

	u32 index_count;

	/* No hidden structure; literally just a pointer to an array of
327
	 * uint32_t indices. Thanks, guys, for not making my life insane for
328 329 330 331
	 * once! NULL for non-indexed draws. */

	uintptr_t indices;

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
332
	u32 zero3;
333
	u32 gl_enables; // 0x5
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
334
	u32 zero4;
335

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
336
	u32 zero5;
337 338
	uintptr_t unknown0;
	uintptr_t unknown1; /* pointer */
339 340 341

	/* For reasons I don't quite understand this is a pointer to a pointer.
	 * That second pointer points to the actual texture descriptor. */
342
	uintptr_t texture_trampoline;
343

344 345 346 347
	/* For OpenGL, from what I've seen, this is intimately connected to
	 * texture_meta. cwabbott says this is not the case under Vulkan, hence
	 * why this field is seperate (Midgard is Vulkan capable) */
	uintptr_t sampler_descriptor;
348

349
	uintptr_t uniforms;
350
	u8 flags : 4;
351 352 353
	uintptr_t _shader_upper : MALI_SHORT_PTR_BITS - 4; /* struct shader_meta */
	uintptr_t attributes; /* struct attribute_buffer[] */
	uintptr_t attribute_meta; /* attribute_meta[] */
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
354
	uintptr_t varyings; /* struct attr */
355
	uintptr_t unknown6; /* pointer */
356
	uintptr_t viewport;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
357
	u32 zero6;
358
	mali_ptr framebuffer;
359 360 361
} __attribute__((packed));
//ASSERT_SIZEOF_TYPE(struct mali_payload_vertex_tiler, 256, 256);

362
/* Pointed to from texture_trampoline, mostly unknown still, haven't
363 364
 * managed to replay successfully */

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
365
/* Purposeful off-by-one in width, height fields. For example, a (64, 64)
366
 * texture is stored as (63, 63) in these fields. This adjusts for that.
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
367 368 369
 * There's an identical pattern in the framebuffer descriptor. Even vertex
 * count fields work this way, hence the generic name -- integral fields that
 * are strictly positive generally need this adjustment. */
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
370

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
371
#define MALI_POSITIVE(dim) (dim - 1)
372

373 374 375 376
/* Opposite of MALI_POSITIVE, found in the depth_units field */

#define MALI_NEGATIVE(dim) (dim + 1)

377 378 379 380 381 382 383 384 385 386 387 388
/* Used with channel swizzling */
enum mali_channel {
	MALI_CHANNEL_RED = 0,
	MALI_CHANNEL_GREEN = 1,
	MALI_CHANNEL_BLUE = 2,
	MALI_CHANNEL_ALPHA = 3,
	MALI_CHANNEL_ZERO = 4,
	MALI_CHANNEL_ONE = 5,
	MALI_CHANNEL_RESERVED_0 = 6,
	MALI_CHANNEL_RESERVED_1 = 7,
};

389 390 391 392 393 394 395 396 397
/* Used with wrapping. Incomplete (there's a fourth mode in ES 3.2; also, this
 * is a 4-bit field...) */

enum mali_wrap_mode {
	MALI_WRAP_REPEAT = 0x8,
	MALI_WRAP_CLAMP_TO_EDGE = 0x9,
	MALI_WRAP_MIRRORED_REPEAT = 0xC
};

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
398
struct mali_texture_descriptor {
399 400 401
	uint16_t width;
	uint16_t height;

402
	uint32_t unknown1;
403 404 405

	uint32_t format1;

406 407
	uint32_t unknown3;

408 409 410 411 412 413 414 415 416 417
	/* Swizzling is a single 32-bit word, broken up here for convenience.
	 * Here, swizzling refers to the ES 3.0 texture parameters for channel
	 * level swizzling, not the internal pixel-level swizzling which is
	 * below OpenGL's reach */

	enum mali_channel swizzle_r : 3;
	enum mali_channel swizzle_g : 3;
	enum mali_channel swizzle_b : 3;
	enum mali_channel swizzle_a : 3;
	unsigned swizzle_zero       : 20;
418

419 420 421 422
	uint32_t unknown5;
	uint32_t unknown6;
	uint32_t unknown7;

423 424
	mali_ptr swizzled_bitmap_0;
	mali_ptr swizzled_bitmap_1;
425 426
} __attribute__((packed));

427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
/* Used as part of filter_mode */

#define MALI_GL_LINEAR 0
#define MALI_GL_NEAREST 1

/* Used to construct low bits of filter_mode */

#define MALI_GL_TEX_MAG(mode) (((mode) & 1) << 0)
#define MALI_GL_TEX_MIN(mode) (((mode) & 1) << 1)

#define MALI_GL_TEX_MAG_MASK (1)
#define MALI_GL_TEX_MIN_MASK (2)

#define MALI_FILTER_NAME(filter) (filter ? "MALI_GL_NEAREST" : "MALI_GL_LINEAR")

442 443 444
struct mali_sampler_descriptor {
	uint32_t filter_mode;
	
445 446
	/* Who knows? ("Someone under NDA" "Um, who else?" "You, in the future,
	 * I hope?") */
447 448
	uint32_t unknown1;

449 450 451 452 453 454 455 456 457 458 459
	/* All one word in reality, but packed a bit */

	enum mali_wrap_mode wrap_s : 4;
	enum mali_wrap_mode wrap_t : 4;
	enum mali_wrap_mode wrap_r : 4;
	enum mali_alt_func compare_func : 3;

	/* A single set bit of unknown, ha! */
	unsigned unknown2 : 1;

	unsigned zero : 16;
460 461
} __attribute__((packed));

462 463
/* TODO: What are the floats? Apparently always { -inf, -inf, inf, inf },
 * unless the scissor test is enabled.
464
 *
465 466
 * viewport0/viewport1 form the arguments to glViewport. viewport1 is modified
 * by MALI_POSITIVE; viewport0 is as-is.
467
 */
468

469
struct mali_viewport {
470 471 472 473
	float floats[4];

	float depth_range_n;
	float depth_range_f;
474

475 476 477
	u16 viewport0[2];
	u16 viewport1[2];
} __attribute__((packed));
478

479 480
/* TODO: Varying meta is symmetrical with attr_meta, but there is some
 * weirdness associated. Figure it out. */
481

482
struct mali_unknown6 {
483 484 485 486
	u64 unknown0;
	u64 unknown1;
};

487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
/* From presentations, 16x16 tiles externally. Use shift for fast computation
 * of tile numbers. */

#define MALI_TILE_SHIFT 4
#define MALI_TILE_LENGTH (1 << MALI_TILE_SHIFT)

/* Tile coordinates are stored as a compact u32, as only 12 bits are needed to
 * each component. Notice that this provides a theoretical upper bound of (1 <<
 * 12) = 4096 tiles in each direction, addressing a maximum framebuffer of size
 * 65536x65536. Multiplying that together, times another four given that Mali
 * framebuffers are 32-bit ARGB8888, means that this upper bound would take 16
 * gigabytes of RAM just to store the uncompressed framebuffer itself, let
 * alone rendering in real-time to such a buffer.
 *
 * Nice job, guys.*/

503 504 505
/* From mali_kbase_10969_workaround.c */
#define MALI_X_COORD_MASK 0x00000FFF
#define MALI_Y_COORD_MASK 0x0FFF0000
506 507 508

/* Extract parts of a tile coordinate */

509 510 511 512
#define MALI_TILE_COORD_X(coord) ((coord) & MALI_X_COORD_MASK)
#define MALI_TILE_COORD_Y(coord) (((coord) & MALI_Y_COORD_MASK) >> 16)
#define MALI_TILE_COORD_FLAGS(coord) ((coord) & ~(MALI_X_COORD_MASK | MALI_Y_COORD_MASK))

513 514 515 516 517 518 519 520 521 522 523
/* No known flags yet, but just in case...? */

#define MALI_TILE_NO_FLAG (0)

/* Helpers to generate tile coordinates based on the boundary coordinates in
 * screen space. So, with the bounds (0, 0) to (128, 128) for the screen, these
 * functions would convert it to the bounding tiles (0, 0) to (7, 7).
 * Intentional "off-by-one"; finding the tile number is a form of fencepost
 * problem. */

#define MALI_MAKE_TILE_COORDS(X, Y, flag) ((X) | ((Y) << 16) | (flag))
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
524 525 526 527
#define MALI_BOUND_TO_TILE(B, bias) ((B - bias) >> MALI_TILE_SHIFT)
#define MALI_COORDINATE_TO_TILE(W, H, flag, bias) MALI_MAKE_TILE_COORDS(MALI_BOUND_TO_TILE(W, bias), MALI_BOUND_TO_TILE(H, bias), flag)
#define MALI_COORDINATE_TO_TILE_MIN(W, H, flag) MALI_COORDINATE_TO_TILE(W, H, flag, 0) 
#define MALI_COORDINATE_TO_TILE_MAX(W, H, flag) MALI_COORDINATE_TO_TILE(W, H, flag, 1)
528

529
struct mali_payload_fragment {
530 531 532
	/* XXX: WTF? */
	u32 zero;

533 534 535 536 537
	/* XXX: we might be able to translate these into bitfields someday, but
	 * that will only be sensible if the mask of flags is limited to
	 * 0xF0000000 or 0x0000F000. If it's 0xF000F000, feel free to just
	 * remove this comment
	 */
538 539
	u32 min_tile_coord;
	u32 max_tile_coord;
540
	mali_ptr framebuffer;
541
} __attribute__((packed));
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
542
//ASSERT_SIZEOF_TYPE(struct mali_payload_fragment, 12, 16);
543

544
/* (Single?) Framebuffer Descriptor */
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
545

546 547 548 549 550 551 552
/* Flags apply to unknown2. With just MSAA_A and MSAA_B, the framebuffer is
 * configured for 4x. With MSAA_8, it is configured for 8x. */

#define MALI_FRAMEBUFFER_MSAA_8 (1 << 3)
#define MALI_FRAMEBUFFER_MSAA_A (1 << 4)
#define MALI_FRAMEBUFFER_MSAA_B (1 << 23)

553 554 555 556 557 558
/* Fast/slow based on whether all three buffers are cleared at once */

#define MALI_CLEAR_FAST         (1 << 18)
#define MALI_CLEAR_SLOW         (1 << 28)
#define MALI_CLEAR_SLOW_STENCIL (1 << 31)

559
struct mali_single_framebuffer {
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
560 561
	u32 unknown1;
	u32 flags;
562
	u64 unknown_address_0;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
563 564 565 566
	u64 zero1;
	u64 heap_free_address;

	u32 unknown2; // 0xB8..
567
	u32 clear_flags;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
568
	u32 zero2;
569 570 571 572 573 574 575

	/* Purposeful off-by-one in these fields should be accounted for by the
	 * MALI_DIMENSION macro */

	u16 width;
	u16 height;

576
	u32 zero3[8];
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
577

578 579
	mali_ptr unknown_address_5;
	u64 unknown10;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
580

581 582
	/* Depth and stencil buffers are interleaved, it appears, as they are
	 * set to the same address in captures. Both fields set to zero if the
583 584 585
	 * buffer is not being cleared. Depending on GL_ENABLE magic, you might
	 * get a zero enable despite the buffer being present; that still is
	 * disabled. */
586

587
	mali_ptr depth_buffer; // not SAME_VA
588
	u64 depth_buffer_enable; 
589 590

	mali_ptr stencil_buffer; // not SAME_VA
591
	u64 stencil_buffer_enable; 
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
592 593 594 595 596 597

	u32 clear_color_1; // RGBA8888 from glClear, actually used by hardware
	u32 clear_color_2; // always equal, but unclear function?
	u32 clear_color_3; // always equal, but unclear function?
	u32 clear_color_4; // always equal, but unclear function?

598 599
	/* Set to zero if not cleared */

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
600 601 602 603 604
	float clear_depth_1; // float32, ditto
	float clear_depth_2; // float32, ditto
	float clear_depth_3; // float32, ditto
	float clear_depth_4; // float32, ditto

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
605 606 607
	u32 clear_stencil; // Exactly as it appears in OpenGL

	u32 zero6[7];
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
608

609 610
	// 48

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
611 612 613 614 615 616
	u32 unknown8; // 0x02000000
	u32 unknown9; // 0x00000001

	u64 unknown_address_1; /* Pointing towards... a zero buffer? */
	u64 unknown_address_2;

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
617 618 619
	/* Determined by symmetry with the replay soft job, documented in the kernel */
	u64 tiler_jc_list;

Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
620
	u64 unknown_address_4;
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
621 622 623 624

	/* More below this, maybe */
} __attribute__((packed));

625 626
/* Multi? Framebuffer Descriptor */

627 628 629 630
struct mali_tentative_mfbd {
	u64 blah; /* XXX: what the fuck is this? */
	/* This GPU address is unknown, except for the fact there's something
	 * executable here... */
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
631
	u64 ugaT;
632 633 634 635
	u32 block1[10];
	u32 unknown1;
	u32 flags;
	u8 block2[16];
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
636 637
	u64 heap_free_address;
	u64 unknown2;
638
	u32 weights[MALI_FBD_HIERARCHY_WEIGHTS];
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
639
	u64 unknown_gpu_addressN;
640
	u8 block3[88];
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
641
	u64 unknown_gpu_address;
642 643 644 645 646 647 648
	u64 unknown3;
	u8 block4[40];
} __attribute__((packed));

/* Originally from chai, which found it from mali_kase_reply.c */

#endif /* __MALI_JOB_H__ */