panfrost: Remove midgard1 bitfield
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 20 Aug 2020 20:25:14 +0000 (16:25 -0400)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Tue, 25 Aug 2020 15:05:36 +0000 (17:05 +0200)
It is now entirely XML, including for decoding. Woo!

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6440>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/panfrost/include/panfrost-job.h
src/panfrost/lib/decode.c
src/panfrost/lib/pan_blit.c

index 6926de6b82d1eca400a5e2644b7269b1846f487b..6ab809091a021fb701d96455d429db7e8d41d7aa 100644 (file)
@@ -337,7 +337,7 @@ panfrost_emit_compute_shader(struct panfrost_context *ctx,
                         cfg.suppress_inf_nan = true; /* XXX */
                 }
 
-                memcpy(&meta->midgard1, &prop, sizeof(prop));
+                memcpy(&meta->midgard_props, &prop, sizeof(prop));
         }
 }
 
@@ -616,7 +616,7 @@ panfrost_emit_frag_shader(struct panfrost_context *ctx,
                         cfg.reads_depth_stencil = zs_enabled && fs->can_discard;
                 }
 
-                memcpy(&fragmeta->midgard1, &prop, sizeof(prop));
+                memcpy(&fragmeta->midgard_props, &prop, sizeof(prop));
         }
 
         bool msaa = rast->multisample;
@@ -695,7 +695,7 @@ panfrost_emit_frag_shader(struct panfrost_context *ctx,
                         cfg.early_z_enable = true;
                 }
 
-                memcpy(&fragmeta->midgard1, &prop, sizeof(prop));
+                memcpy(&fragmeta->midgard_props, &prop, sizeof(prop));
         }
 
         if (dev->quirks & MIDGARD_SFBD) {
index d5a48fd344b22939f3317c3e86158df1888c9302..ae1578589ead19c4cbb743e9ceeae3003fa3412e 100644 (file)
@@ -193,54 +193,6 @@ struct mali_blend_mode {
 #define MALI_CHANNEL_FLOAT 7
 #define MALI_EXTRACT_BITS(fmt) (fmt & 0x7)
 
-/* Applies to midgard1.flags_lo */
-
-/* Should be set when the fragment shader updates the depth value. */
-#define MALI_WRITES_Z (1 << 4)
-
-/* Should the hardware perform early-Z testing? Set if the shader does not use
- * discard, alpha-to-coverage, shader depth writes, and if the shader has no
- * side effects (writes to global memory or images) unless early-z testing is
- * forced in the shader.
- */
-
-#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 << 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 << 8)
-
-/* The shader might write to global memory (via OpenCL, SSBOs, or images).
- * Reading is okay, as are ordinary writes to the tilebuffer/varyings. Setting
- * incurs a performance penalty. On a fragment shader, this bit implies there
- * are side effects, hence it interacts with early-z. */
-#define MALI_WRITES_GLOBAL (1 << 9)
-
-#define MALI_READS_TILEBUFFER (1 << 10)
-
-/* Applies to midgard1.flags_hi */
-
-/* Should be set when the fragment shader updates the stencil value. */
-#define MALI_WRITES_S (1 << 2)
-
-/* Mode to suppress generation of Infinity and NaN values by clamping inf
- * (-inf) to MAX_FLOAT (-MIN_FLOAT) and flushing NaN to 0.0
- *
- * Compare suppress_inf/suppress_nan flags on the Bifrost clause header for the
- * same functionality.
- *
- * This is not conformant on GLES3 or OpenCL, but is optional on GLES2, where
- * it works around app bugs (e.g. in glmark2-es2 -bterrain with FP16).
- */
-#define MALI_SUPPRESS_INF_NAN (1 << 3)
-
 /* Flags for bifrost1.unk1 */
 
 /* Shader uses less than 32 registers, partitioned as [R0, R15] U [R48, R63],
@@ -374,15 +326,7 @@ struct mali_shader_meta {
                         u32 uniform_buffer_count : 4;
                         u32 unk1 : 28; // = 0x800000 for vertex, 0x958020 for tiler
                 } bifrost1;
-                struct {
-                        unsigned uniform_buffer_count : 4;
-                        unsigned flags_lo : 12;
-
-                        /* vec4 units */
-                        unsigned work_count : 5;
-                        unsigned uniform_count : 5;
-                        unsigned flags_hi : 6;
-                } midgard1;
+                struct mali_midgard_properties_packed midgard_props;
         };
 
         /* Same as glPolygoOffset() arguments */
index e7716aeb11c33d6646eca28643da01b52b39739c..53f6f301b9c6cbe4f125b2d47d6cd2284bf32813 100644 (file)
@@ -279,23 +279,6 @@ static const struct pandecode_flag_info mfbd_extra_flag_lo_info[] = {
 };
 #undef FLAG_INFO
 
-#define FLAG_INFO(flag) { MALI_##flag, "MALI_" #flag }
-static const struct pandecode_flag_info shader_midgard1_flag_lo_info [] = {
-        FLAG_INFO(WRITES_Z),
-        FLAG_INFO(EARLY_Z),
-        FLAG_INFO(READS_TILEBUFFER),
-        FLAG_INFO(WRITES_GLOBAL),
-        FLAG_INFO(READS_ZS),
-        {}
-};
-
-static const struct pandecode_flag_info shader_midgard1_flag_hi_info [] = {
-        FLAG_INFO(WRITES_S),
-        FLAG_INFO(SUPPRESS_INF_NAN),
-        {}
-};
-#undef FLAG_INFO
-
 #define FLAG_INFO(flag) { MALI_BIFROST_##flag, "MALI_BIFROST_" #flag }
 static const struct pandecode_flag_info shader_bifrost_info [] = {
         FLAG_INFO(FULL_THREAD),
@@ -1756,6 +1739,8 @@ pandecode_vertex_tiler_postfix_pre(
                 if (s->shader & ~0xF)
                         info = pandecode_shader_disassemble(s->shader & ~0xF, job_no, job_type, is_bifrost, gpu_id);
 
+                struct MALI_MIDGARD_PROPERTIES midg_props;
+
                 pandecode_log("struct mali_shader_meta shader_meta_%"PRIx64"_%d%s = {\n", p->shader, job_no, suffix);
                 pandecode_indent++;
 
@@ -1769,8 +1754,11 @@ pandecode_vertex_tiler_postfix_pre(
                         uniform_count = s->bifrost2.uniform_count;
                         uniform_buffer_count = s->bifrost1.uniform_buffer_count;
                 } else {
-                        uniform_count = s->midgard1.uniform_count;
-                        uniform_buffer_count = s->midgard1.uniform_buffer_count;
+                        uint32_t opaque = s->midgard_props.opaque[0];
+                        MALI_MIDGARD_PROPERTIES_unpack((const uint8_t *) &opaque, &midg_props);
+
+                        uniform_count = midg_props.uniform_count;
+                        uniform_buffer_count = midg_props.uniform_buffer_count;
                 }
 
                 pandecode_shader_address("shader", s->shader);
@@ -1779,39 +1767,13 @@ pandecode_vertex_tiler_postfix_pre(
                 pandecode_shader_prop("sampler_count", s->sampler_count, info.sampler_count, false);
                 pandecode_shader_prop("attribute_count", s->attribute_count, info.attribute_count, false);
                 pandecode_shader_prop("varying_count", s->varying_count, info.varying_count, false);
-                pandecode_shader_prop("uniform_buffer_count",
-                                uniform_buffer_count,
-                                info.uniform_buffer_count, true);
-
-                if (!is_bifrost) {
-                        pandecode_shader_prop("uniform_count",
-                                        uniform_count,
-                                        info.uniform_count, false);
-
-                        pandecode_shader_prop("work_count",
-                                        s->midgard1.work_count, info.work_count, false);
-                }
 
                 if (is_bifrost) {
                         pandecode_log("bifrost1.unk1 = ");
                         pandecode_log_decoded_flags(shader_bifrost_info, s->bifrost1.unk1);
                         pandecode_log_cont(",\n");
                 } else {
-                        bool helpers = s->midgard1.flags_lo & MALI_HELPER_INVOCATIONS;
-
-                        if (helpers != info.helper_invocations) {
-                                pandecode_msg("XXX: expected helpers %u but got %u\n",
-                                                info.helper_invocations, helpers);
-                        }
-
-                        pandecode_log(".midgard1.flags_lo = ");
-                        pandecode_log_decoded_flags(shader_midgard1_flag_lo_info,
-                                                    s->midgard1.flags_lo & ~MALI_HELPER_INVOCATIONS);
-                        pandecode_log_cont(",\n");
-
-                        pandecode_log(".midgard1.flags_hi = ");
-                        pandecode_log_decoded_flags(shader_midgard1_flag_hi_info, s->midgard1.flags_hi);
-                        pandecode_log_cont(",\n");
+                        MALI_MIDGARD_PROPERTIES_print(pandecode_dump_stream, &midg_props, 2);
                 }
 
                 if (s->depth_units || s->depth_factor) {
index a9e6d6d0f0cd16570b09c693693db50d95a8176e..d7c178949c9085a6f4a69e2d588926af120c4188 100644 (file)
@@ -249,10 +249,6 @@ panfrost_load_midg(
                 .sampler_count = 1,
                 .texture_count = 1,
                 .varying_count = 1,
-                .midgard1 = {
-                        .flags_lo = 0x20,
-                        .work_count = 4,
-                },
                 .coverage_mask = ~0,
                 .unknown2_3 = MALI_DEPTH_FUNC(MALI_FUNC_ALWAYS) | 0x10,
                 .unknown2_4 = 0x4e0,
@@ -265,6 +261,19 @@ panfrost_load_midg(
                 }
         };
 
+        struct mali_midgard_properties_packed midgard_props;
+
+        pan_pack(&midgard_props, MIDGARD_PROPERTIES, cfg) {
+                cfg.work_register_count = 4;
+                cfg.early_z_enable = (loc >= FRAG_RESULT_DATA0);
+                cfg.stencil_from_shader = (loc == FRAG_RESULT_STENCIL);
+                cfg.depth_source = (loc == FRAG_RESULT_DEPTH) ?
+                        MALI_DEPTH_SOURCE_SHADER :
+                        MALI_DEPTH_SOURCE_FIXED_FUNCTION;
+        }
+
+        memcpy(&shader_meta.midgard_props, &midgard_props, sizeof(midgard_props));
+
         if (ms)
                 shader_meta.unknown2_3 |= MALI_HAS_MSAA | MALI_PER_SAMPLE;
         else
@@ -277,15 +286,10 @@ panfrost_load_midg(
                 shader_meta.blend = replace;
         }
 
-        if (loc == FRAG_RESULT_DEPTH) {
-                shader_meta.midgard1.flags_lo |= MALI_WRITES_Z;
+        if (loc == FRAG_RESULT_DEPTH)
                 shader_meta.unknown2_3 |= MALI_DEPTH_WRITEMASK;
-        } else if (loc == FRAG_RESULT_STENCIL) {
-                shader_meta.midgard1.flags_hi |= MALI_WRITES_S;
+        else if (loc == FRAG_RESULT_STENCIL)
                 shader_meta.unknown2_4 |= MALI_STENCIL_TEST;
-        } else {
-                shader_meta.midgard1.flags_lo |= MALI_EARLY_Z;
-        }
 
         /* Create the texture descriptor. We partially compute the base address
          * ourselves to account for layer, such that the texture descriptor