diff options
| -rw-r--r-- | src/video_core/memory_manager.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/memory_manager.h | 4 |
2 files changed, 6 insertions, 12 deletions
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 6dc133c93..e76b59842 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp | |||
| @@ -30,8 +30,7 @@ MemoryManager::MemoryManager() { | |||
| 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 u64 aligned_size{Common::AlignUp(size, page_size)}; |
| 33 | const GPUVAddr gpu_addr{ | 33 | const GPUVAddr gpu_addr{FindFreeRegion(address_space_base, aligned_size)}; |
| 34 | FindFreeRegion(address_space_base, aligned_size, align, VirtualMemoryArea::Type::Unmapped)}; | ||
| 35 | 34 | ||
| 36 | AllocateMemory(gpu_addr, 0, aligned_size); | 35 | AllocateMemory(gpu_addr, 0, aligned_size); |
| 37 | 36 | ||
| @@ -48,8 +47,7 @@ GPUVAddr MemoryManager::AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align) { | |||
| 48 | 47 | ||
| 49 | GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) { | 48 | GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) { |
| 50 | const u64 aligned_size{Common::AlignUp(size, page_size)}; | 49 | const u64 aligned_size{Common::AlignUp(size, page_size)}; |
| 51 | const GPUVAddr gpu_addr{FindFreeRegion(address_space_base, aligned_size, page_size, | 50 | const GPUVAddr gpu_addr{FindFreeRegion(address_space_base, aligned_size)}; |
| 52 | VirtualMemoryArea::Type::Unmapped)}; | ||
| 53 | 51 | ||
| 54 | MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr); | 52 | MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr); |
| 55 | 53 | ||
| @@ -79,14 +77,10 @@ GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) { | |||
| 79 | return gpu_addr; | 77 | return gpu_addr; |
| 80 | } | 78 | } |
| 81 | 79 | ||
| 82 | GPUVAddr MemoryManager::FindFreeRegion(GPUVAddr region_start, u64 size, u64 align, | 80 | GPUVAddr MemoryManager::FindFreeRegion(GPUVAddr region_start, u64 size) { |
| 83 | VirtualMemoryArea::Type vma_type) { | ||
| 84 | |||
| 85 | align = (align + page_mask) & ~page_mask; | ||
| 86 | |||
| 87 | // Find the first Free VMA. | 81 | // Find the first Free VMA. |
| 88 | const VMAHandle vma_handle{std::find_if(vma_map.begin(), vma_map.end(), [&](const auto& vma) { | 82 | const VMAHandle vma_handle{std::find_if(vma_map.begin(), vma_map.end(), [&](const auto& vma) { |
| 89 | if (vma.second.type != vma_type) { | 83 | if (vma.second.type != VirtualMemoryArea::Type::Unmapped) { |
| 90 | return false; | 84 | return false; |
| 91 | } | 85 | } |
| 92 | 86 | ||
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h index 60ba6b858..34744bb27 100644 --- a/src/video_core/memory_manager.h +++ b/src/video_core/memory_manager.h | |||
| @@ -126,8 +126,8 @@ private: | |||
| 126 | /// Updates the pages corresponding to this VMA so they match the VMA's attributes. | 126 | /// Updates the pages corresponding to this VMA so they match the VMA's attributes. |
| 127 | void UpdatePageTableForVMA(const VirtualMemoryArea& vma); | 127 | void UpdatePageTableForVMA(const VirtualMemoryArea& vma); |
| 128 | 128 | ||
| 129 | GPUVAddr FindFreeRegion(GPUVAddr region_start, u64 size, u64 align, | 129 | /// Finds a free (unmapped region) of the specified size starting at the specified address. |
| 130 | VirtualMemoryArea::Type vma_type); | 130 | GPUVAddr FindFreeRegion(GPUVAddr region_start, u64 size); |
| 131 | 131 | ||
| 132 | private: | 132 | private: |
| 133 | static constexpr u64 page_bits{16}; | 133 | static constexpr u64 page_bits{16}; |