From c927210245fed6712ecbf2d98db0123952ea09fd Mon Sep 17 00:00:00 2001 From: Panagiotis Apostolou Date: Wed, 11 Dec 2024 09:46:40 +0200 Subject: [PATCH] Vulkan dump resources: Multiple cbs from same qs --- .../decode/vulkan_replay_dump_resources.cpp | 32 ++++++++----------- .../decode/vulkan_replay_dump_resources.h | 2 +- ...ulkan_replay_dump_resources_draw_calls.cpp | 5 ++- framework/decode/vulkan_replay_options.h | 2 +- tools/replay/parse_dump_resources_cli.cpp | 23 ++----------- 5 files changed, 22 insertions(+), 42 deletions(-) diff --git a/framework/decode/vulkan_replay_dump_resources.cpp b/framework/decode/vulkan_replay_dump_resources.cpp index 2d46bb7544..c489d7bc27 100644 --- a/framework/decode/vulkan_replay_dump_resources.cpp +++ b/framework/decode/vulkan_replay_dump_resources.cpp @@ -1922,9 +1922,17 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(const std::vectorIsRecording()) - { - return true; - } - - const DispatchTraceRaysDumpingContext* dr_context = FindDispatchRaysCommandBufferContext(original_command_buffer); - if (dr_context != nullptr && dr_context->IsRecording()) - { - return true; - } + recording_ = !QueueSubmit_indices_.empty(); - recording_ = false; - return false; + return recording_; } bool VulkanReplayDumpResourcesBase::MustDumpQueueSubmitIndex(uint64_t index) const { - // Indices should be sorted - return QueueSubmit_indices_.find(index) != QueueSubmit_indices_.end(); + return std::find(QueueSubmit_indices_.begin(), QueueSubmit_indices_.end(), index) != QueueSubmit_indices_.end(); } bool VulkanReplayDumpResourcesBase::IsRecording(VkCommandBuffer original_command_buffer) const diff --git a/framework/decode/vulkan_replay_dump_resources.h b/framework/decode/vulkan_replay_dump_resources.h index 546cdf8979..897d4a1b42 100644 --- a/framework/decode/vulkan_replay_dump_resources.h +++ b/framework/decode/vulkan_replay_dump_resources.h @@ -342,7 +342,7 @@ class VulkanReplayDumpResourcesBase // Mapping between the original VkCommandBuffer handle and BeginCommandBuffer index std::unordered_map cmd_buf_begin_map_; - std::unordered_set QueueSubmit_indices_; + std::vector QueueSubmit_indices_; // One per BeginCommandBuffer index std::unordered_map draw_call_contexts; diff --git a/framework/decode/vulkan_replay_dump_resources_draw_calls.cpp b/framework/decode/vulkan_replay_dump_resources_draw_calls.cpp index 579b5dc3d5..df4bdad2e1 100644 --- a/framework/decode/vulkan_replay_dump_resources_draw_calls.cpp +++ b/framework/decode/vulkan_replay_dump_resources_draw_calls.cpp @@ -1001,7 +1001,10 @@ void DrawCallsDumpingContext::GenerateOutputJsonDrawCallInfo( auto& current_block = dump_json.GetCurrentSubEntry(); auto& drawcall_json_entries = !output_json_per_command ? current_block["drawCallCommands"] : current_block; - auto& draw_call_entry = !output_json_per_command ? drawcall_json_entries[cmd_buf_index] : drawcall_json_entries; + + static uint64_t unique_json_entry = 0; + auto& draw_call_entry = + !output_json_per_command ? drawcall_json_entries[unique_json_entry++] : drawcall_json_entries; const auto& dc_param_entry = draw_call_params.find(dc_index); assert(dc_param_entry != draw_call_params.end()); diff --git a/framework/decode/vulkan_replay_options.h b/framework/decode/vulkan_replay_options.h index 9585ce9cfb..f10f035427 100644 --- a/framework/decode/vulkan_replay_options.h +++ b/framework/decode/vulkan_replay_options.h @@ -78,7 +78,7 @@ struct VulkanReplayOptions : public ReplayOptions std::vector>> RenderPass_Indices; std::vector> Dispatch_Indices; std::vector> TraceRays_Indices; - std::unordered_set QueueSubmit_Indices; + std::vector QueueSubmit_Indices; std::string dump_resources; util::ScreenshotFormat dump_resources_image_format{ util::ScreenshotFormat::kBmp }; diff --git a/tools/replay/parse_dump_resources_cli.cpp b/tools/replay/parse_dump_resources_cli.cpp index 2faee8bff8..7b00660843 100644 --- a/tools/replay/parse_dump_resources_cli.cpp +++ b/tools/replay/parse_dump_resources_cli.cpp @@ -311,18 +311,7 @@ bool parse_dump_resources_arg(gfxrecon::decode::VulkanReplayOptions& vulkan_repl for (int idx0 = 0; idx0 < jargs["QueueSubmit"].size(); idx0++) { uint64_t qs = static_cast(jargs["QueueSubmit"][idx0]); - if (vulkan_replay_options.QueueSubmit_Indices.find(qs) != - vulkan_replay_options.QueueSubmit_Indices.end()) - { - // QueueSubmit value can't be repeated - parse_error_message = - "Bad --dump-resources parameter: QueueSubmit value of " + std::to_string(qs) + " is repeated"; - parse_error = true; - } - else - { - vulkan_replay_options.QueueSubmit_Indices.insert(static_cast(jargs["QueueSubmit"][idx0])); - } + vulkan_replay_options.QueueSubmit_Indices.push_back(static_cast(jargs["QueueSubmit"][idx0])); } } catch (...) @@ -485,15 +474,7 @@ bool parse_dump_resources_arg(gfxrecon::decode::VulkanReplayOptions& vulkan_repl vulkan_replay_options.TraceRays_Indices[i].push_back(TraceRays); } - auto [itr, inserted] = vulkan_replay_options.QueueSubmit_Indices.insert(QueueSubmit); - if (!inserted) - { - // QueueSubmit value can't be repeated - parse_error = true; - parse_error_message = "Bad --dump-resources parameter: QueueSubmit value of " + - std::to_string(QueueSubmit) + " is repeated"; - break; - } + vulkan_replay_options.QueueSubmit_Indices.push_back(QueueSubmit); } }