panfrost: Identify "uniform buffer count" bits
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 20 Jun 2019 23:41:39 +0000 (16:41 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 24 Jun 2019 19:57:40 +0000 (12:57 -0700)
We've known about this for a while, but it was never formally in the
machine header files / decoder, so let's add them in.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/include/panfrost-job.h
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pandecode/decode.c

index 6da86148cd75ea3d5710ada6d2c987516abfba60..fbef4efdc322fcc59b72ddc56d2f4a1d1d2dae62 100644 (file)
@@ -399,7 +399,7 @@ enum mali_format {
 #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,
@@ -407,19 +407,19 @@ enum mali_format {
  * 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 */
@@ -538,9 +538,8 @@ struct mali_shader_meta {
                         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).
index 5b8e086ee2bc0eb8382623ba82f4a0bb2f05993c..3c7b5bb01584567a0e665d2e63f4b7228e127420 100644 (file)
@@ -1069,7 +1069,8 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                 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;
         }
@@ -1108,11 +1109,11 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                 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 */
@@ -1120,7 +1121,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                 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];
@@ -1139,9 +1140,8 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
 
                 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) */
index 5bc6dd84c6051a56189a4beb7a8284e5d06633c2..c7253d330f99b3d25d9f8b43c9a41be3c15bbb9d 100644 (file)
@@ -219,7 +219,7 @@ static const struct pandecode_flag_info mfbd_extra_flag_info[] = {
 #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),
@@ -1346,8 +1346,7 @@ pandecode_replay_vertex_tiler_postfix_pre(const struct mali_vertex_tiler_postfix
                         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);
@@ -1371,10 +1370,11 @@ pandecode_replay_vertex_tiler_postfix_pre(const struct mali_vertex_tiler_postfix
                         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);