diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index e81f7757aa5..4b23cf11421 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -337,6 +337,19 @@ bi_emit_blend_op(bi_builder *b, bi_index rgba, nir_alu_type T, unsigned rt) b->shader->blend_types[rt] = T; } +/* Blend shaders do not need to run ATEST since they are dependent on a + * fragment shader that runs it. Blit shaders may not need to run ATEST, since + * ATEST is not needed if early-z is forced, alpha-to-coverage is disabled, and + * there are no writes to the coverage mask. The latter two are satisfied for + * all blit shaders, so we just care about early-z, which blit shaders force + * iff they do not write depth or stencil */ + +static bool +bi_skip_atest(bi_context *ctx, bool emit_zs) +{ + return (ctx->is_blit && !emit_zs) || ctx->is_blend; +} + static void bi_emit_fragment_out(bi_builder *b, nir_intrinsic_instr *instr) { @@ -370,7 +383,8 @@ bi_emit_fragment_out(bi_builder *b, nir_intrinsic_instr *instr) * value, but render target #0 might not be floating point. However the * alpha value is only used for alpha-to-coverage, a stage which is * skipped for pure integer framebuffers, so the issue is moot. */ - if (!b->shader->emitted_atest && !b->shader->is_blend) { + + if (!b->shader->emitted_atest && !bi_skip_atest(b->shader, emit_zs)) { nir_alu_type T = nir_intrinsic_src_type(instr); bi_index rgba = bi_src_index(&instr->src[0]);