summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-05-21 05:54:50 +0200
committerGitHub <noreply@github.com>2018-05-21 05:54:50 +0200
commit58857b9f46992753059aa8a6c31aff0ee14c9f99 (patch)
treed49a9d594878a2c2a948b13109e1a6e6c07ffaba /src/video_core
parentCorrect audio command numbers & add or rename some functions (#455) (diff)
parentGPU: Implemented the nvmap Free ioctl. (diff)
downloadyuzu-58857b9f46992753059aa8a6c31aff0ee14c9f99.tar
yuzu-58857b9f46992753059aa8a6c31aff0ee14c9f99.tar.gz
yuzu-58857b9f46992753059aa8a6c31aff0ee14c9f99.tar.bz2
yuzu-58857b9f46992753059aa8a6c31aff0ee14c9f99.tar.lz
yuzu-58857b9f46992753059aa8a6c31aff0ee14c9f99.tar.xz
yuzu-58857b9f46992753059aa8a6c31aff0ee14c9f99.tar.zst
yuzu-58857b9f46992753059aa8a6c31aff0ee14c9f99.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/memory_manager.cpp19
-rw-r--r--src/video_core/memory_manager.h1
2 files changed, 20 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;
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h
index 08140c83a..86765e72a 100644
--- a/src/video_core/memory_manager.h
+++ b/src/video_core/memory_manager.h
@@ -25,6 +25,7 @@ public:
GPUVAddr AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align);
GPUVAddr MapBufferEx(VAddr cpu_addr, u64 size);
GPUVAddr MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size);
+ GPUVAddr UnmapBuffer(GPUVAddr gpu_addr, u64 size);
boost::optional<VAddr> GpuToCpuAddress(GPUVAddr gpu_addr);
std::vector<GPUVAddr> CpuToGpuAddress(VAddr cpu_addr) const;