Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2582,7 +2582,25 @@ void GuestBufferMemory::AddSnapshot(const GuestMemorySnapshot& snapshot) {
}
const auto offset = static_cast<std::size_t>(snapshot.address - owner->begin);
const auto* source = live ? reinterpret_cast<const std::byte*>(snapshot.address) : owner->snapshot.data() + offset;
Require(std::memcmp(source, snapshot.bytes.data(), snapshot.bytes.size()) == 0, "guest snapshot differs from registered memory");
if (std::memcmp(source, snapshot.bytes.data(), snapshot.bytes.size()) != 0) {
std::size_t first = 0;
while (first < snapshot.bytes.size() && source[first] == snapshot.bytes[first]) ++first;
char text[256];
std::snprintf(text, sizeof(text), "guest snapshot differs from registered memory: snapshot 0x%llx+0x%zx (%s region 0x%llx+0x%llx%s%s%s) differs first at +0x%zx", static_cast<unsigned long long>(snapshot.address), snapshot.bytes.size(), live ? "live" : "snapshot-backed", static_cast<unsigned long long>(owner->begin), static_cast<unsigned long long>(owner->end - owner->begin), owner->writable ? ", writable" : "", owner->hostBacked ? ", host-backed" : "", owner->mirror != nullptr ? ", mirrored" : "", first);
static const bool fatal = std::getenv("APS5_SNAPSHOT_CHECK_FATAL") != nullptr;
if (!live || fatal) throw std::runtime_error(text);
static std::mutex reportMutex;
static std::uint64_t mismatches = 0;
static auto lastReport = std::chrono::steady_clock::now() - std::chrono::seconds(60);
std::lock_guard lock(reportMutex);
++mismatches;
const auto now = std::chrono::steady_clock::now();
if (now - lastReport >= std::chrono::seconds(10)) {
lastReport = now;
std::fprintf(stderr, "[gpu] %s; the live region serves the GPU (%llu mismatches so far; APS5_SNAPSHOT_CHECK_FATAL=1 fails the dispatch instead)\n", text, static_cast<unsigned long long>(mismatches));
}
return;
}
if (profile) Snapshots().checked.fetch_add(1, std::memory_order_relaxed);
return;
}
Expand Down
Loading