aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary <me@thog.eu>2020-11-17 22:31:05 +0100
committerGitHub <noreply@github.com>2020-11-17 22:31:05 +0100
commitcc60ba9d22ecc582206b61074a0fd6ee2c987ed1 (patch)
tree7cc15c0ad58b5f9769208bede99fae0617474103
parent383c0390370aa52243abfd1189d23b080cbfbb14 (diff)
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
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs23
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/Cache/CacheManager.cs4
2 files changed, 24 insertions, 3 deletions
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
@@ -34,6 +34,11 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
SaveManifest,
/// <summary>
+ /// Remove entries from the hash manifest and save it.
+ /// </summary>
+ RemoveManifestEntries,
+
+ /// <summary>
/// Flush temporary cache to archive.
/// </summary>
FlushToArchive,
@@ -228,10 +233,23 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
}
/// <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;
diff --git a/Ryujinx.Graphics.Gpu/Shader/Cache/CacheManager.cs b/Ryujinx.Graphics.Gpu/Shader/Cache/CacheManager.cs
index 0c4eba2a..f977e96b 100644
--- a/Ryujinx.Graphics.Gpu/Shader/Cache/CacheManager.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/Cache/CacheManager.cs
@@ -58,8 +58,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
/// <param name="entries">Entries to remove from the manifest of all caches</param>
public void RemoveManifestEntries(HashSet<Hash128> entries)
{
- _guestProgramCache.RemoveManifestEntries(entries);
- _hostProgramCache.RemoveManifestEntries(entries);
+ _guestProgramCache.RemoveManifestEntriesAsync(entries);
+ _hostProgramCache.RemoveManifestEntriesAsync(entries);
}
/// <summary>