diff options
| -rw-r--r-- | src/video_core/memory_manager.cpp | 33 |
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() { | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) { | 31 | GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) { |
| 32 | const u64 aligned_size{Common::AlignUp(size, page_size)}; | ||
| 32 | const GPUVAddr gpu_addr{ | 33 | const GPUVAddr gpu_addr{ |
| 33 | FindFreeRegion(address_space_base, size, align, VirtualMemoryArea::Type::Unmapped)}; | 34 | FindFreeRegion(address_space_base, aligned_size, align, VirtualMemoryArea::Type::Unmapped)}; |
| 34 | AllocateMemory(gpu_addr, 0, size); | 35 | |
| 36 | AllocateMemory(gpu_addr, 0, aligned_size); | ||
| 37 | |||
| 35 | return gpu_addr; | 38 | return gpu_addr; |
| 36 | } | 39 | } |
| 37 | 40 | ||
| 38 | GPUVAddr MemoryManager::AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align) { | 41 | GPUVAddr MemoryManager::AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align) { |
| 39 | AllocateMemory(gpu_addr, 0, size); | 42 | const u64 aligned_size{Common::AlignUp(size, page_size)}; |
| 43 | |||
| 44 | AllocateMemory(gpu_addr, 0, aligned_size); | ||
| 45 | |||
| 40 | return gpu_addr; | 46 | return gpu_addr; |
| 41 | } | 47 | } |
| 42 | 48 | ||
| 43 | GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) { | 49 | GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) { |
| 44 | const GPUVAddr gpu_addr{ | 50 | const u64 aligned_size{Common::AlignUp(size, page_size)}; |
| 45 | FindFreeRegion(address_space_base, size, page_size, VirtualMemoryArea::Type::Unmapped)}; | 51 | const GPUVAddr gpu_addr{FindFreeRegion(address_space_base, aligned_size, page_size, |
| 46 | MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), ((size + page_mask) & ~page_mask), | 52 | VirtualMemoryArea::Type::Unmapped)}; |
| 47 | cpu_addr); | 53 | |
| 54 | MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr); | ||
| 55 | |||
| 48 | return gpu_addr; | 56 | return gpu_addr; |
| 49 | } | 57 | } |
| 50 | 58 | ||
| 51 | GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size) { | 59 | GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size) { |
| 52 | ASSERT((gpu_addr & page_mask) == 0); | 60 | ASSERT((gpu_addr & page_mask) == 0); |
| 53 | 61 | ||
| 54 | MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), ((size + page_mask) & ~page_mask), | 62 | const u64 aligned_size{Common::AlignUp(size, page_size)}; |
| 55 | cpu_addr); | 63 | |
| 64 | MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr); | ||
| 56 | 65 | ||
| 57 | return gpu_addr; | 66 | return gpu_addr; |
| 58 | } | 67 | } |
| @@ -60,10 +69,12 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size) | |||
| 60 | GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) { | 69 | GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) { |
| 61 | ASSERT((gpu_addr & page_mask) == 0); | 70 | ASSERT((gpu_addr & page_mask) == 0); |
| 62 | 71 | ||
| 72 | const u64 aligned_size{Common::AlignUp(size, page_size)}; | ||
| 63 | const CacheAddr cache_addr{ToCacheAddr(GetPointer(gpu_addr))}; | 73 | const CacheAddr cache_addr{ToCacheAddr(GetPointer(gpu_addr))}; |
| 64 | Core::System::GetInstance().Renderer().Rasterizer().FlushAndInvalidateRegion(cache_addr, size); | ||
| 65 | 74 | ||
| 66 | UnmapRange(gpu_addr, ((size + page_mask) & ~page_mask)); | 75 | Core::System::GetInstance().Renderer().Rasterizer().FlushAndInvalidateRegion(cache_addr, |
| 76 | aligned_size); | ||
| 77 | UnmapRange(gpu_addr, aligned_size); | ||
| 67 | 78 | ||
| 68 | return gpu_addr; | 79 | return gpu_addr; |
| 69 | } | 80 | } |