1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 20:52:10 +01:00

[dxvk] Limit maximum size of multi-slice buffers

Reduces memory fragmentation caused by frequently renamed buffers.
This commit is contained in:
Philip Rebohle 2019-07-15 04:14:23 +02:00
parent d8e31f221f
commit acf6c27e76
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 12 additions and 4 deletions

View File

@ -17,6 +17,13 @@ namespace dxvk {
m_physSliceLength = createInfo.size;
m_physSliceStride = align(createInfo.size, 256);
// Limit size of multi-slice buffers to reduce fragmentation
constexpr VkDeviceSize MaxBufferSize = 4 << 20;
m_physSliceMaxCount = MaxBufferSize >= m_physSliceStride
? MaxBufferSize / m_physSliceStride
: 1;
// Allocate a single buffer slice
m_buffer = allocBuffer(1);

View File

@ -257,7 +257,7 @@ namespace dxvk {
}
m_buffers.push_back(std::move(handle));
m_physSliceCount *= 2;
m_physSliceCount = std::min(m_physSliceCount * 2, m_physSliceMaxCount);
}
// Take the first slice from the queue
@ -301,7 +301,8 @@ namespace dxvk {
VkDeviceSize m_physSliceLength = 0;
VkDeviceSize m_physSliceStride = 0;
VkDeviceSize m_physSliceCount = 2;
VkDeviceSize m_physSliceCount = 1;
VkDeviceSize m_physSliceMaxCount = 1;
DxvkBufferHandle allocBuffer(
VkDeviceSize sliceCount) const;