Skip to content

Commit 42cfad2

Browse files
committed
vk: Set up easy debug printing for captured traces
1 parent 85bc1d7 commit 42cfad2

5 files changed

Lines changed: 58 additions & 0 deletions

File tree

rpcs3/Emu/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ if(TARGET 3rdparty_vulkan)
626626
RSX/VK/vkutils/commands.cpp
627627
RSX/VK/vkutils/ex.cpp
628628
RSX/VK/vkutils/data_heap.cpp
629+
RSX/VK/vkutils/debug_print.cpp
629630
RSX/VK/vkutils/descriptors.cpp
630631
RSX/VK/vkutils/image.cpp
631632
RSX/VK/vkutils/image_helpers.cpp
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "debug_print.h"
2+
#include "device.h"
3+
4+
namespace vk
5+
{
6+
void push_debug_label_ex(VkCommandBuffer cmd, DebugPrintLevel level, const std::string& message)
7+
{
8+
static const std::array<color4f, 3> s_message_colors =
9+
{
10+
color4f{ 0.5f, 0.5f, 1.f, 1.f }, // INFO
11+
color4f{ 1.f, 1.f, 0.5f, 1.f }, // WARN
12+
color4f{ 1.f, 0.5f, 0.5f, 1.f }, // ERROR
13+
};
14+
15+
if (message.empty() || !g_render_device->get_debug_utils_support())
16+
{
17+
return;
18+
}
19+
20+
VkDebugUtilsLabelEXT label_info{ VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT };
21+
label_info.pLabelName = message.c_str();
22+
memcpy(label_info.color, s_message_colors.at(static_cast<int>(level)).rgba, sizeof(float) * 4);
23+
_vkCmdInsertDebugUtilsLabelEXT(cmd, &label_info);
24+
}
25+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
#include "../VulkanAPI.h"
3+
#include "Utilities/StrFmt.h"
4+
5+
namespace vk
6+
{
7+
enum DebugPrintLevel
8+
{
9+
DBG_LEVEL_INFO = 0,
10+
DBG_LEVEL_WARN,
11+
DBG_LEVEL_ERROR
12+
};
13+
14+
void push_debug_label_ex(VkCommandBuffer cmd, DebugPrintLevel level, const std::string& message);
15+
16+
// Push a debug label into the command stream. The debug labels can only be viewed from tracing tools like Renderdoc.
17+
template <typename CharT, usz N, typename... Args>
18+
void push_debug_label(VkCommandBuffer cmd, DebugPrintLevel level, const CharT(&fmt)[N], const Args&... args)
19+
{
20+
push_debug_label_ex(cmd, level, fmt::format(fmt, args...));
21+
}
22+
}
23+
24+
using enum vk::DebugPrintLevel;

rpcs3/VKGSRender.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<ClInclude Include="Emu\RSX\VK\vkutils\chip_class.h" />
4545
<ClInclude Include="Emu\RSX\VK\vkutils\commands.h" />
4646
<ClInclude Include="Emu\RSX\VK\vkutils\data_heap.h" />
47+
<ClInclude Include="Emu\RSX\VK\vkutils\debug_print.h" />
4748
<ClInclude Include="Emu\RSX\VK\vkutils\descriptors.h" />
4849
<ClInclude Include="Emu\RSX\VK\vkutils\barriers.h" />
4950
<ClInclude Include="Emu\RSX\VK\vkutils\ex.h" />
@@ -102,6 +103,7 @@
102103
<ClCompile Include="Emu\RSX\VK\vkutils\chip_class.cpp" />
103104
<ClCompile Include="Emu\RSX\VK\vkutils\commands.cpp" />
104105
<ClCompile Include="Emu\RSX\VK\vkutils\data_heap.cpp" />
106+
<ClCompile Include="Emu\RSX\VK\vkutils\debug_print.cpp" />
105107
<ClCompile Include="Emu\RSX\VK\vkutils\ex.cpp" />
106108
<ClCompile Include="Emu\RSX\VK\vkutils\image.cpp" />
107109
<ClCompile Include="Emu\RSX\VK\vkutils\image_helpers.cpp" />

rpcs3/VKGSRender.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
<ClCompile Include="Emu\RSX\VK\vkutils\unique_resource.cpp">
8888
<Filter>vkutils</Filter>
8989
</ClCompile>
90+
<ClCompile Include="Emu\RSX\VK\vkutils\debug_print.cpp">
91+
<Filter>vkutils</Filter>
92+
</ClCompile>
9093
</ItemGroup>
9194
<ItemGroup>
9295
<ClInclude Include="Emu\RSX\VK\VKCommonDecompiler.h" />
@@ -212,6 +215,9 @@
212215
<ClInclude Include="Emu\RSX\VK\vkutils\unique_resource.h">
213216
<Filter>vkutils</Filter>
214217
</ClInclude>
218+
<ClInclude Include="Emu\RSX\VK\vkutils\debug_print.h">
219+
<Filter>vkutils</Filter>
220+
</ClInclude>
215221
</ItemGroup>
216222
<ItemGroup>
217223
<Filter Include="vkutils">

0 commit comments

Comments
 (0)