From 94a64f2aea3225d83a2aa1e61ed8d4bf8be49e5c Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 10 Jan 2023 22:53:56 -0300 Subject: Remove textures from cache on unmap if not mapped and modified (#4211) --- Ryujinx.Graphics.Gpu/Image/TextureGroup.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Ryujinx.Graphics.Gpu/Image/TextureGroup.cs') diff --git a/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs b/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs index ca54dc2f..cd17564a 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs @@ -434,6 +434,32 @@ namespace Ryujinx.Graphics.Gpu.Image } } + /// + /// Checks if a texture was modified by the GPU. + /// + /// The texture to be checked + /// True if any region of the texture was modified by the GPU, false otherwise + public bool AnyModified(Texture texture) + { + bool anyModified = false; + + EvaluateRelevantHandles(texture, (baseHandle, regionCount, split) => + { + for (int i = 0; i < regionCount; i++) + { + TextureGroupHandle group = _handles[baseHandle + i]; + + if (group.Modified) + { + anyModified = true; + break; + } + } + }); + + return anyModified; + } + /// /// Flush modified ranges for a given texture. /// -- cgit v1.2.3