Use a new approach for shader BRX targets (#2532)
* Use a new approach for shader BRX targets * Make shader cache actually work * Improve the shader pattern matching a bit * Extend LDC search to predecessor blocks, catches more cases * Nit * Only save the amount of constant buffer data actually used. Avoids crashes on partially mapped buffers * Ignore Rd on predicate instructions, as they do not have a Rd register (catches more cases)
This commit is contained in:
parent
70f79e689b
commit
d9d18439f6
12 changed files with 472 additions and 149 deletions
|
@ -38,6 +38,11 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
|
|||
/// </summary>
|
||||
RemoveManifestEntries,
|
||||
|
||||
/// <summary>
|
||||
/// Remove entries from the hash manifest and save it, and also deletes the temporary file.
|
||||
/// </summary>
|
||||
RemoveManifestEntryAndTempFile,
|
||||
|
||||
/// <summary>
|
||||
/// Flush temporary cache to archive.
|
||||
/// </summary>
|
||||
|
@ -116,6 +121,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
|
|||
/// </summary>
|
||||
private ZipArchive _cacheArchive;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the cache collection supports modification.
|
||||
/// </summary>
|
||||
public bool IsReadOnly { get; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -264,6 +272,21 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove given entry from the manifest and delete the temporary file.
|
||||
/// </summary>
|
||||
/// <param name="entry">Entry to remove from the manifest</param>
|
||||
private void RemoveManifestEntryAndTempFile(Hash128 entry)
|
||||
{
|
||||
lock (_hashTable)
|
||||
{
|
||||
_hashTable.Remove(entry);
|
||||
SaveManifest();
|
||||
}
|
||||
|
||||
File.Delete(GenCacheTempFilePath(entry));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queue a task to flush temporary files to the archive on the worker.
|
||||
/// </summary>
|
||||
|
@ -440,6 +463,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
|
|||
case CacheFileOperation.RemoveManifestEntries:
|
||||
RemoveManifestEntries((HashSet<Hash128>)task.Data);
|
||||
break;
|
||||
case CacheFileOperation.RemoveManifestEntryAndTempFile:
|
||||
RemoveManifestEntryAndTempFile((Hash128)task.Data);
|
||||
break;
|
||||
case CacheFileOperation.FlushToArchive:
|
||||
FlushToArchive();
|
||||
break;
|
||||
|
@ -472,7 +498,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
|
|||
{
|
||||
if (IsReadOnly)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Gpu, "Trying to add {keyHash} on a read-only cache, ignoring.");
|
||||
Logger.Warning?.Print(LogClass.Gpu, $"Trying to add {keyHash} on a read-only cache, ignoring.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -521,7 +547,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
|
|||
{
|
||||
if (IsReadOnly)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Gpu, "Trying to replace {keyHash} on a read-only cache, ignoring.");
|
||||
Logger.Warning?.Print(LogClass.Gpu, $"Trying to replace {keyHash} on a read-only cache, ignoring.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -540,6 +566,27 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
|
|||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a value at the given hash from the cache.
|
||||
/// </summary>
|
||||
/// <param name="keyHash">The hash of the value in the cache</param>
|
||||
public void RemoveValue(ref Hash128 keyHash)
|
||||
{
|
||||
if (IsReadOnly)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Gpu, $"Trying to remove {keyHash} on a read-only cache, ignoring.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Only queue file change operations
|
||||
_fileWriterWorkerQueue.Add(new CacheFileOperationTask
|
||||
{
|
||||
Type = CacheFileOperation.RemoveManifestEntryAndTempFile,
|
||||
Data = keyHash
|
||||
});
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue