diff options
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs b/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs index d66eab93..634f9448 100644 --- a/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs +++ b/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs @@ -1,3 +1,4 @@ +using Ryujinx.Common.Logging; using System.Collections; using System.Collections.Generic; @@ -40,6 +41,16 @@ namespace Ryujinx.Graphics.Gpu.Image { Texture oldestTexture = _textures.First.Value; + oldestTexture.SynchronizeMemory(); + + if (oldestTexture.IsModified) + { + // The texture must be flushed if it falls out of the auto delete cache. + // Flushes out of the auto delete cache do not trigger write tracking, + // as it is expected that other overlapping textures exist that have more up-to-date contents. + oldestTexture.Flush(false); + } + _textures.RemoveFirst(); oldestTexture.DecrementReferenceCount(); @@ -74,6 +85,26 @@ namespace Ryujinx.Graphics.Gpu.Image } } + public bool Remove(Texture texture, bool flush) + { + if (texture.CacheNode == null) + { + return false; + } + + // Remove our reference to this texture. + if (flush && texture.IsModified) + { + texture.Flush(false); + } + + _textures.Remove(texture.CacheNode); + + texture.CacheNode = null; + + return texture.DecrementReferenceCount(); + } + public IEnumerator<Texture> GetEnumerator() { return _textures.GetEnumerator(); |
