mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 19:00:14 -05:00
memory_manager: Use Common::AlignUp in public interface as needed.
This commit is contained in:
parent
72837e4b3d
commit
5a5fccaa23
1 changed files with 22 additions and 11 deletions
|
@ -29,30 +29,39 @@ MemoryManager::MemoryManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) {
|
GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) {
|
||||||
|
const u64 aligned_size{Common::AlignUp(size, page_size)};
|
||||||
const GPUVAddr gpu_addr{
|
const GPUVAddr gpu_addr{
|
||||||
FindFreeRegion(address_space_base, size, align, VirtualMemoryArea::Type::Unmapped)};
|
FindFreeRegion(address_space_base, aligned_size, align, VirtualMemoryArea::Type::Unmapped)};
|
||||||
AllocateMemory(gpu_addr, 0, size);
|
|
||||||
|
AllocateMemory(gpu_addr, 0, aligned_size);
|
||||||
|
|
||||||
return gpu_addr;
|
return gpu_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUVAddr MemoryManager::AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align) {
|
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;
|
return gpu_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) {
|
GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) {
|
||||||
const GPUVAddr gpu_addr{
|
const u64 aligned_size{Common::AlignUp(size, page_size)};
|
||||||
FindFreeRegion(address_space_base, size, page_size, VirtualMemoryArea::Type::Unmapped)};
|
const GPUVAddr gpu_addr{FindFreeRegion(address_space_base, aligned_size, page_size,
|
||||||
MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), ((size + page_mask) & ~page_mask),
|
VirtualMemoryArea::Type::Unmapped)};
|
||||||
cpu_addr);
|
|
||||||
|
MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr);
|
||||||
|
|
||||||
return gpu_addr;
|
return gpu_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size) {
|
GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size) {
|
||||||
ASSERT((gpu_addr & page_mask) == 0);
|
ASSERT((gpu_addr & page_mask) == 0);
|
||||||
|
|
||||||
MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), ((size + page_mask) & ~page_mask),
|
const u64 aligned_size{Common::AlignUp(size, page_size)};
|
||||||
cpu_addr);
|
|
||||||
|
MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr);
|
||||||
|
|
||||||
return gpu_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) {
|
GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) {
|
||||||
ASSERT((gpu_addr & page_mask) == 0);
|
ASSERT((gpu_addr & page_mask) == 0);
|
||||||
|
|
||||||
|
const u64 aligned_size{Common::AlignUp(size, page_size)};
|
||||||
const CacheAddr cache_addr{ToCacheAddr(GetPointer(gpu_addr))};
|
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;
|
return gpu_addr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue