nir_lower_atomics_to_ssbo: Initialize deref struct

This fixes the use of an uninitialzed value:

Conditional jump or move depends on uninitialised value(s)
  bcmp (vg_replace_strmem.c:1203)
  _mesa_add_sized_state_reference (prog_parameter.c:434)
  st_nir_assign_uniform_locations(gl_context*, gl_program*, nir_shader*) (st_glsl_to_nir.cpp:209)
  st_finalize_nir (st_glsl_to_nir.cpp:1041)
  by 0x58271B9: st_glsl_to_nir_post_opts(st_context*, gl_program*, gl_shader_program*) (st_glsl_to_nir.cpp:571)
  ...
Uninitialised value was created by a heap allocation
  malloc (vg_replace_malloc.c:381)
  ralloc_size (ralloc.c:114)
  ralloc_array_size (ralloc.c:218)
  deref_offset_var (nir_lower_atomics_to_ssbo.c:47)
  lower_instr (nir_lower_atomics_to_ssbo.c:111)
  nir_lower_atomics_to_ssbo (nir_lower_atomics_to_ssbo.c:204)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18227>
This commit is contained in:
Gert Wollny 2022-08-24 09:09:10 +02:00 committed by Marge Bot
parent 8eac45b274
commit 13355232e4

View file

@ -44,7 +44,7 @@ deref_offset_var(nir_builder *b, unsigned binding, unsigned offset_align_state)
}
nir_variable *var = nir_variable_create(b->shader, nir_var_uniform, glsl_uint_type(), "offset");
var->state_slots = ralloc_array(var, nir_state_slot, 1);
var->state_slots = rzalloc_array(var, nir_state_slot, 1);
var->state_slots[0].tokens[0] = offset_align_state;
var->state_slots[0].tokens[1] = binding;
var->num_state_slots = 1;