From c059c721fbc7f2f0396bf30e4e881c7b8b2bd5fb Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Wed, 4 Jun 2025 09:02:52 +0200 Subject: [PATCH] broadcom/compiler: handle moving last ubo load in the block correctly Before we move a UBO load to a previous location in the block we take a reference to the instruction after it so we can continue the loop from there, however, if the load we just moved was already the last instruction in the block we just want to break the loop right there. Fixes crashes with shaders from http://flightradar24.com Fixes: 8998666de7e ("broadcom/compiler: sort constant UBO loads by index and offset") Reviewed-by: Jose Maria Casanova Crespo Part-of: --- src/broadcom/compiler/vir.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index 3eb421c02c9..a747be0bd7c 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -1506,6 +1506,10 @@ v3d_nir_sort_constant_ubo_load(nir_block *block, nir_intrinsic_instr *ref) exec_node_insert_after(&pos->node, &inst->node); progress = true; + + /* If this was the last instruction in the block we are done */ + if (!next_inst) + break; } return progress;