From c7dc483b9aff6abb70381b6cd564cfdb86303acb Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Wed, 1 Nov 2023 10:33:39 -0400 Subject: [PATCH] a/vk: Use VK_EXT_debug_utils to name objects --- src/xrt/auxiliary/vk/vk_debug.c | 28 +++++++++++++++++----------- src/xrt/auxiliary/vk/vk_helpers.h | 16 +++++++++------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/xrt/auxiliary/vk/vk_debug.c b/src/xrt/auxiliary/vk/vk_debug.c index 94de668a8..8bc6b0acf 100644 --- a/src/xrt/auxiliary/vk/vk_debug.c +++ b/src/xrt/auxiliary/vk/vk_debug.c @@ -10,29 +10,35 @@ #include "vk/vk_helpers.h" -#ifdef VK_EXT_debug_marker +#ifdef VK_EXT_debug_utils void -vk_name_object(struct vk_bundle *vk, VkDebugReportObjectTypeEXT object_type, uint64_t object, const char *name) +vk_name_object(struct vk_bundle *vk, VkObjectType type, uint64_t object, const char *name) { - if (!vk->has_EXT_debug_marker) { + if (!vk->has_EXT_debug_utils) { return; } - if (object == 0) { - U_LOG_W("Called with null object!"); + /* + * VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589 + * If objectType is VK_OBJECT_TYPE_UNKNOWN, objectHandle must not be VK_NULL_HANDLE + */ + if (type == VK_OBJECT_TYPE_UNKNOWN && object == 0) { + U_LOG_W("Unknown object type can't be VK_NULL_HANDLE"); return; } - VkDebugMarkerObjectNameInfoEXT name_info = { - .sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT, - .pNext = NULL, - .objectType = object_type, - .object = object, + const VkDebugUtilsObjectNameInfoEXT name_info = { + .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT, + .objectType = type, + .objectHandle = object, .pObjectName = name, }; - vk->vkDebugMarkerSetObjectNameEXT(vk->device, &name_info); + VkResult ret = vk->vkSetDebugUtilsObjectNameEXT(vk->device, &name_info); + if (ret != VK_SUCCESS) { + VK_ERROR(vk, "vkSetDebugUtilsObjectNameEXT: %s", vk_result_string(ret)); + } } #endif diff --git a/src/xrt/auxiliary/vk/vk_helpers.h b/src/xrt/auxiliary/vk/vk_helpers.h index 47d83c341..2fcec9a6d 100644 --- a/src/xrt/auxiliary/vk/vk_helpers.h +++ b/src/xrt/auxiliary/vk/vk_helpers.h @@ -621,15 +621,15 @@ xrt_swapchain_usage_flag_string(enum xrt_swapchain_usage_bits bits, bool null_on * */ -#if defined(VK_EXT_debug_marker) || defined(XRT_DOXYGEN) +#if defined(VK_EXT_debug_utils) || defined(XRT_DOXYGEN) /*! - * Uses VK_EXT_debug_marker to name objects for easier debugging. + * Uses VK_EXT_debug_utils to set a name for an object, for easier debugging. * * @ingroup aux_vk */ void -vk_name_object(struct vk_bundle *vk, VkDebugReportObjectTypeEXT object_type, uint64_t object, const char *name); +vk_name_object(struct vk_bundle *vk, VkObjectType type, uint64_t object, const char *name); /*! * Small helper for @ref vk_name_object that makes use of pre-process to avoid @@ -637,10 +637,12 @@ vk_name_object(struct vk_bundle *vk, VkDebugReportObjectTypeEXT object_type, uin * * @ingroup aux_vk */ -#define VK_NAME_OBJECT(vk, TYPE, obj, name) \ - if (vk->has_EXT_debug_marker) { \ - vk_name_object(vk, VK_DEBUG_REPORT_OBJECT_TYPE_##TYPE##_EXT, (uint64_t)obj, name); \ - } +#define VK_NAME_OBJECT(VK, TYPE, OBJ, NAME) \ + do { \ + if ((VK)->has_EXT_debug_utils) { \ + vk_name_object(VK, VK_OBJECT_TYPE_##TYPE, (uint64_t)OBJ, NAME); \ + } \ + } while (false) #else