Debugger: Combine mem info on duplicates.

Gran Turismo does some churn on texture sizes, we can combine them and
reduce the speed hit even when detailed.
This commit is contained in:
Unknown W. Brackets committed 2022-11-18 23:11:11 -08:00
1 parent 2e6a19fadc
commit 3938c0a3af
1 file changed
+33 -7
+33 -7
View File
@@ -405,6 +405,29 @@ static inline uint32_t NormalizeAddress(uint32_t addr) {
return addr & 0x3FFFFFFF;
}
static inline bool MergeRecentMemInfo(const PendingNotifyMem &info, size_t copyLength) {
if (pendingNotifies.size() < 4)
return false;
for (size_t i = 1; i <= 4; ++i) {
auto &prev = pendingNotifies[pendingNotifies.size() - i];
if (prev.start >= info.start + info.size || prev.start + prev.size <= info.start)
continue;
// This means there's overlap, but not a match, so we can't combine any.
if (prev.start != info.start || prev.size > info.size)
return false;
memcpy(prev.tag, info.tag, copyLength + 1);
prev.size = info.size;
prev.ticks = info.ticks;
prev.pc = info.pc;
return true;
}
return false;
}
void NotifyMemInfoPC(MemBlockFlags flags, uint32_t start, uint32_t size, uint32_t pc, const char *tagStr, size_t strLength) {
if (size == 0) {
return;
@@ -427,14 +450,17 @@ void NotifyMemInfoPC(MemBlockFlags flags, uint32_t start, uint32_t size, uint32_
info.tag[copyLength] = 0;
std::lock_guard<std::mutex> guard(pendingMutex);
if (start < 0x08000000) {
pendingNotifyMinAddr1 = std::min(pendingNotifyMinAddr1.load(), start);
pendingNotifyMaxAddr1 = std::max(pendingNotifyMaxAddr1.load(), start + size);
} else {
pendingNotifyMinAddr2 = std::min(pendingNotifyMinAddr2.load(), start);
pendingNotifyMaxAddr2 = std::max(pendingNotifyMaxAddr2.load(), start + size);
// Sometimes we get duplicates, quickly check.
if (!MergeRecentMemInfo(info, copyLength)) {
if (start < 0x08000000) {
pendingNotifyMinAddr1 = std::min(pendingNotifyMinAddr1.load(), start);
pendingNotifyMaxAddr1 = std::max(pendingNotifyMaxAddr1.load(), start + size);
} else {
pendingNotifyMinAddr2 = std::min(pendingNotifyMinAddr2.load(), start);
pendingNotifyMaxAddr2 = std::max(pendingNotifyMaxAddr2.load(), start + size);
}
pendingNotifies.push_back(info);
}
pendingNotifies.push_back(info);
needFlush = pendingNotifies.size() > MAX_PENDING_NOTIFIES;
}