From 576c8407e60143682cd40c68101c6eae8563ca3d Mon Sep 17 00:00:00 2001 From: lucy96chen <47800040+lucy96chen@users.noreply.github.com> Date: Thu, 20 Oct 2022 09:33:48 -0700 Subject: Cache eviction policy test refinement (#2456) * Refined cache eviction test; Added check to cache file load to ensure only the maximum number of allowed entries is loaded * Fixed logic error in entry count check * Changed getCacheFile to not append the newline at the end of cache files * Refined if check --- tools/gfx/persistent-shader-cache.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools/gfx/persistent-shader-cache.cpp') diff --git a/tools/gfx/persistent-shader-cache.cpp b/tools/gfx/persistent-shader-cache.cpp index 55a95a257..fdf91fbe8 100644 --- a/tools/gfx/persistent-shader-cache.cpp +++ b/tools/gfx/persistent-shader-cache.cpp @@ -68,6 +68,12 @@ void PersistentShaderCache::loadCacheFromFile() ShaderCacheEntry entry = { dependencyDigest, astDigest }; auto entryNode = entries.AddLast(entry); keyToEntry.Add(dependencyDigest, entryNode); + + // If there are more entries present in the cache file than the entry count limit allows, + // ignore the rest. Since we output the lines in the cache file in order of most to least + // recently used, the cache's behavior will still be correct. + if (desc.entryCountLimit > 0 && entries.Count() == desc.entryCountLimit) + break; } } -- cgit v1.2.3