Update shader cache handling to process old versions
This commit is contained in:
parent
4e501f1a70
commit
95a0344eb4
5 changed files with 93 additions and 7 deletions
|
@ -232,10 +232,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
|
||||
for (int index = 0; index < ThreadCount; index++)
|
||||
{
|
||||
workThreads[index] = new Thread(ProcessAsyncQueue)
|
||||
{
|
||||
Name = $"GPU.AsyncTranslationThread.{index}",
|
||||
};
|
||||
workThreads[index] = new Thread(ProcessAsyncQueue) { Name = $"GPU.AsyncTranslationThread.{index}", };
|
||||
}
|
||||
|
||||
int programCount = _hostStorage.GetProgramCount();
|
||||
|
@ -305,6 +302,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
using var streams = _hostStorage.GetOutputStreams(_context);
|
||||
|
||||
int packagedShaders = 0;
|
||||
ProgramPipelineState previousPipelineState = default;
|
||||
ProgramPipelineState currentPipelineState = default;
|
||||
|
||||
foreach (var kv in _programList)
|
||||
{
|
||||
if (!Active)
|
||||
|
@ -314,9 +314,53 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
|
||||
(CachedShaderProgram program, byte[] binaryCode) = kv.Value;
|
||||
|
||||
_hostStorage.AddShader(_context, program, binaryCode, streams);
|
||||
if (program.SpecializationState.PipelineState.HasValue && _context.Capabilities.SupportsExtendedDynamicState)
|
||||
{
|
||||
currentPipelineState = program.SpecializationState.PipelineState.Value;
|
||||
|
||||
_stateChangeCallback(ShaderCacheState.Packaging, ++packagedShaders, _programList.Count);
|
||||
if (_context.Capabilities.SupportsExtendedDynamicState)
|
||||
{
|
||||
currentPipelineState.StencilTest = default;
|
||||
|
||||
currentPipelineState.CullMode = 0;
|
||||
currentPipelineState.FrontFace = 0;
|
||||
currentPipelineState.DepthTest = default;
|
||||
currentPipelineState.Topology = ConvertToClass(currentPipelineState.Topology);
|
||||
}
|
||||
|
||||
if (_context.Capabilities.SupportsExtendedDynamicState2)
|
||||
{
|
||||
currentPipelineState.PrimitiveRestartEnable = false;
|
||||
currentPipelineState.BiasEnable = 0;
|
||||
currentPipelineState.RasterizerDiscard = false;
|
||||
|
||||
}
|
||||
|
||||
if (_context.Capabilities.SupportsLogicOpDynamicState)
|
||||
{
|
||||
currentPipelineState.LogicOp = 0;
|
||||
}
|
||||
|
||||
if (_context.Capabilities.SupportsPatchControlPointsDynamicState)
|
||||
{
|
||||
currentPipelineState.PatchControlPoints = 0;
|
||||
}
|
||||
|
||||
currentPipelineState = program.SpecializationState.PipelineState.Value;
|
||||
}
|
||||
|
||||
|
||||
if (currentPipelineState.Equals(previousPipelineState) || !_context.Capabilities.SupportsExtendedDynamicState)
|
||||
{
|
||||
_hostStorage.AddShader(_context, program, binaryCode, streams);
|
||||
|
||||
_stateChangeCallback(ShaderCacheState.Packaging, ++packagedShaders, _programList.Count);
|
||||
}
|
||||
|
||||
if (_context.Capabilities.SupportsExtendedDynamicState)
|
||||
{
|
||||
previousPipelineState = currentPipelineState;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Info?.Print(LogClass.Gpu, $"Rebuilt {_programList.Count} shaders successfully.");
|
||||
|
@ -343,6 +387,28 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
_stateChangeCallback(ShaderCacheState.Loaded, programCount, programCount);
|
||||
}
|
||||
|
||||
private PrimitiveTopology ConvertToClass(PrimitiveTopology topology)
|
||||
{
|
||||
return topology switch
|
||||
{
|
||||
PrimitiveTopology.Points => PrimitiveTopology.Points,
|
||||
PrimitiveTopology.Lines or
|
||||
PrimitiveTopology.LineStrip or
|
||||
PrimitiveTopology.LinesAdjacency or
|
||||
PrimitiveTopology.LineStripAdjacency => PrimitiveTopology.Lines,
|
||||
PrimitiveTopology.Triangles or
|
||||
PrimitiveTopology.TriangleStrip or
|
||||
PrimitiveTopology.TriangleFan or
|
||||
PrimitiveTopology.TrianglesAdjacency or
|
||||
PrimitiveTopology.TriangleStripAdjacency or
|
||||
PrimitiveTopology.Polygon => PrimitiveTopology.TriangleStrip,
|
||||
PrimitiveTopology.Patches => PrimitiveTopology.Patches,
|
||||
PrimitiveTopology.Quads => PrimitiveTopology.Quads,
|
||||
PrimitiveTopology.QuadStrip => PrimitiveTopology.QuadStrip,
|
||||
PrimitiveTopology.LineLoop => PrimitiveTopology.LineLoop,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enqueues a host program for compilation.
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue