The open source OpenXR runtime

a/vk: Use VK_EXT_debug_utils to name objects

authored by

Simon Zeni and committed by
Jakob Bornecrantz
c7dc483b 91d4e399

+26 -18
+17 -11
src/xrt/auxiliary/vk/vk_debug.c
··· 10 #include "vk/vk_helpers.h" 11 12 13 - #ifdef VK_EXT_debug_marker 14 15 void 16 - vk_name_object(struct vk_bundle *vk, VkDebugReportObjectTypeEXT object_type, uint64_t object, const char *name) 17 { 18 - if (!vk->has_EXT_debug_marker) { 19 return; 20 } 21 22 - if (object == 0) { 23 - U_LOG_W("Called with null object!"); 24 return; 25 } 26 27 - VkDebugMarkerObjectNameInfoEXT name_info = { 28 - .sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT, 29 - .pNext = NULL, 30 - .objectType = object_type, 31 - .object = object, 32 .pObjectName = name, 33 }; 34 35 - vk->vkDebugMarkerSetObjectNameEXT(vk->device, &name_info); 36 } 37 38 #endif
··· 10 #include "vk/vk_helpers.h" 11 12 13 + #ifdef VK_EXT_debug_utils 14 15 void 16 + vk_name_object(struct vk_bundle *vk, VkObjectType type, uint64_t object, const char *name) 17 { 18 + if (!vk->has_EXT_debug_utils) { 19 return; 20 } 21 22 + /* 23 + * VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589 24 + * If objectType is VK_OBJECT_TYPE_UNKNOWN, objectHandle must not be VK_NULL_HANDLE 25 + */ 26 + if (type == VK_OBJECT_TYPE_UNKNOWN && object == 0) { 27 + U_LOG_W("Unknown object type can't be VK_NULL_HANDLE"); 28 return; 29 } 30 31 + const VkDebugUtilsObjectNameInfoEXT name_info = { 32 + .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT, 33 + .objectType = type, 34 + .objectHandle = object, 35 .pObjectName = name, 36 }; 37 38 + VkResult ret = vk->vkSetDebugUtilsObjectNameEXT(vk->device, &name_info); 39 + if (ret != VK_SUCCESS) { 40 + VK_ERROR(vk, "vkSetDebugUtilsObjectNameEXT: %s", vk_result_string(ret)); 41 + } 42 } 43 44 #endif
+9 -7
src/xrt/auxiliary/vk/vk_helpers.h
··· 621 * 622 */ 623 624 - #if defined(VK_EXT_debug_marker) || defined(XRT_DOXYGEN) 625 626 /*! 627 - * Uses VK_EXT_debug_marker to name objects for easier debugging. 628 * 629 * @ingroup aux_vk 630 */ 631 void 632 - vk_name_object(struct vk_bundle *vk, VkDebugReportObjectTypeEXT object_type, uint64_t object, const char *name); 633 634 /*! 635 * Small helper for @ref vk_name_object that makes use of pre-process to avoid ··· 637 * 638 * @ingroup aux_vk 639 */ 640 - #define VK_NAME_OBJECT(vk, TYPE, obj, name) \ 641 - if (vk->has_EXT_debug_marker) { \ 642 - vk_name_object(vk, VK_DEBUG_REPORT_OBJECT_TYPE_##TYPE##_EXT, (uint64_t)obj, name); \ 643 - } 644 645 #else 646
··· 621 * 622 */ 623 624 + #if defined(VK_EXT_debug_utils) || defined(XRT_DOXYGEN) 625 626 /*! 627 + * Uses VK_EXT_debug_utils to set a name for an object, for easier debugging. 628 * 629 * @ingroup aux_vk 630 */ 631 void 632 + vk_name_object(struct vk_bundle *vk, VkObjectType type, uint64_t object, const char *name); 633 634 /*! 635 * Small helper for @ref vk_name_object that makes use of pre-process to avoid ··· 637 * 638 * @ingroup aux_vk 639 */ 640 + #define VK_NAME_OBJECT(VK, TYPE, OBJ, NAME) \ 641 + do { \ 642 + if ((VK)->has_EXT_debug_utils) { \ 643 + vk_name_object(VK, VK_OBJECT_TYPE_##TYPE, (uint64_t)OBJ, NAME); \ 644 + } \ 645 + } while (false) 646 647 #else 648