From 034f58c7e3ea96dc726afa725b2eb775a44f7a8e Mon Sep 17 00:00:00 2001 From: Konstantin Seurer Date: Mon, 8 Dec 2025 15:34:38 +0100 Subject: [PATCH] nir: Ignore ray query ranges that don't start with rq_initialize Handles is a rare edge case where the ray query is used "before" there is a rq_initialize. cc: mesa-stable Reviewed-by: Lionel Landwerlin Part-of: --- src/compiler/nir/nir_opt_ray_queries.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/compiler/nir/nir_opt_ray_queries.c b/src/compiler/nir/nir_opt_ray_queries.c index aac7001da95..af5641bb71d 100644 --- a/src/compiler/nir/nir_opt_ray_queries.c +++ b/src/compiler/nir/nir_opt_ray_queries.c @@ -300,6 +300,19 @@ nir_opt_ray_query_ranges(nir_shader *shader) struct hash_entry *index_entry = _mesa_hash_table_search(range_indices, ray_query_deref->var); + if (!index_entry) { + /* The range doesn't exist yet which means that the first instruction + * isn't the initialize. Ignore it. + */ + for (uint32_t i = 0; i < ray_query_count; i++) { + if (ray_queries[i] == ray_query_deref->var) { + ray_queries[i] = NULL; + break; + } + } + continue; + } + struct rq_range *range = ranges + (uintptr_t)index_entry->data; if (intrinsic->intrinsic != nir_intrinsic_rq_initialize) {