summaryrefslogtreecommitdiff
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.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h
index a040858e8..e66054ed0 100644
--- a/src/video_core/query_cache.h
+++ b/src/video_core/query_cache.h
@@ -62,7 +62,7 @@ public:
62 62
63 /// Returns true when the counter stream is enabled. 63 /// Returns true when the counter stream is enabled.
64 bool IsEnabled() const { 64 bool IsEnabled() const {
65 return static_cast<bool>(current); 65 return current != nullptr;
66 } 66 }
67 67
68private: 68private:
@@ -163,6 +163,11 @@ public:
163 return streams[static_cast<std::size_t>(type)]; 163 return streams[static_cast<std::size_t>(type)];
164 } 164 }
165 165
166 /// Returns the counter stream of the specified type.
167 const CounterStream& Stream(VideoCore::QueryType type) const {
168 return streams[static_cast<std::size_t>(type)];
169 }
170
166protected: 171protected:
167 std::array<QueryPool, VideoCore::NumQueryTypes> query_pools; 172 std::array<QueryPool, VideoCore::NumQueryTypes> query_pools;
168 173
@@ -219,7 +224,7 @@ private:
219 } 224 }
220 225
221 static constexpr std::uintptr_t PAGE_SIZE = 4096; 226 static constexpr std::uintptr_t PAGE_SIZE = 4096;
222 static constexpr int PAGE_SHIFT = 12; 227 static constexpr unsigned PAGE_SHIFT = 12;
223 228
224 Core::System& system; 229 Core::System& system;
225 VideoCore::RasterizerInterface& rasterizer; 230 VideoCore::RasterizerInterface& rasterizer;
@@ -237,13 +242,14 @@ public:
237 explicit HostCounterBase(std::shared_ptr<HostCounter> dependency_) 242 explicit HostCounterBase(std::shared_ptr<HostCounter> dependency_)
238 : dependency{std::move(dependency_)}, depth{dependency ? (dependency->Depth() + 1) : 0} { 243 : dependency{std::move(dependency_)}, depth{dependency ? (dependency->Depth() + 1) : 0} {
239 // Avoid nesting too many dependencies to avoid a stack overflow when these are deleted. 244 // Avoid nesting too many dependencies to avoid a stack overflow when these are deleted.
240 static constexpr u64 depth_threshold = 96; 245 constexpr u64 depth_threshold = 96;
241 if (depth > depth_threshold) { 246 if (depth > depth_threshold) {
242 depth = 0; 247 depth = 0;
243 base_result = dependency->Query(); 248 base_result = dependency->Query();
244 dependency = nullptr; 249 dependency = nullptr;
245 } 250 }
246 } 251 }
252 virtual ~HostCounterBase() = default;
247 253
248 /// Returns the current value of the query. 254 /// Returns the current value of the query.
249 u64 Query() { 255 u64 Query() {
@@ -257,7 +263,8 @@ public:
257 dependency = nullptr; 263 dependency = nullptr;
258 } 264 }
259 265
260 return *(result = value); 266 result = value;
267 return *result;
261 } 268 }
262 269
263 /// Returns true when flushing this query will potentially wait. 270 /// Returns true when flushing this query will potentially wait.
@@ -285,20 +292,13 @@ class CachedQueryBase {
285public: 292public:
286 explicit CachedQueryBase(VAddr cpu_addr, u8* host_ptr) 293 explicit CachedQueryBase(VAddr cpu_addr, u8* host_ptr)
287 : cpu_addr{cpu_addr}, host_ptr{host_ptr} {} 294 : cpu_addr{cpu_addr}, host_ptr{host_ptr} {}
295 virtual ~CachedQueryBase() = default;
288 296
289 CachedQueryBase(CachedQueryBase&& rhs) noexcept 297 CachedQueryBase(CachedQueryBase&&) noexcept = default;
290 : cpu_addr{rhs.cpu_addr}, host_ptr{rhs.host_ptr}, counter{std::move(rhs.counter)},
291 timestamp{rhs.timestamp} {}
292
293 CachedQueryBase(const CachedQueryBase&) = delete; 298 CachedQueryBase(const CachedQueryBase&) = delete;
294 299
295 CachedQueryBase& operator=(CachedQueryBase&& rhs) noexcept { 300 CachedQueryBase& operator=(CachedQueryBase&&) noexcept = default;
296 cpu_addr = rhs.cpu_addr; 301 CachedQueryBase& operator=(const CachedQueryBase&) = delete;
297 host_ptr = rhs.host_ptr;
298 counter = std::move(rhs.counter);
299 timestamp = rhs.timestamp;
300 return *this;
301 }
302 302
303 /// Flushes the query to guest memory. 303 /// Flushes the query to guest memory.
304 virtual void Flush() { 304 virtual void Flush() {
@@ -335,7 +335,7 @@ public:
335 return SizeInBytes(timestamp.has_value()); 335 return SizeInBytes(timestamp.has_value());
336 } 336 }
337 337
338 static u64 SizeInBytes(bool with_timestamp) { 338 static constexpr u64 SizeInBytes(bool with_timestamp) noexcept {
339 return with_timestamp ? LARGE_QUERY_SIZE : SMALL_QUERY_SIZE; 339 return with_timestamp ? LARGE_QUERY_SIZE : SMALL_QUERY_SIZE;
340 } 340 }
341 341