mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 13:20:54 +00:00
Add barrier and invalidate when reading back memory via GPU
This commit is contained in:
@@ -74,6 +74,7 @@ public:
|
||||
|
||||
byte *GetReadbackPtr() { return m_ReadbackPtr; }
|
||||
VkBuffer GetReadbackBuffer() { return m_ReadbackWindow.buf; }
|
||||
VkDeviceMemory GetReadbackMemory() { return m_ReadbackWindow.mem; }
|
||||
VkPipelineCache GetPipelineCache() { return m_PipelineCache; }
|
||||
VkPipeline GetCustomPipeline() { return m_Custom.TexPipeline; }
|
||||
VkImage GetCustomTexture() { return m_Custom.TexImg; }
|
||||
|
||||
@@ -1093,6 +1093,21 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
|
||||
Unwrap(GetDebugManager()->GetReadbackBuffer()), 1,
|
||||
®ion);
|
||||
|
||||
// wait for transfer to finish before reading on CPU
|
||||
VkBufferMemoryBarrier bufBarrier = {
|
||||
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
|
||||
NULL,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_ACCESS_HOST_READ_BIT,
|
||||
VK_QUEUE_FAMILY_IGNORED,
|
||||
VK_QUEUE_FAMILY_IGNORED,
|
||||
Unwrap(GetDebugManager()->GetReadbackBuffer()),
|
||||
0,
|
||||
VK_WHOLE_SIZE,
|
||||
};
|
||||
|
||||
DoPipelineBarrier(copycmd, 1, &bufBarrier);
|
||||
|
||||
ObjDisp(copycmd)->EndCommandBuffer(Unwrap(copycmd));
|
||||
|
||||
VkSubmitInfo submit = {
|
||||
@@ -1103,6 +1118,17 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
|
||||
|
||||
ObjDisp(queue)->QueueWaitIdle(Unwrap(queue));
|
||||
|
||||
VkMappedMemoryRange range = {
|
||||
VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
|
||||
NULL,
|
||||
Unwrap(GetDebugManager()->GetReadbackMemory()),
|
||||
0,
|
||||
VK_WHOLE_SIZE,
|
||||
};
|
||||
|
||||
copyret = ObjDisp(queue)->InvalidateMappedMemoryRanges(Unwrap(m_Device), 1, &range);
|
||||
RDCASSERTEQUAL(copyret, VK_SUCCESS);
|
||||
|
||||
RemovePendingCommandBuffer(copycmd);
|
||||
AddFreeCommandBuffer(copycmd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user