Skip to content

Commit

Permalink
Add delegate for Vulkan dump resources
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
locke-lunarg committed Jan 7, 2025
1 parent acc5f4d commit 1a66e5d
Show file tree
Hide file tree
Showing 10 changed files with 2,799 additions and 2,496 deletions.
2 changes: 2 additions & 0 deletions framework/decode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ target_sources(gfxrecon_decode
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_draw_calls.cpp
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_compute_ray_tracing.h
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_compute_ray_tracing.cpp
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_delegate.h
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_delegate.cpp
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_json.h
${CMAKE_CURRENT_LIST_DIR}/vulkan_replay_dump_resources_json.cpp
${CMAKE_CURRENT_LIST_DIR}/vulkan_resource_allocator.h
Expand Down
2 changes: 1 addition & 1 deletion framework/decode/dx12_browse_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct TrackRootParameter
// The other parameter types have no resources or descriptors info, so no track.
};

enum DumpDrawCallType
enum class DumpDrawCallType
{
kUnknown,
kDraw,
Expand Down
30 changes: 20 additions & 10 deletions framework/decode/vulkan_replay_dump_resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "decode/vulkan_object_info.h"
#include "decode/vulkan_replay_dump_resources_compute_ray_tracing.h"
#include "decode/vulkan_replay_options.h"
#include "decode/vulkan_replay_dump_resources_json.h"
#include "decode/vulkan_replay_dump_resources_delegate.h"
#include "format/format.h"
#include "generated/generated_vulkan_enum_to_string.h"
#include "generated/generated_vulkan_struct_decoders.h"
Expand All @@ -48,7 +48,8 @@ VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayO
CommonObjectInfoTable* object_info_table) :
QueueSubmit_indices_(options.QueueSubmit_Indices),
recording_(false), dump_resources_before_(options.dump_resources_before), object_info_table_(object_info_table),
output_json_per_command(options.dump_resources_json_per_command), dump_json_(options)
output_json_per_command(options.dump_resources_json_per_command), user_delegate_(nullptr),
active_delegate_(nullptr), default_delegate_(nullptr)
{
capture_filename = std::filesystem::path(options.capture_filename).stem().string();

Expand All @@ -57,9 +58,20 @@ VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayO
return;
}

if (user_delegate_ != nullptr)
{
active_delegate_ = user_delegate_;
}
else
{
// Use a default delegate if none was provided.
default_delegate_ = std::make_unique<DefaultVulkanDumpResourcesDelegate>(options, capture_filename);
active_delegate_ = default_delegate_.get();
}

if (!options.dump_resources_json_per_command)
{
dump_json_.Open(options.capture_filename, options.dump_resources_output_dir);
active_delegate_->Open();
}

for (size_t i = 0; i < options.BeginCommandBuffer_Indices.size(); ++i)
Expand All @@ -75,8 +87,7 @@ VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayO
options.RenderPass_Indices[i],
*object_info_table,
options,
dump_json_,
capture_filename));
*active_delegate_));
}

if ((i < options.Dispatch_Indices.size() && options.Dispatch_Indices[i].size()) ||
Expand All @@ -92,8 +103,7 @@ VulkanReplayDumpResourcesBase::VulkanReplayDumpResourcesBase(const VulkanReplayO
: std::vector<uint64_t>(),
*object_info_table_,
options,
dump_json_,
capture_filename));
*active_delegate_));
}
}
}
Expand All @@ -105,7 +115,7 @@ VulkanReplayDumpResourcesBase::~VulkanReplayDumpResourcesBase()

void VulkanReplayDumpResourcesBase::Release()
{
dump_json_.Close();
active_delegate_->Close();
draw_call_contexts.clear();
dispatch_ray_contexts.clear();
cmd_buf_begin_map_.clear();
Expand Down Expand Up @@ -1847,7 +1857,7 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(const std::vector<VkSubmitIn

if (!output_json_per_command)
{
dump_json_.BlockStart();
active_delegate_->DumpStart();
}

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

if (!output_json_per_command)
{
dump_json_.BlockEnd();
active_delegate_->DumpEnd();
}

// Looks like we didn't submit anything. Do the submission as it would have been done
Expand Down
17 changes: 11 additions & 6 deletions framework/decode/vulkan_replay_dump_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "decode/vulkan_replay_dump_resources_draw_calls.h"
#include "decode/vulkan_replay_dump_resources_compute_ray_tracing.h"
#include "generated/generated_vulkan_dispatch_table.h"
#include "decode/vulkan_replay_dump_resources_json.h"
#include "format/format.h"
#include "util/defines.h"
#include "vulkan/vulkan_core.h"
Expand All @@ -45,6 +44,9 @@
GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(decode)

class VulkanDumpResourcesDelegate;
class DefaultVulkanDumpResourcesDelegate;

class VulkanReplayDumpResourcesBase
{
public:
Expand Down Expand Up @@ -348,11 +350,14 @@ class VulkanReplayDumpResourcesBase
std::unordered_map<uint64_t, DrawCallsDumpingContext> draw_call_contexts;
std::unordered_map<uint64_t, DispatchTraceRaysDumpingContext> dispatch_ray_contexts;

bool recording_;
bool dump_resources_before_;
CommonObjectInfoTable* object_info_table_;
VulkanReplayDumpResourcesJson dump_json_;
bool output_json_per_command;
bool recording_;
bool dump_resources_before_;
CommonObjectInfoTable* object_info_table_;
bool output_json_per_command;

std::unique_ptr<DefaultVulkanDumpResourcesDelegate> default_delegate_;
VulkanDumpResourcesDelegate* user_delegate_;
VulkanDumpResourcesDelegate* active_delegate_;

std::string capture_filename;

Expand Down
Loading

0 comments on commit 1a66e5d

Please sign in to comment.