unsigned zero : 4;
} __attribute__((packed));
-/* Blending is a mess, since anything fancy triggers a blend shader, and
- * -those- are not understood whatsover yet */
-
#define MALI_MASK_R (1 << 0)
#define MALI_MASK_G (1 << 1)
#define MALI_MASK_B (1 << 2)
/* On MRT Midgard systems (using an MFBD), each render target gets its own
* blend descriptor */
+#define MALI_BLEND_SRGB (0x400)
+
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 with 0-2 registers
* OR with 0x3 for programmable blending with 2+ registers
+ * OR with MALI_BLEND_SRGB for implicit sRGB
*/
u64 flags;
/* TODO: MRT */
for (unsigned i = 0; i < 1; ++i) {
+ bool is_srgb =
+ util_format_is_srgb(ctx->pipe_framebuffer.cbufs[i]->format);
+
rts[i].flags = blend_count;
+ if (is_srgb)
+ rts[i].flags |= MALI_BLEND_SRGB;
+
+ /* TODO: sRGB in blend shaders is currently
+ * unimplemented. Contact me (Alyssa) if you're
+ * interested in working on this. We have
+ * native Midgard ops for helping here, but
+ * they're not well-understood yet. */
+
+ assert(!(is_srgb && ctx->blend->has_blend_shader));
+
if (ctx->blend->has_blend_shader) {
rts[i].blend.shader = ctx->blend->blend_shader;
} else {