1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 22:08:59 +01:00

[dxvk] Free empty memory chunks

This commit is contained in:
Philip Rebohle 2022-01-12 14:11:42 +01:00
parent e6442d64be
commit d34bbdb58e
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 22 additions and 1 deletions

View File

@ -1,3 +1,5 @@
#include <algorithm>
#include "dxvk_device.h"
#include "dxvk_memory.h"
@ -152,6 +154,12 @@ namespace dxvk {
}
bool DxvkMemoryChunk::isEmpty() const {
return m_freeList.size() == 1
&& m_freeList[0].length == m_memory.memSize;
}
DxvkMemoryAllocator::DxvkMemoryAllocator(const DxvkDevice* device)
: m_vkd (device->vkd()),
m_device (device),
@ -406,6 +414,13 @@ namespace dxvk {
VkDeviceSize offset,
VkDeviceSize length) {
chunk->free(offset, length);
if (chunk->isEmpty()) {
auto e = std::find(type->chunks.begin(), type->chunks.end(), chunk);
if (e != type->chunks.end())
type->chunks.erase(e);
}
}

View File

@ -203,7 +203,13 @@ namespace dxvk {
void free(
VkDeviceSize offset,
VkDeviceSize length);
/**
* \brief Checks whether the chunk is being used
* \returns \c true if there are no allocations left
*/
bool isEmpty() const;
private:
struct FreeSlice {