From cc60ba9d22ecc582206b61074a0fd6ee2c987ed1 Mon Sep 17 00:00:00 2001 From: Mary <me@thog.eu> Date: Tue, 17 Nov 2020 22:31:05 +0100 Subject: shader cache: Fix possible race causing crashes on manifest at startup (#1718) * shader cache: Fix possible race causing crashes on manifest at startup This fix a misplace function call ending up causing possibly two write on the cache.info at the same time. * shader cache: Make RemoveManifestEntries async too to be sure all operations are perform before starting the game --- .../Shader/Cache/CacheCollection.cs | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs') diff --git a/Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs b/Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs index effd893a..924d720b 100644 --- a/Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs +++ b/Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs @@ -33,6 +33,11 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache /// </summary> SaveManifest, + /// <summary> + /// Remove entries from the hash manifest and save it. + /// </summary> + RemoveManifestEntries, + /// <summary> /// Flush temporary cache to archive. /// </summary> @@ -227,11 +232,24 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache FlushToArchive(); } + /// <summary> + /// Queue a task to remove entries from the hash manifest. + /// </summary> + /// <param name="entries">Entries to remove from the manifest</param> + public void RemoveManifestEntriesAsync(HashSet<Hash128> entries) + { + _fileWriterWorkerQueue.Add(new CacheFileOperationTask + { + Type = CacheFileOperation.RemoveManifestEntries, + Data = entries + }); + } + /// <summary> /// Remove given entries from the manifest. /// </summary> /// <param name="entries">Entries to remove from the manifest</param> - public void RemoveManifestEntries(HashSet<Hash128> entries) + private void RemoveManifestEntries(HashSet<Hash128> entries) { lock (_hashTable) { @@ -488,6 +506,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache case CacheFileOperation.SaveManifest: SaveManifest(); break; + case CacheFileOperation.RemoveManifestEntries: + RemoveManifestEntries((HashSet<Hash128>)task.Data); + break; case CacheFileOperation.FlushToArchive: FlushToArchive(); break; -- cgit v1.2.3-70-g09d2