mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Use VK_EXT_debug_utils instead of deprecated VK_EXT_debug_report. (#389)
This commit is contained in:
parent
48d540a23d
commit
9df0fac638
@ -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 */
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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 <iostream>
|
||||
#include <sstream>
|
||||
|
||||
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<vk::ExtensionProperties> 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<PFN_vkCreateDebugReportCallbackEXT>(instance->getProcAddr("vkCreateDebugReportCallbackEXT"));
|
||||
if (!pfnVkCreateDebugReportCallbackEXT)
|
||||
{
|
||||
std::cout << "GetInstanceProcAddr: Unable to find vkCreateDebugReportCallbackEXT function." << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pfnVkDestroyDebugReportCallbackEXT = reinterpret_cast<PFN_vkDestroyDebugReportCallbackEXT>(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;
|
||||
}
|
@ -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}")
|
144
samples/CreateDebugUtilsMessenger/CreateDebugUtilsMessenger.cpp
Normal file
144
samples/CreateDebugUtilsMessenger/CreateDebugUtilsMessenger.cpp
Normal file
@ -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 <iostream>
|
||||
#include <sstream>
|
||||
|
||||
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<vk::DebugUtilsMessageSeverityFlagBitsEXT>(messageSeverity)) << ": " << vk::to_string(static_cast<vk::DebugUtilsMessageTypeFlagsEXT>(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<vk::ObjectType>(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<vk::ExtensionProperties> 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<PFN_vkCreateDebugUtilsMessengerEXT>(instance->getProcAddr("vkCreateDebugUtilsMessengerEXT"));
|
||||
if (!pfnVkCreateDebugUtilsMessengerEXT)
|
||||
{
|
||||
std::cout << "GetInstanceProcAddr: Unable to find pfnVkCreateDebugUtilsMessengerEXT function." << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pfnVkDestroyDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkDestroyDebugUtilsMessengerEXT>(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;
|
||||
}
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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<vk::DebugUtilsMessageSeverityFlagBitsEXT>(messageSeverity)) << ": " << vk::to_string(static_cast<vk::DebugUtilsMessageTypeFlagsEXT>(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<vk::ObjectType>(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<char const*> 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<uint32_t>(instanceLayerNames.size()), instanceLayerNames.data(),
|
||||
vk::su::checked_cast<uint32_t>(instanceExtensionNames.size()) , instanceExtensionNames.data() );
|
||||
vk::UniqueInstance instance = vk::createInstanceUnique(instanceCreateInfo);
|
||||
|
||||
pfnVkCreateDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkCreateDebugUtilsMessengerEXT>(instance->getProcAddr("vkCreateDebugUtilsMessengerEXT"));
|
||||
if (!pfnVkCreateDebugUtilsMessengerEXT)
|
||||
{
|
||||
std::cout << "GetInstanceProcAddr: Unable to find pfnVkCreateDebugUtilsMessengerEXT function." << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pfnVkDestroyDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkDestroyDebugUtilsMessengerEXT>(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<vk::QueueFamilyProperties> 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<PFN_vkCreateDebugReportCallbackEXT>(instance->getProcAddr("vkCreateDebugReportCallbackEXT"));
|
||||
if (!pfnVkCreateDebugReportCallbackEXT)
|
||||
{
|
||||
std::cout << "GetInstanceProcAddr: Unable to find vkCreateDebugReportCallbackEXT function." << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
pfnVkDestroyDebugReportCallbackEXT = reinterpret_cast<PFN_vkDestroyDebugReportCallbackEXT>(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));
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -18,17 +18,17 @@
|
||||
#include <iomanip>
|
||||
#include <numeric>
|
||||
|
||||
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<vk::DescriptorPoolSize> 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<PFN_vkCreateDebugReportCallbackEXT>(instance->getProcAddr("vkCreateDebugReportCallbackEXT"));
|
||||
pfnVkDestroyDebugReportCallbackEXT = reinterpret_cast<PFN_vkDestroyDebugReportCallbackEXT>(instance->getProcAddr("vkDestroyDebugReportCallbackEXT"));
|
||||
assert(pfnVkCreateDebugReportCallbackEXT && pfnVkDestroyDebugReportCallbackEXT);
|
||||
pfnVkCreateDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkCreateDebugUtilsMessengerEXT>(instance->getProcAddr("vkCreateDebugUtilsMessengerEXT"));
|
||||
pfnVkDestroyDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkDestroyDebugUtilsMessengerEXT>(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<vk::DebugUtilsMessageSeverityFlagBitsEXT>(messageSeverity)) << ": " << vk::to_string(static_cast<vk::DebugUtilsMessageTypeFlagsEXT>(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<vk::ObjectType>(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;
|
||||
}
|
||||
|
||||
|
@ -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<vk::DescriptorPoolSize> const& poolSizes);
|
||||
vk::UniqueDescriptorSetLayout createDescriptorSetLayout(vk::UniqueDevice const& device, std::vector<std::tuple<vk::DescriptorType, uint32_t, vk::ShaderStageFlags>> const& bindingData,
|
||||
vk::DescriptorSetLayoutCreateFlags flags = {});
|
||||
@ -278,7 +278,7 @@ namespace vk
|
||||
vk::UniqueInstance createInstance(std::string const& appName, std::string const& engineName, std::vector<std::string> const& layers = {}, std::vector<std::string> 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<vk::QueueFamilyProperties> const& queueFamilyProperties);
|
||||
std::pair<uint32_t, uint32_t> findGraphicsAndPresentQueueFamilyIndex(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR const& surface);
|
||||
uint32_t findMemoryType(vk::PhysicalDeviceMemoryProperties const& memoryProperties, uint32_t typeBits, vk::MemoryPropertyFlags requirementsMask);
|
||||
|
Loading…
Reference in New Issue
Block a user