summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-03-21 03:58:49 +0100
committerbunnei <bunneidev@gmail.com>2019-03-21 03:58:49 +0100
commit5a5fccaa23f8670d85666efd6ea12b42883c4edc (patch)
tree7f775e358c9bc8f7ff730997ca57af88f9670f46 /src/video_core
parentmemory_manager: Bug fixes and further cleanup. (diff)
downloadyuzu-5a5fccaa23f8670d85666efd6ea12b42883c4edc.tar
yuzu-5a5fccaa23f8670d85666efd6ea12b42883c4edc.tar.gz
yuzu-5a5fccaa23f8670d85666efd6ea12b42883c4edc.tar.bz2
yuzu-5a5fccaa23f8670d85666efd6ea12b42883c4edc.tar.lz
yuzu-5a5fccaa23f8670d85666efd6ea12b42883c4edc.tar.xz
yuzu-5a5fccaa23f8670d85666efd6ea12b42883c4edc.tar.zst
yuzu-5a5fccaa23f8670d85666efd6ea12b42883c4edc.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/memory_manager.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp
index 0c4cf3974..6dc133c93 100644
--- a/src/video_core/memory_manager.cpp
+++ b/src/video_core/memory_manager.cpp
@@ -29,30 +29,39 @@ MemoryManager::MemoryManager() {
}
GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) {
+ const u64 aligned_size{Common::AlignUp(size, page_size)};
const GPUVAddr gpu_addr{
- FindFreeRegion(address_space_base, size, align, VirtualMemoryArea::Type::Unmapped)};
- AllocateMemory(gpu_addr, 0, size);
+ FindFreeRegion(address_space_base, aligned_size, align, VirtualMemoryArea::Type::Unmapped)};
+
+ AllocateMemory(gpu_addr, 0, aligned_size);
+
return gpu_addr;
}
GPUVAddr MemoryManager::AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align) {
- AllocateMemory(gpu_addr, 0, size);
+ const u64 aligned_size{Common::AlignUp(size, page_size)};
+
+ AllocateMemory(gpu_addr, 0, aligned_size);
+
return gpu_addr;
}
GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) {
- const GPUVAddr gpu_addr{
- FindFreeRegion(address_space_base, size, page_size, VirtualMemoryArea::Type::Unmapped)};
- MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), ((size + page_mask) & ~page_mask),
- cpu_addr);
+ const u64 aligned_size{Common::AlignUp(size, page_size)};
+ const GPUVAddr gpu_addr{FindFreeRegion(address_space_base, aligned_size, page_size,
+ VirtualMemoryArea::Type::Unmapped)};
+
+ MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr);
+
return gpu_addr;
}
GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size) {
ASSERT((gpu_addr & page_mask) == 0);
- MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), ((size + page_mask) & ~page_mask),
- cpu_addr);
+ const u64 aligned_size{Common::AlignUp(size, page_size)};
+
+ MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr);
return gpu_addr;
}
@@ -60,10 +69,12 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size)
GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) {
ASSERT((gpu_addr & page_mask) == 0);
+ const u64 aligned_size{Common::AlignUp(size, page_size)};
const CacheAddr cache_addr{ToCacheAddr(GetPointer(gpu_addr))};
- Core::System::GetInstance().Renderer().Rasterizer().FlushAndInvalidateRegion(cache_addr, size);
- UnmapRange(gpu_addr, ((size + page_mask) & ~page_mask));
+ Core::System::GetInstance().Renderer().Rasterizer().FlushAndInvalidateRegion(cache_addr,
+ aligned_size);
+ UnmapRange(gpu_addr, aligned_size);
return gpu_addr;
}