+
+bool
+etna_update_blend(struct etna_context *ctx)
+{
+ struct pipe_framebuffer_state *pfb = &ctx->framebuffer_s;
+ struct pipe_blend_state *pblend = ctx->blend;
+ struct etna_blend_state *blend = etna_blend_state(pblend);
+ const struct pipe_rt_blend_state *rt0 = &pblend->rt[0];
+ uint32_t colormask;
+
+ if (pfb->cbufs[0] &&
+ translate_rs_format_rb_swap(pfb->cbufs[0]->texture->format)) {
+ colormask = rt0->colormask & (PIPE_MASK_A | PIPE_MASK_G);
+ if (rt0->colormask & PIPE_MASK_R)
+ colormask |= PIPE_MASK_B;
+ if (rt0->colormask & PIPE_MASK_B)
+ colormask |= PIPE_MASK_R;
+ } else {
+ colormask = rt0->colormask;
+ }
+
+ /* If the complete render target is written, set full_overwrite:
+ * - The color mask is 1111
+ * - No blending is used
+ */
+ bool full_overwrite = (rt0->colormask == 0xf) && !blend->enable;
+ blend->PE_COLOR_FORMAT =
+ VIVS_PE_COLOR_FORMAT_COMPONENTS(colormask) |
+ COND(full_overwrite, VIVS_PE_COLOR_FORMAT_OVERWRITE);
+
+ return true;
+}