diff options
Diffstat (limited to 'src/video_core/query_cache.h')
| -rw-r--r-- | src/video_core/query_cache.h | 50 |
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 @@ | |||
| 12 | #include <mutex> | 12 | #include <mutex> |
| 13 | #include <optional> | 13 | #include <optional> |
| 14 | #include <unordered_map> | 14 | #include <unordered_map> |
| 15 | #include <unordered_set> | ||
| 15 | #include <vector> | 16 | #include <vector> |
| 16 | 17 | ||
| 17 | #include "common/assert.h" | 18 | #include "common/assert.h" |
| @@ -130,6 +131,7 @@ public: | |||
| 130 | } | 131 | } |
| 131 | 132 | ||
| 132 | query->BindCounter(Stream(type).Current(), timestamp); | 133 | query->BindCounter(Stream(type).Current(), timestamp); |
| 134 | AsyncFlushQuery(cpu_addr); | ||
| 133 | } | 135 | } |
| 134 | 136 | ||
| 135 | /// Updates counters from GPU state. Expected to be called once per draw, clear or dispatch. | 137 | /// Updates counters from GPU state. Expected to be called once per draw, clear or dispatch. |
| @@ -170,6 +172,44 @@ public: | |||
| 170 | return streams[static_cast<std::size_t>(type)]; | 172 | return streams[static_cast<std::size_t>(type)]; |
| 171 | } | 173 | } |
| 172 | 174 | ||
| 175 | void CommitAsyncFlushes() { | ||
| 176 | commited_flushes.push_back(uncommited_flushes); | ||
| 177 | uncommited_flushes.reset(); | ||
| 178 | } | ||
| 179 | |||
| 180 | bool HasUncommitedFlushes() { | ||
| 181 | if (uncommited_flushes) { | ||
| 182 | return true; | ||
| 183 | } | ||
| 184 | return false; | ||
| 185 | } | ||
| 186 | |||
| 187 | bool ShouldWaitAsyncFlushes() { | ||
| 188 | if (commited_flushes.empty()) { | ||
| 189 | return false; | ||
| 190 | } | ||
| 191 | auto& flush_list = commited_flushes.front(); | ||
| 192 | if (!flush_list) { | ||
| 193 | return false; | ||
| 194 | } | ||
| 195 | return true; | ||
| 196 | } | ||
| 197 | |||
| 198 | void PopAsyncFlushes() { | ||
| 199 | if (commited_flushes.empty()) { | ||
| 200 | return; | ||
| 201 | } | ||
| 202 | auto& flush_list = commited_flushes.front(); | ||
| 203 | if (!flush_list) { | ||
| 204 | commited_flushes.pop_front(); | ||
| 205 | return; | ||
| 206 | } | ||
| 207 | for (VAddr query_address : *flush_list) { | ||
| 208 | FlushAndRemoveRegion(query_address, 4); | ||
| 209 | } | ||
| 210 | commited_flushes.pop_front(); | ||
| 211 | } | ||
| 212 | |||
| 173 | protected: | 213 | protected: |
| 174 | std::array<QueryPool, VideoCore::NumQueryTypes> query_pools; | 214 | std::array<QueryPool, VideoCore::NumQueryTypes> query_pools; |
| 175 | 215 | ||
| @@ -224,6 +264,13 @@ private: | |||
| 224 | return found != std::end(contents) ? &*found : nullptr; | 264 | return found != std::end(contents) ? &*found : nullptr; |
| 225 | } | 265 | } |
| 226 | 266 | ||
| 267 | void AsyncFlushQuery(VAddr addr) { | ||
| 268 | if (!uncommited_flushes) { | ||
| 269 | uncommited_flushes = std::make_shared<std::unordered_set<VAddr>>(); | ||
| 270 | } | ||
| 271 | uncommited_flushes->insert(addr); | ||
| 272 | } | ||
| 273 | |||
| 227 | static constexpr std::uintptr_t PAGE_SIZE = 4096; | 274 | static constexpr std::uintptr_t PAGE_SIZE = 4096; |
| 228 | static constexpr unsigned PAGE_SHIFT = 12; | 275 | static constexpr unsigned PAGE_SHIFT = 12; |
| 229 | 276 | ||
| @@ -235,6 +282,9 @@ private: | |||
| 235 | std::unordered_map<u64, std::vector<CachedQuery>> cached_queries; | 282 | std::unordered_map<u64, std::vector<CachedQuery>> cached_queries; |
| 236 | 283 | ||
| 237 | std::array<CounterStream, VideoCore::NumQueryTypes> streams; | 284 | std::array<CounterStream, VideoCore::NumQueryTypes> streams; |
| 285 | |||
| 286 | std::shared_ptr<std::unordered_set<VAddr>> uncommited_flushes{}; | ||
| 287 | std::list<std::shared_ptr<std::unordered_set<VAddr>>> commited_flushes; | ||
| 238 | }; | 288 | }; |
| 239 | 289 | ||
| 240 | template <class QueryCache, class HostCounter> | 290 | template <class QueryCache, class HostCounter> |