diff options
author | Tony Wasserka <NeoBrainX@gmail.com> | 2015-05-21 02:24:24 +0200 |
---|---|---|
committer | Tony Wasserka <NeoBrainX@gmail.com> | 2015-07-13 22:27:21 +0200 |
commit | 0799b40caad0deff18d5fd8cf82955156273f157 (patch) | |
tree | 6f5dc12a68c0689766540850e2062e880cc8a0cc | |
parent | citra-qt: Properly disable the CiTrace widget upon starting/stopping emulation. (diff) | |
download | yuzu-0799b40caad0deff18d5fd8cf82955156273f157.tar yuzu-0799b40caad0deff18d5fd8cf82955156273f157.tar.gz yuzu-0799b40caad0deff18d5fd8cf82955156273f157.tar.bz2 yuzu-0799b40caad0deff18d5fd8cf82955156273f157.tar.lz yuzu-0799b40caad0deff18d5fd8cf82955156273f157.tar.xz yuzu-0799b40caad0deff18d5fd8cf82955156273f157.tar.zst yuzu-0799b40caad0deff18d5fd8cf82955156273f157.zip |
-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) { } } - // map physical start address to size - std::map<u32, u32> accessed_ranges; - static auto SimplifyRanges = [](std::map<u32, u32>& ranges) { - for (auto it = ranges.begin(); it != ranges.end(); ++it) { - - // Combine overlapping ranges ... artificially extend first range by 32 bytes to merge "close" ranges - auto it2 = std::next(it); - while (it2 != ranges.end() && it->first + it->second + 32 >= it2->first) { - it->second = std::max(it->second, it2->first + it2->second - it->first); - it2 = ranges.erase(it2); + class { + /// Combine overlapping and close ranges + void SimplifyRanges() { + for (auto it = ranges.begin(); it != ranges.end(); ++it) { + // NOTE: We add 32 to the range end address to make sure "close" ranges are combined, too + auto it2 = std::next(it); + while (it2 != ranges.end() && it->first + it->second + 32 >= it2->first) { + it->second = std::max(it->second, it2->first + it2->second - it->first); + it2 = ranges.erase(it2); + } } } - }; - static auto AddMemoryAccess = [](std::map<u32, u32>& ranges, u32 paddr, u32 size) { - // Create new range or extend existing one - ranges[paddr] = std::max(ranges[paddr], size); + public: + /// Record a particular memory access in the list + void AddAccess(u32 paddr, u32 size) { + // Create new range or extend existing one + ranges[paddr] = std::max(ranges[paddr], size); + + // Simplify ranges... + SimplifyRanges(); + } - // Simplify ranges... - SimplifyRanges(ranges); - }; + /// Map of accessed ranges (mapping start address to range size) + std::map<u32, u32> ranges; + } memory_accesses; for (unsigned int index = 0; index < regs.num_vertices; ++index) { @@ -165,7 +170,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { // TODO: Implement some sort of vertex cache! if (g_debug_context && Pica::g_debug_context->recorder) { int size = index_u16 ? 2 : 1; - AddMemoryAccess(accessed_ranges, base_address + index_info.offset + size*index, size); + memory_accesses.AddAccess(base_address + index_info.offset + size * index, size); } } @@ -193,9 +198,9 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { const u8* srcdata = Memory::GetPhysicalPointer(source_addr); if (g_debug_context && Pica::g_debug_context->recorder) { - AddMemoryAccess(accessed_ranges, source_addr, - (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::FLOAT) ? 4 - : (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? 2 : 1); + memory_accesses.AddAccess(source_addr, + (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::FLOAT) ? 4 + : (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? 2 : 1); } 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) { } } - for (auto& range : accessed_ranges) { + for (auto& range : memory_accesses.ranges) { g_debug_context->recorder->MemoryAccessed(Memory::GetPhysicalPointer(range.first), range.second, range.first); } |