Refactor shader translator ShaderConfig and reduce the number of out args (#1438)
This commit is contained in:
parent
b3c051bbec
commit
636542d817
4 changed files with 29 additions and 35 deletions
|
@ -16,24 +16,20 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
public static ShaderProgram Translate(ulong address, IGpuAccessor gpuAccessor, TranslationFlags flags)
|
||||
{
|
||||
Operation[] ops = DecodeShader(address, gpuAccessor, flags, out ShaderConfig config, out int size, out FeatureFlags featureFlags);
|
||||
|
||||
config.UsedFeatures = featureFlags;
|
||||
|
||||
return Translate(ops, config, size);
|
||||
return Translate(DecodeShader(address, gpuAccessor, flags, out ShaderConfig config), config);
|
||||
}
|
||||
|
||||
public static ShaderProgram Translate(ulong addressA, ulong addressB, IGpuAccessor gpuAccessor, TranslationFlags flags)
|
||||
{
|
||||
Operation[] opsA = DecodeShader(addressA, gpuAccessor, flags | TranslationFlags.VertexA, out _, out int sizeA, out FeatureFlags featureFlagsA);
|
||||
Operation[] opsB = DecodeShader(addressB, gpuAccessor, flags, out ShaderConfig config, out int sizeB, out FeatureFlags featureFlagsB);
|
||||
Operation[] opsA = DecodeShader(addressA, gpuAccessor, flags | TranslationFlags.VertexA, out ShaderConfig configA);
|
||||
Operation[] opsB = DecodeShader(addressB, gpuAccessor, flags, out ShaderConfig config);
|
||||
|
||||
config.UsedFeatures = featureFlagsA | featureFlagsB;
|
||||
config.SetUsedFeature(configA.UsedFeatures);
|
||||
|
||||
return Translate(Combine(opsA, opsB), config, sizeB, sizeA);
|
||||
return Translate(Combine(opsA, opsB), config, configA.Size);
|
||||
}
|
||||
|
||||
private static ShaderProgram Translate(Operation[] ops, ShaderConfig config, int size, int sizeA = 0)
|
||||
private static ShaderProgram Translate(Operation[] ops, ShaderConfig config, int sizeA = 0)
|
||||
{
|
||||
BasicBlock[] blocks = ControlFlowGraph.MakeCfg(ops);
|
||||
|
||||
|
@ -63,16 +59,10 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
string glslCode = program.Code;
|
||||
|
||||
return new ShaderProgram(spInfo, config.Stage, glslCode, size, sizeA);
|
||||
return new ShaderProgram(spInfo, config.Stage, glslCode, config.Size, sizeA);
|
||||
}
|
||||
|
||||
private static Operation[] DecodeShader(
|
||||
ulong address,
|
||||
IGpuAccessor gpuAccessor,
|
||||
TranslationFlags flags,
|
||||
out ShaderConfig config,
|
||||
out int size,
|
||||
out FeatureFlags featureFlags)
|
||||
private static Operation[] DecodeShader(ulong address, IGpuAccessor gpuAccessor, TranslationFlags flags, out ShaderConfig config)
|
||||
{
|
||||
Block[] cfg;
|
||||
|
||||
|
@ -93,10 +83,6 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
{
|
||||
gpuAccessor.Log("Invalid branch detected, failed to build CFG.");
|
||||
|
||||
size = 0;
|
||||
|
||||
featureFlags = FeatureFlags.None;
|
||||
|
||||
return Array.Empty<Operation>();
|
||||
}
|
||||
|
||||
|
@ -197,9 +183,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
}
|
||||
}
|
||||
|
||||
size = (int)maxEndAddress + (((flags & TranslationFlags.Compute) != 0) ? 0 : HeaderSize);
|
||||
|
||||
featureFlags = context.UsedFeatures;
|
||||
config.SizeAdd((int)maxEndAddress + (flags.HasFlag(TranslationFlags.Compute) ? 0 : HeaderSize));
|
||||
|
||||
return context.GetOperations();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue