Skip to content

Commit

Permalink
Vulkan dump resources: Multiple cbs from same qs
Browse files Browse the repository at this point in the history
  • Loading branch information
panos-lunarg committed Jan 4, 2025
1 parent acc5f4d commit c927210
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 42 deletions.
32 changes: 14 additions & 18 deletions framework/decode/vulkan_replay_dump_resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1922,9 +1922,17 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(const std::vector<VkSubmitIn
}
else
{
auto index_it = QueueSubmit_indices_.find(index);
assert(index_it != QueueSubmit_indices_.end());
QueueSubmit_indices_.erase(index_it);
for (auto i = QueueSubmit_indices_.begin(); i != QueueSubmit_indices_.end();)
{
if (*i == 1)
{
QueueSubmit_indices_.erase(i);
}
else
{
++i;
}
}

// Once all submissions are complete release resources
if (QueueSubmit_indices_.empty())
Expand Down Expand Up @@ -1994,26 +2002,14 @@ bool VulkanReplayDumpResourcesBase::UpdateRecordingStatus(VkCommandBuffer origin
{
assert(recording_);

const DrawCallsDumpingContext* dc_context = FindDrawCallCommandBufferContext(original_command_buffer);
if (dc_context != nullptr && dc_context->IsRecording())
{
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
Expand Down
2 changes: 1 addition & 1 deletion framework/decode/vulkan_replay_dump_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class VulkanReplayDumpResourcesBase
// Mapping between the original VkCommandBuffer handle and BeginCommandBuffer index
std::unordered_map<VkCommandBuffer, uint64_t> cmd_buf_begin_map_;

std::unordered_set<uint64_t> QueueSubmit_indices_;
std::vector<uint64_t> QueueSubmit_indices_;

// One per BeginCommandBuffer index
std::unordered_map<uint64_t, DrawCallsDumpingContext> draw_call_contexts;
Expand Down
5 changes: 4 additions & 1 deletion framework/decode/vulkan_replay_dump_resources_draw_calls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion framework/decode/vulkan_replay_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct VulkanReplayOptions : public ReplayOptions
std::vector<std::vector<std::vector<uint64_t>>> RenderPass_Indices;
std::vector<std::vector<uint64_t>> Dispatch_Indices;
std::vector<std::vector<uint64_t>> TraceRays_Indices;
std::unordered_set<uint64_t> QueueSubmit_Indices;
std::vector<uint64_t> QueueSubmit_Indices;
std::string dump_resources;
util::ScreenshotFormat dump_resources_image_format{ util::ScreenshotFormat::kBmp };

Expand Down
23 changes: 2 additions & 21 deletions tools/replay/parse_dump_resources_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t>(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<uint64_t>(jargs["QueueSubmit"][idx0]));
}
vulkan_replay_options.QueueSubmit_Indices.push_back(static_cast<uint64_t>(jargs["QueueSubmit"][idx0]));
}
}
catch (...)
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit c927210

Please sign in to comment.