blob: a6252bec33b122022e1cbf4cb0b5210c4c6846e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#pragma once
#include "compat/defs.hpp"
#include <Corrade/Containers/Array.h>
namespace Magnum::GL { class AbstractTexture; }
namespace floormat {
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);
[[nodiscard]] int32_t bind(GL::AbstractTexture& x);
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 reuse_immediately = true);
size_t reuse_count() const { return cache_hit_count; }
size_t bind_count() const { return cache_miss_count; }
void output_stats();
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, cache_miss_count = 0, cache_hit_count = 0;
Array<unit_data> units;
};
} // namespace floormat
|