From 73a548c8f80490526cf3c15e92f95918491e3e2e Mon Sep 17 00:00:00 2001 From: Maciej Jesionowski Date: Wed, 23 Nov 2016 10:44:34 +0100 Subject: layers: Handle partial failure in vkCreate*Pipelines This applies to vkCreate*Pipelines creating multiple objects with a single call. Creation of *some* pipelines may fail and an error code will be returned. In this case invalid handles will be set to NULL, and the remaining handles must be managed properly. --- layers/unique_objects.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'layers/unique_objects.cpp') diff --git a/layers/unique_objects.cpp b/layers/unique_objects.cpp index 0d81c809..3a0945a8 100644 --- a/layers/unique_objects.cpp +++ b/layers/unique_objects.cpp @@ -428,13 +428,15 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelin VkResult result = my_device_data->device_dispatch_table->CreateComputePipelines( device, pipelineCache, createInfoCount, (const VkComputePipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines); delete[] local_pCreateInfos; - if (VK_SUCCESS == result) { + { uint64_t unique_id = 0; std::lock_guard lock(global_lock); for (uint32_t i = 0; i < createInfoCount; ++i) { - unique_id = global_unique_id++; - my_device_data->unique_id_mapping[unique_id] = reinterpret_cast(pPipelines[i]); - pPipelines[i] = reinterpret_cast(unique_id); + if (pPipelines[i] != VK_NULL_HANDLE) { + unique_id = global_unique_id++; + my_device_data->unique_id_mapping[unique_id] = reinterpret_cast(pPipelines[i]); + pPipelines[i] = reinterpret_cast(unique_id); + } } } return result; @@ -484,13 +486,15 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelines(VkDevice device, VkPipeli VkResult result = my_device_data->device_dispatch_table->CreateGraphicsPipelines( device, pipelineCache, createInfoCount, (const VkGraphicsPipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines); delete[] local_pCreateInfos; - if (VK_SUCCESS == result) { + { uint64_t unique_id = 0; std::lock_guard lock(global_lock); for (uint32_t i = 0; i < createInfoCount; ++i) { - unique_id = global_unique_id++; - my_device_data->unique_id_mapping[unique_id] = reinterpret_cast(pPipelines[i]); - pPipelines[i] = reinterpret_cast(unique_id); + if (pPipelines[i] != VK_NULL_HANDLE) { + unique_id = global_unique_id++; + my_device_data->unique_id_mapping[unique_id] = reinterpret_cast(pPipelines[i]); + pPipelines[i] = reinterpret_cast(unique_id); + } } } return result; -- cgit v1.2.3