summaryrefslogtreecommitdiffstats
path: root/tools/gfx/persistent-shader-cache.cpp
diff options
context:
space:
mode:
authorlucy96chen <47800040+lucy96chen@users.noreply.github.com>2022-10-20 09:33:48 -0700
committerGitHub <noreply@github.com>2022-10-20 09:33:48 -0700
commit576c8407e60143682cd40c68101c6eae8563ca3d (patch)
tree0191ffff817dcd2903ff467642234da5265df552 /tools/gfx/persistent-shader-cache.cpp
parentdec930150f42a22892e567c769a1c9e24e761fde (diff)
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
Diffstat (limited to 'tools/gfx/persistent-shader-cache.cpp')
-rw-r--r--tools/gfx/persistent-shader-cache.cpp6
1 files changed, 6 insertions, 0 deletions
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;
}
}