panfrost: XMLify blend flags
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 18 Aug 2020 21:06:01 +0000 (17:06 -0400)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Tue, 25 Aug 2020 15:05:33 +0000 (17:05 +0200)
Shared between Midgard/Bifrost. We get printing this way!

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/midgard.xml
src/panfrost/lib/pan_blit.c

index 538c6eee648d693eab754b89252a2179ed1b7f11..f57d240748a5dd1fbe76cadc17975df0f9ac0010 100644 (file)
@@ -651,16 +651,18 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts,
         for (unsigned i = 0; i < rt_count; ++i) {
                 unsigned flags = 0;
 
-                if (!blend[i].no_colour) {
-                        flags = 0x200;
+                pan_pack(&flags, BLEND_FLAGS, cfg) {
+                        if (blend[i].no_colour)
+                                break;
+
                         batch->draws |= (PIPE_CLEAR_COLOR0 << i);
 
-                        bool is_srgb = util_format_is_srgb(batch->key.cbufs[i]->format);
+                        cfg.srgb = util_format_is_srgb(batch->key.cbufs[i]->format);
+                        cfg.load_destination = !blend[i].no_blending; /* XXX */
+                        cfg.dither_disable = !batch->ctx->blend->base.dither;
 
-                        SET_BIT(flags, MALI_BLEND_MRT_SHADER, blend[i].is_shader);
-                        SET_BIT(flags, MALI_BLEND_LOAD_TIB, !blend[i].no_blending);
-                        SET_BIT(flags, MALI_BLEND_SRGB, is_srgb);
-                        SET_BIT(flags, MALI_BLEND_NO_DITHER, !batch->ctx->blend->base.dither);
+                        if (!(dev->quirks & IS_BIFROST))
+                                cfg.midgard_blend_shader = blend[i].is_shader;
                 }
 
                 if (dev->quirks & IS_BIFROST) {
@@ -696,7 +698,7 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts,
                                 brts[i].shader_type = fs->blend_types[i];
                         }
                 } else {
-                        mrts[i].flags = flags;
+                        memcpy(&mrts[i].flags, &flags, sizeof(flags));
 
                         if (blend[i].is_shader) {
                                 mrts[i].blend.shader = blend[i].shader.gpu | blend[i].shader.first_tag;
index 057aed2419db2c0c82e16e6b33527e8f1a304f93..3f227fdc8b7434ac4c1886a711f119f07f62a5cb 100644 (file)
@@ -286,30 +286,9 @@ union midgard_blend {
         };
 };
 
-/* We need to load the tilebuffer to blend (i.e. the destination factor is not
- * ZERO) */
-
-#define MALI_BLEND_LOAD_TIB (0x1)
-
-/* A blend shader is used to blend this render target */
-#define MALI_BLEND_MRT_SHADER (0x2)
-
-/* On MRT Midgard systems (using an MFBD), each render target gets its own
- * blend descriptor */
-
-#define MALI_BLEND_SRGB (0x400)
-
-/* Dithering is specified here for MFBD, otherwise NO_DITHER for SFBD */
-#define MALI_BLEND_NO_DITHER (0x800)
-
 struct midgard_blend_rt {
-        /* Flags base value of 0x200 to enable the render target.
-         * OR with 0x1 for blending (anything other than REPLACE).
-         * OR with 0x2 for programmable blending
-         * OR with MALI_BLEND_SRGB for implicit sRGB
-         */
-
-        u64 flags;
+        struct mali_blend_flags_packed flags;
+        u32 zero;
         union midgard_blend blend;
 } __attribute__((packed));
 
index f2f5df97dc687945a14dacab5fa78f82ef3009bb..d8567f41d7ab776eb64566f3b0e20667e4ae437b 100644 (file)
@@ -1276,12 +1276,12 @@ pandecode_midgard_blend_mrt(void *descs, int job_no, int rt_no)
                 ((struct midgard_blend_rt *) descs) + rt_no;
 
         /* Flags determine presence of blend shader */
-        bool is_shader = (b->flags & 0xF) >= 0x2;
+        bool is_shader = b->flags.opaque[0] & 0x2;
 
         pandecode_log("struct midgard_blend_rt blend_rt_%d_%d = {\n", job_no, rt_no);
         pandecode_indent++;
 
-        pandecode_prop("flags = 0x%" PRIx64, b->flags);
+        DUMP_CL("Flags", BLEND_FLAGS, &b->flags, 2);
 
         union midgard_blend blend = b->blend;
         mali_ptr shader = pandecode_midgard_blend(&blend, is_shader);
index 30a6423063c24f9eecadcf30f674e42274a28e6c..0a3b6b15f7fb0d683e14bf0753cab6dc4bcddb07 100644 (file)
     <field name="Divisor" size="32" start="3:0" type="uint"/>
   </struct>
 
+  <struct name="Blend Flags" size="1">
+    <field name="Load destination" size="1" start="0" type="bool" default="false"/>
+    <field name="Midgard blend shader" size="1" start="1" type="bool" default="false"/>
+    <field name="Enable" size="1" start="9" type="bool" default="true"/>
+    <field name="sRGB" size="1" start="10" type="bool" default="false"/>
+    <field name="Dither disable" size="1" start="11" type="bool" default="false"/>
+  </struct>
+
   <struct name="Midgard Sampler">
     <field name="Magnify Nearest" size="1" start="0" type="bool" default="true"/>
     <field name="Minify Nearest" size="1" start="1" type="bool" default="true"/>
index 7494b0a273192e24e6063f510051a4288275f2d7..0676b85f25f50d535cabd72d9da08c6c0244ced4 100644 (file)
@@ -322,17 +322,19 @@ panfrost_load_midg(
 
                 if (loc == (FRAG_RESULT_DATA0 + i)) {
                         struct midgard_blend_rt blend_rt = {
-                                .flags = 0x200 | MALI_BLEND_NO_DITHER,
                                 .blend = replace,
                         };
 
-                        if (util_format_is_srgb(image->format))
-                                blend_rt.flags |= MALI_BLEND_SRGB;
+                        unsigned flags = 0;
+                        pan_pack(&flags, BLEND_FLAGS, cfg) {
+                                cfg.dither_disable = true;
+                                cfg.srgb = util_format_is_srgb(image->format);
+                                cfg.midgard_blend_shader = blend_shader;
+                        }
+                        blend_rt.flags.opaque[0] = flags;
 
-                        if (blend_shader) {
-                                blend_rt.flags |= MALI_BLEND_MRT_SHADER;
+                        if (blend_shader)
                                 blend_rt.blend.shader = blend_shader;
-                        }
 
                         memcpy(dest, &blend_rt, sizeof(struct midgard_blend_rt));
                 } else {