From dbfb0a3b0d9d5925f3f06baa5e501dc7b6dc83ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Mon, 4 May 2026 13:29:56 -0700 Subject: [PATCH] anv: Add assert to make sure we don't push more than max_push_regs to push constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the push constant size limit is only valid in stages that don't use inline param I had to add and call stage_has_inline_param() first. Reviewed-by: Lionel Landwerlin Signed-off-by: José Roberto de Souza Part-of: --- .../vulkan/anv_nir_compute_push_layout.c | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/intel/vulkan/anv_nir_compute_push_layout.c b/src/intel/vulkan/anv_nir_compute_push_layout.c index 51004548ce8..f49e4c7302a 100644 --- a/src/intel/vulkan/anv_nir_compute_push_layout.c +++ b/src/intel/vulkan/anv_nir_compute_push_layout.c @@ -501,6 +501,15 @@ lower_to_push_data_intel(nir_builder *b, } } +static inline bool +stage_has_inline_param(const struct intel_device_info *devinfo, mesa_shader_stage stage) +{ + return devinfo->verx10 >= 125 && + (stage == MESA_SHADER_TASK || + stage == MESA_SHADER_MESH || + stage == MESA_SHADER_COMPUTE); +} + static struct anv_push_range compute_final_push_range(const nir_shader *nir, const struct intel_device_info *devinfo, @@ -539,11 +548,7 @@ compute_final_push_range(const nir_shader *nir, * (unlike all Gfx stages) and so we can bound+align the allocation there * (see anv_cmd_buffer_cs_push_constants). */ - const bool has_inline_param = - devinfo->verx10 >= 125 && - (nir->info.stage == MESA_SHADER_TASK || - nir->info.stage == MESA_SHADER_MESH || - nir->info.stage == MESA_SHADER_COMPUTE); + const bool has_inline_param = stage_has_inline_param(devinfo, nir->info.stage); map->inline_dwords_count = 0; @@ -708,7 +713,10 @@ anv_nir_compute_push_layout(nir_shader *nir, map->push_ranges[n_push_ranges++] = push_constant_padding_range; } - assert(n_push_ranges <= 4); + if (!stage_has_inline_param(devinfo, nir->info.stage)) { + assert(n_push_ranges <= 4); + assert(total_push_regs <= max_push_regs); + } struct lower_to_push_data_intel_state lower_state = { .devinfo = devinfo,