a/vk: Use VK_EXT_debug_utils to name objects

This commit is contained in:
Simon Zeni 2023-11-01 10:33:39 -04:00 committed by Jakob Bornecrantz
parent 91d4e399c8
commit c7dc483b9a
2 changed files with 26 additions and 18 deletions

View file

@ -10,29 +10,35 @@
#include "vk/vk_helpers.h" #include "vk/vk_helpers.h"
#ifdef VK_EXT_debug_marker #ifdef VK_EXT_debug_utils
void 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; 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; return;
} }
VkDebugMarkerObjectNameInfoEXT name_info = { const VkDebugUtilsObjectNameInfoEXT name_info = {
.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT, .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
.pNext = NULL, .objectType = type,
.objectType = object_type, .objectHandle = object,
.object = object,
.pObjectName = name, .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 #endif

View file

@ -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 * @ingroup aux_vk
*/ */
void 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 * 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 * @ingroup aux_vk
*/ */
#define VK_NAME_OBJECT(vk, TYPE, obj, name) \ #define VK_NAME_OBJECT(VK, TYPE, OBJ, NAME) \
if (vk->has_EXT_debug_marker) { \ do { \
vk_name_object(vk, VK_DEBUG_REPORT_OBJECT_TYPE_##TYPE##_EXT, (uint64_t)obj, name); \ if ((VK)->has_EXT_debug_utils) { \
} vk_name_object(VK, VK_OBJECT_TYPE_##TYPE, (uint64_t)OBJ, NAME); \
} \
} while (false)
#else #else