diff --git a/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs b/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs index 3c74c1647..5077cb6a7 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs @@ -127,6 +127,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod return; } + memoryManager.Physical.TextureCache.Lift(srcTexture); + // When the source texture that was found has a depth format, // we must enforce the target texture also has a depth format, // as copies between depth and color formats are not allowed. diff --git a/Ryujinx.Graphics.Gpu/Image/Texture.cs b/Ryujinx.Graphics.Gpu/Image/Texture.cs index c9c3c59ac..3a66960d4 100644 --- a/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -1235,6 +1235,8 @@ namespace Ryujinx.Graphics.Gpu.Image IsModified = true; Group.SignalModified(this, !wasModified); } + + _physicalMemory.TextureCache.Lift(this); } /// @@ -1252,6 +1254,8 @@ namespace Ryujinx.Graphics.Gpu.Image Group.SignalModifying(this, bound, !wasModified); } + _physicalMemory.TextureCache.Lift(this); + if (bound) { IncrementReferenceCount(); diff --git a/Ryujinx.Graphics.Gpu/Image/TextureCache.cs b/Ryujinx.Graphics.Gpu/Image/TextureCache.cs index 44c974e8f..ea64f46c1 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureCache.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureCache.cs @@ -154,6 +154,17 @@ namespace Ryujinx.Graphics.Gpu.Image return true; } + /// + /// Lifts the texture to the top of the AutoDeleteCache. This is primarily used to enforce that + /// data written to a target will be flushed to memory should the texture be deleted, but also + /// keeps rendered textures alive without a pool reference. + /// + /// Texture to lift + public void Lift(Texture texture) + { + _cache.Lift(texture); + } + /// /// Tries to find an existing texture, or create a new one if not found. /// @@ -442,14 +453,6 @@ namespace Ryujinx.Graphics.Gpu.Image if (texture != null) { - if (!isSamplerTexture) - { - // If not a sampler texture, it is managed by the auto delete - // cache, ensure that it is on the "top" of the list to avoid - // deletion. - _cache.Lift(texture); - } - ChangeSizeIfNeeded(info, texture, isSamplerTexture, sizeHint); texture.SynchronizeMemory(); @@ -849,7 +852,6 @@ namespace Ryujinx.Graphics.Gpu.Image if (match) { - _cache.Lift(texture); return texture; } }