|
@@ -16,24 +16,20 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|
|
|
|
|
|
|
public static ShaderProgram Translate(ulong address, IGpuAccessor gpuAccessor, TranslationFlags flags)
|
|
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)
|
|
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);
|
|
BasicBlock[] blocks = ControlFlowGraph.MakeCfg(ops);
|
|
|
|
|
|
|
@@ -63,16 +59,10 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|
|
|
|
|
|
|
string glslCode = program.Code;
|
|
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;
|
|
Block[] cfg;
|
|
|
|
|
|
|
@@ -93,10 +83,6 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|
|
{
|
|
{
|
|
|
gpuAccessor.Log("Invalid branch detected, failed to build CFG.");
|
|
gpuAccessor.Log("Invalid branch detected, failed to build CFG.");
|
|
|
|
|
|
|
|
- size = 0;
|
|
|
|
|
-
|
|
|
|
|
- featureFlags = FeatureFlags.None;
|
|
|
|
|
-
|
|
|
|
|
return Array.Empty<Operation>();
|
|
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();
|
|
return context.GetOperations();
|
|
|
}
|
|
}
|