texture_cache: Use unordered_map::find instead of operator[] on hot code
This commit is contained in:
parent
d2b2557542
commit
b8b6f94ba9
|
@ -310,19 +310,21 @@ public:
|
||||||
dst_surface.first->MarkAsModified(true, Tick());
|
dst_surface.first->MarkAsModified(true, Tick());
|
||||||
}
|
}
|
||||||
|
|
||||||
TSurface TryFindFramebufferSurface(VAddr addr) {
|
TSurface TryFindFramebufferSurface(VAddr addr) const {
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
const VAddr page = addr >> registry_page_bits;
|
const VAddr page = addr >> registry_page_bits;
|
||||||
std::vector<TSurface>& list = registry[page];
|
const auto it = registry.find(page);
|
||||||
for (auto& surface : list) {
|
if (it == registry.end()) {
|
||||||
if (surface->GetCpuAddr() == addr) {
|
|
||||||
return surface;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
const auto& list = it->second;
|
||||||
|
const auto found = std::find_if(list.begin(), list.end(), [addr](const auto& surface) {
|
||||||
|
return surface->GetCpuAddr() == addr;
|
||||||
|
});
|
||||||
|
return found != list.end() ? *found : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
u64 Tick() {
|
u64 Tick() {
|
||||||
return ++ticks;
|
return ++ticks;
|
||||||
|
@ -1130,19 +1132,21 @@ private:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const VAddr cpu_addr_end = cpu_addr + size;
|
const VAddr cpu_addr_end = cpu_addr + size;
|
||||||
VAddr start = cpu_addr >> registry_page_bits;
|
|
||||||
const VAddr end = (cpu_addr_end - 1) >> registry_page_bits;
|
const VAddr end = (cpu_addr_end - 1) >> registry_page_bits;
|
||||||
VectorSurface surfaces;
|
VectorSurface surfaces;
|
||||||
while (start <= end) {
|
for (VAddr start = cpu_addr >> registry_page_bits; start <= end; ++start) {
|
||||||
std::vector<TSurface>& list = registry[start];
|
const auto it = registry.find(start);
|
||||||
for (auto& surface : list) {
|
if (it == registry.end()) {
|
||||||
if (!surface->IsPicked() && surface->Overlaps(cpu_addr, cpu_addr_end)) {
|
continue;
|
||||||
|
}
|
||||||
|
for (auto& surface : it->second) {
|
||||||
|
if (surface->IsPicked() || !surface->Overlaps(cpu_addr, cpu_addr_end)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
surface->MarkAsPicked(true);
|
surface->MarkAsPicked(true);
|
||||||
surfaces.push_back(surface);
|
surfaces.push_back(surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
start++;
|
|
||||||
}
|
|
||||||
for (auto& surface : surfaces) {
|
for (auto& surface : surfaces) {
|
||||||
surface->MarkAsPicked(false);
|
surface->MarkAsPicked(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue