address_space: Don't reserve space again
This commit is contained in:
parent
edaeee194d
commit
e9679f8309
|
@ -116,6 +116,7 @@ struct AddressSpace::Impl {
|
||||||
void* MapPrivate(VAddr virtual_addr, size_t size, u64 alignment, ULONG prot,
|
void* MapPrivate(VAddr virtual_addr, size_t size, u64 alignment, ULONG prot,
|
||||||
bool no_commit = false) {
|
bool no_commit = false) {
|
||||||
// Map a private allocation
|
// Map a private allocation
|
||||||
|
PVOID addr = reinterpret_cast<PVOID>(virtual_addr);
|
||||||
MEM_ADDRESS_REQUIREMENTS req{};
|
MEM_ADDRESS_REQUIREMENTS req{};
|
||||||
MEM_EXTENDED_PARAMETER param{};
|
MEM_EXTENDED_PARAMETER param{};
|
||||||
// req.LowestStartingAddress =
|
// req.LowestStartingAddress =
|
||||||
|
@ -129,9 +130,23 @@ struct AddressSpace::Impl {
|
||||||
if (!no_commit) {
|
if (!no_commit) {
|
||||||
alloc_type |= MEM_COMMIT;
|
alloc_type |= MEM_COMMIT;
|
||||||
}
|
}
|
||||||
void* const ptr = VirtualAlloc2(process, reinterpret_cast<PVOID>(virtual_addr), size,
|
// Check if the area has been reserved beforehand (typically for tesselation buffer)
|
||||||
alloc_type, prot, ¶m, 1);
|
// and in that case don't reserve it again as Windows complains.
|
||||||
ASSERT_MSG(ptr, "{}", Common::GetLastErrorMsg());
|
if (virtual_addr) {
|
||||||
|
MEMORY_BASIC_INFORMATION info;
|
||||||
|
VirtualQuery(addr, &info, sizeof(info));
|
||||||
|
if (info.State == MEM_RESERVE) {
|
||||||
|
alloc_type &= ~MEM_RESERVE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void* ptr{};
|
||||||
|
if (virtual_addr) {
|
||||||
|
ptr = VirtualAlloc2(process, addr, size, alloc_type, prot, NULL, 0);
|
||||||
|
ASSERT_MSG(ptr && VAddr(ptr) == virtual_addr, "{}", Common::GetLastErrorMsg());
|
||||||
|
} else {
|
||||||
|
ptr = VirtualAlloc2(process, nullptr, size, alloc_type, prot, ¶m, 1);
|
||||||
|
ASSERT_MSG(ptr, "{}", Common::GetLastErrorMsg());
|
||||||
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,10 +92,7 @@ int MemoryManager::MapMemory(void** out_addr, VAddr virtual_addr, size_t size, M
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
ASSERT(it != vma_map.end());
|
ASSERT(it != vma_map.end());
|
||||||
if (alignment > 0) {
|
mapped_addr = alignment > 0 ? Common::AlignUp(it->second.base, alignment) : it->second.base;
|
||||||
ASSERT_MSG(it->second.base % alignment == 0, "Free region base is not aligned");
|
|
||||||
}
|
|
||||||
mapped_addr = it->second.base;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform the mapping.
|
// Perform the mapping.
|
||||||
|
|
Loading…
Reference in New Issue