From 0b4d62d3407a45e8441759018c1839623be01d3c Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Fri, 18 Apr 2025 16:59:27 -0700 Subject: [PATCH] anv: Allocate prog_data->param array when making internal kernels As we set prog_data->nr_params, allocate the array like elsewhere. Current code is getting by because the logic for adding a new element will realloc it. But later changes will make the array be accessed before this reallocation. This will make sure later patches won't cause tests like dEQP-VK.query_pool.statistics_query.compute_shader_invocations.32bits_cmdcopyquerypoolresults_secondary to fail in gfxver < 125. Note the bug appears when DRI option to tweak the thresold to use these shaders is set to 0. This is done by the GitLab CI, which allowed testing later patches to find this issue. Reviewed-by: Kenneth Graunke Part-of: --- src/intel/vulkan/anv_internal_kernels.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/intel/vulkan/anv_internal_kernels.c b/src/intel/vulkan/anv_internal_kernels.c index bef4631c290..6ee596193a1 100644 --- a/src/intel/vulkan/anv_internal_kernels.c +++ b/src/intel/vulkan/anv_internal_kernels.c @@ -144,12 +144,13 @@ compile_shader(struct anv_device *device, nir->num_uniforms = uniform_size; + void *temp_ctx = ralloc_context(NULL); + prog_data.base.nr_params = nir->num_uniforms / 4; + prog_data.base.param = rzalloc_array(temp_ctx, uint32_t, prog_data.base.nr_params); brw_nir_analyze_ubo_ranges(compiler, nir, prog_data.base.ubo_ranges); - void *temp_ctx = ralloc_context(NULL); - const unsigned *program; if (stage == MESA_SHADER_FRAGMENT) { struct brw_compile_stats stats[3];