diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-12-25 06:01:13 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-12-31 06:07:33 +0100 |
commit | 47843b4f097ced5e99c5567b8ac3fd53b80fab0a (patch) | |
tree | 190309df63e67b03d651da034c07b0e4a994cc5f /src/video_core/vulkan_common/vulkan_debug_callback.cpp | |
parent | renderer_vulkan: Move instance initialization to a separate file (diff) | |
download | yuzu-47843b4f097ced5e99c5567b8ac3fd53b80fab0a.tar yuzu-47843b4f097ced5e99c5567b8ac3fd53b80fab0a.tar.gz yuzu-47843b4f097ced5e99c5567b8ac3fd53b80fab0a.tar.bz2 yuzu-47843b4f097ced5e99c5567b8ac3fd53b80fab0a.tar.lz yuzu-47843b4f097ced5e99c5567b8ac3fd53b80fab0a.tar.xz yuzu-47843b4f097ced5e99c5567b8ac3fd53b80fab0a.tar.zst yuzu-47843b4f097ced5e99c5567b8ac3fd53b80fab0a.zip |
Diffstat (limited to 'src/video_core/vulkan_common/vulkan_debug_callback.cpp')
-rw-r--r-- | src/video_core/vulkan_common/vulkan_debug_callback.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/video_core/vulkan_common/vulkan_debug_callback.cpp b/src/video_core/vulkan_common/vulkan_debug_callback.cpp new file mode 100644 index 000000000..ea7af8ad4 --- /dev/null +++ b/src/video_core/vulkan_common/vulkan_debug_callback.cpp @@ -0,0 +1,45 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <string_view> +#include "common/logging/log.h" +#include "video_core/vulkan_common/vulkan_debug_callback.h" + +namespace Vulkan { +namespace { +VkBool32 Callback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, + VkDebugUtilsMessageTypeFlagsEXT type, + const VkDebugUtilsMessengerCallbackDataEXT* data, + [[maybe_unused]] void* user_data) { + const std::string_view message{data->pMessage}; + if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) { + LOG_CRITICAL(Render_Vulkan, "{}", message); + } else if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) { + LOG_WARNING(Render_Vulkan, "{}", message); + } else if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) { + LOG_INFO(Render_Vulkan, "{}", message); + } else if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) { + LOG_DEBUG(Render_Vulkan, "{}", message); + } + return VK_FALSE; +} +} // Anonymous namespace + +vk::DebugUtilsMessenger CreateDebugCallback(const vk::Instance& instance) { + return instance.CreateDebugUtilsMessenger(VkDebugUtilsMessengerCreateInfoEXT{ + .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, + .pNext = nullptr, + .flags = 0, + .messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | + VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | + VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | + VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, + .messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | + VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | + VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, + .pfnUserCallback = Callback, + }); +} + +} // namespace Vulkan |