Lazily create readback buffer

* This means we don't allocate a large buffer even though we won't actually use
  it. Most important for memory constrained platforms like android.
This commit is contained in:
baldurk committed 2020-08-10 16:09:32 +01:00
1 parent c456d16fc7
commit 6bb177ec02
3 files changed
+16

No files matched your search

+13
View File
@@ -2204,6 +2204,19 @@ void VulkanDebugManager::FillWithDiscardPattern(VkCommandBuffer cmd, DiscardType
DoPipelineBarrier(cmd, 1, &dstimBarrier);
}
void VulkanDebugManager::InitReadbackBuffer()
{
if(m_ReadbackWindow.buf == VK_NULL_HANDLE)
{
VkDevice dev = m_pDriver->GetDev();
m_ReadbackWindow.Create(m_pDriver, dev, 256 * 1024 * 1024ULL, 1, GPUBuffer::eGPUBufferReadback);
VkResult vkr = ObjDisp(dev)->MapMemory(Unwrap(dev), Unwrap(m_ReadbackWindow.mem), 0,
VK_WHOLE_SIZE, 0, (void **)&m_ReadbackPtr);
RDCASSERTEQUAL(vkr, VK_SUCCESS);
}
}
void VulkanReplay::PatchReservedDescriptors(const VulkanStatePipeline &pipe,
VkDescriptorPool &descpool,
rdcarray<VkDescriptorSetLayout> &setLayouts,
+1
View File
@@ -72,6 +72,7 @@ public:
VkImageLayout curLayout, VkImageSubresourceRange discardRange,
VkRect2D discardRect);
void InitReadbackBuffer();
byte *GetReadbackPtr() { return m_ReadbackPtr; }
VkBuffer GetReadbackBuffer() { return m_ReadbackWindow.buf; }
VkDeviceMemory GetReadbackMemory() { return m_ReadbackWindow.mem; }
@@ -1077,6 +1077,8 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
RDCDEBUG("Reading back %s with GPU for comparison",
ToStr(record->GetResourceID()).c_str());
GetDebugManager()->InitReadbackBuffer();
// immediately issue a command buffer to copy back the data. We do that on this queue to
// avoid complexity with synchronising with another queue, but the transfer queue if
// available would be better for this purpose.