diff --git a/samples/02_EnumerateDevices/02_EnumerateDevices.cpp b/samples/02_EnumerateDevices/02_EnumerateDevices.cpp index 99b8015..b292bef 100644 --- a/samples/02_EnumerateDevices/02_EnumerateDevices.cpp +++ b/samples/02_EnumerateDevices/02_EnumerateDevices.cpp @@ -28,7 +28,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif /* VULKAN_HPP_KEY_START */ diff --git a/samples/03_InitDevice/03_InitDevice.cpp b/samples/03_InitDevice/03_InitDevice.cpp index 2373443..0843845 100644 --- a/samples/03_InitDevice/03_InitDevice.cpp +++ b/samples/03_InitDevice/03_InitDevice.cpp @@ -28,7 +28,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/04_InitCommandBuffer/04_InitCommandBuffer.cpp b/samples/04_InitCommandBuffer/04_InitCommandBuffer.cpp index 82bcf32..f2e46f2 100644 --- a/samples/04_InitCommandBuffer/04_InitCommandBuffer.cpp +++ b/samples/04_InitCommandBuffer/04_InitCommandBuffer.cpp @@ -28,7 +28,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/05_InitSwapchain/05_InitSwapchain.cpp b/samples/05_InitSwapchain/05_InitSwapchain.cpp index a3d2ca2..d4a9ac2 100644 --- a/samples/05_InitSwapchain/05_InitSwapchain.cpp +++ b/samples/05_InitSwapchain/05_InitSwapchain.cpp @@ -28,7 +28,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp b/samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp index 6b38676..4525a68 100644 --- a/samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp +++ b/samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp @@ -28,7 +28,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/07_InitUniformBuffer/07_InitUniformBuffer.cpp b/samples/07_InitUniformBuffer/07_InitUniformBuffer.cpp index 2d2b2ac..065e84d 100644 --- a/samples/07_InitUniformBuffer/07_InitUniformBuffer.cpp +++ b/samples/07_InitUniformBuffer/07_InitUniformBuffer.cpp @@ -32,7 +32,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/08_InitPipelineLayout/08_InitPipelineLayout.cpp b/samples/08_InitPipelineLayout/08_InitPipelineLayout.cpp index 32daad4..da36ca4 100644 --- a/samples/08_InitPipelineLayout/08_InitPipelineLayout.cpp +++ b/samples/08_InitPipelineLayout/08_InitPipelineLayout.cpp @@ -28,7 +28,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/09_InitDescriptorSet/09_InitDescriptorSet.cpp b/samples/09_InitDescriptorSet/09_InitDescriptorSet.cpp index 3fd218a..8877716 100644 --- a/samples/09_InitDescriptorSet/09_InitDescriptorSet.cpp +++ b/samples/09_InitDescriptorSet/09_InitDescriptorSet.cpp @@ -33,7 +33,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/10_InitRenderPass/10_InitRenderPass.cpp b/samples/10_InitRenderPass/10_InitRenderPass.cpp index ca5e8a0..6b3d158 100644 --- a/samples/10_InitRenderPass/10_InitRenderPass.cpp +++ b/samples/10_InitRenderPass/10_InitRenderPass.cpp @@ -32,7 +32,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/11_InitShaders/11_InitShaders.cpp b/samples/11_InitShaders/11_InitShaders.cpp index f4751f1..81e63d8 100644 --- a/samples/11_InitShaders/11_InitShaders.cpp +++ b/samples/11_InitShaders/11_InitShaders.cpp @@ -30,7 +30,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/12_InitFrameBuffers/12_InitFrameBuffers.cpp b/samples/12_InitFrameBuffers/12_InitFrameBuffers.cpp index 2340e04..a4ff0d5 100644 --- a/samples/12_InitFrameBuffers/12_InitFrameBuffers.cpp +++ b/samples/12_InitFrameBuffers/12_InitFrameBuffers.cpp @@ -28,7 +28,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp b/samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp index d8a654a..fc8a657 100644 --- a/samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp +++ b/samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp @@ -29,7 +29,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/14_InitPipeline/14_InitPipeline.cpp b/samples/14_InitPipeline/14_InitPipeline.cpp index 4394ed2..2feb392 100644 --- a/samples/14_InitPipeline/14_InitPipeline.cpp +++ b/samples/14_InitPipeline/14_InitPipeline.cpp @@ -32,7 +32,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/15_DrawCube/15_DrawCube.cpp b/samples/15_DrawCube/15_DrawCube.cpp index c714571..af2ac12 100644 --- a/samples/15_DrawCube/15_DrawCube.cpp +++ b/samples/15_DrawCube/15_DrawCube.cpp @@ -32,7 +32,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/16_Vulkan_1_1/16_Vulkan_1_1.cpp b/samples/16_Vulkan_1_1/16_Vulkan_1_1.cpp index a7f4be6..ca18d5a 100644 --- a/samples/16_Vulkan_1_1/16_Vulkan_1_1.cpp +++ b/samples/16_Vulkan_1_1/16_Vulkan_1_1.cpp @@ -56,7 +56,7 @@ int main(int /*argc*/, char ** /*argv*/) // Create the instance vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions(), desiredVersion); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif // Get the list of physical devices diff --git a/samples/CopyBlitImage/CopyBlitImage.cpp b/samples/CopyBlitImage/CopyBlitImage.cpp index 2898c8b..5135be9 100644 --- a/samples/CopyBlitImage/CopyBlitImage.cpp +++ b/samples/CopyBlitImage/CopyBlitImage.cpp @@ -27,7 +27,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/CreateDebugReportCallback/CreateDebugReportCallback.cpp b/samples/CreateDebugReportCallback/CreateDebugReportCallback.cpp deleted file mode 100644 index 3f0bb39..0000000 --- a/samples/CreateDebugReportCallback/CreateDebugReportCallback.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright(c) 2019, NVIDIA CORPORATION. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// VulkanHpp Samples : CreateDebugReportCallback -// Draw a cube - -#include "vulkan/vulkan.hpp" -#include -#include - -static char const* AppName = "CreateDebugReportCallback"; -static char const* EngineName = "Vulkan.hpp"; - -PFN_vkCreateDebugReportCallbackEXT pfnVkCreateDebugReportCallbackEXT; -PFN_vkDestroyDebugReportCallbackEXT pfnVkDestroyDebugReportCallbackEXT; - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback) -{ - return pfnVkCreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator) -{ - pfnVkDestroyDebugReportCallbackEXT(instance, callback, pAllocator); -} - - -VKAPI_ATTR VkBool32 VKAPI_CALL dbgFunc(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT /*objType*/, uint64_t /*srcObject*/, size_t /*location*/, int32_t msgCode, const char *pLayerPrefix, const char *pMsg, void * /*pUserData*/) -{ - std::ostringstream message; - - switch (flags) - { - case VK_DEBUG_REPORT_INFORMATION_BIT_EXT: - message << "INFORMATION: "; - break; - case VK_DEBUG_REPORT_WARNING_BIT_EXT: - message << "WARNING: "; - break; - case VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT: - message << "PERFORMANCE WARNING: "; - break; - case VK_DEBUG_REPORT_ERROR_BIT_EXT: - message << "ERROR: "; - break; - case VK_DEBUG_REPORT_DEBUG_BIT_EXT: - message << "DEBUG: "; - break; - default: - message << "unknown flag (" << flags << "): "; - break; - } - message << "[" << pLayerPrefix << "] Code " << msgCode << " : " << pMsg; - -#ifdef _WIN32 - MessageBox(NULL, message.str().c_str(), "Alert", MB_OK); -#else - std::cout << message.str() << std::endl; -#endif - - return false; -} - - -int main(int /*argc*/, char ** /*argv*/) -{ - try - { - /* VULKAN_KEY_START */ - - std::vector props = vk::enumerateInstanceExtensionProperties(); - - auto propsIterator = std::find_if(props.begin(), props.end(), [](vk::ExtensionProperties const& ep) { return strcmp(ep.extensionName, VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0; }); - if (propsIterator == props.end()) - { - std::cout << "Something went very wrong, cannot find " << VK_EXT_DEBUG_REPORT_EXTENSION_NAME << " extension" << std::endl; - exit(1); - } - - vk::ApplicationInfo applicationInfo(AppName, 1, EngineName, 1, VK_API_VERSION_1_0); - const char *extensionName = VK_EXT_DEBUG_REPORT_EXTENSION_NAME; - vk::UniqueInstance instance = vk::createInstanceUnique(vk::InstanceCreateInfo(vk::InstanceCreateFlags(), &applicationInfo, 0, nullptr, 1, &extensionName)); - - pfnVkCreateDebugReportCallbackEXT = reinterpret_cast(instance->getProcAddr("vkCreateDebugReportCallbackEXT")); - if (!pfnVkCreateDebugReportCallbackEXT) - { - std::cout << "GetInstanceProcAddr: Unable to find vkCreateDebugReportCallbackEXT function." << std::endl; - exit(1); - } - - pfnVkDestroyDebugReportCallbackEXT = reinterpret_cast(instance->getProcAddr("vkDestroyDebugReportCallbackEXT")); - if (!pfnVkDestroyDebugReportCallbackEXT) - { - std::cout << "GetInstanceProcAddr: Unable to find vkDestroyDebugReportCallbackEXT function." << std::endl; - exit(1); - } - - vk::UniqueDebugReportCallbackEXT debugReportCallback = instance->createDebugReportCallbackEXTUnique(vk::DebugReportCallbackCreateInfoEXT(vk::DebugReportFlagBitsEXT::eError | vk::DebugReportFlagBitsEXT::eWarning, dbgFunc)); - - /* VULKAN_KEY_END */ - } - catch (vk::SystemError err) - { - std::cout << "vk::SystemError: " << err.what() << std::endl; - exit(-1); - } - catch (std::runtime_error err) - { - std::cout << "std::runtime_error: " << err.what() << std::endl; - exit(-1); - } - catch (...) - { - std::cout << "unknown error\n"; - exit(-1); - } - return 0; -} diff --git a/samples/CreateDebugReportCallback/CMakeLists.txt b/samples/CreateDebugUtilsMessenger/CMakeLists.txt similarity index 77% rename from samples/CreateDebugReportCallback/CMakeLists.txt rename to samples/CreateDebugUtilsMessenger/CMakeLists.txt index 21be8ba..e6a202f 100644 --- a/samples/CreateDebugReportCallback/CMakeLists.txt +++ b/samples/CreateDebugUtilsMessenger/CMakeLists.txt @@ -14,22 +14,22 @@ cmake_minimum_required(VERSION 3.2) -project(CreateDebugReportCallback) +project(CreateDebugUtilsMessenger) set(HEADERS ) set(SOURCES - CreateDebugReportCallback.cpp + CreateDebugUtilsMessenger.cpp ) source_group(headers FILES ${HEADERS}) source_group(sources FILES ${SOURCES}) -add_executable(CreateDebugReportCallback +add_executable(CreateDebugUtilsMessenger ${HEADERS} ${SOURCES} ) -set_target_properties(CreateDebugReportCallback PROPERTIES FOLDER "Samples") -target_link_libraries(CreateDebugReportCallback PUBLIC "${Vulkan_LIBRARIES}") +set_target_properties(CreateDebugUtilsMessenger PROPERTIES FOLDER "Samples") +target_link_libraries(CreateDebugUtilsMessenger PUBLIC "${Vulkan_LIBRARIES}") diff --git a/samples/CreateDebugUtilsMessenger/CreateDebugUtilsMessenger.cpp b/samples/CreateDebugUtilsMessenger/CreateDebugUtilsMessenger.cpp new file mode 100644 index 0000000..7a50ac2 --- /dev/null +++ b/samples/CreateDebugUtilsMessenger/CreateDebugUtilsMessenger.cpp @@ -0,0 +1,144 @@ +// Copyright(c) 2019, NVIDIA CORPORATION. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// VulkanHpp Samples : CreateDebugReportMessenger +// Draw a cube + +#include "vulkan/vulkan.hpp" +#include +#include + +static char const* AppName = "CreateDebugReportMessenger"; +static char const* EngineName = "Vulkan.hpp"; + +PFN_vkCreateDebugUtilsMessengerEXT pfnVkCreateDebugUtilsMessengerEXT; +PFN_vkDestroyDebugUtilsMessengerEXT pfnVkDestroyDebugUtilsMessengerEXT; + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pMessenger) +{ + return pfnVkCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger); +} + +VKAPI_ATTR void VKAPI_CALL vkDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, VkAllocationCallbacks const * pAllocator) +{ + return pfnVkDestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator); +} + + +VkBool32 debugMessageFunc(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, + VkDebugUtilsMessengerCallbackDataEXT const * pCallbackData, void * /*pUserData*/) +{ + std::ostringstream message; + + message << vk::to_string(static_cast(messageSeverity)) << ": " << vk::to_string(static_cast(messageTypes)) << ":\n"; + message << "\t" << "messageIDName = <" << pCallbackData->pMessageIdName << ">\n"; + message << "\t" << "messageIdNumber = " << pCallbackData->messageIdNumber << "\n"; + message << "\t" << "message = <" << pCallbackData->pMessage << ">\n"; + if (0 < pCallbackData->queueLabelCount) + { + message << "\t" << "Queue Labels:\n"; + for (uint8_t i = 0; i < pCallbackData->queueLabelCount; i++) + { + message << "\t\t" << "lableName = <" << pCallbackData->pQueueLabels[i].pLabelName << ">\n"; + } + } + if (0 < pCallbackData->cmdBufLabelCount) + { + message << "\t" << "CommandBuffer Labels:\n"; + for (uint8_t i = 0; i < pCallbackData->cmdBufLabelCount; i++) + { + message << "\t\t" << "labelName = <" << pCallbackData->pCmdBufLabels[i].pLabelName << ">\n"; + } + } + if (0 < pCallbackData->objectCount) + { + message << "\t" << "Objects:\n"; + for (uint8_t i = 0; i < pCallbackData->objectCount; i++) + { + message << "\t\t" << "Object " << i << "\n"; + message << "\t\t\t" << "objectType = " << vk::to_string(static_cast(pCallbackData->pObjects[i].objectType)) << "\n"; + message << "\t\t\t" << "objectHandle = " << pCallbackData->pObjects[i].objectHandle << "\n"; + if (pCallbackData->pObjects[i].pObjectName) + { + message << "\t\t\t" << "objectName = <" << pCallbackData->pObjects[i].pObjectName << ">\n"; + } + } + } + +#ifdef _WIN32 + MessageBox(NULL, message.str().c_str(), "Alert", MB_OK); +#else + std::cout << message.str() << std::endl; +#endif + + return false; +} + + +int main(int /*argc*/, char ** /*argv*/) +{ + try + { + /* VULKAN_KEY_START */ + + std::vector props = vk::enumerateInstanceExtensionProperties(); + + auto propsIterator = std::find_if(props.begin(), props.end(), [](vk::ExtensionProperties const& ep) { return strcmp(ep.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) == 0; }); + if (propsIterator == props.end()) + { + std::cout << "Something went very wrong, cannot find " << VK_EXT_DEBUG_UTILS_EXTENSION_NAME << " extension" << std::endl; + exit(1); + } + + vk::ApplicationInfo applicationInfo(AppName, 1, EngineName, 1, VK_API_VERSION_1_1); + const char *extensionName = VK_EXT_DEBUG_UTILS_EXTENSION_NAME; + vk::UniqueInstance instance = vk::createInstanceUnique(vk::InstanceCreateInfo(vk::InstanceCreateFlags(), &applicationInfo, 0, nullptr, 1, &extensionName)); + + pfnVkCreateDebugUtilsMessengerEXT = reinterpret_cast(instance->getProcAddr("vkCreateDebugUtilsMessengerEXT")); + if (!pfnVkCreateDebugUtilsMessengerEXT) + { + std::cout << "GetInstanceProcAddr: Unable to find pfnVkCreateDebugUtilsMessengerEXT function." << std::endl; + exit(1); + } + + pfnVkDestroyDebugUtilsMessengerEXT = reinterpret_cast(instance->getProcAddr("vkDestroyDebugUtilsMessengerEXT")); + if (!pfnVkDestroyDebugUtilsMessengerEXT) + { + std::cout << "GetInstanceProcAddr: Unable to find pfnVkDestroyDebugUtilsMessengerEXT function." << std::endl; + exit(1); + } + + vk::DebugUtilsMessageSeverityFlagsEXT severityFlags(vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eError); + vk::DebugUtilsMessageTypeFlagsEXT messageTypeFlags(vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = instance->createDebugUtilsMessengerEXTUnique(vk::DebugUtilsMessengerCreateInfoEXT({}, severityFlags, messageTypeFlags, &debugMessageFunc)); + + /* VULKAN_KEY_END */ + } + catch (vk::SystemError err) + { + std::cout << "vk::SystemError: " << err.what() << std::endl; + exit(-1); + } + catch (std::runtime_error err) + { + std::cout << "std::runtime_error: " << err.what() << std::endl; + exit(-1); + } + catch (...) + { + std::cout << "unknown error\n"; + exit(-1); + } + return 0; +} diff --git a/samples/DrawTexturedCube/DrawTexturedCube.cpp b/samples/DrawTexturedCube/DrawTexturedCube.cpp index 5f5a180..71de62d 100644 --- a/samples/DrawTexturedCube/DrawTexturedCube.cpp +++ b/samples/DrawTexturedCube/DrawTexturedCube.cpp @@ -32,7 +32,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/DynamicUniform/DynamicUniform.cpp b/samples/DynamicUniform/DynamicUniform.cpp index 3c811a6..ff9487c 100644 --- a/samples/DynamicUniform/DynamicUniform.cpp +++ b/samples/DynamicUniform/DynamicUniform.cpp @@ -32,7 +32,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp b/samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp index ef3ea64..f78d8e0 100644 --- a/samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp +++ b/samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp @@ -24,46 +24,59 @@ static char const* AppName = "EnableValidationWithCallback"; static char const* EngineName = "Vulkan.hpp"; -PFN_vkCreateDebugReportCallbackEXT pfnVkCreateDebugReportCallbackEXT; -PFN_vkDestroyDebugReportCallbackEXT pfnVkDestroyDebugReportCallbackEXT; +PFN_vkCreateDebugUtilsMessengerEXT pfnVkCreateDebugUtilsMessengerEXT; +PFN_vkDestroyDebugUtilsMessengerEXT pfnVkDestroyDebugUtilsMessengerEXT; -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback) +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pMessenger) { - return pfnVkCreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback); + return pfnVkCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger); } -VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator) +VKAPI_ATTR void VKAPI_CALL vkDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, VkAllocationCallbacks const * pAllocator) { - pfnVkDestroyDebugReportCallbackEXT(instance, callback, pAllocator); + return pfnVkDestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator); } -VKAPI_ATTR VkBool32 VKAPI_CALL dbgFunc(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT /*objType*/, uint64_t /*srcObject*/, size_t /*location*/, int32_t msgCode, const char *pLayerPrefix, const char *pMsg, void * /*pUserData*/) +VkBool32 debugMessageFunc(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, + VkDebugUtilsMessengerCallbackDataEXT const * pCallbackData, void * /*pUserData*/) { std::ostringstream message; - switch (flags) + message << vk::to_string(static_cast(messageSeverity)) << ": " << vk::to_string(static_cast(messageTypes)) << ":\n"; + message << "\t" << "messageIDName = <" << pCallbackData->pMessageIdName << ">\n"; + message << "\t" << "messageIdNumber = " << pCallbackData->messageIdNumber << "\n"; + message << "\t" << "message = <" << pCallbackData->pMessage << ">\n"; + if (0 < pCallbackData->queueLabelCount) { - case VK_DEBUG_REPORT_INFORMATION_BIT_EXT: - message << "INFORMATION: "; - break; - case VK_DEBUG_REPORT_WARNING_BIT_EXT: - message << "WARNING: "; - break; - case VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT: - message << "PERFORMANCE WARNING: "; - break; - case VK_DEBUG_REPORT_ERROR_BIT_EXT: - message << "ERROR: "; - break; - case VK_DEBUG_REPORT_DEBUG_BIT_EXT: - message << "DEBUG: "; - break; - default: - message << "unknown flag (" << flags << "): "; - break; + message << "\t" << "Queue Labels:\n"; + for (uint8_t i = 0; i < pCallbackData->queueLabelCount; i++) + { + message << "\t\t" << "lableName = <" << pCallbackData->pQueueLabels[i].pLabelName << ">\n"; + } } - message << "[" << pLayerPrefix << "] Code " << msgCode << " : " << pMsg; + if (0 < pCallbackData->cmdBufLabelCount) + { + message << "\t" << "CommandBuffer Labels:\n"; + for (uint8_t i = 0; i < pCallbackData->cmdBufLabelCount; i++) + { + message << "\t\t" << "labelName = <" << pCallbackData->pCmdBufLabels[i].pLabelName << ">\n"; + } + } + if (0 < pCallbackData->objectCount) + { + message << "\t" << "Objects:\n"; + for (uint8_t i = 0; i < pCallbackData->objectCount; i++) + { + message << "\t\t" << "Object " << i << "\n"; + message << "\t\t\t" << "objectType = " << vk::to_string(static_cast(pCallbackData->pObjects[i].objectType)) << "\n"; + message << "\t\t\t" << "objectHandle = " << pCallbackData->pObjects[i].objectHandle << "\n"; + if (pCallbackData->pObjects[i].pObjectName) + { + message << "\t\t\t" << "objectName = <" << pCallbackData->pObjects[i].pObjectName << ">\n"; + } + } +} #ifdef _WIN32 MessageBox(NULL, message.str().c_str(), "Alert", MB_OK); @@ -102,13 +115,31 @@ int main(int /*argc*/, char ** /*argv*/) /* Enable debug callback extension */ std::vector instanceExtensionNames; - instanceExtensionNames.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); + instanceExtensionNames.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); - vk::ApplicationInfo applicationInfo(AppName, 1, EngineName, 1, VK_API_VERSION_1_0); + vk::ApplicationInfo applicationInfo(AppName, 1, EngineName, 1, VK_API_VERSION_1_1); vk::InstanceCreateInfo instanceCreateInfo( vk::InstanceCreateFlags(), &applicationInfo, vk::su::checked_cast(instanceLayerNames.size()), instanceLayerNames.data(), vk::su::checked_cast(instanceExtensionNames.size()) , instanceExtensionNames.data() ); vk::UniqueInstance instance = vk::createInstanceUnique(instanceCreateInfo); + pfnVkCreateDebugUtilsMessengerEXT = reinterpret_cast(instance->getProcAddr("vkCreateDebugUtilsMessengerEXT")); + if (!pfnVkCreateDebugUtilsMessengerEXT) + { + std::cout << "GetInstanceProcAddr: Unable to find pfnVkCreateDebugUtilsMessengerEXT function." << std::endl; + exit(1); + } + + pfnVkDestroyDebugUtilsMessengerEXT = reinterpret_cast(instance->getProcAddr("vkDestroyDebugUtilsMessengerEXT")); + if (!pfnVkDestroyDebugUtilsMessengerEXT) + { + std::cout << "GetInstanceProcAddr: Unable to find pfnVkDestroyDebugUtilsMessengerEXT function." << std::endl; + exit(1); + } + + vk::DebugUtilsMessageSeverityFlagsEXT severityFlags(vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eError); + vk::DebugUtilsMessageTypeFlagsEXT messageTypeFlags(vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = instance->createDebugUtilsMessengerEXTUnique(vk::DebugUtilsMessengerCreateInfoEXT({}, severityFlags, messageTypeFlags, &debugMessageFunc)); + vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); std::vector queueFamilyProperties = physicalDevice.getQueueFamilyProperties(); @@ -122,21 +153,6 @@ int main(int /*argc*/, char ** /*argv*/) vk::DeviceQueueCreateInfo deviceQueueCreateInfo(vk::DeviceQueueCreateFlags(), queueFamilyIndex, 1, &queuePriority); vk::UniqueDevice device = physicalDevice.createDeviceUnique(vk::DeviceCreateInfo(vk::DeviceCreateFlags(), 1, &deviceQueueCreateInfo)); - pfnVkCreateDebugReportCallbackEXT = reinterpret_cast(instance->getProcAddr("vkCreateDebugReportCallbackEXT")); - if (!pfnVkCreateDebugReportCallbackEXT) - { - std::cout << "GetInstanceProcAddr: Unable to find vkCreateDebugReportCallbackEXT function." << std::endl; - exit(1); - } - pfnVkDestroyDebugReportCallbackEXT = reinterpret_cast(instance->getProcAddr("vkDestroyDebugReportCallbackEXT")); - if (!pfnVkDestroyDebugReportCallbackEXT) - { - std::cout << "GetInstanceProcAddr: Unable to find vkDestroyDebugReportCallbackEXT function." << std::endl; - exit(1); - } - - vk::UniqueDebugReportCallbackEXT debugReportCallback = instance->createDebugReportCallbackEXTUnique(vk::DebugReportCallbackCreateInfoEXT(vk::DebugReportFlagBitsEXT::eError | vk::DebugReportFlagBitsEXT::eWarning, dbgFunc)); - // Create a command pool (not a UniqueCommandPool, for testing purposes! vk::CommandPool commandPool = device->createCommandPool(vk::CommandPoolCreateInfo(vk::CommandPoolCreateFlags(), queueFamilyIndex)); diff --git a/samples/EnumerateDevicesAdvanced/EnumerateDevicesAdvanced.cpp b/samples/EnumerateDevicesAdvanced/EnumerateDevicesAdvanced.cpp index 0050ea9..fe640a3 100644 --- a/samples/EnumerateDevicesAdvanced/EnumerateDevicesAdvanced.cpp +++ b/samples/EnumerateDevicesAdvanced/EnumerateDevicesAdvanced.cpp @@ -29,7 +29,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif /* VULKAN_HPP_KEY_START */ diff --git a/samples/Events/Events.cpp b/samples/Events/Events.cpp index 92a39db..258393b 100644 --- a/samples/Events/Events.cpp +++ b/samples/Events/Events.cpp @@ -28,7 +28,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/ImmutableSampler/ImmutableSampler.cpp b/samples/ImmutableSampler/ImmutableSampler.cpp index 43ecd98..3b57556 100644 --- a/samples/ImmutableSampler/ImmutableSampler.cpp +++ b/samples/ImmutableSampler/ImmutableSampler.cpp @@ -32,7 +32,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/InitTexture/InitTexture.cpp b/samples/InitTexture/InitTexture.cpp index 0ae2f2f..d9bf2eb 100644 --- a/samples/InitTexture/InitTexture.cpp +++ b/samples/InitTexture/InitTexture.cpp @@ -32,7 +32,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/InputAttachment/InputAttachment.cpp b/samples/InputAttachment/InputAttachment.cpp index c32cb2e..55b3234 100644 --- a/samples/InputAttachment/InputAttachment.cpp +++ b/samples/InputAttachment/InputAttachment.cpp @@ -60,7 +60,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/MultipleSets/MultipleSets.cpp b/samples/MultipleSets/MultipleSets.cpp index d10ca27..b1c4d39 100644 --- a/samples/MultipleSets/MultipleSets.cpp +++ b/samples/MultipleSets/MultipleSets.cpp @@ -82,7 +82,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/OcclusionQuery/OcclusionQuery.cpp b/samples/OcclusionQuery/OcclusionQuery.cpp index 611385f..0441c4e 100644 --- a/samples/OcclusionQuery/OcclusionQuery.cpp +++ b/samples/OcclusionQuery/OcclusionQuery.cpp @@ -32,7 +32,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/PipelineCache/PipelineCache.cpp b/samples/PipelineCache/PipelineCache.cpp index e3e4a6a..63325f1 100644 --- a/samples/PipelineCache/PipelineCache.cpp +++ b/samples/PipelineCache/PipelineCache.cpp @@ -64,7 +64,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/PipelineDerivative/PipelineDerivative.cpp b/samples/PipelineDerivative/PipelineDerivative.cpp index 1b6f6bc..e69e8df 100644 --- a/samples/PipelineDerivative/PipelineDerivative.cpp +++ b/samples/PipelineDerivative/PipelineDerivative.cpp @@ -31,7 +31,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/PushConstants/PushConstants.cpp b/samples/PushConstants/PushConstants.cpp index 82beac6..95d4345 100644 --- a/samples/PushConstants/PushConstants.cpp +++ b/samples/PushConstants/PushConstants.cpp @@ -73,7 +73,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/PushDescriptors/PushDescriptors.cpp b/samples/PushDescriptors/PushDescriptors.cpp index 1522b4f..f7fd5af 100644 --- a/samples/PushDescriptors/PushDescriptors.cpp +++ b/samples/PushDescriptors/PushDescriptors.cpp @@ -45,7 +45,7 @@ int main(int /*argc*/, char ** /*argv*/) vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, instanceExtensions); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/RayTracing/RayTracing.cpp b/samples/RayTracing/RayTracing.cpp index bd9158e..43e67c2 100644 --- a/samples/RayTracing/RayTracing.cpp +++ b/samples/RayTracing/RayTracing.cpp @@ -650,7 +650,7 @@ int main(int /*argc*/, char** /*argv*/) vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, instanceExtensions); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReport = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp b/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp index 6cf2029..ca7b7ed 100644 --- a/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp +++ b/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp @@ -32,7 +32,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/SeparateImageSampler/SeparateImageSampler.cpp b/samples/SeparateImageSampler/SeparateImageSampler.cpp index 70adad4..216905c 100644 --- a/samples/SeparateImageSampler/SeparateImageSampler.cpp +++ b/samples/SeparateImageSampler/SeparateImageSampler.cpp @@ -62,7 +62,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/Template/Template.cpp b/samples/Template/Template.cpp index dbd06cc..5eb4e93 100644 --- a/samples/Template/Template.cpp +++ b/samples/Template/Template.cpp @@ -32,7 +32,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/TexelBuffer/TexelBuffer.cpp b/samples/TexelBuffer/TexelBuffer.cpp index 144a446..f473539 100644 --- a/samples/TexelBuffer/TexelBuffer.cpp +++ b/samples/TexelBuffer/TexelBuffer.cpp @@ -59,7 +59,7 @@ int main(int /*argc*/, char ** /*argv*/) { vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions()); #if !defined(NDEBUG) - vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); + vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance); #endif vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); diff --git a/samples/utils/utils.cpp b/samples/utils/utils.cpp index 408d6dc..59c0828 100644 --- a/samples/utils/utils.cpp +++ b/samples/utils/utils.cpp @@ -18,17 +18,17 @@ #include #include -PFN_vkCreateDebugReportCallbackEXT pfnVkCreateDebugReportCallbackEXT; -PFN_vkDestroyDebugReportCallbackEXT pfnVkDestroyDebugReportCallbackEXT; +PFN_vkCreateDebugUtilsMessengerEXT pfnVkCreateDebugUtilsMessengerEXT; +PFN_vkDestroyDebugUtilsMessengerEXT pfnVkDestroyDebugUtilsMessengerEXT; -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback) +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pMessenger) { - return pfnVkCreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback); + return pfnVkCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger); } -VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator) +VKAPI_ATTR void VKAPI_CALL vkDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, VkAllocationCallbacks const * pAllocator) { - pfnVkDestroyDebugReportCallbackEXT(instance, callback, pAllocator); + return pfnVkDestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator); } namespace vk @@ -49,10 +49,11 @@ namespace vk return device->createCommandPoolUnique(commandPoolCreateInfo); } - vk::UniqueDebugReportCallbackEXT createDebugReportCallback(vk::UniqueInstance &instance) + vk::UniqueDebugUtilsMessengerEXT createDebugUtilsMessenger(vk::UniqueInstance &instance) { - vk::DebugReportFlagsEXT flags(vk::DebugReportFlagBitsEXT::eWarning | vk::DebugReportFlagBitsEXT::ePerformanceWarning | vk::DebugReportFlagBitsEXT::eError); - return instance->createDebugReportCallbackEXTUnique(vk::DebugReportCallbackCreateInfoEXT(flags, &vk::su::debugReportCallback)); + vk::DebugUtilsMessageSeverityFlagsEXT severityFlags(vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eError); + vk::DebugUtilsMessageTypeFlagsEXT messageTypeFlags(vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); + return instance->createDebugUtilsMessengerEXTUnique(vk::DebugUtilsMessengerCreateInfoEXT({}, severityFlags, messageTypeFlags, &vk::su::debugUtilsMessengerCallback)); } vk::UniqueDescriptorPool createDescriptorPool(vk::UniqueDevice &device, std::vector const& poolSizes) @@ -193,9 +194,9 @@ namespace vk enabledExtensions.push_back(ext.data()); } #if !defined(NDEBUG) - if (std::find(extensions.begin(), extensions.end(), VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == extensions.end()) + if (std::find(extensions.begin(), extensions.end(), VK_EXT_DEBUG_UTILS_EXTENSION_NAME) == extensions.end()) { - enabledExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); + enabledExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); } #endif @@ -208,9 +209,9 @@ namespace vk static bool initialized = false; if (!initialized) { - pfnVkCreateDebugReportCallbackEXT = reinterpret_cast(instance->getProcAddr("vkCreateDebugReportCallbackEXT")); - pfnVkDestroyDebugReportCallbackEXT = reinterpret_cast(instance->getProcAddr("vkDestroyDebugReportCallbackEXT")); - assert(pfnVkCreateDebugReportCallbackEXT && pfnVkDestroyDebugReportCallbackEXT); + pfnVkCreateDebugUtilsMessengerEXT = reinterpret_cast(instance->getProcAddr("vkCreateDebugUtilsMessengerEXT")); + pfnVkDestroyDebugUtilsMessengerEXT = reinterpret_cast(instance->getProcAddr("vkDestroyDebugUtilsMessengerEXT")); + assert(pfnVkCreateDebugUtilsMessengerEXT && pfnVkDestroyDebugUtilsMessengerEXT); initialized = true; } #endif @@ -238,30 +239,43 @@ namespace vk &subpassDescription)); } - VkBool32 debugReportCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT /*objectType*/, uint64_t /*object*/, size_t /*location*/, int32_t /*messageCode*/, const char* /*pLayerPrefix*/, const char* pMessage, void* /*pUserData*/) + VkBool32 debugUtilsMessengerCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, + VkDebugUtilsMessengerCallbackDataEXT const * pCallbackData, void * /*pUserData*/) { - switch (flags) + std::cerr << vk::to_string(static_cast(messageSeverity)) << ": " << vk::to_string(static_cast(messageTypes)) << ":\n"; + std::cerr << "\t" << "messageIDName = <" << pCallbackData->pMessageIdName << ">\n"; + std::cerr << "\t" << "messageIdNumber = " << pCallbackData->messageIdNumber << "\n"; + std::cerr << "\t" << "message = <" << pCallbackData->pMessage << ">\n"; + if (0 < pCallbackData->queueLabelCount) { - case VK_DEBUG_REPORT_INFORMATION_BIT_EXT: - std::cerr << "INFORMATION: "; - break; - case VK_DEBUG_REPORT_WARNING_BIT_EXT: - std::cerr << "WARNING: "; - break; - case VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT: - std::cerr << "PERFORMANCE WARNING: "; - break; - case VK_DEBUG_REPORT_ERROR_BIT_EXT: - std::cerr << "ERROR: "; - break; - case VK_DEBUG_REPORT_DEBUG_BIT_EXT: - std::cerr << "DEBUG: "; - break; - default: - std::cerr << "unknown flag (" << flags << "): "; - break; + std::cerr << "\t" << "Queue Labels:\n"; + for (uint8_t i = 0; i < pCallbackData->queueLabelCount; i++) + { + std::cerr << "\t\t" << "lableName = <" << pCallbackData->pQueueLabels[i].pLabelName << ">\n"; + } + } + if (0 < pCallbackData->cmdBufLabelCount) + { + std::cerr << "\t" << "CommandBuffer Labels:\n"; + for (uint8_t i = 0; i < pCallbackData->cmdBufLabelCount; i++) + { + std::cerr << "\t\t" << "labelName = <" << pCallbackData->pCmdBufLabels[i].pLabelName << ">\n"; + } + } + if (0 < pCallbackData->objectCount) + { + std::cerr << "\t" << "Objects:\n"; + for (uint8_t i = 0; i < pCallbackData->objectCount; i++) + { + std::cerr << "\t\t" << "Object " << i << "\n"; + std::cerr << "\t\t\t" << "objectType = " << vk::to_string(static_cast(pCallbackData->pObjects[i].objectType)) << "\n"; + std::cerr << "\t\t\t" << "objectHandle = " << pCallbackData->pObjects[i].objectHandle << "\n"; + if (pCallbackData->pObjects[i].pObjectName) + { + std::cerr << "\t\t\t" << "objectName = <" << pCallbackData->pObjects[i].pObjectName << ">\n"; + } + } } - std::cerr << pMessage << std::endl; return VK_TRUE; } diff --git a/samples/utils/utils.hpp b/samples/utils/utils.hpp index 26e1eeb..d8a40a5 100644 --- a/samples/utils/utils.hpp +++ b/samples/utils/utils.hpp @@ -264,7 +264,7 @@ namespace vk vk::UniqueDeviceMemory allocateMemory(vk::UniqueDevice const& device, vk::PhysicalDeviceMemoryProperties const& memoryProperties, vk::MemoryRequirements const& memoryRequirements, vk::MemoryPropertyFlags memoryPropertyFlags); vk::UniqueCommandPool createCommandPool(vk::UniqueDevice &device, uint32_t queueFamilyIndex); - vk::UniqueDebugReportCallbackEXT createDebugReportCallback(vk::UniqueInstance &instance); + vk::UniqueDebugUtilsMessengerEXT createDebugUtilsMessenger(vk::UniqueInstance &instance); vk::UniqueDescriptorPool createDescriptorPool(vk::UniqueDevice &device, std::vector const& poolSizes); vk::UniqueDescriptorSetLayout createDescriptorSetLayout(vk::UniqueDevice const& device, std::vector> const& bindingData, vk::DescriptorSetLayoutCreateFlags flags = {}); @@ -278,7 +278,7 @@ namespace vk vk::UniqueInstance createInstance(std::string const& appName, std::string const& engineName, std::vector const& layers = {}, std::vector const& extensions = {}, uint32_t apiVersion = VK_API_VERSION_1_0); vk::UniqueRenderPass createRenderPass(vk::UniqueDevice &device, vk::Format colorFormat, vk::Format depthFormat, vk::AttachmentLoadOp loadOp = vk::AttachmentLoadOp::eClear, vk::ImageLayout colorFinalLayout = vk::ImageLayout::ePresentSrcKHR); - VkBool32 debugReportCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData); + VkBool32 debugUtilsMessengerCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, VkDebugUtilsMessengerCallbackDataEXT const * pCallbackData, void * /*pUserData*/); uint32_t findGraphicsQueueFamilyIndex(std::vector const& queueFamilyProperties); std::pair findGraphicsAndPresentQueueFamilyIndex(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR const& surface); uint32_t findMemoryType(vk::PhysicalDeviceMemoryProperties const& memoryProperties, uint32_t typeBits, vk::MemoryPropertyFlags requirementsMask);