diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 538c6eee648..f57d240748a 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -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;
diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h
index 057aed2419d..3f227fdc8b7 100644
--- a/src/panfrost/include/panfrost-job.h
+++ b/src/panfrost/include/panfrost-job.h
@@ -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));
diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c
index f2f5df97dc6..d8567f41d7a 100644
--- a/src/panfrost/lib/decode.c
+++ b/src/panfrost/lib/decode.c
@@ -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);
diff --git a/src/panfrost/lib/midgard.xml b/src/panfrost/lib/midgard.xml
index 30a6423063c..0a3b6b15f7f 100644
--- a/src/panfrost/lib/midgard.xml
+++ b/src/panfrost/lib/midgard.xml
@@ -256,6 +256,14 @@
+
+
+
+
+
+
+
+
diff --git a/src/panfrost/lib/pan_blit.c b/src/panfrost/lib/pan_blit.c
index 7494b0a2731..0676b85f25f 100644
--- a/src/panfrost/lib/pan_blit.c
+++ b/src/panfrost/lib/pan_blit.c
@@ -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;
-
- if (blend_shader) {
- blend_rt.flags |= MALI_BLEND_MRT_SHADER;
- blend_rt.blend.shader = blend_shader;
+ 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.blend.shader = blend_shader;
memcpy(dest, &blend_rt, sizeof(struct midgard_blend_rt));
} else {