summaryrefslogtreecommitdiffstats
path: root/src/video_core/query_cache.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/query_cache.h')
-rw-r--r--src/video_core/query_cache.h50
1 files changed, 50 insertions, 0 deletions
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 <mutex>
#include <optional>
#include <unordered_map>
+#include <unordered_set>
#include <vector>
#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<std::size_t>(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<QueryPool, VideoCore::NumQueryTypes> 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<std::unordered_set<VAddr>>();
+ }
+ 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<u64, std::vector<CachedQuery>> cached_queries;
std::array<CounterStream, VideoCore::NumQueryTypes> streams;
+
+ std::shared_ptr<std::unordered_set<VAddr>> uncommited_flushes{};
+ std::list<std::shared_ptr<std::unordered_set<VAddr>>> commited_flushes;
};
template <class QueryCache, class HostCounter>