diff options
| -rw-r--r-- | src/video_core/command_processor.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 2095e7b15..2a1c885a7 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -135,27 +135,32 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 135 | } | 135 | } |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | // map physical start address to size | 138 | class { |
| 139 | std::map<u32, u32> accessed_ranges; | 139 | /// Combine overlapping and close ranges |
| 140 | static auto SimplifyRanges = [](std::map<u32, u32>& ranges) { | 140 | void SimplifyRanges() { |
| 141 | for (auto it = ranges.begin(); it != ranges.end(); ++it) { | 141 | for (auto it = ranges.begin(); it != ranges.end(); ++it) { |
| 142 | 142 | // NOTE: We add 32 to the range end address to make sure "close" ranges are combined, too | |
| 143 | // Combine overlapping ranges ... artificially extend first range by 32 bytes to merge "close" ranges | 143 | auto it2 = std::next(it); |
| 144 | auto it2 = std::next(it); | 144 | while (it2 != ranges.end() && it->first + it->second + 32 >= it2->first) { |
| 145 | while (it2 != ranges.end() && it->first + it->second + 32 >= it2->first) { | 145 | it->second = std::max(it->second, it2->first + it2->second - it->first); |
| 146 | it->second = std::max(it->second, it2->first + it2->second - it->first); | 146 | it2 = ranges.erase(it2); |
| 147 | it2 = ranges.erase(it2); | 147 | } |
| 148 | } | 148 | } |
| 149 | } | 149 | } |
| 150 | }; | ||
| 151 | 150 | ||
| 152 | static auto AddMemoryAccess = [](std::map<u32, u32>& ranges, u32 paddr, u32 size) { | 151 | public: |
| 153 | // Create new range or extend existing one | 152 | /// Record a particular memory access in the list |
| 154 | ranges[paddr] = std::max(ranges[paddr], size); | 153 | void AddAccess(u32 paddr, u32 size) { |
| 154 | // Create new range or extend existing one | ||
| 155 | ranges[paddr] = std::max(ranges[paddr], size); | ||
| 156 | |||
| 157 | // Simplify ranges... | ||
| 158 | SimplifyRanges(); | ||
| 159 | } | ||
| 155 | 160 | ||
| 156 | // Simplify ranges... | 161 | /// Map of accessed ranges (mapping start address to range size) |
| 157 | SimplifyRanges(ranges); | 162 | std::map<u32, u32> ranges; |
| 158 | }; | 163 | } memory_accesses; |
| 159 | 164 | ||
| 160 | for (unsigned int index = 0; index < regs.num_vertices; ++index) | 165 | for (unsigned int index = 0; index < regs.num_vertices; ++index) |
| 161 | { | 166 | { |
| @@ -165,7 +170,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 165 | // TODO: Implement some sort of vertex cache! | 170 | // TODO: Implement some sort of vertex cache! |
| 166 | if (g_debug_context && Pica::g_debug_context->recorder) { | 171 | if (g_debug_context && Pica::g_debug_context->recorder) { |
| 167 | int size = index_u16 ? 2 : 1; | 172 | int size = index_u16 ? 2 : 1; |
| 168 | AddMemoryAccess(accessed_ranges, base_address + index_info.offset + size*index, size); | 173 | memory_accesses.AddAccess(base_address + index_info.offset + size * index, size); |
| 169 | } | 174 | } |
| 170 | } | 175 | } |
| 171 | 176 | ||
| @@ -193,9 +198,9 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 193 | const u8* srcdata = Memory::GetPhysicalPointer(source_addr); | 198 | const u8* srcdata = Memory::GetPhysicalPointer(source_addr); |
| 194 | 199 | ||
| 195 | if (g_debug_context && Pica::g_debug_context->recorder) { | 200 | if (g_debug_context && Pica::g_debug_context->recorder) { |
| 196 | AddMemoryAccess(accessed_ranges, source_addr, | 201 | memory_accesses.AddAccess(source_addr, |
| 197 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::FLOAT) ? 4 | 202 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::FLOAT) ? 4 |
| 198 | : (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? 2 : 1); | 203 | : (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? 2 : 1); |
| 199 | } | 204 | } |
| 200 | 205 | ||
| 201 | const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata : | 206 | const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata : |
| @@ -258,7 +263,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 258 | } | 263 | } |
| 259 | } | 264 | } |
| 260 | 265 | ||
| 261 | for (auto& range : accessed_ranges) { | 266 | for (auto& range : memory_accesses.ranges) { |
| 262 | g_debug_context->recorder->MemoryAccessed(Memory::GetPhysicalPointer(range.first), | 267 | g_debug_context->recorder->MemoryAccessed(Memory::GetPhysicalPointer(range.first), |
| 263 | range.second, range.first); | 268 | range.second, range.first); |
| 264 | } | 269 | } |