radv: store engine name
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Sun, 8 Sep 2019 09:57:16 +0000 (12:57 +0300)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Sun, 15 Sep 2019 12:37:02 +0000 (15:37 +0300)
We'll use this later for a new driconfig matching parameter.

v2: Avoid leak in device creation error case (Bas)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Cc: 19.2 <mesa-stable@lists.freedesktop.org>
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_private.h

index beeec37e54a3c84c029f47056ccea9775773d780..57f492088bd57b92c62010cb3f93c1c35d19e3ab 100644 (file)
@@ -588,6 +588,13 @@ VkResult radv_CreateInstance(
                client_version = VK_API_VERSION_1_0;
        }
 
+       const char *engine_name = NULL;
+       uint32_t engine_version = 0;
+       if (pCreateInfo->pApplicationInfo) {
+               engine_name = pCreateInfo->pApplicationInfo->pEngineName;
+               engine_version = pCreateInfo->pApplicationInfo->engineVersion;
+       }
+
        instance = vk_zalloc2(&default_alloc, pAllocator, sizeof(*instance), 8,
                              VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
        if (!instance)
@@ -631,6 +638,10 @@ VkResult radv_CreateInstance(
                return vk_error(instance, result);
        }
 
+       instance->engineName = vk_strdup(&instance->alloc, engine_name,
+                                        VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+       instance->engineVersion = engine_version;
+
        _mesa_locale_init();
        glsl_type_singleton_init_or_ref();
 
@@ -657,6 +668,8 @@ void radv_DestroyInstance(
                radv_physical_device_finish(instance->physicalDevices + i);
        }
 
+       vk_free(&instance->alloc, instance->engineName);
+
        VG(VALGRIND_DESTROY_MEMPOOL(instance));
 
        glsl_type_singleton_decref();
index bf62ccc9c1d8bfbed8acb34e037da67b7ef03721..d6c446abd06b529d8c4c15ace342b3f070c2df73 100644 (file)
@@ -315,6 +315,9 @@ struct radv_instance {
        int                                         physicalDeviceCount;
        struct radv_physical_device                 physicalDevices[RADV_MAX_DRM_DEVICES];
 
+       char *                                      engineName;
+       uint32_t                                    engineVersion;
+
        uint64_t debug_flags;
        uint64_t perftest_flags;