From 026fa1799b955ea3995cfe54c0e5eb509a622b2b Mon Sep 17 00:00:00 2001 From: Daivik Bhatia Date: Thu, 5 Feb 2026 01:02:57 +0530 Subject: [PATCH] broadcom/compiler: Update comment clarifying OpTerminate implementation Explain why the driver uses demote instead of an immediate jump to the end of the shader for OpTerminate, noting that the jump approach showed no performance gains. Reference: !38381 Reviewed-by: Iago Toral Quiroga Part-of: --- src/broadcom/compiler/nir_to_vir.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index 750fe9f90f4..0a39445ca0b 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -3638,13 +3638,16 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) ntq_emit_image_size(c, instr); break; - /* FIXME: the Vulkan and SPIR-V specs specify that OpTerminate (which + /* The Vulkan and SPIR-V specs specify that OpTerminate (which * is intended to match the semantics of GLSL's discard) should - * terminate the invocation immediately. Our implementation doesn't - * do that. What we do is actually a demote by removing the invocations - * from the sample mask. Maybe we could be more strict and force an - * early termination by emitting a (maybe conditional) jump to the - * end section of the fragment shader for affected invocations. + * terminate the invocation immediately but our implementation + * doesn't do that. We could implement it by emitting a jump to + * the end of the shader, however, we have not observed any gains + * from this in real use cases, and doing that would require us to + * always emit additional instructions for terminates, so we discarded + * that approach. See + * https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38381 + * for more details. */ case nir_intrinsic_terminate: c->emitted_discard = true;