Skip to content

Commit 5e7fc3e

Browse files
committed
New mainBB
2 parents df09ed2 + 0eee36c commit 5e7fc3e

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

externals/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ endif()
213213

214214
# Discord RPC
215215
if (ENABLE_DISCORD_RPC)
216-
set(BUILD_EXAMPLES OFF)
217216
add_subdirectory(discord-rpc)
218-
target_include_directories(discord-rpc INTERFACE discord-rpc/include)
219217
endif()
220218

221219
# GCN Headers

src/core/memory.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,11 @@ int MemoryManager::PoolReserve(void** out_addr, VAddr virtual_addr, size_t size,
171171

172172
// Fixed mapping means the virtual address must exactly match the provided one.
173173
if (True(flags & MemoryMapFlags::Fixed)) {
174-
const auto& vma = FindVMA(mapped_addr)->second;
174+
auto& vma = FindVMA(mapped_addr)->second;
175175
// If the VMA is mapped, unmap the region first.
176176
if (vma.IsMapped()) {
177177
UnmapMemoryImpl(mapped_addr, size);
178+
vma = FindVMA(mapped_addr)->second;
178179
}
179180
const size_t remaining_size = vma.base + vma.size - mapped_addr;
180181
ASSERT_MSG(vma.type == VMAType::Free && remaining_size >= size);
@@ -208,10 +209,11 @@ int MemoryManager::Reserve(void** out_addr, VAddr virtual_addr, size_t size, Mem
208209

209210
// Fixed mapping means the virtual address must exactly match the provided one.
210211
if (True(flags & MemoryMapFlags::Fixed)) {
211-
const auto& vma = FindVMA(mapped_addr)->second;
212+
auto& vma = FindVMA(mapped_addr)->second;
212213
// If the VMA is mapped, unmap the region first.
213214
if (vma.IsMapped()) {
214215
UnmapMemoryImpl(mapped_addr, size);
216+
vma = FindVMA(mapped_addr)->second;
215217
}
216218
const size_t remaining_size = vma.base + vma.size - mapped_addr;
217219
ASSERT_MSG(vma.type == VMAType::Free && remaining_size >= size);
@@ -393,14 +395,18 @@ s32 MemoryManager::UnmapMemoryImpl(VAddr virtual_addr, size_t size) {
393395
ASSERT_MSG(vma_base.Contains(virtual_addr, size),
394396
"Existing mapping does not contain requested unmap range");
395397

398+
const auto type = vma_base.type;
399+
if (type == VMAType::Free) {
400+
return ORBIS_OK;
401+
}
402+
396403
const auto vma_base_addr = vma_base.base;
397404
const auto vma_base_size = vma_base.size;
398405
const auto phys_base = vma_base.phys_base;
399406
const bool is_exec = vma_base.is_exec;
400407
const auto start_in_vma = virtual_addr - vma_base_addr;
401-
const auto type = vma_base.type;
402408
const bool has_backing = type == VMAType::Direct || type == VMAType::File;
403-
if (type == VMAType::Direct) {
409+
if (type == VMAType::Direct || type == VMAType::Pooled) {
404410
rasterizer->UnmapMemory(virtual_addr, size);
405411
}
406412
if (type == VMAType::Flexible) {
@@ -418,10 +424,12 @@ s32 MemoryManager::UnmapMemoryImpl(VAddr virtual_addr, size_t size) {
418424
MergeAdjacent(vma_map, new_it);
419425
bool readonly_file = vma.prot == MemoryProt::CpuRead && type == VMAType::File;
420426

421-
// Unmap the memory region.
422-
impl.Unmap(vma_base_addr, vma_base_size, start_in_vma, start_in_vma + size, phys_base, is_exec,
423-
has_backing, readonly_file);
424-
TRACK_FREE(virtual_addr, "VMEM");
427+
if (type != VMAType::Reserved && type != VMAType::PoolReserved) {
428+
// Unmap the memory region.
429+
impl.Unmap(vma_base_addr, vma_base_size, start_in_vma, start_in_vma + size, phys_base,
430+
is_exec, has_backing, readonly_file);
431+
TRACK_FREE(virtual_addr, "VMEM");
432+
}
425433

426434
return ORBIS_OK;
427435
}

0 commit comments

Comments
 (0)