Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delegate for Vulkan dump resources #1941

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions android/framework/decode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ target_sources(gfxrecon_decode
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_draw_calls.cpp
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_compute_ray_tracing.h
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_compute_ray_tracing.cpp
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_delegate.h
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_delegate.cpp
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_json.h
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_replay_dump_resources_json.cpp
${GFXRECON_SOURCE_DIR}/framework/decode/vulkan_resource_allocator.h
Expand Down
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
36 changes: 26 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,13 @@ VulkanReplayDumpResourcesBase::~VulkanReplayDumpResourcesBase()

void VulkanReplayDumpResourcesBase::Release()
{
dump_json_.Close();
// active_delegate_ could be nullptr because constructor could return before creating delegate.
if (active_delegate_)
{
active_delegate_->Close();
active_delegate_ = nullptr;
default_delegate_ = nullptr;
}
draw_call_contexts.clear();
dispatch_ray_contexts.clear();
cmd_buf_begin_map_.clear();
Expand Down Expand Up @@ -1847,7 +1863,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 +1922,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
14 changes: 8 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 Down Expand Up @@ -348,11 +347,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
25 changes: 25 additions & 0 deletions framework/decode/vulkan_replay_dump_resources_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,31 @@ VkResult CreateVkBuffer(VkDeviceSize size,

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

class VulkanDumpResourcesDelegate;
class DefaultVulkanDumpResourcesDelegate;

enum class DumpResourceType : uint32_t
{
kUnknown,
kRtv,
kDsv,
kVertex,
kIndex,
kImageDescriptor,
kBufferDescriptor,
kInlineUniformBufferDescriptor,
kDrawCallInfo,
kDispatchInfo,
kTraceRaysIndex,
kDispatchTraceRaysImage,
kDispatchTraceRaysBuffer,
kDispatchTraceRaysImageDescriptor,
kDispatchTraceRaysBufferDescriptor,
kDispatchTraceRaysInlineUniformBufferDescriptor,
};

#define DEPTH_ATTACHMENT ~0

GFXRECON_END_NAMESPACE(gfxrecon)
GFXRECON_END_NAMESPACE(decode)

Expand Down
Loading
Loading