From 0979af18e4494769fd635e9eec626b87c5dd3587 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Fri, 23 Aug 2019 15:13:34 +0300 Subject: [PATCH] [vulkan] Workaround for vkCreatePipelineCache unspecified return codes --- drape/vulkan/vulkan_pipeline.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drape/vulkan/vulkan_pipeline.cpp b/drape/vulkan/vulkan_pipeline.cpp index 7e17ce2ff3..eebf9d6f69 100644 --- a/drape/vulkan/vulkan_pipeline.cpp +++ b/drape/vulkan/vulkan_pipeline.cpp @@ -185,7 +185,21 @@ VulkanPipeline::VulkanPipeline(VkDevice device, int appVersionCode) pipelineCacheCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; pipelineCacheCreateInfo.initialDataSize = dumpData.size(); pipelineCacheCreateInfo.pInitialData = dumpData.data(); - CHECK_VK_CALL(vkCreatePipelineCache(device, &pipelineCacheCreateInfo, nullptr, &m_vulkanPipelineCache)); + auto result = vkCreatePipelineCache(device, &pipelineCacheCreateInfo, nullptr, &m_vulkanPipelineCache); + if (result != VK_SUCCESS && pipelineCacheCreateInfo.pInitialData != nullptr) + { + FileWriter::DeleteFileX(dumpFilePath); + pipelineCacheCreateInfo.initialDataSize = 0; + pipelineCacheCreateInfo.pInitialData = nullptr; + result = vkCreatePipelineCache(device, &pipelineCacheCreateInfo, nullptr, &m_vulkanPipelineCache); + } + if (result != VK_SUCCESS) + { + // The function vkCreatePipelineCache can return unspecified codes, so if we aren't able to + // create pipeline cache without saved state, we consider it as a driver issue and forbid Vulkan. + SupportManager::Instance().ForbidVulkan(); + CHECK(false, ("Fatal driver issue.")); + } } void VulkanPipeline::Dump(VkDevice device)