summaryrefslogtreecommitdiffhomepage
path: root/shaders/texture-unit-cache.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-08-28 14:03:44 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-08-30 18:22:56 +0200
commita936a998fd6441679f123850bf4b62178ad4336e (patch)
treeb7aa1e8642355aaf2e6ef412c24f1c0988a56a20 /shaders/texture-unit-cache.hpp
parentb38454d56373125fc4715c509e5204c564f9e332 (diff)
shaders/tuc: output stats every few seconds
Diffstat (limited to 'shaders/texture-unit-cache.hpp')
-rw-r--r--shaders/texture-unit-cache.hpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/shaders/texture-unit-cache.hpp b/shaders/texture-unit-cache.hpp
index 2647ea8c..5f09ecb9 100644
--- a/shaders/texture-unit-cache.hpp
+++ b/shaders/texture-unit-cache.hpp
@@ -11,6 +11,8 @@ struct texture_unit_cache final
fm_DECLARE_DELETED_COPY_ASSIGNMENT(texture_unit_cache);
fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(texture_unit_cache);
+ struct statistics { size_t cache_hit, cache_miss; };
+
texture_unit_cache();
[[nodiscard]] int32_t bind(GL::AbstractTexture* ptr);
@@ -18,17 +20,21 @@ struct texture_unit_cache final
void invalidate();
void lock(size_t i, GL::AbstractTexture* = (GL::AbstractTexture*)-1);
void lock(size_t i, GL::AbstractTexture& tex) { lock(i, &tex); }
- void unlock(size_t i, bool immediately = true);
+ void unlock(size_t i, bool reuse_immediately = true);
size_t reuse_count() const { return cache_hit_count; }
- size_t bind_count() const { return rebind_count; }
- void reset_stats() { rebind_count = cache_hit_count = 0; }
+ size_t bind_count() const { return cache_miss_count; }
+
+ void output_stats() const;
+ statistics stats() const { return statistics { cache_hit_count, cache_miss_count }; }
+
+ void reset_stats() { cache_miss_count = cache_hit_count = 0; }
private:
static size_t get_unit_count();
struct unit_data;
- size_t unit_count, lru_counter = 0, rebind_count = 0, cache_hit_count = 0;
+ size_t unit_count, lru_counter = 0, cache_miss_count = 0, cache_hit_count = 0;
Array<unit_data> units;
};