nir: fix a leak of ralloc ctx in nir_opt_ray_query_ranges

Fixes following leak:

  ==7520== 48 bytes in 1 blocks are definitely lost in loss record 1,597 of 2,016
  ==7520==    at 0x484486F: malloc (vg_replace_malloc.c:381)
  ==7520==    by 0x5314A4E: ralloc_size (ralloc.c:117)
  ==7520==    by 0x5314A1F: ralloc_context (ralloc.c:104)
  ==7520==    by 0x6A95D68: nir_opt_ray_query_ranges (nir_opt_ray_queries.c:235)

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: f5b6576585 ("nir: Add a pass for combining ray queries")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20002>
This commit is contained in:
Tapani Pälli 2022-11-25 10:31:36 +02:00 committed by Marge Bot
parent 2de7d6d1d8
commit dba75d345d
1 changed files with 2 additions and 2 deletions

View File

@ -232,8 +232,6 @@ nir_opt_ray_query_ranges(nir_shader *shader)
(struct nir_function *)exec_list_get_head_const(&shader->functions);
assert(func->impl);
void *mem_ctx = ralloc_context(NULL);
uint32_t ray_query_count = 0;
nir_foreach_variable_in_shader(var, shader) {
if (!var->data.ray_query || glsl_type_is_array(var->type))
@ -251,6 +249,8 @@ nir_opt_ray_query_ranges(nir_shader *shader)
return false;
}
void *mem_ctx = ralloc_context(NULL);
nir_metadata_require(func->impl, nir_metadata_instr_index | nir_metadata_dominance);
nir_variable **ray_queries = ralloc_array(mem_ctx, nir_variable*, ray_query_count);