diff options
Diffstat (limited to 'loader/trampoline.c')
-rw-r--r-- | loader/trampoline.c | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/loader/trampoline.c b/loader/trampoline.c index fa07218da..b8d76322a 100644 --- a/loader/trampoline.c +++ b/loader/trampoline.c @@ -160,21 +160,19 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionPropert // Get the implicit layers struct loader_layer_list layers; + loader_platform_dl_handle *libs = NULL; + size_t lib_count = 0; memset(&layers, 0, sizeof(layers)); - loader_scan_for_implicit_layers(NULL, &layers); - // We'll need to save the dl handles so we can close them later - loader_platform_dl_handle *libs = - loader_calloc(NULL, sizeof(loader_platform_dl_handle) * layers.count, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); - if (libs == NULL && layers.count > 0) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = loader_scan_for_implicit_layers(NULL, &layers, &libs); + if (VK_SUCCESS != res) { + return res; } - size_t lib_count = 0; // Prepend layers onto the chain if they implement this entry point for (uint32_t i = 0; i < layers.count; ++i) { - if (!loader_implicit_layer_is_enabled(NULL, layers.list + i) || - layers.list[i].pre_instance_functions.enumerate_instance_extension_properties[0] == '\0') { + // Skip this layer if it doesn't expose the entry-point + if (layers.list[i].pre_instance_functions.enumerate_instance_extension_properties[0] == '\0') { continue; } @@ -255,24 +253,17 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties( // Get the implicit layers struct loader_layer_list layers; + loader_platform_dl_handle *libs = NULL; + size_t lib_count = 0; memset(&layers, 0, sizeof(layers)); - loader_scan_for_implicit_layers(NULL, &layers); - // We'll need to save the dl handles so we can close them later - loader_platform_dl_handle *libs = - loader_calloc(NULL, sizeof(loader_platform_dl_handle) * layers.count, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); - if (libs == NULL && layers.count > 0) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = loader_scan_for_implicit_layers(NULL, &layers, &libs); + if (VK_SUCCESS != res) { + return res; } - size_t lib_count = 0; // Prepend layers onto the chain if they implement this entry point for (uint32_t i = 0; i < layers.count; ++i) { - if (!loader_implicit_layer_is_enabled(NULL, layers.list + i) || - layers.list[i].pre_instance_functions.enumerate_instance_layer_properties[0] == '\0') { - continue; - } - loader_platform_dl_handle layer_lib = loader_platform_open_library(layers.list[i].lib_name); if (layer_lib == NULL) { loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "%s: Unable to load implicit layer library \"%s\"", __FUNCTION__, @@ -357,21 +348,19 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion(uint32_t // Get the implicit layers struct loader_layer_list layers; + loader_platform_dl_handle *libs = NULL; + size_t lib_count = 0; memset(&layers, 0, sizeof(layers)); - loader_scan_for_implicit_layers(NULL, &layers); - // We'll need to save the dl handles so we can close them later - loader_platform_dl_handle *libs = - loader_calloc(NULL, sizeof(loader_platform_dl_handle) * layers.count, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); - if (libs == NULL && layers.count > 0) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = loader_scan_for_implicit_layers(NULL, &layers, &libs); + if (VK_SUCCESS != res) { + return res; } - size_t lib_count = 0; // Prepend layers onto the chain if they implement this entry point for (uint32_t i = 0; i < layers.count; ++i) { - if (!loader_implicit_layer_is_enabled(NULL, layers.list + i) || - layers.list[i].pre_instance_functions.enumerate_instance_version[0] == '\0') { + // Skip this layer if it doesn't expose the entry-point + if (layers.list[i].pre_instance_functions.enumerate_instance_version[0] == '\0') { continue; } @@ -520,7 +509,10 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr // enabledLayerCount == 0 and VK_INSTANCE_LAYERS is unset. For now always // get layer list via loader_scan_for_layers(). memset(&ptr_instance->instance_layer_list, 0, sizeof(ptr_instance->instance_layer_list)); - loader_scan_for_layers(ptr_instance, &ptr_instance->instance_layer_list); + res = loader_scan_for_layers(ptr_instance, &ptr_instance->instance_layer_list); + if (VK_SUCCESS != res) { + goto out; + } // Validate the app requested layers to be enabled if (pCreateInfo->enabledLayerCount > 0) { |