vk: Set up easy debug printing for captured traces

This commit is contained in:
kd-11
2026-08-28 14:55:44 +03:00
committed by kd-11
parent 85bc1d7074
commit 42cfad20eb
5 changed files with 58 additions and 0 deletions
+1
View File
@@ -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
+25
View File
@@ -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<color4f, 3> 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<int>(level)).rgba, sizeof(float) * 4);
_vkCmdInsertDebugUtilsLabelEXT(cmd, &label_info);
}
}
+24
View File
@@ -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 <typename CharT, usz N, typename... Args>
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;
+2
View File
@@ -44,6 +44,7 @@
<ClInclude Include="Emu\RSX\VK\vkutils\chip_class.h" />
<ClInclude Include="Emu\RSX\VK\vkutils\commands.h" />
<ClInclude Include="Emu\RSX\VK\vkutils\data_heap.h" />
<ClInclude Include="Emu\RSX\VK\vkutils\debug_print.h" />
<ClInclude Include="Emu\RSX\VK\vkutils\descriptors.h" />
<ClInclude Include="Emu\RSX\VK\vkutils\barriers.h" />
<ClInclude Include="Emu\RSX\VK\vkutils\ex.h" />
@@ -102,6 +103,7 @@
<ClCompile Include="Emu\RSX\VK\vkutils\chip_class.cpp" />
<ClCompile Include="Emu\RSX\VK\vkutils\commands.cpp" />
<ClCompile Include="Emu\RSX\VK\vkutils\data_heap.cpp" />
<ClCompile Include="Emu\RSX\VK\vkutils\debug_print.cpp" />
<ClCompile Include="Emu\RSX\VK\vkutils\ex.cpp" />
<ClCompile Include="Emu\RSX\VK\vkutils\image.cpp" />
<ClCompile Include="Emu\RSX\VK\vkutils\image_helpers.cpp" />
+6
View File
@@ -87,6 +87,9 @@
<ClCompile Include="Emu\RSX\VK\vkutils\unique_resource.cpp">
<Filter>vkutils</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\VK\vkutils\debug_print.cpp">
<Filter>vkutils</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Emu\RSX\VK\VKCommonDecompiler.h" />
@@ -212,6 +215,9 @@
<ClInclude Include="Emu\RSX\VK\vkutils\unique_resource.h">
<Filter>vkutils</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\VK\vkutils\debug_print.h">
<Filter>vkutils</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="vkutils">