RenderableCache performance improvement

This commit is contained in:
dexyfex 2017-11-26 21:31:45 +11:00
parent d9247de1c4
commit 858cab95f2

View File

@ -221,11 +221,13 @@ namespace CodeWalker.Rendering
public long CacheUse = 0; public long CacheUse = 0;
public double CacheTime; public double CacheTime;
public int LoadedCount = 0;//temporary, per loop public int LoadedCount = 0;//temporary, per loop
private long LastFrameTime = 0;
public RenderableCacheLookup(long limit, double time) public RenderableCacheLookup(long limit, double time)
{ {
CacheLimit = limit; CacheLimit = limit;
CacheTime = time; CacheTime = time;
LastFrameTime = DateTime.UtcNow.ToBinary();
} }
public int CurrentLoadedCount public int CurrentLoadedCount
@ -315,6 +317,7 @@ namespace CodeWalker.Rendering
public void RenderThreadSync() public void RenderThreadSync()
{ {
LastFrameTime = DateTime.UtcNow.ToBinary();
TVal item; TVal item;
while (itemsToUnload.TryPop(out item)) while (itemsToUnload.TryPop(out item))
{ {
@ -339,7 +342,7 @@ namespace CodeWalker.Rendering
item.Init(key); item.Init(key);
cacheitems.Add(key, item); cacheitems.Add(key, item);
} }
Interlocked.Exchange(ref item.LastUseTime, DateTime.UtcNow.ToBinary()); Interlocked.Exchange(ref item.LastUseTime, LastFrameTime);
if ((!item.IsLoaded) && (!item.LoadQueued))// || if ((!item.IsLoaded) && (!item.LoadQueued))// ||
{ {
item.LoadQueued = true; item.LoadQueued = true;