Skip to content

Commit 3dbff02

Browse files
Add delegate for Vulkan dump resources (#1941)
* 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. * Fix cmd buf index confusion * Each output json gen func keeps its own index * Incorporate json indexing fix from dev --------- Co-authored-by: Panagiotis Apostolou <[email protected]>
1 parent 21c7b71 commit 3dbff02

12 files changed

+2796
-2513
lines changed

android/framework/decode/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ target_sources(gfxrecon_decode
9393
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_draw_calls.cpp
9494
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_compute_ray_tracing.h
9595
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_compute_ray_tracing.cpp
96+
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_delegate.h
97+
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_delegate.cpp
9698
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_json.h
9799
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_json.cpp
98100
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_resource_allocator.h

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

+28-12
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"
@@ -46,9 +46,10 @@ GFXRECON_BEGIN_NAMESPACE(decode)
4646

4747
VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayOptions& options,
4848
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)
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,13 @@ VulkanReplayDumpResourcesBase::~VulkanReplayDumpResourcesBase()
105115

106116
void VulkanReplayDumpResourcesBase::Release()
107117
{
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+
}
109125
draw_call_contexts.clear();
110126
dispatch_ray_contexts.clear();
111127
cmd_buf_begin_map_.clear();
@@ -1847,7 +1863,7 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(const std::vector<VkSubmitIn
18471863

18481864
if (!output_json_per_command)
18491865
{
1850-
dump_json_.BlockStart();
1866+
active_delegate_->DumpStart();
18511867
}
18521868

18531869
for (size_t s = 0; s < submit_infos.size(); s++)
@@ -1910,7 +1926,7 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(const std::vector<VkSubmitIn
19101926

19111927
if (!output_json_per_command)
19121928
{
1913-
dump_json_.BlockEnd();
1929+
active_delegate_->DumpEnd();
19141930
}
19151931

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

framework/decode/vulkan_replay_dump_resources.h

+8-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"
@@ -348,11 +347,14 @@ class VulkanReplayDumpResourcesBase
348347
std::unordered_map<uint64_t, DrawCallsDumpingContext> draw_call_contexts;
349348
std::unordered_map<uint64_t, DispatchTraceRaysDumpingContext> dispatch_ray_contexts;
350349

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

357359
std::string capture_filename;
358360

framework/decode/vulkan_replay_dump_resources_common.h

+25
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,31 @@ VkResult CreateVkBuffer(VkDeviceSize size,
138138

139139
void GetFormatAspects(VkFormat format, std::vector<VkImageAspectFlagBits>& aspects);
140140

141+
class VulkanDumpResourcesDelegate;
142+
class DefaultVulkanDumpResourcesDelegate;
143+
144+
enum class DumpResourceType : uint32_t
145+
{
146+
kUnknown,
147+
kRtv,
148+
kDsv,
149+
kVertex,
150+
kIndex,
151+
kImageDescriptor,
152+
kBufferDescriptor,
153+
kInlineUniformBufferDescriptor,
154+
kDrawCallInfo,
155+
kDispatchInfo,
156+
kTraceRaysIndex,
157+
kDispatchTraceRaysImage,
158+
kDispatchTraceRaysBuffer,
159+
kDispatchTraceRaysImageDescriptor,
160+
kDispatchTraceRaysBufferDescriptor,
161+
kDispatchTraceRaysInlineUniformBufferDescriptor,
162+
};
163+
164+
#define DEPTH_ATTACHMENT ~0
165+
141166
GFXRECON_END_NAMESPACE(gfxrecon)
142167
GFXRECON_END_NAMESPACE(decode)
143168

0 commit comments

Comments
 (0)