mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
[dxvk] Handle dead chunks in pool allocator
This commit is contained in:
parent
a9bcb40655
commit
c7a9c626f5
@ -374,6 +374,28 @@ namespace dxvk {
|
||||
// Obtain a page for the size category
|
||||
int32_t pageIndex = m_pageLists[listIndex].head;
|
||||
|
||||
if (likely(pageIndex >= 0)) {
|
||||
uint32_t chunkIndex = uint32_t(pageIndex) >> DxvkPageAllocator::ChunkPageBits;
|
||||
|
||||
// If the selected page is from a dead chunk, do not allocate
|
||||
// into it anymore so that the chunk can actually be freed.
|
||||
if (unlikely(!m_pageAllocator->chunkIsAvailable(chunkIndex))) {
|
||||
int32_t nextIndex = pageIndex;
|
||||
|
||||
do {
|
||||
// This works because we add pages to the end
|
||||
removePageFromList(nextIndex, listIndex);
|
||||
addPageToList(nextIndex, listIndex);
|
||||
|
||||
nextIndex = m_pageLists[listIndex].head;
|
||||
chunkIndex = uint32_t(nextIndex) >> DxvkPageAllocator::ChunkPageBits;
|
||||
} while (nextIndex != pageIndex && !m_pageAllocator->chunkIsAvailable(chunkIndex));
|
||||
|
||||
// Allocate a new page if the entire list is dead
|
||||
pageIndex = nextIndex != pageIndex ? nextIndex : -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely(pageIndex < 0)) {
|
||||
if ((pageIndex = allocPage(listIndex)) < 0)
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user