aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Image/TextureCache.cs
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2023-03-14 20:08:44 +0000
committerGitHub <noreply@github.com>2023-03-14 17:08:44 -0300
commit1fc90e57d2e7f7bb6886a58b81bcd1f4cb25f8cf (patch)
treeb2b2063d9ec830ef380651886a33d1e2dee9b497 /Ryujinx.Graphics.Gpu/Image/TextureCache.cs
parenteafcc314a96f2dc893291c6268ad00278159762f (diff)
Update range for remapped sparse textures instead of recreating them (#4442)1.1.664
* Update sparsely mapped texture ranges without recreating Important TODO in TexturePool. Smaller TODO: should I look into making textures with views also do this? It needs to be able to detect if the views can be instantly deleted without issue if they're now remapped. * Actually do partial updates * Signal group dirty after mappings changed * Fix various issues (should work now) * Further optimisation Should load a lot less data (16x) when partial updating 3d textures. * Improve stability * Allow granular uploads on large textures, improve rules * Actually avoid updating slices that aren't modified. * Address some feedback, minor optimisation * Small tweak * Refactor DereferenceRequest More specific initialization methods. * Improve code for resetting handles * Explain data loading a bit more * Add some safety for setting null from different threads. All texture sets come from the one thread, but null sets can come from multiple. Only decrement ref count if we succeeded the null set first. * Address feedback 1 * Make a bit safer
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image/TextureCache.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Image/TextureCache.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureCache.cs b/Ryujinx.Graphics.Gpu/Image/TextureCache.cs
index 261d0603..c3243cf2 100644
--- a/Ryujinx.Graphics.Gpu/Image/TextureCache.cs
+++ b/Ryujinx.Graphics.Gpu/Image/TextureCache.cs
@@ -195,6 +195,39 @@ namespace Ryujinx.Graphics.Gpu.Image
}
/// <summary>
+ /// Attempts to update a texture's physical memory range.
+ /// Returns false if there is an existing texture that matches with the updated range.
+ /// </summary>
+ /// <param name="texture">Texture to update</param>
+ /// <param name="range">New physical memory range</param>
+ /// <returns>True if the mapping was updated, false otherwise</returns>
+ public bool UpdateMapping(Texture texture, MultiRange range)
+ {
+ // There cannot be an existing texture compatible with this mapping in the texture cache already.
+ int overlapCount = _textures.FindOverlaps(range, ref _textureOverlaps);
+
+ for (int i = 0; i < overlapCount; i++)
+ {
+ var other = _textureOverlaps[i];
+
+ if (texture != other &&
+ (texture.IsViewCompatible(other.Info, other.Range, true, other.LayerSize, _context.Capabilities, out _, out _) != TextureViewCompatibility.Incompatible ||
+ other.IsViewCompatible(texture.Info, texture.Range, true, texture.LayerSize, _context.Capabilities, out _, out _) != TextureViewCompatibility.Incompatible))
+ {
+ return false;
+ }
+ }
+
+ _textures.Remove(texture);
+
+ texture.ReplaceRange(range);
+
+ _textures.Add(texture);
+
+ return true;
+ }
+
+ /// <summary>
/// Tries to find an existing texture, or create a new one if not found.
/// </summary>
/// <param name="memoryManager">GPU memory manager where the texture is mapped</param>