mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-05 13:20:11 +00:00
perf(agc): decode a label write without allocating before noting a taken store
noteLabelIssue runs for every executed store packet. RELEASE_MEM and WRITE_DATA, the common label writes, now go through DecodeLabelWrite, which DecodeStores already used for them and which allocates nothing, and stores the label history doesn't keep are dropped before labelStoresMutex is taken.
This commit is contained in:
1 parent
5e06fd0776
commit
780d350fbb
1 file changed
+19
-12
+19
-12
@@ -39,21 +39,28 @@ void Driver::noteLabelPass(std::span<const std::uint32_t> packet, std::uint32_t
|
||||
}
|
||||
|
||||
void Driver::noteLabelIssue(std::span<const std::uint32_t> packet, std::uint32_t queue) {
|
||||
switch ((packet[0] >> 8u) & 0xffu) {
|
||||
case 0x37: case 0x40: case 0x49: case 0x50: case 0x83: break;
|
||||
default: return;
|
||||
}
|
||||
const auto stores = Pm4::DecodeStores(packet);
|
||||
if (stores.empty()) return;
|
||||
std::lock_guard lock(labelStoresMutex);
|
||||
if (labelPasses.empty()) return;
|
||||
for (const auto& store : stores) {
|
||||
if (store.conditional || !KeepsLabelStore(store.address, static_cast<std::size_t>(store.bytes))) continue;
|
||||
for (std::uint64_t offset = 0; offset < store.bytes; offset += 4) {
|
||||
const auto key = queueDword(queue, store.address + offset);
|
||||
const auto take = [&](std::uint64_t address, std::uint64_t bytes) {
|
||||
for (std::uint64_t offset = 0; offset < bytes; offset += 4) {
|
||||
const auto key = queueDword(queue, address + offset);
|
||||
if (const auto pass = labelPasses.find(key); pass != labelPasses.end()) labelTaken[key] = pass->second;
|
||||
}
|
||||
};
|
||||
switch ((packet[0] >> 8u) & 0xffu) {
|
||||
case 0x37: case 0x49: {
|
||||
const auto label = Pm4::DecodeLabelWrite(packet);
|
||||
if (!label.has_value() || !KeepsLabelStore(label->address, label->Bytes().size())) return;
|
||||
std::lock_guard lock(labelStoresMutex);
|
||||
take(label->address, label->Bytes().size());
|
||||
return;
|
||||
}
|
||||
case 0x40: case 0x50: case 0x83: break;
|
||||
default: return;
|
||||
}
|
||||
auto stores = Pm4::DecodeStores(packet);
|
||||
std::erase_if(stores, [](const Pm4::PacketStore& store) { return store.conditional || !KeepsLabelStore(store.address, static_cast<std::size_t>(store.bytes)); });
|
||||
if (stores.empty()) return;
|
||||
std::lock_guard lock(labelStoresMutex);
|
||||
for (const auto& store : stores) take(store.address, store.bytes);
|
||||
}
|
||||
|
||||
bool Driver::storedSince(std::span<const std::uint32_t> packet, std::uint64_t address, std::size_t bytes, std::uint64_t received, std::uint32_t queue, std::uint32_t* writer) {
|
||||
|
||||
Reference in new issue
Block a user