Skip to content

Commit c779945

Browse files
committed
Add delegate for Vulkan dump resources
Move code about writing data from vulkan_replay_dump_resources_draw_calls and vulkan_replay_dump_resources_compute_ray_tracing to vulkan_replay_dump_resources_delegate.
1 parent acc5f4d commit c779945

10 files changed

+2793
-2489
lines changed

framework/decode/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ target_sources(gfxrecon_decode
191191
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_draw_calls.cpp
192192
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_compute_ray_tracing.h
193193
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_compute_ray_tracing.cpp
194+
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_delegate.h
195+
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_delegate.cpp
194196
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_json.h
195197
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_json.cpp
196198
${CMAKE_CURRENT_LIST_DIR}/vulkan_resource_allocator.h

framework/decode/dx12_browse_consumer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct TrackRootParameter
6363
// The other parameter types have no resources or descriptors info, so no track.
6464
};
6565

66-
enum DumpDrawCallType
66+
enum class DumpDrawCallType
6767
{
6868
kUnknown,
6969
kDraw,

framework/decode/vulkan_replay_dump_resources.cpp

+20-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "decode/vulkan_object_info.h"
2424
#include "decode/vulkan_replay_dump_resources_compute_ray_tracing.h"
2525
#include "decode/vulkan_replay_options.h"
26-
#include "decode/vulkan_replay_dump_resources_json.h"
26+
#include "decode/vulkan_replay_dump_resources_delegate.h"
2727
#include "format/format.h"
2828
#include "generated/generated_vulkan_enum_to_string.h"
2929
#include "generated/generated_vulkan_struct_decoders.h"
@@ -48,7 +48,8 @@ VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayO
4848
CommonObjectInfoTable* object_info_table) :
4949
QueueSubmit_indices_(options.QueueSubmit_Indices),
5050
recording_(false), dump_resources_before_(options.dump_resources_before), object_info_table_(object_info_table),
51-
output_json_per_command(options.dump_resources_json_per_command), dump_json_(options)
51+
output_json_per_command(options.dump_resources_json_per_command), user_delegate_(nullptr),
52+
active_delegate_(nullptr), default_delegate_(nullptr)
5253
{
5354
capture_filename = std::filesystem::path(options.capture_filename).stem().string();
5455

@@ -57,9 +58,20 @@ VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayO
5758
return;
5859
}
5960

61+
if (user_delegate_ != nullptr)
62+
{
63+
active_delegate_ = user_delegate_;
64+
}
65+
else
66+
{
67+
// Use a default delegate if none was provided.
68+
default_delegate_ = std::make_unique<DefaultVulkanDumpResourcesDelegate>(options, capture_filename);
69+
active_delegate_ = default_delegate_.get();
70+
}
71+
6072
if (!options.dump_resources_json_per_command)
6173
{
62-
dump_json_.Open(options.capture_filename, options.dump_resources_output_dir);
74+
active_delegate_->Open();
6375
}
6476

6577
for (size_t i = 0; i < options.BeginCommandBuffer_Indices.size(); ++i)
@@ -75,8 +87,7 @@ VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayO
7587
options.RenderPass_Indices[i],
7688
*object_info_table,
7789
options,
78-
dump_json_,
79-
capture_filename));
90+
*active_delegate_));
8091
}
8192

8293
if ((i < options.Dispatch_Indices.size() && options.Dispatch_Indices[i].size()) ||
@@ -92,8 +103,7 @@ VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayO
92103
: std::vector<uint64_t>(),
93104
*object_info_table_,
94105
options,
95-
dump_json_,
96-
capture_filename));
106+
*active_delegate_));
97107
}
98108
}
99109
}
@@ -105,7 +115,7 @@ VulkanReplayDumpResourcesBase::~VulkanReplayDumpResourcesBase()
105115

106116
void VulkanReplayDumpResourcesBase::Release()
107117
{
108-
dump_json_.Close();
118+
active_delegate_->Close();
109119
draw_call_contexts.clear();
110120
dispatch_ray_contexts.clear();
111121
cmd_buf_begin_map_.clear();
@@ -1847,7 +1857,7 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(const std::vector<VkSubmitIn
18471857

18481858
if (!output_json_per_command)
18491859
{
1850-
dump_json_.BlockStart();
1860+
active_delegate_->DumpStart();
18511861
}
18521862

18531863
for (size_t s = 0; s < submit_infos.size(); s++)
@@ -1906,7 +1916,7 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(const std::vector<VkSubmitIn
19061916

19071917
if (!output_json_per_command)
19081918
{
1909-
dump_json_.BlockEnd();
1919+
active_delegate_->DumpEnd();
19101920
}
19111921

19121922
// Looks like we didn't submit anything. Do the submission as it would have been done

framework/decode/vulkan_replay_dump_resources.h

+11-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "decode/vulkan_replay_dump_resources_draw_calls.h"
3333
#include "decode/vulkan_replay_dump_resources_compute_ray_tracing.h"
3434
#include "generated/generated_vulkan_dispatch_table.h"
35-
#include "decode/vulkan_replay_dump_resources_json.h"
3635
#include "format/format.h"
3736
#include "util/defines.h"
3837
#include "vulkan/vulkan_core.h"
@@ -45,6 +44,9 @@
4544
GFXRECON_BEGIN_NAMESPACE(gfxrecon)
4645
GFXRECON_BEGIN_NAMESPACE(decode)
4746

47+
class VulkanDumpResourcesDelegate;
48+
class DefaultVulkanDumpResourcesDelegate;
49+
4850
class VulkanReplayDumpResourcesBase
4951
{
5052
public:
@@ -348,11 +350,14 @@ class VulkanReplayDumpResourcesBase
348350
std::unordered_map<uint64_t, DrawCallsDumpingContext> draw_call_contexts;
349351
std::unordered_map<uint64_t, DispatchTraceRaysDumpingContext> dispatch_ray_contexts;
350352

351-
bool recording_;
352-
bool dump_resources_before_;
353-
CommonObjectInfoTable* object_info_table_;
354-
VulkanReplayDumpResourcesJson dump_json_;
355-
bool output_json_per_command;
353+
bool recording_;
354+
bool dump_resources_before_;
355+
CommonObjectInfoTable* object_info_table_;
356+
bool output_json_per_command;
357+
358+
std::unique_ptr<DefaultVulkanDumpResourcesDelegate> default_delegate_;
359+
VulkanDumpResourcesDelegate* user_delegate_;
360+
VulkanDumpResourcesDelegate* active_delegate_;
356361

357362
std::string capture_filename;
358363

0 commit comments

Comments
 (0)