Remove texture from modified list when data is disposed.

In case the game does not call either flush method at any point.
This commit is contained in:
riperiperi 2020-02-05 23:43:20 +00:00
parent 21a523d600
commit 4999e3a44a
2 changed files with 19 additions and 1 deletions

View file

@ -54,10 +54,15 @@ namespace Ryujinx.Graphics.Gpu.Image
public LinkedListNode<Texture> CacheNode { get; set; }
/// <summary>
/// Event to fire when texture data modified by the GPU.
/// Event to fire when texture data is modified by the GPU.
/// </summary>
public event Action<Texture> Modified;
/// <summary>
/// Event to fire when texture data is disposed.
/// </summary>
public event Action<Texture> Disposed;
/// <summary>
/// Start address of the texture in guest memory.
/// </summary>
@ -1020,6 +1025,8 @@ namespace Ryujinx.Graphics.Gpu.Image
_arrayViewTexture?.Dispose();
_arrayViewTexture = null;
Disposed?.Invoke(this);
}
/// <summary>

View file

@ -585,6 +585,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
_cache.Add(texture);
texture.Modified += CacheTextureModified;
texture.Disposed += CacheTextureDisposed;
}
_textures.Add(texture);
@ -603,6 +604,15 @@ namespace Ryujinx.Graphics.Gpu.Image
_modified.Add(texture);
}
/// <summary>
/// Signaled when a cache texture is disposed, so it can be removed from the set of modified textures if present.
/// </summary>
/// <param name="texture">The texture that was diosposed.</param>
private void CacheTextureDisposed(Texture texture)
{
_modified.Remove(texture);
}
/// <summary>
/// Resizes the temporary buffer used for range list intersection results, if it has grown too much.
/// </summary>
@ -785,6 +795,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
foreach (Texture texture in _textures)
{
_modified.Remove(texture);
texture.Dispose();
}
}