Skip to content

Commit

Permalink
Fixing logic on readback pool: growing was not growing with the corre…
Browse files Browse the repository at this point in the history
…ct next size
  • Loading branch information
kecho committed Nov 26, 2023
1 parent 4914040 commit a95f824
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions Source/modules/render/dx12/Dx12BufferPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Dx12BufferPool::Dx12BufferPool(Dx12Device& device, bool isReadback)
{
bool success = createNewHeap(InitialBufferPoolSize);
CPY_ASSERT_MSG(success, "Could not allocate heap.");
m_nextHeapSize = 2 * InitialBufferPoolSize;
m_nextHeapSize = InitialBufferPoolSize;
}

bool Dx12BufferPool::createNewHeap(size_t size)
Expand Down Expand Up @@ -79,10 +79,9 @@ Dx12CpuMemBlock Dx12BufferPool::allocate(size_t size)
if (selectedHeapIndex == -1)
{
selectedHeapIndex = m_heaps.size();
m_nextHeapSize = (2 * m_nextHeapSize) > size ? (2 * m_nextHeapSize) : size;
if (!createNewHeap(m_nextHeapSize))
return Dx12CpuMemBlock();

m_nextHeapSize = (2 * m_nextHeapSize) > size ? (2 * m_nextHeapSize) : size;
}

HeapState& selectedHeap = m_heaps[selectedHeapIndex];
Expand Down
5 changes: 2 additions & 3 deletions Source/modules/render/vulkan/VulkanReadbackBufferPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ VulkanReadbackBufferPool::VulkanReadbackBufferPool(VulkanDevice& device)
{
bool success = createNewHeap(InitialBufferPoolSize);
CPY_ASSERT_MSG(success, "Could not allocate heap.");
m_nextHeapSize = 2 * InitialBufferPoolSize;
m_nextHeapSize = InitialBufferPoolSize;
}

VulkanReadbackBufferPool::~VulkanReadbackBufferPool()
Expand Down Expand Up @@ -79,10 +79,9 @@ VulkanReadbackMemBlock VulkanReadbackBufferPool::allocate(size_t size)
if (selectedHeapIndex == -1)
{
selectedHeapIndex = m_heaps.size();
m_nextHeapSize = (2 * m_nextHeapSize) > size ? (2 * m_nextHeapSize) : size;
if (!createNewHeap(m_nextHeapSize))
return VulkanReadbackMemBlock();

m_nextHeapSize = (2 * m_nextHeapSize) > size ? (2 * m_nextHeapSize) : size;
}

HeapState& selectedHeap = m_heaps[selectedHeapIndex];
Expand Down

0 comments on commit a95f824

Please sign in to comment.