Skip to content

Commit 54d7a6b

Browse files
authored
Vdr preserve submit and execute information (#2932)
* VDR: Preserve submission and execution information Preserve submission information (the pSubmits and pCommandBuffers indices) and CmdExecuteCommands information (pCommandBuffers index). This commit affects only draw call dumping context. * VDR: Preserve submission and execution information Preserve submission information (the pSubmits and pCommandBuffers indices) and CmdExecuteCommands information (pCommandBuffers index). This commit affects only dispatch/trace rays dumping context. * VDR: Preserve submission information Preserve submission information (the pSubmits and pCommandBuffers indices) but not CmdExecuteCommands info. This commit affects only transfer dumping context. * VDR: Clean up DumpedResourceBase ctors * Address rebase conflicts fallout
1 parent 21a3a1b commit 54d7a6b

10 files changed

Lines changed: 675 additions & 434 deletions

framework/decode/vulkan_replay_dump_resources.cpp

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,31 +1878,31 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(std::span<const VkSubmitInfo
18781878
return _res_; \
18791879
}
18801880

1881-
std::vector<std::shared_ptr<TransferDumpingContext>> transfer_contexts;
1882-
std::vector<std::shared_ptr<DispatchTraceRaysDumpingContext>> dispatch_contexts;
1881+
std::map<std::pair<Index, Index>, std::shared_ptr<TransferDumpingContext>> transfer_contexts;
1882+
std::map<std::pair<Index, Index>, std::shared_ptr<DispatchTraceRaysDumpingContext>> dispatch_contexts;
18831883

18841884
if (!output_json_per_command)
18851885
{
18861886
active_delegate_->DumpStart();
18871887
}
18881888

18891889
const size_t submit_count = submit_infos.size();
1890-
for (const auto& si : submit_infos)
1890+
for (size_t si = 0; si < submit_count; ++si)
18911891
{
18921892
std::vector<VkCommandBuffer> submit_cbs;
18931893
VkResult res = VK_SUCCESS;
18941894

18951895
// For each VkSubmitInfo we shall create a different fence. The provided fence will be used only in the last
18961896
// VkSubmitInfo. If none is provided then we will create one.
1897-
const bool last_submit_info = (&si == &submit_infos.back());
1897+
const bool last_submit_info = (si == submit_count - 1);
18981898
const bool create_temp_fence = (!last_submit_info) || (last_submit_info && (fence == VK_NULL_HANDLE));
18991899
TemporaryFence submission_fence(create_temp_fence ? VK_NULL_HANDLE : fence, queue_info->parent, device_table);
19001900

1901-
VkSubmitInfo modified_submit_info = si;
1902-
for (uint32_t cb = 0; cb < si.commandBufferCount; ++cb)
1901+
VkSubmitInfo modified_submit_info = submit_infos[si];
1902+
for (uint32_t cb = 0; cb < submit_infos[si].commandBufferCount; ++cb)
19031903
{
1904-
const bool last_cmd_buf = (cb == si.commandBufferCount - 1);
1905-
const VkCommandBuffer command_buffer = si.pCommandBuffers[cb];
1904+
const bool last_cmd_buf = (cb == submit_infos[si].commandBufferCount - 1);
1905+
const VkCommandBuffer command_buffer = submit_infos[si].pCommandBuffers[cb];
19061906

19071907
if (cb_bcb_map_.find(command_buffer) == cb_bcb_map_.end())
19081908
{
@@ -1913,7 +1913,8 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(std::span<const VkSubmitInfo
19131913
{
19141914
if (bcb_qs_pair.second == qs_index)
19151915
{
1916-
transfer_contexts.push_back(transf_context);
1916+
transfer_contexts.emplace(std::make_pair(static_cast<Index>(si), static_cast<Index>(cb)),
1917+
transf_context);
19171918
}
19181919
}
19191920
}
@@ -1924,7 +1925,8 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(std::span<const VkSubmitInfo
19241925
// Handle Transfer commands
19251926
if (auto transfer_context = FindTransferContext(command_buffer, qs_index))
19261927
{
1927-
transfer_contexts.push_back(transfer_context);
1928+
transfer_contexts.emplace(std::make_pair(static_cast<Index>(si), static_cast<Index>(cb)),
1929+
transfer_context);
19281930
// Transfer context does not use a clone command buffer. We submit the original one.
19291931
submit_cbs.push_back(command_buffer);
19301932
has_transfer_or_dispatch = true;
@@ -1936,7 +1938,8 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(std::span<const VkSubmitInfo
19361938
{
19371939
if (bcb_qs_pair.second == qs_index)
19381940
{
1939-
transfer_contexts.push_back(transf_context);
1941+
transfer_contexts.emplace(std::make_pair(static_cast<Index>(si), static_cast<Index>(cb)),
1942+
transfer_context);
19401943
submit_cbs.push_back(command_buffer);
19411944
has_transfer_or_dispatch = true;
19421945
}
@@ -1946,7 +1949,8 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(std::span<const VkSubmitInfo
19461949
// Handle Dispatch/TraceRays commands
19471950
if (auto dispatch_context = FindDispatchTraceRaysContext(command_buffer, qs_index))
19481951
{
1949-
dispatch_contexts.push_back(dispatch_context);
1952+
dispatch_contexts.emplace(std::make_pair(static_cast<Index>(si), static_cast<Index>(cb)),
1953+
dispatch_context);
19501954
// Dispatch/RayTracing context uses a clone command buffer. We submit that one instead of the
19511955
// original.
19521956
submit_cbs.push_back(dispatch_context->GetDispatchRaysCommandBuffer());
@@ -1986,7 +1990,8 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(std::span<const VkSubmitInfo
19861990
submit_cbs.clear();
19871991
}
19881992

1989-
res = dc_context->DumpDrawCalls(queue_info->handle, modified_submit_info);
1993+
res = dc_context->DumpDrawCalls(
1994+
queue_info->handle, modified_submit_info, static_cast<Index>(si), static_cast<Index>(cb));
19901995
CHECK_VK_ERROR(res, "DumpDrawCalls")
19911996

19921997
// The semaphores have been used up by the submission. Don't use them again.
@@ -2020,15 +2025,15 @@ VkResult VulkanReplayDumpResourcesBase::QueueSubmit(std::span<const VkSubmitInfo
20202025
}
20212026
}
20222027

2023-
for (auto& transfer_context : transfer_contexts)
2028+
for (auto& [pair, transfer_context] : transfer_contexts)
20242029
{
2025-
VkResult res = transfer_context->DumpTransferCommands();
2030+
VkResult res = transfer_context->DumpTransferCommands(pair.first, pair.second);
20262031
CHECK_VK_ERROR(res, "DumpTransferCommands")
20272032
}
20282033

2029-
for (auto& disp_context : dispatch_contexts)
2034+
for (auto& [pair, disp_context] : dispatch_contexts)
20302035
{
2031-
VkResult res = disp_context->DumpDispatchTraceRays();
2036+
VkResult res = disp_context->DumpDispatchTraceRays(pair.first, pair.second);
20322037
CHECK_VK_ERROR(res, "DumpDispatchTraceRays")
20332038
}
20342039

@@ -2254,7 +2259,7 @@ void VulkanReplayDumpResourcesBase::OverrideCmdExecuteCommands(const ApiCallInfo
22542259
func(*primary_it, 1, &pCommandBuffers[i]);
22552260
}
22562261

2257-
dc_primary_context->UpdateSecondaries(*dc_secondary_context.get());
2262+
dc_primary_context->UpdateSecondaries(*dc_secondary_context.get(), call_info.index, i);
22582263

22592264
// All primaries have been finalized. Nothing else to do
22602265
if (finalized_primaries == primary_last - primary_first)
@@ -2305,14 +2310,15 @@ void VulkanReplayDumpResourcesBase::OverrideCmdExecuteCommands(const ApiCallInfo
23052310
VkCommandBuffer secondary_command_buffer =
23062311
dr_secondary_context->GetDispatchRaysCommandBuffer();
23072312
func(dispatch_rays_command_buffer, 1, &secondary_command_buffer);
2313+
2314+
dr_primary_context->UpdateSecondaries(*dr_secondary_context, call_info.index, i);
23082315
}
23092316
}
23102317
else
23112318
{
23122319
func(dispatch_rays_command_buffer, 1, &pCommandBuffers[i]);
23132320
}
23142321
}
2315-
dr_primary_context->UpdateSecondaries();
23162322
}
23172323
else
23182324
{
@@ -3256,7 +3262,7 @@ void VulkanReplayDumpResourcesBase::ProcessStateEndMarker()
32563262
std::shared_ptr<TransferDumpingContext> transfer_context = FindTransferContextBcbQsIndex(0, 0);
32573263
if (transfer_context != nullptr)
32583264
{
3259-
VkResult res = transfer_context->DumpTransferCommands();
3265+
VkResult res = transfer_context->DumpTransferCommands(0, 0);
32603266
if (res != VK_SUCCESS)
32613267
{
32623268
Release();

framework/decode/vulkan_replay_dump_resources_common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ enum class DumpResourcesCommandBufferLevel
238238
kSecondary
239239
};
240240

241+
struct SecondaryIdentifiers
242+
{
243+
// vkCmdExecuteCommands block index
244+
Index execute_cmds_index{ UNDEFINED_INDEX };
245+
246+
// Secondary's command buffer index inside pCommandBuffers
247+
Index execute_cmds_cmd_buf_index{ UNDEFINED_INDEX };
248+
};
249+
241250
#define DEPTH_ATTACHMENT ~0
242251

243252
// Wrapper class for VkFence. Either holds an existing VkFence or creates and handles destruction of one

0 commit comments

Comments
 (0)