@@ -19,6 +19,22 @@ class LRUCacheTestApp final : public nbl::application_templates::MonoSystemMonoL
19
19
public:
20
20
using base_t ::base_t ;
21
21
22
+ constexpr static uint32_t InvalidTextureIdx = 41234 ;
23
+ struct TextureReference
24
+ {
25
+ uint32_t alloc_idx;
26
+ uint64_t lastUsedSemaphoreValue;
27
+
28
+ TextureReference (uint32_t alloc_idx, uint64_t semaphoreVal) : alloc_idx(alloc_idx), lastUsedSemaphoreValue(semaphoreVal) {}
29
+ TextureReference (uint64_t semaphoreVal) : TextureReference(InvalidTextureIdx, semaphoreVal) {}
30
+ TextureReference () : TextureReference(InvalidTextureIdx, ~0ull ) {}
31
+
32
+ // In LRU Cache `insert` function, in case of cache hit, we need to assign semaphore value to TextureReference without changing `alloc_idx`
33
+ inline TextureReference& operator =(uint64_t semamphoreVal) { lastUsedSemaphoreValue = semamphoreVal; return *this ; }
34
+ };
35
+
36
+ using TextureLRUCache = core::LRUCache<uint32_t , TextureReference>;
37
+
22
38
// we stuff all our work here because its a "single shot" app
23
39
bool onAppInitialized (smart_refctd_ptr<ISystem>&& system) override
24
40
{
@@ -108,6 +124,24 @@ class LRUCacheTestApp final : public nbl::application_templates::MonoSystemMonoL
108
124
cache2.print (m_logger);
109
125
cache2.insert (++i, " key is 112" );
110
126
127
+ m_textureLRUCache = std::unique_ptr<TextureLRUCache>(new TextureLRUCache (1024u ));
128
+ {
129
+ SIntendedSubmitInfo intendedNextSubmit = {};
130
+ auto evictionCallback = [&](const TextureReference& evicted)
131
+ {
132
+ };
133
+ const auto nextSemaSignal = intendedNextSubmit.getFutureScratchSemaphore ();
134
+ TextureReference* inserted = m_textureLRUCache->insert (69420 , nextSemaSignal.value , evictionCallback);
135
+ }
136
+ {
137
+ SIntendedSubmitInfo intendedNextSubmit = {};
138
+ auto evictionCallback = [&](const TextureReference& evicted)
139
+ {
140
+ };
141
+ const auto nextSemaSignal = intendedNextSubmit.getFutureScratchSemaphore ();
142
+ TextureReference* inserted = m_textureLRUCache->insert (69420 , nextSemaSignal.value , evictionCallback);
143
+ }
144
+
111
145
#ifdef _NBL_DEBUG
112
146
cache2.print (m_logger);
113
147
#endif
@@ -153,6 +187,7 @@ class LRUCacheTestApp final : public nbl::application_templates::MonoSystemMonoL
153
187
154
188
return true ;
155
189
}
190
+ std::unique_ptr<TextureLRUCache> m_textureLRUCache;
156
191
157
192
void workLoopBody () override {}
158
193
0 commit comments