0
0
Fork 0

Do not set modified flag again if texture was not modified (#5909)

* Do not set modified flag again if texture was not modified

* Formatting

* Fix copy dep regression
This commit is contained in:
gdkchan 2023-11-13 18:07:05 -03:00 committed by GitHub
parent 51065d9129
commit e6e5838916
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 19 deletions

View file

@ -102,9 +102,9 @@ namespace Ryujinx.Graphics.Gpu.Image
public bool AlwaysFlushOnOverlap { get; private set; } public bool AlwaysFlushOnOverlap { get; private set; }
/// <summary> /// <summary>
/// Indicates that the texture was fully unmapped since the modified flag was set, and flushes should be ignored until it is modified again. /// Indicates that the texture was modified since the last time it was flushed.
/// </summary> /// </summary>
public bool FlushStale { get; private set; } public bool ModifiedSinceLastFlush { get; set; }
/// <summary> /// <summary>
/// Increments when the host texture is swapped, or when the texture is removed from all pools. /// Increments when the host texture is swapped, or when the texture is removed from all pools.
@ -1417,7 +1417,6 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary> /// </summary>
public void SignalModified() public void SignalModified()
{ {
FlushStale = false;
_scaledSetScore = Math.Max(0, _scaledSetScore - 1); _scaledSetScore = Math.Max(0, _scaledSetScore - 1);
if (_modifiedStale || Group.HasCopyDependencies) if (_modifiedStale || Group.HasCopyDependencies)
@ -1438,15 +1437,18 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
if (bound) if (bound)
{ {
FlushStale = false;
_scaledSetScore = Math.Max(0, _scaledSetScore - 1); _scaledSetScore = Math.Max(0, _scaledSetScore - 1);
} }
if (_modifiedStale || Group.HasCopyDependencies || Group.HasFlushBuffer) if (_modifiedStale || Group.HasCopyDependencies || Group.HasFlushBuffer)
{ {
_modifiedStale = false; _modifiedStale = false;
if (bound || ModifiedSinceLastFlush || Group.HasCopyDependencies || Group.HasFlushBuffer)
{
Group.SignalModifying(this, bound); Group.SignalModifying(this, bound);
} }
}
_physicalMemory.TextureCache.Lift(this); _physicalMemory.TextureCache.Lift(this);
@ -1703,12 +1705,6 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="unmapRange">The range of memory being unmapped</param> /// <param name="unmapRange">The range of memory being unmapped</param>
public void Unmapped(MultiRange unmapRange) public void Unmapped(MultiRange unmapRange)
{ {
if (unmapRange.Contains(Range))
{
// If this is a full unmap, prevent flushes until the texture is mapped again.
FlushStale = true;
}
ChangedMapping = true; ChangedMapping = true;
if (Group.Storage == this) if (Group.Storage == this)

View file

@ -1660,13 +1660,13 @@ namespace Ryujinx.Graphics.Gpu.Image
} }
// If size is zero, we have nothing to flush. // If size is zero, we have nothing to flush.
// If the flush is stale, we should ignore it because the texture was unmapped since the modified if (size == 0)
// flag was set, and flushing it is not safe anymore as the GPU might no longer own the memory.
if (size == 0 || Storage.FlushStale)
{ {
return; return;
} }
Storage.ModifiedSinceLastFlush = false;
// There is a small gap here where the action is removed but _actionRegistered is still 1. // There is a small gap here where the action is removed but _actionRegistered is still 1.
// In this case it will skip registering the action, but here we are already handling it, // In this case it will skip registering the action, but here we are already handling it,
// so there shouldn't be any issue as it's the same handler for all actions. // so there shouldn't be any issue as it's the same handler for all actions.

View file

@ -413,21 +413,35 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
bool anyChanged = false; bool anyChanged = false;
if (_rtHostDs != _rtDepthStencil?.HostTexture) Texture dsTexture = _rtDepthStencil;
{ ITexture hostDsTexture = null;
_rtHostDs = _rtDepthStencil?.HostTexture;
if (dsTexture != null)
{
hostDsTexture = dsTexture.HostTexture;
dsTexture.ModifiedSinceLastFlush = true;
}
if (_rtHostDs != hostDsTexture)
{
_rtHostDs = hostDsTexture;
anyChanged = true; anyChanged = true;
} }
for (int index = 0; index < _rtColors.Length; index++) for (int index = 0; index < _rtColors.Length; index++)
{ {
ITexture hostTexture = _rtColors[index]?.HostTexture; Texture texture = _rtColors[index];
ITexture hostTexture = null;
if (texture != null)
{
hostTexture = texture.HostTexture;
texture.ModifiedSinceLastFlush = true;
}
if (_rtHostColors[index] != hostTexture) if (_rtHostColors[index] != hostTexture)
{ {
_rtHostColors[index] = hostTexture; _rtHostColors[index] = hostTexture;
anyChanged = true; anyChanged = true;
} }
} }