diff options
| author | Charles Giessen <charles@lunarg.com> | 2022-12-02 15:03:49 -0700 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2023-01-18 15:31:35 -0700 |
| commit | c37dcfbae606437a59d35d7bd5384b1a425efd41 (patch) | |
| tree | 4a34b7fe1b9c4957e9bb690fa009cd5d0435d0c8 /cube/cube.cpp | |
| parent | c757a2a8f8d1ef46e5f11e9308f1d5c7cd3bb8a3 (diff) | |
| download | usermoji-c37dcfbae606437a59d35d7bd5384b1a425efd41.tar.xz | |
vkcube: Fix object type printing in 32 bit mode
Previously the code assumed that all types were convertable to void*, since
they happened to have the same size on 64 bit platforms. But in 32 bit, this
is not true.
Now the code converts dispatchable handles to uintptr_t then to void* only for
dispatchable types, printing all other types as non-dispatchable 64 bit ints.
Diffstat (limited to 'cube/cube.cpp')
| -rw-r--r-- | cube/cube.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/cube/cube.cpp b/cube/cube.cpp index cf5822f9..9bdb17ce 100644 --- a/cube/cube.cpp +++ b/cube/cube.cpp @@ -1040,15 +1040,21 @@ VKAPI_ATTR VkBool32 VKAPI_CALL Demo::debug_messenger_callback(VkDebugUtilsMessag if (pCallbackData->objectCount > 0) { message << "\n\tObjects - " << pCallbackData->objectCount << "\n"; for (uint32_t object = 0; object < pCallbackData->objectCount; ++object) { + message << "\t\tObject[" << object << "] - " + << vk::to_string(vk::ObjectType(pCallbackData->pObjects[object].objectType)) << ", Handle "; + + // Print handle correctly if it is a dispatchable handle - aka a pointer + VkObjectType t = pCallbackData->pObjects[object].objectType; + if (t == VK_OBJECT_TYPE_INSTANCE || t == VK_OBJECT_TYPE_PHYSICAL_DEVICE || t == VK_OBJECT_TYPE_DEVICE || + t == VK_OBJECT_TYPE_COMMAND_BUFFER || t == VK_OBJECT_TYPE_QUEUE) { + message << reinterpret_cast<void*>(static_cast<uintptr_t>(pCallbackData->pObjects[object].objectHandle)); + } else { + message << pCallbackData->pObjects[object].objectHandle; + } if (NULL != pCallbackData->pObjects[object].pObjectName && strlen(pCallbackData->pObjects[object].pObjectName) > 0) { - message << "\t\tObject[" << object << "] - " - << vk::to_string(vk::ObjectType(pCallbackData->pObjects[object].objectType)) << ", Handle " - << pCallbackData->pObjects[object].objectHandle << ", Name \"" - << pCallbackData->pObjects[object].pObjectName << "\"\n"; + message << ", Name \"" << pCallbackData->pObjects[object].pObjectName << "\"\n"; } else { - message << "\t\tObject[" << object << "] - " - << vk::to_string(vk::ObjectType(pCallbackData->pObjects[object].objectType)) << ", Handle " - << pCallbackData->pObjects[object].objectHandle << "\n"; + message << "\n"; } } } |
