From 0649f0590047e8cc0b16a10dec5eb74938fef718 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Wed, 15 Apr 2020 16:36:14 -0400 Subject: QueryCache: Implement Async Flushes. --- src/video_core/query_cache.h | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/video_core/query_cache.h') diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index 5ea2b01f2..1b1c23995 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "common/assert.h" @@ -130,6 +131,7 @@ public: } query->BindCounter(Stream(type).Current(), timestamp); + AsyncFlushQuery(cpu_addr); } /// Updates counters from GPU state. Expected to be called once per draw, clear or dispatch. @@ -170,6 +172,44 @@ public: return streams[static_cast(type)]; } + void CommitAsyncFlushes() { + commited_flushes.push_back(uncommited_flushes); + uncommited_flushes.reset(); + } + + bool HasUncommitedFlushes() { + if (uncommited_flushes) { + return true; + } + return false; + } + + bool ShouldWaitAsyncFlushes() { + if (commited_flushes.empty()) { + return false; + } + auto& flush_list = commited_flushes.front(); + if (!flush_list) { + return false; + } + return true; + } + + void PopAsyncFlushes() { + if (commited_flushes.empty()) { + return; + } + auto& flush_list = commited_flushes.front(); + if (!flush_list) { + commited_flushes.pop_front(); + return; + } + for (VAddr query_address : *flush_list) { + FlushAndRemoveRegion(query_address, 4); + } + commited_flushes.pop_front(); + } + protected: std::array query_pools; @@ -224,6 +264,13 @@ private: return found != std::end(contents) ? &*found : nullptr; } + void AsyncFlushQuery(VAddr addr) { + if (!uncommited_flushes) { + uncommited_flushes = std::make_shared>(); + } + uncommited_flushes->insert(addr); + } + static constexpr std::uintptr_t PAGE_SIZE = 4096; static constexpr unsigned PAGE_SHIFT = 12; @@ -235,6 +282,9 @@ private: std::unordered_map> cached_queries; std::array streams; + + std::shared_ptr> uncommited_flushes{}; + std::list>> commited_flushes; }; template -- cgit v1.2.3