radv: malloc graphics pipeline stages

This uses a lot of stack, which is apparently a problem for musl libc.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29379>
This commit is contained in:
Rhys Perry 2024-03-26 14:11:26 +00:00 committed by Marge Bot
parent 139bc6b813
commit c9f5152ddd

View file

@ -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;
}