summaryrefslogtreecommitdiff
path: root/src/video_core/query_cache.h
diff options
context:
space:
mode:
authorGravatar bunnei2020-04-22 22:09:38 -0400
committerGravatar GitHub2020-04-22 22:09:38 -0400
commitbf2ddb8fd5feaeaf2806fe102de8e3089f893137 (patch)
treeb97d388da23608c00808b6662e3c0564fc4f6d59 /src/video_core/query_cache.h
parentMerge pull request #3767 from ReinUsesLisp/point-size-pipeline (diff)
parentGL_Fence_Manager: use GL_TIMEOUT_IGNORED instead of a loop, (diff)
downloadyuzu-bf2ddb8fd5feaeaf2806fe102de8e3089f893137.tar.gz
yuzu-bf2ddb8fd5feaeaf2806fe102de8e3089f893137.tar.xz
yuzu-bf2ddb8fd5feaeaf2806fe102de8e3089f893137.zip
Merge pull request #3677 from FernandoS27/better-sync
Introduce Predictive Flushing and Improve ASYNC GPU
Diffstat (limited to 'src/video_core/query_cache.h')
-rw-r--r--src/video_core/query_cache.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h
index 5ea2b01f2..2f75f8801 100644
--- a/src/video_core/query_cache.h
+++ b/src/video_core/query_cache.h
@@ -12,10 +12,12 @@
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"
18#include "core/core.h" 19#include "core/core.h"
20#include "core/settings.h"
19#include "video_core/engines/maxwell_3d.h" 21#include "video_core/engines/maxwell_3d.h"
20#include "video_core/gpu.h" 22#include "video_core/gpu.h"
21#include "video_core/memory_manager.h" 23#include "video_core/memory_manager.h"
@@ -130,6 +132,9 @@ public:
130 } 132 }
131 133
132 query->BindCounter(Stream(type).Current(), timestamp); 134 query->BindCounter(Stream(type).Current(), timestamp);
135 if (Settings::values.use_asynchronous_gpu_emulation) {
136 AsyncFlushQuery(cpu_addr);
137 }
133 } 138 }
134 139
135 /// Updates counters from GPU state. Expected to be called once per draw, clear or dispatch. 140 /// Updates counters from GPU state. Expected to be called once per draw, clear or dispatch.
@@ -170,6 +175,37 @@ public:
170 return streams[static_cast<std::size_t>(type)]; 175 return streams[static_cast<std::size_t>(type)];
171 } 176 }
172 177
178 void CommitAsyncFlushes() {
179 committed_flushes.push_back(uncommitted_flushes);
180 uncommitted_flushes.reset();
181 }
182
183 bool HasUncommittedFlushes() const {
184 return uncommitted_flushes != nullptr;
185 }
186
187 bool ShouldWaitAsyncFlushes() const {
188 if (committed_flushes.empty()) {
189 return false;
190 }
191 return committed_flushes.front() != nullptr;
192 }
193
194 void PopAsyncFlushes() {
195 if (committed_flushes.empty()) {
196 return;
197 }
198 auto& flush_list = committed_flushes.front();
199 if (!flush_list) {
200 committed_flushes.pop_front();
201 return;
202 }
203 for (VAddr query_address : *flush_list) {
204 FlushAndRemoveRegion(query_address, 4);
205 }
206 committed_flushes.pop_front();
207 }
208
173protected: 209protected:
174 std::array<QueryPool, VideoCore::NumQueryTypes> query_pools; 210 std::array<QueryPool, VideoCore::NumQueryTypes> query_pools;
175 211
@@ -224,6 +260,13 @@ private:
224 return found != std::end(contents) ? &*found : nullptr; 260 return found != std::end(contents) ? &*found : nullptr;
225 } 261 }
226 262
263 void AsyncFlushQuery(VAddr addr) {
264 if (!uncommitted_flushes) {
265 uncommitted_flushes = std::make_shared<std::unordered_set<VAddr>>();
266 }
267 uncommitted_flushes->insert(addr);
268 }
269
227 static constexpr std::uintptr_t PAGE_SIZE = 4096; 270 static constexpr std::uintptr_t PAGE_SIZE = 4096;
228 static constexpr unsigned PAGE_SHIFT = 12; 271 static constexpr unsigned PAGE_SHIFT = 12;
229 272
@@ -235,6 +278,9 @@ private:
235 std::unordered_map<u64, std::vector<CachedQuery>> cached_queries; 278 std::unordered_map<u64, std::vector<CachedQuery>> cached_queries;
236 279
237 std::array<CounterStream, VideoCore::NumQueryTypes> streams; 280 std::array<CounterStream, VideoCore::NumQueryTypes> streams;
281
282 std::shared_ptr<std::unordered_set<VAddr>> uncommitted_flushes{};
283 std::list<std::shared_ptr<std::unordered_set<VAddr>>> committed_flushes;
238}; 284};
239 285
240template <class QueryCache, class HostCounter> 286template <class QueryCache, class HostCounter>