When a VkBufferMemoryBarrier (in a vkCmdPipelineBarrier or vkCmdWaitEvents call) has srcQueueFamilyIndex = VK_QUEUE_FAMILY_EXTERNAL, this indicates that the buffer contents may have been changed by an external process. This PR saves the contents when tracing, and restores the contents when replaying.
Capture:
Command buffer recording: maintain a map (mExternalMemoryBarriers) from command buffers to the VkBufferMemoryBarriers recorded in the command buffers that acquire from VK_QUEUE_FAMILY_EXTERNAL.
Queue submission:
Insert new command buffers to:
acquire the buffers from the external queue family
copy the contents into a staging buffer, and
transfer the buffer back to the external queue family (so that the original acquire operation is valid).
These new command buffers are inserted before the command buffers containing the corresponding VkBufferMemoryBarriers.
When the queue submission is complete, map the staging memory, and record the contents as an ExternalMemoryData extra.
Replay:
Command buffer recording: remove all queue family transfers to/from VK_QUEUE_FAMILY_EXTERNAL; for queue family transfers from VK_QUEUE_FAMILY_EXTERNAL, add VK_ACCESS_TRANSFER_WRITE_BIT to srcAccessMask and add VK_PIPELINE_STAGE_TRANSFER_BIT to the srcStageMask.
Queue submission:
Load the contents into a staging buffer
Insert new command buffers to:
copy the contents from the staging buffer into the corresponding buffers.
This PR is work toward supporting external memory (https://github.com/bjoeris/gapid/tree/extern-mem).
When a
VkBufferMemoryBarrier
(in avkCmdPipelineBarrier
orvkCmdWaitEvents
call) hassrcQueueFamilyIndex = VK_QUEUE_FAMILY_EXTERNAL
, this indicates that the buffer contents may have been changed by an external process. This PR saves the contents when tracing, and restores the contents when replaying.Capture:
mExternalMemoryBarriers
) from command buffers to theVkBufferMemoryBarrier
s recorded in the command buffers that acquire fromVK_QUEUE_FAMILY_EXTERNAL
.VkBufferMemoryBarrier
s.ExternalMemoryData
extra.Replay:
VK_QUEUE_FAMILY_EXTERNAL
; for queue family transfers fromVK_QUEUE_FAMILY_EXTERNAL
, addVK_ACCESS_TRANSFER_WRITE_BIT
tosrcAccessMask
and addVK_PIPELINE_STAGE_TRANSFER_BIT
to thesrcStageMask
.