radv/rt: defer library_pipeline allocation

We will need the number of groups at allocation time.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21667>
This commit is contained in:
Daniel Schürmann 2023-03-02 17:34:16 +01:00 committed by Marge Bot
parent a62d699664
commit 4dafb69d61

View file

@ -160,10 +160,14 @@ radv_create_merged_rt_create_info(const VkRayTracingPipelineCreateInfoKHR *pCrea
local_create_info.groupCount = total_groups; local_create_info.groupCount = total_groups;
local_create_info.pStages = stages = local_create_info.pStages = stages =
malloc(sizeof(VkPipelineShaderStageCreateInfo) * total_stages); malloc(sizeof(VkPipelineShaderStageCreateInfo) * total_stages);
if (!local_create_info.pStages)
return local_create_info;
local_create_info.pGroups = groups = local_create_info.pGroups = groups =
malloc(sizeof(VkRayTracingShaderGroupCreateInfoKHR) * total_groups); malloc(sizeof(VkRayTracingShaderGroupCreateInfoKHR) * total_groups);
if (!local_create_info.pStages || !local_create_info.pGroups) if (!local_create_info.pGroups) {
free((void *)local_create_info.pStages);
return local_create_info; return local_create_info;
}
total_stages = pCreateInfo->stageCount; total_stages = pCreateInfo->stageCount;
total_groups = pCreateInfo->groupCount; total_groups = pCreateInfo->groupCount;
@ -213,6 +217,11 @@ radv_rt_pipeline_library_create(VkDevice _device, VkPipelineCache _cache,
RADV_FROM_HANDLE(radv_device, device, _device); RADV_FROM_HANDLE(radv_device, device, _device);
struct radv_library_pipeline *pipeline; struct radv_library_pipeline *pipeline;
VkRayTracingPipelineCreateInfoKHR local_create_info =
radv_create_merged_rt_create_info(pCreateInfo);
if (!local_create_info.pStages || !local_create_info.pGroups)
return VK_ERROR_OUT_OF_HOST_MEMORY;
pipeline = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*pipeline), 8, pipeline = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*pipeline), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pipeline == NULL) if (pipeline == NULL)
@ -222,11 +231,6 @@ radv_rt_pipeline_library_create(VkDevice _device, VkPipelineCache _cache,
pipeline->ctx = ralloc_context(NULL); pipeline->ctx = ralloc_context(NULL);
VkRayTracingPipelineCreateInfoKHR local_create_info =
radv_create_merged_rt_create_info(pCreateInfo);
if (!local_create_info.pStages || !local_create_info.pGroups)
goto fail;
VkResult result = VkResult result =
radv_create_group_handles(device, &local_create_info, &pipeline->group_handles); radv_create_group_handles(device, &local_create_info, &pipeline->group_handles);
if (result != VK_SUCCESS) if (result != VK_SUCCESS)
@ -442,10 +446,8 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache,
VkRayTracingPipelineCreateInfoKHR local_create_info = VkRayTracingPipelineCreateInfoKHR local_create_info =
radv_create_merged_rt_create_info(pCreateInfo); radv_create_merged_rt_create_info(pCreateInfo);
if (!local_create_info.pStages || !local_create_info.pGroups) { if (!local_create_info.pStages || !local_create_info.pGroups)
result = VK_ERROR_OUT_OF_HOST_MEMORY; return VK_ERROR_OUT_OF_HOST_MEMORY;
goto fail;
}
struct vk_shader_module module = {.base.type = VK_OBJECT_TYPE_SHADER_MODULE}; struct vk_shader_module module = {.base.type = VK_OBJECT_TYPE_SHADER_MODULE};