diff options
author | 2016-04-27 11:57:53 +0800 | |
---|---|---|
committer | 2016-04-28 08:52:42 +0800 | |
commit | 6184b20d8e2301ecc21f815e1f9c2676c43878d1 (patch) | |
tree | ba54a6b817b207b4164df9702659778c5e1076a1 /vulkan/libvulkan/api.cpp | |
parent | dab25658fb17ec76569b8e91dfed801855027f08 (diff) |
vulkan: detect errors in VkEnumerate*ExtensionProperties
Return VK_ERROR_LAYER_NOT_PRESENT when the layer is not available.
Change-Id: I9d9aafe6e40c2ca49e58bc7c70114d0f11de2f81
Diffstat (limited to 'vulkan/libvulkan/api.cpp')
-rw-r--r-- | vulkan/libvulkan/api.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp index 3db625fbe7..21a6c895bd 100644 --- a/vulkan/libvulkan/api.cpp +++ b/vulkan/libvulkan/api.cpp @@ -1131,16 +1131,13 @@ VkResult EnumerateInstanceExtensionProperties( return VK_ERROR_INITIALIZATION_FAILED; if (pLayerName) { - const VkExtensionProperties* props; - uint32_t count; - const Layer* layer = FindLayer(pLayerName); - if (layer) { - props = GetLayerInstanceExtensions(*layer, count); - } else { - props = nullptr; - count = 0; - } + if (!layer) + return VK_ERROR_LAYER_NOT_PRESENT; + + uint32_t count; + const VkExtensionProperties* props = + GetLayerInstanceExtensions(*layer, count); if (!pProperties || *pPropertyCount > count) *pPropertyCount = count; @@ -1196,16 +1193,13 @@ VkResult EnumerateDeviceExtensionProperties( uint32_t* pPropertyCount, VkExtensionProperties* pProperties) { if (pLayerName) { - const VkExtensionProperties* props; - uint32_t count; - const Layer* layer = FindLayer(pLayerName); - if (layer && IsLayerGlobal(*layer)) { - props = GetLayerDeviceExtensions(*layer, count); - } else { - props = nullptr; - count = 0; - } + if (!layer || !IsLayerGlobal(*layer)) + return VK_ERROR_LAYER_NOT_PRESENT; + + uint32_t count; + const VkExtensionProperties* props = + GetLayerDeviceExtensions(*layer, count); if (!pProperties || *pPropertyCount > count) *pPropertyCount = count; |