summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/memory_manager.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp
index 2f814a184..98a6ca040 100644
--- a/src/video_core/memory_manager.cpp
+++ b/src/video_core/memory_manager.cpp
@@ -13,8 +13,10 @@ GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) {
13 ASSERT(gpu_addr); 13 ASSERT(gpu_addr);
14 14
15 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) { 15 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) {
16 ASSERT(PageSlot(*gpu_addr + offset) == static_cast<u64>(PageStatus::Unmapped)); 16 VAddr& slot = PageSlot(*gpu_addr + offset);
17 PageSlot(*gpu_addr + offset) = static_cast<u64>(PageStatus::Allocated); 17
18 ASSERT(slot == static_cast<u64>(PageStatus::Unmapped));
19 slot = static_cast<u64>(PageStatus::Allocated);
18 } 20 }
19 21
20 return *gpu_addr; 22 return *gpu_addr;
@@ -22,8 +24,10 @@ GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) {
22 24
23GPUVAddr MemoryManager::AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align) { 25GPUVAddr MemoryManager::AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align) {
24 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) { 26 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) {
25 ASSERT(PageSlot(gpu_addr + offset) == static_cast<u64>(PageStatus::Unmapped)); 27 VAddr& slot = PageSlot(gpu_addr + offset);
26 PageSlot(gpu_addr + offset) = static_cast<u64>(PageStatus::Allocated); 28
29 ASSERT(slot == static_cast<u64>(PageStatus::Unmapped));
30 slot = static_cast<u64>(PageStatus::Allocated);
27 } 31 }
28 32
29 return gpu_addr; 33 return gpu_addr;
@@ -34,8 +38,10 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) {
34 ASSERT(gpu_addr); 38 ASSERT(gpu_addr);
35 39
36 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) { 40 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) {
37 ASSERT(PageSlot(*gpu_addr + offset) == static_cast<u64>(PageStatus::Unmapped)); 41 VAddr& slot = PageSlot(*gpu_addr + offset);
38 PageSlot(*gpu_addr + offset) = cpu_addr + offset; 42
43 ASSERT(slot == static_cast<u64>(PageStatus::Unmapped));
44 slot = cpu_addr + offset;
39 } 45 }
40 46
41 MappedRegion region{cpu_addr, *gpu_addr, size}; 47 MappedRegion region{cpu_addr, *gpu_addr, size};
@@ -48,8 +54,10 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size)
48 ASSERT((gpu_addr & PAGE_MASK) == 0); 54 ASSERT((gpu_addr & PAGE_MASK) == 0);
49 55
50 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) { 56 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) {
51 ASSERT(PageSlot(gpu_addr + offset) == static_cast<u64>(PageStatus::Allocated)); 57 VAddr& slot = PageSlot(gpu_addr + offset);
52 PageSlot(gpu_addr + offset) = cpu_addr + offset; 58
59 ASSERT(slot == static_cast<u64>(PageStatus::Allocated));
60 slot = cpu_addr + offset;
53 } 61 }
54 62
55 MappedRegion region{cpu_addr, gpu_addr, size}; 63 MappedRegion region{cpu_addr, gpu_addr, size};
@@ -62,9 +70,11 @@ GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) {
62 ASSERT((gpu_addr & PAGE_MASK) == 0); 70 ASSERT((gpu_addr & PAGE_MASK) == 0);
63 71
64 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) { 72 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) {
65 ASSERT(PageSlot(gpu_addr + offset) != static_cast<u64>(PageStatus::Allocated) && 73 VAddr& slot = PageSlot(gpu_addr + offset);
66 PageSlot(gpu_addr + offset) != static_cast<u64>(PageStatus::Unmapped)); 74
67 PageSlot(gpu_addr + offset) = static_cast<u64>(PageStatus::Unmapped); 75 ASSERT(slot != static_cast<u64>(PageStatus::Allocated) &&
76 slot != static_cast<u64>(PageStatus::Unmapped));
77 slot = static_cast<u64>(PageStatus::Unmapped);
68 } 78 }
69 79
70 // Delete the region mappings that are contained within the unmapped region 80 // Delete the region mappings that are contained within the unmapped region