From c9f5152ddd5cee3c160cc52a4c748da1dd42883d Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 26 Mar 2024 14:11:26 +0000 Subject: [PATCH] radv: malloc graphics pipeline stages This uses a lot of stack, which is apparently a problem for musl libc. Signed-off-by: Rhys Perry Cc: mesa-stable Part-of: --- src/amd/vulkan/radv_pipeline_graphics.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index aaf086cefe2..86a59742210 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -2592,7 +2592,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk struct radv_shader_binary *gs_copy_binary = NULL; bool keep_executable_info = radv_pipeline_capture_shaders(device, pipeline->base.create_flags); bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pipeline->base.create_flags); - struct radv_shader_stage stages[MESA_VULKAN_SHADER_STAGES]; + struct radv_shader_stage *stages = malloc(sizeof(struct radv_shader_stage) * MESA_VULKAN_SHADER_STAGES); const VkPipelineCreationFeedbackCreateInfo *creation_feedback = vk_find_struct_const(pCreateInfo->pNext, PIPELINE_CREATION_FEEDBACK_CREATE_INFO); VkPipelineCreationFeedback pipeline_feedback = { @@ -2604,6 +2604,9 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk !!(pipeline->base.create_flags & VK_PIPELINE_CREATE_2_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT); struct radv_retained_shaders *retained_shaders = NULL; + if (!stages) + return VK_ERROR_OUT_OF_HOST_MEMORY; + int64_t pipeline_start = os_time_get_nano(); for (unsigned i = 0; i < MESA_VULKAN_SHADER_STAGES; i++) { @@ -2662,8 +2665,10 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk gfx_pipeline_lib->stages = radv_copy_shader_stage_create_info(device, pCreateInfo->stageCount, pCreateInfo->pStages, gfx_pipeline_lib->mem_ctx); - if (!gfx_pipeline_lib->stages) + if (!gfx_pipeline_lib->stages) { + free(stages); return VK_ERROR_OUT_OF_HOST_MEMORY; + } gfx_pipeline_lib->stage_count = pCreateInfo->stageCount; @@ -2677,8 +2682,10 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk goto done; } - if (pipeline->base.create_flags & VK_PIPELINE_CREATE_2_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_KHR) + if (pipeline->base.create_flags & VK_PIPELINE_CREATE_2_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_KHR) { + free(stages); return VK_PIPELINE_COMPILE_REQUIRED; + } if (retain_shaders) { struct radv_graphics_lib_pipeline *gfx_pipeline_lib = radv_pipeline_to_graphics_lib(&pipeline->base); @@ -2746,6 +2753,7 @@ done: } } + free(stages); return result; }