diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index 42e363665d..bcf6130fcf 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -626,6 +626,7 @@ if(TARGET 3rdparty_vulkan) RSX/VK/vkutils/commands.cpp RSX/VK/vkutils/ex.cpp RSX/VK/vkutils/data_heap.cpp + RSX/VK/vkutils/debug_print.cpp RSX/VK/vkutils/descriptors.cpp RSX/VK/vkutils/image.cpp RSX/VK/vkutils/image_helpers.cpp diff --git a/rpcs3/Emu/RSX/VK/vkutils/debug_print.cpp b/rpcs3/Emu/RSX/VK/vkutils/debug_print.cpp new file mode 100644 index 0000000000..34ac9d8413 --- /dev/null +++ b/rpcs3/Emu/RSX/VK/vkutils/debug_print.cpp @@ -0,0 +1,25 @@ +#include "debug_print.h" +#include "device.h" + +namespace vk +{ + void push_debug_label_ex(VkCommandBuffer cmd, DebugPrintLevel level, const std::string& message) + { + static const std::array s_message_colors = + { + color4f{ 0.5f, 0.5f, 1.f, 1.f }, // INFO + color4f{ 1.f, 1.f, 0.5f, 1.f }, // WARN + color4f{ 1.f, 0.5f, 0.5f, 1.f }, // ERROR + }; + + if (message.empty() || !g_render_device->get_debug_utils_support()) + { + return; + } + + VkDebugUtilsLabelEXT label_info{ VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT }; + label_info.pLabelName = message.c_str(); + memcpy(label_info.color, s_message_colors.at(static_cast(level)).rgba, sizeof(float) * 4); + _vkCmdInsertDebugUtilsLabelEXT(cmd, &label_info); + } +} diff --git a/rpcs3/Emu/RSX/VK/vkutils/debug_print.h b/rpcs3/Emu/RSX/VK/vkutils/debug_print.h new file mode 100644 index 0000000000..c84396c0f6 --- /dev/null +++ b/rpcs3/Emu/RSX/VK/vkutils/debug_print.h @@ -0,0 +1,24 @@ +#pragma once +#include "../VulkanAPI.h" +#include "Utilities/StrFmt.h" + +namespace vk +{ + enum DebugPrintLevel + { + DBG_LEVEL_INFO = 0, + DBG_LEVEL_WARN, + DBG_LEVEL_ERROR + }; + + void push_debug_label_ex(VkCommandBuffer cmd, DebugPrintLevel level, const std::string& message); + + // Push a debug label into the command stream. The debug labels can only be viewed from tracing tools like Renderdoc. + template + void push_debug_label(VkCommandBuffer cmd, DebugPrintLevel level, const CharT(&fmt)[N], const Args&... args) + { + push_debug_label_ex(cmd, level, fmt::format(fmt, args...)); + } +} + +using enum vk::DebugPrintLevel; diff --git a/rpcs3/VKGSRender.vcxproj b/rpcs3/VKGSRender.vcxproj index 2b02e062fb..31fdad901c 100644 --- a/rpcs3/VKGSRender.vcxproj +++ b/rpcs3/VKGSRender.vcxproj @@ -44,6 +44,7 @@ + @@ -102,6 +103,7 @@ + diff --git a/rpcs3/VKGSRender.vcxproj.filters b/rpcs3/VKGSRender.vcxproj.filters index de87d27733..f66dd39483 100644 --- a/rpcs3/VKGSRender.vcxproj.filters +++ b/rpcs3/VKGSRender.vcxproj.filters @@ -87,6 +87,9 @@ vkutils + + vkutils + @@ -212,6 +215,9 @@ vkutils + + vkutils +