diff options
| author | 2023-12-19 17:32:31 -0500 | |
|---|---|---|
| committer | 2023-12-19 17:32:31 -0500 | |
| commit | db8a601cf82cd4797c32931f13a585c64527780d (patch) | |
| tree | ec0f8a7f5355c9ecb01b03580b65d01671ac3359 /src/video_core/query_cache.h | |
| parent | Merge pull request #12382 from liamwhite/image-limit (diff) | |
| download | yuzu-db8a601cf82cd4797c32931f13a585c64527780d.tar.gz yuzu-db8a601cf82cd4797c32931f13a585c64527780d.tar.xz yuzu-db8a601cf82cd4797c32931f13a585c64527780d.zip | |
OpenGL: Add GL_PRIMITIVES_GENERATED and GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN queries
Diffstat (limited to 'src/video_core/query_cache.h')
| -rw-r--r-- | src/video_core/query_cache.h | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index 9fcaeeac7..a64404ce4 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h | |||
| @@ -28,8 +28,11 @@ | |||
| 28 | namespace VideoCore { | 28 | namespace VideoCore { |
| 29 | enum class QueryType { | 29 | enum class QueryType { |
| 30 | SamplesPassed, | 30 | SamplesPassed, |
| 31 | PrimitivesGenerated, | ||
| 32 | TfbPrimitivesWritten, | ||
| 33 | Count, | ||
| 31 | }; | 34 | }; |
| 32 | constexpr std::size_t NumQueryTypes = 1; | 35 | constexpr std::size_t NumQueryTypes = static_cast<size_t>(QueryType::Count); |
| 33 | } // namespace VideoCore | 36 | } // namespace VideoCore |
| 34 | 37 | ||
| 35 | namespace VideoCommon { | 38 | namespace VideoCommon { |
| @@ -44,15 +47,6 @@ public: | |||
| 44 | explicit CounterStreamBase(QueryCache& cache_, VideoCore::QueryType type_) | 47 | explicit CounterStreamBase(QueryCache& cache_, VideoCore::QueryType type_) |
| 45 | : cache{cache_}, type{type_} {} | 48 | : cache{cache_}, type{type_} {} |
| 46 | 49 | ||
| 47 | /// Updates the state of the stream, enabling or disabling as needed. | ||
| 48 | void Update(bool enabled) { | ||
| 49 | if (enabled) { | ||
| 50 | Enable(); | ||
| 51 | } else { | ||
| 52 | Disable(); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | /// Resets the stream to zero. It doesn't disable the query after resetting. | 50 | /// Resets the stream to zero. It doesn't disable the query after resetting. |
| 57 | void Reset() { | 51 | void Reset() { |
| 58 | if (current) { | 52 | if (current) { |
| @@ -80,7 +74,6 @@ public: | |||
| 80 | return current != nullptr; | 74 | return current != nullptr; |
| 81 | } | 75 | } |
| 82 | 76 | ||
| 83 | private: | ||
| 84 | /// Enables the stream. | 77 | /// Enables the stream. |
| 85 | void Enable() { | 78 | void Enable() { |
| 86 | if (current) { | 79 | if (current) { |
| @@ -97,6 +90,7 @@ private: | |||
| 97 | last = std::exchange(current, nullptr); | 90 | last = std::exchange(current, nullptr); |
| 98 | } | 91 | } |
| 99 | 92 | ||
| 93 | private: | ||
| 100 | QueryCache& cache; | 94 | QueryCache& cache; |
| 101 | const VideoCore::QueryType type; | 95 | const VideoCore::QueryType type; |
| 102 | 96 | ||
| @@ -112,8 +106,14 @@ public: | |||
| 112 | : rasterizer{rasterizer_}, | 106 | : rasterizer{rasterizer_}, |
| 113 | // Use reinterpret_cast instead of static_cast as workaround for | 107 | // Use reinterpret_cast instead of static_cast as workaround for |
| 114 | // UBSan bug (https://github.com/llvm/llvm-project/issues/59060) | 108 | // UBSan bug (https://github.com/llvm/llvm-project/issues/59060) |
| 115 | cpu_memory{cpu_memory_}, streams{{CounterStream{reinterpret_cast<QueryCache&>(*this), | 109 | cpu_memory{cpu_memory_}, streams{{ |
| 116 | VideoCore::QueryType::SamplesPassed}}} { | 110 | {CounterStream{reinterpret_cast<QueryCache&>(*this), |
| 111 | VideoCore::QueryType::SamplesPassed}}, | ||
| 112 | {CounterStream{reinterpret_cast<QueryCache&>(*this), | ||
| 113 | VideoCore::QueryType::PrimitivesGenerated}}, | ||
| 114 | {CounterStream{reinterpret_cast<QueryCache&>(*this), | ||
| 115 | VideoCore::QueryType::TfbPrimitivesWritten}}, | ||
| 116 | }} { | ||
| 117 | (void)slot_async_jobs.insert(); // Null value | 117 | (void)slot_async_jobs.insert(); // Null value |
| 118 | } | 118 | } |
| 119 | 119 | ||
| @@ -157,12 +157,11 @@ public: | |||
| 157 | AsyncFlushQuery(query, timestamp, lock); | 157 | AsyncFlushQuery(query, timestamp, lock); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | /// Updates counters from GPU state. Expected to be called once per draw, clear or dispatch. | 160 | /// Enables all available GPU counters |
| 161 | void UpdateCounters() { | 161 | void EnableCounters() { |
| 162 | std::unique_lock lock{mutex}; | 162 | std::unique_lock lock{mutex}; |
| 163 | if (maxwell3d) { | 163 | for (auto& stream : streams) { |
| 164 | const auto& regs = maxwell3d->regs; | 164 | stream.Enable(); |
| 165 | Stream(VideoCore::QueryType::SamplesPassed).Update(regs.zpass_pixel_count_enable); | ||
| 166 | } | 165 | } |
| 167 | } | 166 | } |
| 168 | 167 | ||
| @@ -176,7 +175,7 @@ public: | |||
| 176 | void DisableStreams() { | 175 | void DisableStreams() { |
| 177 | std::unique_lock lock{mutex}; | 176 | std::unique_lock lock{mutex}; |
| 178 | for (auto& stream : streams) { | 177 | for (auto& stream : streams) { |
| 179 | stream.Update(false); | 178 | stream.Disable(); |
| 180 | } | 179 | } |
| 181 | } | 180 | } |
| 182 | 181 | ||
| @@ -353,7 +352,7 @@ private: | |||
| 353 | 352 | ||
| 354 | std::shared_ptr<std::vector<AsyncJobId>> uncommitted_flushes{}; | 353 | std::shared_ptr<std::vector<AsyncJobId>> uncommitted_flushes{}; |
| 355 | std::list<std::shared_ptr<std::vector<AsyncJobId>>> committed_flushes; | 354 | std::list<std::shared_ptr<std::vector<AsyncJobId>>> committed_flushes; |
| 356 | }; | 355 | }; // namespace VideoCommon |
| 357 | 356 | ||
| 358 | template <class QueryCache, class HostCounter> | 357 | template <class QueryCache, class HostCounter> |
| 359 | class HostCounterBase { | 358 | class HostCounterBase { |