v3d: Fix MRT blending with independent blending disabled.
authorEric Anholt <eric@anholt.net>
Wed, 11 Jul 2018 18:02:11 +0000 (11:02 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 12 Jul 2018 18:31:08 +0000 (11:31 -0700)
We were only emitting the RT blend state for RT 0 and only enabling it for
RT 0, when the gallium API for !independent_blend is for rt0's state to
apply to all of them.

Fixes piglit fbo-drawbuffers-blend-add.

src/gallium/drivers/v3d/v3dx_emit.c
src/gallium/drivers/v3d/v3dx_state.c

index 9c97bb6c25d84f0c5342cc9eb3c0e11217b38875..4402218f40437493efbc93031177bba0a8ef6421 100644 (file)
@@ -286,7 +286,10 @@ emit_rt_blend(struct v3d_context *v3d, struct v3d_job *job,
 
         cl_emit(&job->bcl, BLEND_CONFIG, config) {
 #if V3D_VERSION >= 40
-                config.render_target_mask = 1 << rt;
+                if (blend->independent_blend_enable)
+                        config.render_target_mask = 1 << rt;
+                else
+                        config.render_target_mask = (1 << VC5_MAX_DRAW_BUFFERS) - 1;
 #else
                 assert(rt == 0);
 #endif
index f775c531e5f640564c68ebdc0e87107fd582f321..a092b1fb9e1e65d9319827eb8908266a33787db3 100644 (file)
@@ -126,12 +126,17 @@ v3d_create_blend_state(struct pipe_context *pctx,
 
         so->base = *cso;
 
-        for (int i = 0; i < VC5_MAX_DRAW_BUFFERS; i++) {
-                so->blend_enables |= cso->rt[i].blend_enable << i;
+        if (cso->independent_blend_enable) {
+                for (int i = 0; i < VC5_MAX_DRAW_BUFFERS; i++) {
+                        so->blend_enables |= cso->rt[i].blend_enable << i;
 
-                /* V3D 4.x is when we got independent blend enables. */
-                assert(V3D_VERSION >= 40 ||
-                       cso->rt[i].blend_enable == cso->rt[0].blend_enable);
+                        /* V3D 4.x is when we got independent blend enables. */
+                        assert(V3D_VERSION >= 40 ||
+                               cso->rt[i].blend_enable == cso->rt[0].blend_enable);
+                }
+        } else {
+                if (cso->rt[0].blend_enable)
+                        so->blend_enables = (1 << VC5_MAX_DRAW_BUFFERS) - 1;
         }
 
         return so;