Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6184b20d authored by Chia-I Wu's avatar Chia-I Wu
Browse files

vulkan: detect errors in VkEnumerate*ExtensionProperties

Return VK_ERROR_LAYER_NOT_PRESENT when the layer is not available.

Change-Id: I9d9aafe6e40c2ca49e58bc7c70114d0f11de2f81
parent dab25658
Loading
Loading
Loading
Loading
+12 −18
Original line number Diff line number Diff line
@@ -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;