mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-26 17:02:53 +08:00
Fixed RenderableCache item invalidation and cleaned up code
This commit is contained in:
parent
0c4001fa4b
commit
a7e2c7a0b6
@ -339,12 +339,9 @@ namespace CodeWalker.Rendering
|
|||||||
}
|
}
|
||||||
while (itemsToInvalidate.TryPop(out item))
|
while (itemsToInvalidate.TryPop(out item))
|
||||||
{
|
{
|
||||||
//if (!item.IsLoaded) continue;//can't invalidate item that's not currently loaded
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Interlocked.Add(ref CacheUse, -item.DataSize);
|
item.Load(device); //invalidated items just need to get reloaded. (they are already unloaded and re-inited)
|
||||||
//item.Unload();
|
|
||||||
item.Load(device);
|
|
||||||
Interlocked.Add(ref CacheUse, item.DataSize);
|
Interlocked.Add(ref CacheUse, item.DataSize);
|
||||||
}
|
}
|
||||||
catch //(Exception ex)
|
catch //(Exception ex)
|
||||||
@ -387,9 +384,11 @@ namespace CodeWalker.Rendering
|
|||||||
{
|
{
|
||||||
if (cacheitems.TryGetValue(key, out item))
|
if (cacheitems.TryGetValue(key, out item))
|
||||||
{
|
{
|
||||||
itemsToInvalidate.Push(item);
|
|
||||||
item.Unload();
|
item.Unload();
|
||||||
item.Init(key);
|
item.Init(key);
|
||||||
|
item.LoadQueued = true;
|
||||||
|
itemsToInvalidate.Push(item);
|
||||||
|
Interlocked.Add(ref CacheUse, -item.DataSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (itemsToUnload.TryPop(out item))
|
while (itemsToUnload.TryPop(out item))
|
||||||
@ -431,24 +430,6 @@ namespace CodeWalker.Rendering
|
|||||||
|
|
||||||
keysToInvalidate.Push(key);
|
keysToInvalidate.Push(key);
|
||||||
|
|
||||||
//TVal item = null;
|
|
||||||
//if (!cacheitems.TryGetValue(key, out item)) return;
|
|
||||||
//if (item == null) return;
|
|
||||||
|
|
||||||
//if ((item.Key != null) && (cacheitems.ContainsKey(item.Key)))
|
|
||||||
//{
|
|
||||||
|
|
||||||
// cacheitems.Remove(item.Key);
|
|
||||||
|
|
||||||
// item.Unload();
|
|
||||||
// item.LoadQueued = false;
|
|
||||||
// CacheUse -= item.DataSize;
|
|
||||||
// //Interlocked.Add(ref CacheUse, -item.DataSize);
|
|
||||||
// Interlocked.Exchange(ref item.LastUseTime, DateTime.UtcNow.AddHours(-1).ToBinary());
|
|
||||||
|
|
||||||
// loadeditems.Remove(item);//slow...
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user