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:
parent
e6442d64be
commit
d34bbdb58e
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user