freedreno/a6xx: disable LRZ when color channels are masked
[mesa.git] / src / gallium / drivers / freedreno / a6xx / fd6_blend.c
index 3d4b100552471e0675746812d72457ff0d6b09d3..fe63be97fd5c83fd8d8dfff144716979c8d247f5 100644 (file)
@@ -132,6 +132,7 @@ __fd6_setup_blend_variant(struct fd6_blend_stateobj *blend, unsigned sample_mask
        OUT_REG(ring, A6XX_RB_BLEND_CNTL(
                        .enable_blend      = mrt_blend,
                        .alpha_to_coverage = cso->alpha_to_coverage,
+                       .alpha_to_one = cso->alpha_to_one,
                        .independent_blend = cso->independent_blend_enable,
                        .sample_mask       = sample_mask
                ));
@@ -165,7 +166,20 @@ fd6_blend_state_create(struct pipe_context *pctx,
                const struct pipe_rt_blend_state *rt = &cso->rt[i];
 
                so->reads_dest |= rt->blend_enable;
-               if (rt->blend_enable) {
+
+               /* From the PoV of LRZ, having masked color channels is
+                * the same as having blend enabled, in that the draw will
+                * care about the fragments from an earlier draw.
+                *
+                * NOTE we actually don't care about masked color channels
+                * that don't actually exist in the render target, but we
+                * don't know the render target format here to determine
+                * that.  It is probably not worth worrying about, but if
+                * we find a game/benchmark that goes out of it's way to
+                * mask off non-existent channels, we should fixup the
+                * pipe_blend_state to give us more info.
+                */
+               if (rt->blend_enable || (rt->colormask != 0xf)) {
                        so->reads_dest = true;
                }
        }