mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-10-08 13:21:45 +00:00
Fix readback window being always allocated. Closes #2060
* This should only be allocated when the config flag isn't disabled and when it's needed, but we were always allocating it during capture. * We also only allocate as much as is needed, since it seems on AMD linux the CPU memory can actually be quite arbitrarily constrained.
This commit is contained in:
3 files changed
+13
-13
No files matched your search
@@ -754,14 +754,6 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver)
|
||||
{
|
||||
m_ReadbackWindow.Create(driver, dev, STAGE_BUFFER_BYTE_SIZE, 1, GPUBuffer::eGPUBufferReadback);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ReadbackWindow.Create(driver, dev, 256 * 1024 * 1024ULL, 1, GPUBuffer::eGPUBufferReadback);
|
||||
|
||||
vkr = ObjDisp(dev)->MapMemory(Unwrap(dev), Unwrap(m_ReadbackWindow.mem), 0, VK_WHOLE_SIZE, 0,
|
||||
(void **)&m_ReadbackPtr);
|
||||
RDCASSERTEQUAL(vkr, VK_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
VulkanDebugManager::~VulkanDebugManager()
|
||||
@@ -2167,12 +2159,20 @@ void VulkanDebugManager::FillWithDiscardPattern(VkCommandBuffer cmd, DiscardType
|
||||
DoPipelineBarrier(cmd, 1, &dstimBarrier);
|
||||
}
|
||||
|
||||
void VulkanDebugManager::InitReadbackBuffer()
|
||||
void VulkanDebugManager::InitReadbackBuffer(VkDeviceSize sz)
|
||||
{
|
||||
if(m_ReadbackWindow.buf == VK_NULL_HANDLE)
|
||||
if(m_ReadbackWindow.buf == VK_NULL_HANDLE || m_ReadbackWindow.sz < sz)
|
||||
{
|
||||
if(m_ReadbackWindow.buf != VK_NULL_HANDLE)
|
||||
{
|
||||
m_ReadbackWindow.Destroy();
|
||||
}
|
||||
|
||||
VkDevice dev = m_pDriver->GetDev();
|
||||
m_ReadbackWindow.Create(m_pDriver, dev, 256 * 1024 * 1024ULL, 1, GPUBuffer::eGPUBufferReadback);
|
||||
m_ReadbackWindow.Create(m_pDriver, dev, AlignUp(sz, (VkDeviceSize)4096), 1,
|
||||
GPUBuffer::eGPUBufferReadback);
|
||||
|
||||
RDCLOG("Allocating readback window of %llu bytes", m_ReadbackWindow.sz);
|
||||
|
||||
VkResult vkr = ObjDisp(dev)->MapMemory(Unwrap(dev), Unwrap(m_ReadbackWindow.mem), 0,
|
||||
VK_WHOLE_SIZE, 0, (void **)&m_ReadbackPtr);
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
VkImageLayout curLayout, VkImageSubresourceRange discardRange,
|
||||
VkRect2D discardRect);
|
||||
|
||||
void InitReadbackBuffer();
|
||||
void InitReadbackBuffer(VkDeviceSize sz);
|
||||
byte *GetReadbackPtr() { return m_ReadbackPtr; }
|
||||
VkBuffer GetReadbackBuffer() { return m_ReadbackWindow.buf; }
|
||||
VkDeviceMemory GetReadbackMemory() { return m_ReadbackWindow.mem; }
|
||||
|
||||
@@ -1055,7 +1055,7 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
|
||||
RDCDEBUG("Reading back %s with GPU for comparison",
|
||||
ToStr(record->GetResourceID()).c_str());
|
||||
|
||||
GetDebugManager()->InitReadbackBuffer();
|
||||
GetDebugManager()->InitReadbackBuffer(state.mapOffset + state.mapSize);
|
||||
|
||||
// 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
|
||||
|
||||
Reference in new issue
Block a user