aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/buffer_cache/buffer_base.h
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-01-18 17:14:14 -0300
committerReinUsesLisp <reinuseslisp@airmail.cc>2021-02-13 02:17:24 -0300
commit2b95c137ff1796daf2b262f90c25104db1161b5f (patch)
tree4f5c57a9a476ba92488713e2ca99d1aa212c99ad /src/video_core/buffer_cache/buffer_base.h
parentec9354d6d92f4190d06dfb6b86e0098fa0108eac (diff)
buffer_cache: Heuristically detect stream buffers
Detect when a memory region has been joined several times and increase the size of the created buffer on those instances. The buffer is assumed to be a "stream buffer", increasing its size should stop us from constantly recreating it and fragmenting memory.
Diffstat (limited to 'src/video_core/buffer_cache/buffer_base.h')
-rw-r--r--src/video_core/buffer_cache/buffer_base.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/video_core/buffer_cache/buffer_base.h b/src/video_core/buffer_cache/buffer_base.h
index 8a5e6a3e7..0c00ae280 100644
--- a/src/video_core/buffer_cache/buffer_base.h
+++ b/src/video_core/buffer_cache/buffer_base.h
@@ -251,6 +251,16 @@ public:
flags &= ~BufferFlagBits::Picked;
}
+ /// Increases the likeliness of this being a stream buffer
+ void IncreaseStreamScore(int score) noexcept {
+ stream_score += score;
+ }
+
+ /// Returns the likeliness of this being a stream buffer
+ [[nodiscard]] int StreamScore() const noexcept {
+ return stream_score;
+ }
+
/// Returns true when vaddr -> vaddr+size is fully contained in the buffer
[[nodiscard]] bool IsInBounds(VAddr addr, u64 size) const noexcept {
return addr >= cpu_addr && addr + size <= cpu_addr + SizeBytes();
@@ -574,6 +584,7 @@ private:
VAddr cpu_addr = 0;
Words words;
BufferFlagBits flags{};
+ int stream_score = 0;
};
} // namespace VideoCommon