Simplify handling of shader vertex A (#1999)
* Simplify handling of shader vertex A * Theres no transformation feedback, its transform * Merge TextureHandlesForCache
This commit is contained in:
parent
1319eda8b7
commit
4047477866
6 changed files with 52 additions and 94 deletions
|
@ -36,22 +36,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
return new TranslatorContext(address, cfg, config);
|
||||
}
|
||||
|
||||
public static TranslatorContext CreateContext(
|
||||
ulong addressA,
|
||||
ulong addressB,
|
||||
IGpuAccessor gpuAccessor,
|
||||
TranslationFlags flags,
|
||||
TranslationCounts counts = null)
|
||||
{
|
||||
counts ??= new TranslationCounts();
|
||||
|
||||
Block[][] cfgA = DecodeShader(addressA, gpuAccessor, flags | TranslationFlags.VertexA, counts, out ShaderConfig configA);
|
||||
Block[][] cfgB = DecodeShader(addressB, gpuAccessor, flags, counts, out ShaderConfig configB);
|
||||
|
||||
return new TranslatorContext(addressA, addressB, cfgA, cfgB, configA, configB);
|
||||
}
|
||||
|
||||
internal static ShaderProgram Translate(FunctionCode[] functions, ShaderConfig config, out ShaderProgramInfo shaderProgramInfo, int sizeA = 0)
|
||||
internal static ShaderProgram Translate(FunctionCode[] functions, ShaderConfig config, out ShaderProgramInfo shaderProgramInfo)
|
||||
{
|
||||
var cfgs = new ControlFlowGraph[functions.Length];
|
||||
var frus = new RegisterUsage.FunctionRegisterUsage[functions.Length];
|
||||
|
@ -113,7 +98,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
string glslCode = program.Code;
|
||||
|
||||
return new ShaderProgram(config.Stage, glslCode, config.Size, sizeA);
|
||||
return new ShaderProgram(config.Stage, glslCode);
|
||||
}
|
||||
|
||||
private static Block[][] DecodeShader(
|
||||
|
|
|
@ -10,16 +10,12 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
public class TranslatorContext
|
||||
{
|
||||
private readonly Block[][] _cfg;
|
||||
private readonly Block[][] _cfgA;
|
||||
private ShaderConfig _config;
|
||||
private ShaderConfig _configA;
|
||||
|
||||
public ulong Address { get; }
|
||||
public ulong AddressA { get; }
|
||||
|
||||
public ShaderStage Stage => _config.Stage;
|
||||
public int Size => _config.Size;
|
||||
public int SizeA => _configA != null ? _configA.Size : 0;
|
||||
|
||||
public HashSet<int> TextureHandlesForCache => _config.TextureHandlesForCache;
|
||||
|
||||
|
@ -27,22 +23,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
internal TranslatorContext(ulong address, Block[][] cfg, ShaderConfig config)
|
||||
{
|
||||
Address = address;
|
||||
AddressA = 0;
|
||||
_config = config;
|
||||
_configA = null;
|
||||
_cfg = cfg;
|
||||
_cfgA = null;
|
||||
}
|
||||
|
||||
internal TranslatorContext(ulong addressA, ulong addressB, Block[][] cfgA, Block[][] cfgB, ShaderConfig configA, ShaderConfig configB)
|
||||
{
|
||||
Address = addressB;
|
||||
AddressA = addressA;
|
||||
_config = configB;
|
||||
_configA = configA;
|
||||
_cfg = cfgB;
|
||||
_cfgA = cfgA;
|
||||
Address = address;
|
||||
_config = config;
|
||||
_cfg = cfg;
|
||||
}
|
||||
|
||||
private static bool IsUserAttribute(Operand operand)
|
||||
|
@ -141,20 +124,19 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
return output;
|
||||
}
|
||||
|
||||
public ShaderProgram Translate(out ShaderProgramInfo shaderProgramInfo)
|
||||
public ShaderProgram Translate(out ShaderProgramInfo shaderProgramInfo, TranslatorContext other = null)
|
||||
{
|
||||
FunctionCode[] code = EmitShader(_cfg, _config);
|
||||
|
||||
if (_configA != null)
|
||||
if (other != null)
|
||||
{
|
||||
FunctionCode[] codeA = EmitShader(_cfgA, _configA);
|
||||
_config.SetUsedFeature(other._config.UsedFeatures);
|
||||
TextureHandlesForCache.UnionWith(other.TextureHandlesForCache);
|
||||
|
||||
_config.SetUsedFeature(_configA.UsedFeatures);
|
||||
|
||||
code = Combine(codeA, code);
|
||||
code = Combine(EmitShader(other._cfg, other._config), code);
|
||||
}
|
||||
|
||||
return Translator.Translate(code, _config, out shaderProgramInfo, SizeA);
|
||||
return Translator.Translate(code, _config, out shaderProgramInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue