mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +01:00
[dxvk] Fixed potential memory allocation issue
This commit is contained in:
parent
d74db72add
commit
dbe3662bfc
@ -162,9 +162,12 @@ namespace dxvk {
|
|||||||
// chunks since that might lead to severe fragmentation.
|
// chunks since that might lead to severe fragmentation.
|
||||||
if (size >= (m_chunkSize / 4)) {
|
if (size >= (m_chunkSize / 4)) {
|
||||||
VkDeviceMemory memory = this->allocDeviceMemory(size);
|
VkDeviceMemory memory = this->allocDeviceMemory(size);
|
||||||
void* mapPtr = this->mapDeviceMemory(memory);
|
|
||||||
|
|
||||||
return DxvkMemory(nullptr, this, memory, 0, size, mapPtr);
|
if (memory == VK_NULL_HANDLE)
|
||||||
|
return DxvkMemory();
|
||||||
|
|
||||||
|
return DxvkMemory(nullptr, this, memory,
|
||||||
|
0, size, this->mapDeviceMemory(memory));
|
||||||
} else {
|
} else {
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
@ -179,10 +182,12 @@ namespace dxvk {
|
|||||||
// None of the existing chunks could satisfy
|
// None of the existing chunks could satisfy
|
||||||
// the request, we need to create a new one
|
// the request, we need to create a new one
|
||||||
VkDeviceMemory chunkMem = this->allocDeviceMemory(m_chunkSize);
|
VkDeviceMemory chunkMem = this->allocDeviceMemory(m_chunkSize);
|
||||||
void* chunkPtr = this->mapDeviceMemory(chunkMem);
|
|
||||||
|
|
||||||
Rc<DxvkMemoryChunk> newChunk = new DxvkMemoryChunk(
|
if (chunkMem == VK_NULL_HANDLE)
|
||||||
this, chunkMem, chunkPtr, m_chunkSize);
|
return DxvkMemory();
|
||||||
|
|
||||||
|
Rc<DxvkMemoryChunk> newChunk = new DxvkMemoryChunk(this,
|
||||||
|
chunkMem, this->mapDeviceMemory(chunkMem), m_chunkSize);
|
||||||
DxvkMemory memory = newChunk->alloc(size, align);
|
DxvkMemory memory = newChunk->alloc(size, align);
|
||||||
|
|
||||||
m_chunks.push_back(std::move(newChunk));
|
m_chunks.push_back(std::move(newChunk));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user