#define MALI_ALPHA_COVERAGE(clampf) ((uint16_t) (int) (clampf * 15.0f))
#define MALI_GET_ALPHA_COVERAGE(nibble) ((float) nibble / 15.0f)
-/* Applies to unknown1 */
+/* Applies to midgard1.flags */
/* Should the hardware perform early-Z testing? Normally should be set
* for performance reasons. Clear if you use: discard,
* forward-pixel kill; we're not quite sure which bit is which yet.
* TODO: How does this interact with blending?*/
-#define MALI_EARLY_Z (1 << 10)
+#define MALI_EARLY_Z (1 << 6)
/* Should the hardware calculate derivatives (via helper invocations)? Set in a
* fragment shader that uses texturing or derivative functions */
-#define MALI_HELPER_INVOCATIONS (1 << 11)
+#define MALI_HELPER_INVOCATIONS (1 << 7)
/* Flags denoting the fragment shader's use of tilebuffer readback. If the
* shader might read any part of the tilebuffer, set MALI_READS_TILEBUFFER. If
* it might read depth/stencil in particular, also set MALI_READS_ZS */
-#define MALI_READS_ZS (1 << 12)
-#define MALI_READS_TILEBUFFER (1 << 16)
+#define MALI_READS_ZS (1 << 8)
+#define MALI_READS_TILEBUFFER (1 << 12)
/* The raw Midgard blend payload can either be an equation or a shader
* address, depending on the context */
u32 unk1 : 28; // = 0x800000 for vertex, 0x958020 for tiler
} bifrost1;
struct {
- /* 0x200 except MALI_NO_ALPHA_TO_COVERAGE. Mysterious 1
- * other times. Who knows really? */
- u16 unknown1;
+ unsigned uniform_buffer_count : 4;
+ unsigned flags : 12;
/* Whole number of uniform registers used, times two;
* whole number of work registers used (no scale).
vs->tripipe->sampler_count = ctx->sampler_count[PIPE_SHADER_VERTEX];
/* Who knows */
- vs->tripipe->midgard1.unknown1 = 0x2201;
+ vs->tripipe->midgard1.flags = 0x220;
+ vs->tripipe->midgard1.uniform_buffer_count = 1;
ctx->payload_vertex.postfix._shader_upper = vs->tripipe_gpu >> 4;
}
if (ctx->blend->has_blend_shader)
ctx->fragment_shader_core.midgard1.work_count = /*MAX2(ctx->fragment_shader_core.midgard1.work_count, ctx->blend->blend_work_count)*/16;
- /* Set late due to depending on render state */
-
- /* The bottom bits seem to mean UBO count */
unsigned ubo_count = panfrost_ubo_count(ctx, PIPE_SHADER_FRAGMENT);
- unsigned flags = MALI_EARLY_Z | 0x200 | 0x2000 | ubo_count;
+ ctx->fragment_shader_core.midgard1.uniform_buffer_count = ubo_count;
+
+ /* Set late due to depending on render state */
+ unsigned flags = MALI_EARLY_Z | 0x20 | 0x200;
/* Any time texturing is used, derivatives are implicitly
* calculated, so we need to enable helper invocations */
if (ctx->sampler_view_count[PIPE_SHADER_FRAGMENT])
flags |= MALI_HELPER_INVOCATIONS;
- ctx->fragment_shader_core.midgard1.unknown1 = flags;
+ ctx->fragment_shader_core.midgard1.flags = flags;
/* Assign texture/sample count right before upload */
ctx->fragment_shader_core.texture_count = ctx->sampler_view_count[PIPE_SHADER_FRAGMENT];
if (variant->can_discard) {
ctx->fragment_shader_core.unknown2_3 |= MALI_CAN_DISCARD;
- ctx->fragment_shader_core.midgard1.unknown1 &= ~MALI_EARLY_Z;
- ctx->fragment_shader_core.midgard1.unknown1 |= 0x4000;
- ctx->fragment_shader_core.midgard1.unknown1 = 0x4200;
+ ctx->fragment_shader_core.midgard1.flags &= ~MALI_EARLY_Z;
+ ctx->fragment_shader_core.midgard1.flags |= 0x400;
}
/* Check if we're using the default blend descriptor (fast path) */
#undef FLAG_INFO
#define FLAG_INFO(flag) { MALI_##flag, "MALI_" #flag }
-static const struct pandecode_flag_info shader_unknown1_flag_info [] = {
+static const struct pandecode_flag_info shader_midgard1_flag_info [] = {
FLAG_INFO(EARLY_Z),
FLAG_INFO(HELPER_INVOCATIONS),
FLAG_INFO(READS_TILEBUFFER),
uniform_buffer_count = s->bifrost1.uniform_buffer_count;
} else {
uniform_count = s->midgard1.uniform_count;
- /* TODO figure this out */
- uniform_buffer_count = 1;
+ uniform_buffer_count = s->midgard1.uniform_buffer_count;
}
mali_ptr shader_ptr = pandecode_replay_shader_address("shader", s->shader);
pandecode_indent++;
pandecode_prop("uniform_count = %" PRId16, s->midgard1.uniform_count);
+ pandecode_prop("uniform_buffer_count = %" PRId16, s->midgard1.uniform_buffer_count);
pandecode_prop("work_count = %" PRId16, s->midgard1.work_count);
- pandecode_log(".unknown1 = ");
- pandecode_log_decoded_flags(shader_unknown1_flag_info, s->midgard1.unknown1);
+ pandecode_log(".flags = ");
+ pandecode_log_decoded_flags(shader_midgard1_flag_info, s->midgard1.flags);
pandecode_log_cont(",\n");
pandecode_prop("unknown2 = 0x%" PRIx32, s->midgard1.unknown2);