Only enumarate cached textures that are modified when flushing, rather than all of them.
This commit is contained in:
parent
796e5d14b4
commit
0914001177
4 changed files with 45 additions and 15 deletions
|
@ -94,7 +94,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
srcTexture.HostTexture.CopyTo(dstTexture.HostTexture, srcRegion, dstRegion, linearFilter);
|
||||
}
|
||||
|
||||
dstTexture.Modified = true;
|
||||
dstTexture.SignalModified();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -286,7 +286,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
if (color != null)
|
||||
{
|
||||
color.Modified = true;
|
||||
color.SignalModified();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
if (depthStencil != null)
|
||||
{
|
||||
depthStencil.Modified = true;
|
||||
depthStencil.SignalModified();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,9 +54,9 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
public LinkedListNode<Texture> CacheNode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Texture data modified by the GPU.
|
||||
/// Event to fire when texture data modified by the GPU.
|
||||
/// </summary>
|
||||
public bool Modified { get; set; }
|
||||
public event Action<Texture> Modified;
|
||||
|
||||
/// <summary>
|
||||
/// Start address of the texture in guest memory.
|
||||
|
@ -933,6 +933,14 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
_layers = info.GetLayers();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signals that the texture has been modified.
|
||||
/// </summary>
|
||||
public void SignalModified()
|
||||
{
|
||||
Modified?.Invoke(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the host texture, while disposing of the old one if needed.
|
||||
/// </summary>
|
||||
|
|
|
@ -5,6 +5,7 @@ using Ryujinx.Graphics.Gpu.Memory;
|
|||
using Ryujinx.Graphics.Gpu.State;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Graphics.Gpu.Image
|
||||
{
|
||||
|
@ -35,6 +36,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
|
||||
private readonly AutoDeleteCache _cache;
|
||||
|
||||
private readonly HashSet<Texture> _modified;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of the texture manager.
|
||||
/// </summary>
|
||||
|
@ -57,6 +60,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
_textureOverlaps = new Texture[OverlapsBufferInitialCapacity];
|
||||
|
||||
_cache = new AutoDeleteCache();
|
||||
|
||||
_modified = new HashSet<Texture>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -579,6 +584,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
if (!isSamplerTexture)
|
||||
{
|
||||
_cache.Add(texture);
|
||||
texture.Modified += CacheTextureModified;
|
||||
}
|
||||
|
||||
_textures.Add(texture);
|
||||
|
@ -588,6 +594,18 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signaled when a cache texture is modified, and adds it to a set to be enumerated when flushing textures.
|
||||
/// </summary>
|
||||
/// <param name="texture">The texture that was modified.</param>
|
||||
private void CacheTextureModified(Texture texture)
|
||||
{
|
||||
lock (_modified)
|
||||
{
|
||||
_modified.Add(texture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resizes the temporary buffer used for range list intersection results, if it has grown too much.
|
||||
/// </summary>
|
||||
|
@ -722,14 +740,16 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
/// </summary>
|
||||
public void Flush()
|
||||
{
|
||||
foreach (Texture texture in _cache)
|
||||
lock (_modified)
|
||||
{
|
||||
if (texture.Info.IsLinear && texture.Modified)
|
||||
foreach (Texture texture in _modified)
|
||||
{
|
||||
texture.Flush();
|
||||
|
||||
texture.Modified = false;
|
||||
if (texture.Info.IsLinear)
|
||||
{
|
||||
texture.Flush();
|
||||
}
|
||||
}
|
||||
_modified.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -740,14 +760,16 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
/// <param name="size">The range size</param>
|
||||
public void Flush(ulong address, ulong size)
|
||||
{
|
||||
foreach (Texture texture in _cache)
|
||||
lock (_modified)
|
||||
{
|
||||
if (texture.OverlapsWith(address, size) && texture.Modified)
|
||||
foreach (Texture texture in _modified)
|
||||
{
|
||||
texture.Flush();
|
||||
|
||||
texture.Modified = false;
|
||||
if (texture.OverlapsWith(address, size))
|
||||
{
|
||||
texture.Flush();
|
||||
}
|
||||
}
|
||||
_modified.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue