panfrost: XMLify bifrost1
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 20 Aug 2020 20:41:41 +0000 (16:41 -0400)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Tue, 25 Aug 2020 15:05:36 +0000 (17:05 +0200)
It's so poorly understood there's not much to do in this commit, sadly.

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/bifrost/test/bi_submit.c
src/panfrost/include/panfrost-job.h
src/panfrost/lib/decode.c
src/panfrost/lib/midgard.xml

index 6ab809091a021fb701d96455d429db7e8d41d7aa..c214dd6ba726a3458de27d809826b91fff4e861c 100644 (file)
@@ -322,10 +322,17 @@ panfrost_emit_compute_shader(struct panfrost_context *ctx,
         meta->sampler_count = ctx->sampler_count[st];
 
         if (dev->quirks & IS_BIFROST) {
-                meta->bifrost1.unk1 = 0x800000;
+                struct mali_bifrost_properties_packed prop;
+
+                pan_pack(&prop, BIFROST_PROPERTIES, cfg) {
+                        cfg.unknown = 0x800000; /* XXX */
+                        cfg.uniform_buffer_count = panfrost_ubo_count(ctx, st);
+                }
+
+                memcpy(&meta->bifrost_props, &prop, sizeof(prop));
+
                 meta->bifrost2.preload_regs = 0xC0;
                 meta->bifrost2.uniform_count = ss->uniform_count;
-                meta->bifrost1.uniform_buffer_count = panfrost_ubo_count(ctx, st);
         } else {
                 struct mali_midgard_properties_packed prop;
 
@@ -564,11 +571,21 @@ panfrost_emit_frag_shader(struct panfrost_context *ctx,
         fragmeta->sampler_count = ctx->sampler_count[PIPE_SHADER_FRAGMENT];
 
         if (dev->quirks & IS_BIFROST) {
-                /* First clause ATEST |= 0x4000000.
-                 * Lefs than 32 regs |= 0x200 */
-                fragmeta->bifrost1.unk1 = 0x950020;
+                struct mali_bifrost_properties_packed prop;
+
+                bool no_blend = true;
+
+                for (unsigned i = 0; i < rt_count; ++i)
+                        no_blend &= (!blend[i].load_dest | blend[i].no_colour);
+
+                pan_pack(&prop, BIFROST_PROPERTIES, cfg) {
+                        cfg.unknown = 0x950020; /* XXX */
+                        cfg.uniform_buffer_count = panfrost_ubo_count(ctx, PIPE_SHADER_FRAGMENT);
+                        cfg.early_z_enable = !fs->can_discard && !fs->writes_depth && no_blend;
+                }
+
+                memcpy(&fragmeta->bifrost_props, &prop, sizeof(prop));
 
-                fragmeta->bifrost1.uniform_buffer_count = panfrost_ubo_count(ctx, PIPE_SHADER_FRAGMENT);
                 fragmeta->bifrost2.preload_regs = 0x1;
                 SET_BIT(fragmeta->bifrost2.preload_regs, 0x10, fs->reads_frag_coord);
 
@@ -730,16 +747,6 @@ panfrost_emit_frag_shader(struct panfrost_context *ctx,
                         break;
                 }
         }
-
-        if (dev->quirks & IS_BIFROST) {
-                bool no_blend = true;
-
-                for (unsigned i = 0; i < rt_count; ++i)
-                        no_blend &= (!blend[i].load_dest | blend[i].no_colour);
-
-                SET_BIT(fragmeta->bifrost1.unk1, MALI_BIFROST_EARLY_Z,
-                        !fs->can_discard && !fs->writes_depth && no_blend);
-        }
 }
 
 void
index 85837eb49633298e95048970de4f0e529f739c68..3688e2be1a586632d2211844631c9f25a5da8412 100644 (file)
@@ -175,10 +175,7 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog,
                 .shader = shader->gpu,
                 .attribute_count = 1,
                 .varying_count = 1,
-                .bifrost1 = {
-                        .unk1 = 0x800200,
-                        .uniform_buffer_count = 1,
-                },
+                .bifrost_props = { .opaque = { 0x80020001 } },
                 .bifrost2 = {
                         .unk3 = 0x0,
                         .preload_regs = 0xc0,
index ae1578589ead19c4cbb743e9ceeae3003fa3412e..af70f56be3ab8ce730938678ca814377a934604e 100644 (file)
@@ -193,27 +193,6 @@ struct mali_blend_mode {
 #define MALI_CHANNEL_FLOAT 7
 #define MALI_EXTRACT_BITS(fmt) (fmt & 0x7)
 
-/* Flags for bifrost1.unk1 */
-
-/* Shader uses less than 32 registers, partitioned as [R0, R15] U [R48, R63],
- * allowing for full thread count. If clear, the full [R0, R63] register set is
- * available at half thread count */
-#define MALI_BIFROST_FULL_THREAD (1 << 9)
-
-/* Enable early-z testing (presumably). This flag may not be set if the shader:
- *
- *  - Uses blending
- *  - Uses discard
- *  - Writes gl_FragDepth
- *
- * This differs from Midgard which sets the MALI_EARLY_Z flag even with
- * blending, although I've begun to suspect that flag does not in fact enable
- * EARLY_Z alone. */
-#define MALI_BIFROST_EARLY_Z (1 << 15)
-
-/* First clause type is ATEST */
-#define MALI_BIFROST_FIRST_ATEST (1 << 26)
-
 /* The raw Midgard blend payload can either be an equation or a shader
  * address, depending on the context */
 
@@ -322,10 +301,7 @@ struct mali_shader_meta {
         u16 varying_count;
 
         union {
-                struct {
-                        u32 uniform_buffer_count : 4;
-                        u32 unk1 : 28; // = 0x800000 for vertex, 0x958020 for tiler
-                } bifrost1;
+                struct mali_bifrost_properties_packed bifrost_props;
                 struct mali_midgard_properties_packed midgard_props;
         };
 
index 53f6f301b9c6cbe4f125b2d47d6cd2284bf32813..6b2e71ae12bd67ec0cb8e6ed9b639c2d7c7c078f 100644 (file)
@@ -279,16 +279,6 @@ static const struct pandecode_flag_info mfbd_extra_flag_lo_info[] = {
 };
 #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),
-        FLAG_INFO(EARLY_Z),
-        FLAG_INFO(FIRST_ATEST),
-        {}
-};
-
-#undef FLAG_INFO
-
 #define FLAG_INFO(flag) { MALI_MFBD_##flag, "MALI_MFBD_" #flag }
 static const struct pandecode_flag_info mfbd_flag_info [] = {
         FLAG_INFO(DEPTH_WRITE),
@@ -1740,6 +1730,7 @@ pandecode_vertex_tiler_postfix_pre(
                         info = pandecode_shader_disassemble(s->shader & ~0xF, job_no, job_type, is_bifrost, gpu_id);
 
                 struct MALI_MIDGARD_PROPERTIES midg_props;
+                struct MALI_BIFROST_PROPERTIES bi_props;
 
                 pandecode_log("struct mali_shader_meta shader_meta_%"PRIx64"_%d%s = {\n", p->shader, job_no, suffix);
                 pandecode_indent++;
@@ -1751,8 +1742,11 @@ pandecode_vertex_tiler_postfix_pre(
                 sampler_count = s->sampler_count;
 
                 if (is_bifrost) {
+                        uint32_t opaque = s->bifrost_props.opaque[0];
+                        MALI_BIFROST_PROPERTIES_unpack((const uint8_t *) &opaque, &bi_props);
+
                         uniform_count = s->bifrost2.uniform_count;
-                        uniform_buffer_count = s->bifrost1.uniform_buffer_count;
+                        uniform_buffer_count = bi_props.uniform_buffer_count;
                 } else {
                         uint32_t opaque = s->midgard_props.opaque[0];
                         MALI_MIDGARD_PROPERTIES_unpack((const uint8_t *) &opaque, &midg_props);
@@ -1768,13 +1762,10 @@ pandecode_vertex_tiler_postfix_pre(
                 pandecode_shader_prop("attribute_count", s->attribute_count, info.attribute_count, false);
                 pandecode_shader_prop("varying_count", s->varying_count, info.varying_count, false);
 
-                if (is_bifrost) {
-                        pandecode_log("bifrost1.unk1 = ");
-                        pandecode_log_decoded_flags(shader_bifrost_info, s->bifrost1.unk1);
-                        pandecode_log_cont(",\n");
-                } else {
+                if (is_bifrost)
+                        MALI_BIFROST_PROPERTIES_print(pandecode_dump_stream, &bi_props, 2);
+                else
                         MALI_MIDGARD_PROPERTIES_print(pandecode_dump_stream, &midg_props, 2);
-                }
 
                 if (s->depth_units || s->depth_factor) {
                         pandecode_prop("depth_factor = %f", s->depth_factor);
index 42e26232b29d30e4779687fd3545bc88fcf81f7c..352398b515f3e203ae83ab5b79d81edef005f6b9 100644 (file)
     <field name="Suppress Inf/NaN" size="1" start="29" type="bool"/>
   </struct>
 
+  <struct name="Bifrost Properties" size="1">
+    <field name="Uniform buffer count" size="8" start="0" type="uint"/>
+    <!--- If set, disables registers [R16, R47] for full thread count -->
+    <field name="Full thread" size="1" start="13" type="bool" default="false"/>
+    <field name="Early-z enable" size="1" start="19" type="bool" default="false"/>
+    <field name="First ATEST" size="1" start="30" type="bool" default="false"/>
+    <!-- XXX: This is awful -->
+    <field name="Unknown" size="32" start="0" type="uint"/>
+  </struct>
+
   <struct name="Stencil">
     <field name="Reference Value" size="8" start="0" type="uint"/>
     <field name="Mask" size="8" start="8" type="uint" default="0xFF"/>