@@ -19,6 +19,22 @@ class LRUCacheTestApp final : public nbl::application_templates::MonoSystemMonoL
1919 public:
2020 using base_t ::base_t ;
2121
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+
2238 // we stuff all our work here because its a "single shot" app
2339 bool onAppInitialized (smart_refctd_ptr<ISystem>&& system) override
2440 {
@@ -108,6 +124,24 @@ class LRUCacheTestApp final : public nbl::application_templates::MonoSystemMonoL
108124 cache2.print (m_logger);
109125 cache2.insert (++i, " key is 112" );
110126
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+
111145 #ifdef _NBL_DEBUG
112146 cache2.print (m_logger);
113147 #endif
@@ -153,6 +187,7 @@ class LRUCacheTestApp final : public nbl::application_templates::MonoSystemMonoL
153187
154188 return true ;
155189 }
190+ std::unique_ptr<TextureLRUCache> m_textureLRUCache;
156191
157192 void workLoopBody () override {}
158193
0 commit comments