From fee8e928559b6f35a45aee2efc424519045ff395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 1 Aug 2025 23:44:05 -0400 Subject: [PATCH] nir: use gc_ctx for nir_variable to reduce ralloc/malloc overhead gc_ctx uses a slab allocator. This reduces GLSL compile times by 1-3% with the gallium noop driver. This reduces the number of ralloc_size calls for Heaven shaders by 14.3%. Note that gc_ctx also uses ralloc_size, so the reduction is a net change. Reviewed-by: Timothy Arceri Part-of: --- src/compiler/nir/nir.c | 2 +- src/compiler/nir/nir_sweep.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index d49f4f2c2ed..f4684377582 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -271,7 +271,7 @@ nir_shader_add_variable(nir_shader *shader, nir_variable *var) nir_variable * nir_variable_create_zeroed(nir_shader *nir) { - return rzalloc(nir, nir_variable); + return gc_zalloc_size(nir->gctx, sizeof(nir_variable), 8); } void diff --git a/src/compiler/nir/nir_sweep.c b/src/compiler/nir/nir_sweep.c index c64bde183f2..d4a22c276f4 100644 --- a/src/compiler/nir/nir_sweep.c +++ b/src/compiler/nir/nir_sweep.c @@ -54,7 +54,7 @@ sweep_constant(nir_shader *nir, nir_constant *c) static void sweep_variable(nir_shader *nir, nir_variable *var) { - ralloc_steal(nir, var); + gc_mark_live(nir->gctx, var); nir_variable_steal_name(nir, var, var); ralloc_steal(nir, var->max_ifc_array_access); ralloc_steal(nir, var->state_slots);