23
23
#include " decode/vulkan_object_info.h"
24
24
#include " decode/vulkan_replay_dump_resources_compute_ray_tracing.h"
25
25
#include " decode/vulkan_replay_options.h"
26
- #include " decode/vulkan_replay_dump_resources_json .h"
26
+ #include " decode/vulkan_replay_dump_resources_delegate .h"
27
27
#include " format/format.h"
28
28
#include " generated/generated_vulkan_enum_to_string.h"
29
29
#include " generated/generated_vulkan_struct_decoders.h"
@@ -46,9 +46,10 @@ GFXRECON_BEGIN_NAMESPACE(decode)
46
46
47
47
VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayOptions& options,
48
48
CommonObjectInfoTable* object_info_table) :
49
- QueueSubmit_indices_(options.QueueSubmit_Indices),
50
- 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)
49
+ QueueSubmit_indices_(options.QueueSubmit_Indices), recording_(false ),
50
+ dump_resources_before_(options.dump_resources_before), object_info_table_(object_info_table),
51
+ output_json_per_command(options.dump_resources_json_per_command), user_delegate_(nullptr ),
52
+ active_delegate_(nullptr ), default_delegate_(nullptr )
52
53
{
53
54
capture_filename = std::filesystem::path (options.capture_filename ).stem ().string ();
54
55
@@ -57,9 +58,20 @@ VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayO
57
58
return ;
58
59
}
59
60
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
+
60
72
if (!options.dump_resources_json_per_command )
61
73
{
62
- dump_json_. Open (options. capture_filename , options. dump_resources_output_dir );
74
+ active_delegate_-> Open ();
63
75
}
64
76
65
77
for (size_t i = 0 ; i < options.BeginCommandBuffer_Indices .size (); ++i)
@@ -75,8 +87,7 @@ VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayO
75
87
options.RenderPass_Indices [i],
76
88
*object_info_table,
77
89
options,
78
- dump_json_,
79
- capture_filename));
90
+ *active_delegate_));
80
91
}
81
92
82
93
if ((i < options.Dispatch_Indices .size () && options.Dispatch_Indices [i].size ()) ||
@@ -92,8 +103,7 @@ VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayO
92
103
: std::vector<uint64_t >(),
93
104
*object_info_table_,
94
105
options,
95
- dump_json_,
96
- capture_filename));
106
+ *active_delegate_));
97
107
}
98
108
}
99
109
}
@@ -105,7 +115,13 @@ VulkanReplayDumpResourcesBase::~VulkanReplayDumpResourcesBase()
105
115
106
116
void VulkanReplayDumpResourcesBase::Release ()
107
117
{
108
- dump_json_.Close ();
118
+ // active_delegate_ could be nullptr because constructor could return before creating delegate.
119
+ if (active_delegate_)
120
+ {
121
+ active_delegate_->Close ();
122
+ active_delegate_ = nullptr ;
123
+ default_delegate_ = nullptr ;
124
+ }
109
125
draw_call_contexts.clear ();
110
126
dispatch_ray_contexts.clear ();
111
127
cmd_buf_begin_map_.clear ();
@@ -1847,7 +1863,7 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(const std::vector<VkSubmitIn
1847
1863
1848
1864
if (!output_json_per_command)
1849
1865
{
1850
- dump_json_. BlockStart ();
1866
+ active_delegate_-> DumpStart ();
1851
1867
}
1852
1868
1853
1869
for (size_t s = 0 ; s < submit_infos.size (); s++)
@@ -1910,7 +1926,7 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(const std::vector<VkSubmitIn
1910
1926
1911
1927
if (!output_json_per_command)
1912
1928
{
1913
- dump_json_. BlockEnd ();
1929
+ active_delegate_-> DumpEnd ();
1914
1930
}
1915
1931
1916
1932
// Looks like we didn't submit anything. Do the submission as it would have been done
0 commit comments