nir: Use STACK_ARRAY instead of NIR_VLA

The number of fields comes from the shader, so it could be a value large
enough that using alloca would be problematic.

Fixes: c11833ab24 ("nir,spirv: Rework function calls")
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
(cherry picked from commit 9017d37e84)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39969>
This commit is contained in:
Ian Romanick 2026-01-23 10:07:27 -08:00 committed by Dylan Baker
parent 3db355dc37
commit cc3303b3d2
2 changed files with 4 additions and 3 deletions

View file

@ -1234,7 +1234,7 @@
"description": "nir: Use STACK_ARRAY instead of NIR_VLA",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "c11833ab24dcba26de1b0a5805e35a5d6761514e",
"notes": null

View file

@ -22,10 +22,10 @@
*/
#include "util/u_printf.h"
#include "util/stack_array.h"
#include "nir.h"
#include "nir_builder.h"
#include "nir_control_flow.h"
#include "nir_vla.h"
/*
* TODO: write a proper inliner for GPUs.
@ -240,12 +240,13 @@ inline_functions_pass(nir_builder *b,
* to an SSA value first.
*/
const unsigned num_params = call->num_params;
NIR_VLA(nir_def *, params, num_params);
STACK_ARRAY(nir_def *, params, num_params);
for (unsigned i = 0; i < num_params; i++) {
params[i] = call->params[i].ssa;
}
nir_inline_function_impl(b, call->callee->impl, params, NULL);
STACK_ARRAY_FINISH(params);
return true;
}