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 <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36538>
This commit is contained in:
Marek Olšák
2025-08-01 23:44:05 -04:00
committed by Marge Bot
parent 44350bce1f
commit fee8e92855
2 changed files with 2 additions and 2 deletions

View File

@@ -271,7 +271,7 @@ nir_shader_add_variable(nir_shader *shader, nir_variable *var)
nir_variable * nir_variable *
nir_variable_create_zeroed(nir_shader *nir) nir_variable_create_zeroed(nir_shader *nir)
{ {
return rzalloc(nir, nir_variable); return gc_zalloc_size(nir->gctx, sizeof(nir_variable), 8);
} }
void void

View File

@@ -54,7 +54,7 @@ sweep_constant(nir_shader *nir, nir_constant *c)
static void static void
sweep_variable(nir_shader *nir, nir_variable *var) 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); nir_variable_steal_name(nir, var, var);
ralloc_steal(nir, var->max_ifc_array_access); ralloc_steal(nir, var->max_ifc_array_access);
ralloc_steal(nir, var->state_slots); ralloc_steal(nir, var->state_slots);