vulkan: use instance allocator for object_name in some objects

The allocator passed to VkDevice won't be available once it is destroyed
and thefore it cannot be used to allocate `object_name` for instance
level objects such as `VkInstance` or `VkPhysicalDevice` or else there
would be no way of deallocating it when those objects are destroyed.

Cc: mesa-stable
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Mark Collins <mark@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26085>
This commit is contained in:
antonino
2023-11-06 22:52:35 +01:00
committed by Marge Bot
parent fcd025c1ce
commit 2d49f834b2
6 changed files with 51 additions and 9 deletions
+5 -2
View File
@@ -213,11 +213,14 @@ vk_common_SetDebugUtilsObjectNameEXT(
vk_object_base_from_u64_handle(pNameInfo->objectHandle,
pNameInfo->objectType);
assert(object->device != NULL || object->instance != NULL);
VkAllocationCallbacks *alloc = object->device != NULL ?
&object->device->alloc : &object->instance->alloc;
if (object->object_name) {
vk_free(&device->alloc, object->object_name);
vk_free(alloc, object->object_name);
object->object_name = NULL;
}
object->object_name = vk_strdup(&device->alloc, pNameInfo->pObjectName,
object->object_name = vk_strdup(alloc, pNameInfo->pObjectName,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!object->object_name)
return VK_ERROR_OUT_OF_HOST_MEMORY;