diff options
author | Subv <subv2112@gmail.com> | 2018-05-20 21:21:06 +0200 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2018-05-20 21:25:56 +0200 |
commit | 72b5c448cfe5d21fea9dd7a996ca8b50539ec64a (patch) | |
tree | 7cd6e266d128e057791033c74af65b3666b31953 /src/video_core/memory_manager.cpp | |
parent | Merge pull request #436 from bunnei/multi-core (diff) | |
download | yuzu-72b5c448cfe5d21fea9dd7a996ca8b50539ec64a.tar yuzu-72b5c448cfe5d21fea9dd7a996ca8b50539ec64a.tar.gz yuzu-72b5c448cfe5d21fea9dd7a996ca8b50539ec64a.tar.bz2 yuzu-72b5c448cfe5d21fea9dd7a996ca8b50539ec64a.tar.lz yuzu-72b5c448cfe5d21fea9dd7a996ca8b50539ec64a.tar.xz yuzu-72b5c448cfe5d21fea9dd7a996ca8b50539ec64a.tar.zst yuzu-72b5c448cfe5d21fea9dd7a996ca8b50539ec64a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/memory_manager.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 25984439d..5cefce9fc 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -58,6 +58,25 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size) return gpu_addr; } +GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) { + ASSERT((gpu_addr & PAGE_MASK) == 0); + + for (u64 offset = 0; offset < size; offset += PAGE_SIZE) { + ASSERT(PageSlot(gpu_addr + offset) != static_cast<u64>(PageStatus::Allocated) && + PageSlot(gpu_addr + offset) != static_cast<u64>(PageStatus::Unmapped)); + PageSlot(gpu_addr + offset) = static_cast<u64>(PageStatus::Unmapped); + } + + // Delete the region mappings that are contained within the unmapped region + mapped_regions.erase(std::remove_if(mapped_regions.begin(), mapped_regions.end(), + [&](const MappedRegion& region) { + return region.gpu_addr <= gpu_addr && + region.gpu_addr + region.size < gpu_addr + size; + }), + mapped_regions.end()); + return gpu_addr; +} + boost::optional<GPUVAddr> MemoryManager::FindFreeBlock(u64 size, u64 align) { GPUVAddr gpu_addr = 0; u64 free_space = 0; |