From aa6587d854e4953876b02ca71278a665bcae8179 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 4 Aug 2023 13:38:49 +0200 Subject: QueryCache: Implement dependant queries. --- src/video_core/query_cache/query_base.h | 1 + src/video_core/query_cache/query_cache.h | 18 ++++++++++++++++-- src/video_core/query_cache/query_stream.h | 6 +++++- 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src/video_core/query_cache') diff --git a/src/video_core/query_cache/query_base.h b/src/video_core/query_cache/query_base.h index 485ed669c..0ae23af9f 100644 --- a/src/video_core/query_cache/query_base.h +++ b/src/video_core/query_cache/query_base.h @@ -18,6 +18,7 @@ enum class QueryFlagBits : u32 { IsInvalidated = 1 << 6, ///< Indicates the value of th query has been nullified. IsOrphan = 1 << 7, ///< Indicates the query has not been set by a guest query. IsFence = 1 << 8, ///< Indicates the query is a fence. + IsQueuedForAsyncFlush = 1 <<9,///< Indicates that the query can be flushed at any moment }; DECLARE_ENUM_FLAG_OPERATORS(QueryFlagBits) diff --git a/src/video_core/query_cache/query_cache.h b/src/video_core/query_cache/query_cache.h index f6af48d14..f1393d5c7 100644 --- a/src/video_core/query_cache/query_cache.h +++ b/src/video_core/query_cache/query_cache.h @@ -489,8 +489,22 @@ void QueryCacheBase::PopAsyncFlushes() { if (mask == 0) { return; } - impl->ForEachStreamerIn(mask, - [](StreamerInterface* streamer) { streamer->PopUnsyncedQueries(); }); + u64 ran_mask = 0; + u64 next_phase = 0; + while (mask) { + impl->ForEachStreamerIn(mask, [&mask, &ran_mask, &next_phase](StreamerInterface* streamer) { + u64 dep_mask = streamer->GetDependenceMask(); + if ((dep_mask & ~ran_mask) != 0) { + next_phase |= dep_mask; + return; + } + u64 index = streamer->GetId(); + ran_mask |= (1ULL << index); + mask &= ~(1ULL << index); + streamer->PopUnsyncedQueries(); + }); + ran_mask |= next_phase; + } } // Invalidation diff --git a/src/video_core/query_cache/query_stream.h b/src/video_core/query_cache/query_stream.h index dd5f95b3c..0e9275565 100644 --- a/src/video_core/query_cache/query_stream.h +++ b/src/video_core/query_cache/query_stream.h @@ -70,6 +70,10 @@ public: return id; } + u64 GetDependenceMask() const { + return dependance_mask; + } + protected: const size_t id; const u64 dependance_mask; @@ -78,7 +82,7 @@ protected: template class SimpleStreamer : public StreamerInterface { public: - SimpleStreamer(size_t id_) : StreamerInterface{id_} {} + SimpleStreamer(size_t id_, u64 dependance_mask_ = 0) : StreamerInterface{id_, dependance_mask_} {} virtual ~SimpleStreamer() = default; protected: -- cgit v1.2.3