case MESA_SHADER_FRAGMENT:
meta->attribute_count = 0;
meta->varying_count = util_bitcount64(s->info.inputs_read);
+ if (s->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH))
+ state->writes_depth = true;
+ if (s->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_STENCIL))
+ state->writes_stencil = true;
break;
case MESA_SHADER_COMPUTE:
/* TODO: images */
/* Depending on whether it's legal to in the given shader, we
* try to enable early-z testing (or forward-pixel kill?) */
- SET_BIT(ctx->fragment_shader_core.midgard1.flags_lo, MALI_EARLY_Z, !variant->can_discard);
+ SET_BIT(ctx->fragment_shader_core.midgard1.flags_lo, MALI_EARLY_Z,
+ !variant->can_discard && !variant->writes_depth);
+
+ /* Add the writes Z/S flags if needed. */
+ SET_BIT(ctx->fragment_shader_core.midgard1.flags_lo,
+ MALI_WRITES_Z, variant->writes_depth);
+ SET_BIT(ctx->fragment_shader_core.midgard1.flags_hi,
+ MALI_WRITES_S, variant->writes_stencil);
/* Any time texturing is used, derivatives are implicitly
* calculated, so we need to enable helper invocations */