Skip to content

Conversation

@panos-lunarg
Copy link
Contributor

@panos-lunarg panos-lunarg commented Dec 15, 2025

VDR: Transfer commands
It is now possible to dump resources targeted by transfer API calls. The
following transfer commands are added:
vkCmdCopyBuffer
vkCmdCopyBuffer2
vkCmdCopyBuffer2KHR
vkCmdCopyBufferToImage
vkCmdCopyBufferToImage2
vkCmdCopyBufferToImage2KHR
vkCmdCopyImage
vkCmdCopyImage2
vkCmdCopyImage2KHR
vkCmdCopyImageToBuffer
vkCmdCopyImageToBuffer2
vkCmdCopyImageToBuffer2KHR
vkCmdBuildAccelerationStructuresKHR
vkCmdCopyAccelerationStructureKHR

Additionaly the following GFXR transfer meta commands are also
supported:
kInitBufferCommand
kInitImageCommand
kVulkanBuildAccelerationStructuresCommand
kVulkanCopyAccelerationStructuresCommand

More details can be found in the vulkan_dump_resources.md documentation

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build queued with queue ID 601674.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8353 running.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8353 passed.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build queued with queue ID 601798.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8355 running.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8355 passed.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build queued with queue ID 601922.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8356 running.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8356 passed.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build queued with queue ID 602778.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8357 running.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build queued with queue ID 602877.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8358 running.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8358 passed.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build queued with queue ID 603105.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8361 running.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build queued with queue ID 603133.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8362 running.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8362 passed.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build queued with queue ID 604037.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8375 running.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8375 passed.

return true;
}

void DefaultVulkanDumpResourcesDelegate::GenerateOutputJsonTransferInfo(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really long function - would it make sense to break it out into smaller utility subfunctions for readability? Maybe just the chunks on the inside of the case blocks?


if (bc)
{
before_params = CopyBuffer(s, d);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like before_params is identical to params; can you help me understand what the purpose is of having separate params and before_params?

VulkanImageInfo image_info;
};

// kInitBufferCommand
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these would be better as a polymorphic construct, like TransferParamsBase, and then subclasses - virtual destructors would remove the get_if chain and the variants wouldn't need to be maintained when the list of classes changes. There are a lot of dependencies on things, like sometimes there's a before_params and sometimes not, and it would be nice if that was presented directly in the subclass and not left to being an empty reference or variant.

Copy link
Contributor

@bradgrantham-lunarg bradgrantham-lunarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this change you're storing the contexts in the map as smart pointers but still returning a vector of raw pointers. Store them in the map as shared_ptr and return a vector of shared_pointer instead of a vector of raw pointers. (I may have said "unique_ptr" before and if so I apologize.)

The maps that hold the dumping contexts store the contexts themselves
inside the map. This makes them vulnerable to errors where a
pointer/reference to a contexts becomes invalid when there's a
modification to the map.

This commits switches to storing them as smart pointers instead, making
them more robust against map changes.
IsRecording()'s job is to guard the resource dumping logic to be called
when not actually dumping anything. In its current logic it searches
among available dumping contexts in an inefficient and complicated way
which is not 100% correct.

This commit simplifies the logic by keeping track of the currently
active dumping contexts.
ReleaseDrawCallContexts, ReleaseDispatchTraceRaysContexts, and
ReleaseTransferContexts iterator over existing contexts with iterator
based for loops. These are replaces with range-based loops
TransferDumpingContext is storing each different transfer command using
a variant. This commit refactors this by removing the variant and use
inheritance instead. A base class TransferParamsBase is defined and each
transfer command is a child of the base class. This should simplify
adding new commands
Each transfer command dumps only one "resource" so
DumpedResourcesInfo::dumped_transfer_commands is made from a vector into
a smart pointer.
Split DefaultVulkanDumpResourcesDelegate::GenerateOutputJsonTransferInfo
into smaller ones that handle each case separately
DumpedBuffer::buffer_info now is initialized in DumpedBuffer's
constructors initialization lists
@panos-lunarg panos-lunarg force-pushed the VDR_transfer_commands branch from 223fbef to 5b461c3 Compare January 4, 2026 14:17
@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build queued with queue ID 614190.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8486 running.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8486 failed.

@panos-lunarg panos-lunarg force-pushed the VDR_transfer_commands branch from 5b461c3 to fb2ad32 Compare January 4, 2026 15:04
@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build queued with queue ID 614215.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8487 running.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8487 failed.

CloneBuffer is removed as it has a deceiving name and does the same job
as CreateVkBuffer.

For same reasons CloneImage is renamed into CreateVkImage
GetMemoryTypeIndex() from vulkan_replay_dump_resources_common.h/cpp is
remove as there is an identical function in vulkan_device_util.h/cpp
Move helper functions ScaleToMipLevel and ScaleExtent from
vulkan_replay_dump_resources_common.h into graphics/vulkan_util.h
The pattern of vkCmdCopyBuffer + PipelineBarrier was repeating in
several places.
Some of the Find*Context were not used. Also some of them are renamed
for uniformity
Move dumped resources structures that are related to the delegate class
into a separate file.

Also move AccelerationStructureDumpResourcesContext related code into a
separate file
@panos-lunarg panos-lunarg force-pushed the VDR_transfer_commands branch from fb2ad32 to 741683c Compare January 4, 2026 16:16
@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build queued with queue ID 614307.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8488 running.

@ci-tester-lunarg
Copy link
Collaborator

CI gfxreconstruct build # 8488 passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants