From c7f486c57cec2aae901dec6123fc57dfb5133f46 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Sat, 11 Feb 2023 12:16:56 +0800 Subject: Comment call to vkCreateInstance with a potential pitfall (#2642) Although we could in principle write this explanatory message to stderr, that would entangle this call with the layer search above for what is probably a very unlikely possibility on any normal system. --- tools/gfx/vulkan/vk-device.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/gfx/vulkan/vk-device.cpp b/tools/gfx/vulkan/vk-device.cpp index 866b53d23..b5eec0b72 100644 --- a/tools/gfx/vulkan/vk-device.cpp +++ b/tools/gfx/vulkan/vk-device.cpp @@ -221,7 +221,13 @@ Result DeviceImpl::initVulkanInstanceAndDevice( for (auto apiVersion : apiVersionsToTry) { applicationInfo.apiVersion = apiVersion; - if (m_api.vkCreateInstance(&instanceCreateInfo, nullptr, &instance) == VK_SUCCESS) + // If r is VK_ERROR_LAYER_NOT_PRESENT, it's almost certainly + // because the layer shared library failed to load (we check that + // the layer is known earlier). It might, for example, be absent + // from the system library search path, and not referenced with an + // absolute path in VkLayer_khronos_validation.json. + const auto r = m_api.vkCreateInstance(&instanceCreateInfo, nullptr, &instance) ; + if (r == VK_SUCCESS) { break; } -- cgit v1.2.3