From c9525a167b9dff5a4ecdd297bcc3a5115ad30e61 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 29 Jan 2018 18:12:04 -0800 Subject: anv: Copy the appliation info into the instance Cc: "18.2" Reviewed-by: Lionel Landwerlin (cherry picked from commit 8c048af5890d43578ca41eb9dcfa60cb9cc3fc9c) Squashed with commit: anv: Free the app and engine name Fixes: 8c048af5890d4 "anv: Copy the appliation info into the instance" Reviewed-by: Lionel Landwerlin (cherry picked from commit cdea5d996edaaf59ab0acf3e758c3d9a4c22c335) --- src/intel/vulkan/anv_device.c | 30 +++++++++++++++++++++++------- src/intel/vulkan/anv_private.h | 11 ++++++++++- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index c40b94d69f3..74c251a90e7 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -610,20 +610,33 @@ VkResult anv_CreateInstance( else instance->alloc = default_alloc; - if (pCreateInfo->pApplicationInfo && - pCreateInfo->pApplicationInfo->apiVersion != 0) { - instance->apiVersion = pCreateInfo->pApplicationInfo->apiVersion; - } else { - anv_EnumerateInstanceVersion(&instance->apiVersion); + instance->app_info = (struct anv_app_info) { .api_version = 0 }; + if (pCreateInfo->pApplicationInfo) { + const VkApplicationInfo *app = pCreateInfo->pApplicationInfo; + + instance->app_info.app_name = + vk_strdup(&instance->alloc, app->pApplicationName, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + instance->app_info.app_version = app->applicationVersion; + + instance->app_info.engine_name = + vk_strdup(&instance->alloc, app->pEngineName, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + instance->app_info.engine_version = app->engineVersion; + + instance->app_info.api_version = app->apiVersion; } + if (instance->app_info.api_version == 0) + anv_EnumerateInstanceVersion(&instance->app_info.api_version); + instance->enabled_extensions = enabled_extensions; for (unsigned i = 0; i < ARRAY_SIZE(instance->dispatch.entrypoints); i++) { /* Vulkan requires that entrypoints for extensions which have not been * enabled must not be advertised. */ - if (!anv_entrypoint_is_enabled(i, instance->apiVersion, + if (!anv_entrypoint_is_enabled(i, instance->app_info.api_version, &instance->enabled_extensions, NULL)) { instance->dispatch.entrypoints[i] = NULL; } else if (anv_dispatch_table.entrypoints[i] != NULL) { @@ -669,6 +682,9 @@ void anv_DestroyInstance( anv_physical_device_finish(&instance->physicalDevice); } + vk_free(&instance->alloc, instance->app_info.app_name); + vk_free(&instance->alloc, instance->app_info.engine_name); + VG(VALGRIND_DESTROY_MEMPOOL(instance)); vk_debug_report_instance_destroy(&instance->debug_report_callbacks); @@ -1489,7 +1505,7 @@ anv_device_init_dispatch(struct anv_device *device) /* Vulkan requires that entrypoints for extensions which have not been * enabled must not be advertised. */ - if (!anv_entrypoint_is_enabled(i, device->instance->apiVersion, + if (!anv_entrypoint_is_enabled(i, device->instance->app_info.api_version, &device->instance->enabled_extensions, &device->enabled_extensions)) { device->dispatch.entrypoints[i] = NULL; diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 1660fcbbc87..4e50ab27898 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -882,12 +882,21 @@ struct anv_physical_device { int master_fd; }; +struct anv_app_info { + const char* app_name; + uint32_t app_version; + const char* engine_name; + uint32_t engine_version; + uint32_t api_version; +}; + struct anv_instance { VK_LOADER_DATA _loader_data; VkAllocationCallbacks alloc; - uint32_t apiVersion; + struct anv_app_info app_info; + struct anv_instance_extension_table enabled_extensions; struct anv_dispatch_table dispatch; -- cgit v1.2.3