From c19607b5055927ccba9711e22a4d877afdc81808 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 8 Jun 2026 19:18:43 -0700 Subject: [PATCH] jay: Still predicate Null RT store if everything is discarded Even if nothing is being written, we still need to avoid generating fragments for occlusion query purposes. Fixes dEQP-GLES31.functional.fbo.no_attachments.maximums.height as well as misrendering in Baldurs Gate 3 and Elder Scrolls Online. Fixes: e7cfcf41f47 ("jay: Ignore RT store condition if there are no outputs") Part-of: --- src/intel/compiler/jay/jay_nir.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/intel/compiler/jay/jay_nir.c b/src/intel/compiler/jay/jay_nir.c index c3bf942bfb1..4d363021dfa 100644 --- a/src/intel/compiler/jay/jay_nir.c +++ b/src/intel/compiler/jay/jay_nir.c @@ -178,13 +178,10 @@ insert_rt_store(nir_builder *b, nir_def *src0_colour, nir_def *depth, nir_def *stencil, - nir_def *sample_mask) + nir_def *sample_mask, + nir_def *disable) { bool null_rt = target < 0; - bool eot_only = null_rt && - !colour && - nir_def_is_undef(depth) && - nir_def_is_undef(stencil); colour = nir_pad_vec4(b, colour ?: nir_undef(b, 4, 32)); dual_colour = nir_pad_vec4(b, dual_colour ?: nir_undef(b, 4, 32)); @@ -199,10 +196,6 @@ insert_rt_store(nir_builder *b, nir_def *src0_alpha = nir_channel_or_undef(b, src0_colour ?: colour, 3); - nir_def *disable = b->shader->info.fs.uses_discard && !eot_only ? - nir_is_helper_invocation(b, 1) : - nir_imm_false(b); - nir_store_render_target_intel(b, colour, dual_colour, src0_alpha, sample_mask, depth, stencil, disable, .target = target); @@ -223,10 +216,14 @@ lower_fragment_outputs(nir_function_impl *impl, nir_def *undef = nir_undef(b, 1, 32); + nir_def *disable = b->shader->info.fs.uses_discard ? + nir_is_helper_invocation(b, 1) : + nir_imm_false(b); + if (ctx.dual_blend) { insert_rt_store(b, 0, ctx.colour[0], ctx.colour[1], NULL, ctx.depth ?: undef, ctx.stencil ?: undef, - ctx.sample_mask ?: undef); + ctx.sample_mask ?: undef, disable); return; } @@ -242,13 +239,14 @@ lower_fragment_outputs(nir_function_impl *impl, if (ctx.colour[i]) { insert_rt_store(b, i, ctx.colour[i], NULL, i > 0 ? ctx.colour[0] : NULL, ctx.depth ?: undef, - ctx.stencil ?: undef, ctx.sample_mask ?: undef); + ctx.stencil ?: undef, ctx.sample_mask ?: undef, + disable); } } insert_rt_store(b, last, last >= 0 ? ctx.colour[last] : NULL, NULL, last > 0 ? ctx.colour[0] : NULL, ctx.depth ?: undef, - ctx.stencil ?: undef, ctx.sample_mask ?: undef); + ctx.stencil ?: undef, ctx.sample_mask ?: undef, disable); } /** @@ -313,7 +311,8 @@ opt_unconditional_discards(nir_shader *nir) if (!any_remaining_rt_writes) { nir_builder b = nir_builder_at(nir_after_impl(impl)); nir_def *undef = nir_undef(&b, 1, 32); - insert_rt_store(&b, -1, NULL, NULL, NULL, undef, undef, undef); + insert_rt_store(&b, -1, NULL, NULL, NULL, undef, undef, undef, + nir_imm_true(&b)); } return nir_progress(progress, impl, nir_metadata_control_flow);