diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-05-27 22:59:04 +0200 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-05-27 22:59:04 +0200 |
commit | b8b6f94ba9a662857c40d819ac40755c7984cb16 (patch) | |
tree | 82b2c6097f4f4aff94313e06fd87aef5860908fa | |
parent | texture_cache: Use small vector for surface vectors (diff) | |
download | yuzu-b8b6f94ba9a662857c40d819ac40755c7984cb16.tar yuzu-b8b6f94ba9a662857c40d819ac40755c7984cb16.tar.gz yuzu-b8b6f94ba9a662857c40d819ac40755c7984cb16.tar.bz2 yuzu-b8b6f94ba9a662857c40d819ac40755c7984cb16.tar.lz yuzu-b8b6f94ba9a662857c40d819ac40755c7984cb16.tar.xz yuzu-b8b6f94ba9a662857c40d819ac40755c7984cb16.tar.zst yuzu-b8b6f94ba9a662857c40d819ac40755c7984cb16.zip |
-rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index d7e42697d..99f74e6c4 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -310,18 +310,20 @@ public: dst_surface.first->MarkAsModified(true, Tick()); } - TSurface TryFindFramebufferSurface(VAddr addr) { + TSurface TryFindFramebufferSurface(VAddr addr) const { if (!addr) { return nullptr; } const VAddr page = addr >> registry_page_bits; - std::vector<TSurface>& list = registry[page]; - for (auto& surface : list) { - if (surface->GetCpuAddr() == addr) { - return surface; - } + const auto it = registry.find(page); + if (it == registry.end()) { + 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() { @@ -1130,18 +1132,20 @@ private: return {}; } 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; VectorSurface surfaces; - while (start <= end) { - std::vector<TSurface>& list = registry[start]; - for (auto& surface : list) { - if (!surface->IsPicked() && surface->Overlaps(cpu_addr, cpu_addr_end)) { - surface->MarkAsPicked(true); - surfaces.push_back(surface); + for (VAddr start = cpu_addr >> registry_page_bits; start <= end; ++start) { + const auto it = registry.find(start); + if (it == registry.end()) { + continue; + } + for (auto& surface : it->second) { + if (surface->IsPicked() || !surface->Overlaps(cpu_addr, cpu_addr_end)) { + continue; } + surface->MarkAsPicked(true); + surfaces.push_back(surface); } - start++; } for (auto& surface : surfaces) { surface->MarkAsPicked(false); |