mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
vulkan: Handle vkSetDebugUtilsObjectNameEXT on WSI objects
Some WSI objects don't extend `vk_object_base` therefore they need special handling. Fixes:3c87618d35("vulkan: Handle vkGet/SetPrivateDataEXT on Android swapchains") Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24752> (cherry picked from commit76d150674b)
This commit is contained in:
parent
94af1fc561
commit
a77ac552ea
3 changed files with 53 additions and 1 deletions
|
|
@ -571,7 +571,7 @@
|
|||
"description": "vulkan: Handle vkSetDebugUtilsObjectNameEXT on WSI objects",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "3c87618d357a4f75a4f47b2638c8f89939fd6c61"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -153,12 +153,62 @@ vk_common_DestroyDebugUtilsMessengerEXT(
|
|||
vk_free2(&instance->alloc, pAllocator, messenger);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
vk_common_set_object_name_locked(
|
||||
struct vk_device *device,
|
||||
const VkDebugUtilsObjectNameInfoEXT *pNameInfo)
|
||||
{
|
||||
if (unlikely(device->swapchain_name == NULL)) {
|
||||
/* Even though VkSwapchain/Surface are non-dispatchable objects, we know
|
||||
* a priori that these are actually pointers so we can use
|
||||
* the pointer hash table for them.
|
||||
*/
|
||||
device->swapchain_name = _mesa_pointer_hash_table_create(NULL);
|
||||
if (device->swapchain_name == NULL)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
char *object_name = vk_strdup(&device->alloc, pNameInfo->pObjectName,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (object_name == NULL)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
struct hash_entry *entry =
|
||||
_mesa_hash_table_search(device->swapchain_name,
|
||||
(void *)(uintptr_t)pNameInfo->objectHandle);
|
||||
if (unlikely(entry == NULL)) {
|
||||
entry = _mesa_hash_table_insert(device->swapchain_name,
|
||||
(void *)(uintptr_t)pNameInfo->objectHandle,
|
||||
object_name);
|
||||
if (entry == NULL) {
|
||||
vk_free(&device->alloc, object_name);
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
} else {
|
||||
vk_free(&device->alloc, entry->data);
|
||||
entry->data = object_name;
|
||||
}
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
vk_common_SetDebugUtilsObjectNameEXT(
|
||||
VkDevice _device,
|
||||
const VkDebugUtilsObjectNameInfoEXT *pNameInfo)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_device, device, _device);
|
||||
|
||||
#ifdef ANDROID
|
||||
if (pNameInfo->objectType == VK_OBJECT_TYPE_SWAPCHAIN_KHR ||
|
||||
pNameInfo->objectType == VK_OBJECT_TYPE_SURFACE_KHR) {
|
||||
#else
|
||||
if (pNameInfo->objectType == VK_OBJECT_TYPE_SURFACE_KHR) {
|
||||
#endif
|
||||
mtx_lock(&device->swapchain_name_mtx);
|
||||
VkResult res = vk_common_set_object_name_locked(device, pNameInfo);
|
||||
mtx_unlock(&device->swapchain_name_mtx);
|
||||
return res;
|
||||
}
|
||||
|
||||
struct vk_object_base *object =
|
||||
vk_object_base_from_u64_handle(pNameInfo->objectHandle,
|
||||
pNameInfo->objectType);
|
||||
|
|
|
|||
|
|
@ -244,6 +244,8 @@ struct vk_device {
|
|||
|
||||
mtx_t swapchain_private_mtx;
|
||||
struct hash_table *swapchain_private;
|
||||
mtx_t swapchain_name_mtx;
|
||||
struct hash_table *swapchain_name;
|
||||
};
|
||||
|
||||
VK_DEFINE_HANDLE_CASTS(vk_device, base, VkDevice,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue