diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2023-10-04 19:46:11 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-04 19:46:11 -0300 |
| commit | a0af6e4d07f623692943c5fe68b183365b38c812 (patch) | |
| tree | c8bec298b2671a8a1cc205a2cee6c5a583655173 /src/Ryujinx.Graphics.Shader/CodeGen | |
| parent | f61b7818c3330fa0cda3fcde5b1de51b1477bfa0 (diff) | |
Use unique temporary variables for function call parameters on SPIR-V (#5757)
* Use unique temporary variables for function call parameters on SPIR-V
* Shader cache version bump
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/CodeGen')
4 files changed, 1 insertions, 41 deletions
diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs index 9f9411a9..53267c60 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs @@ -44,7 +44,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv public StructuredFunction CurrentFunction { get; set; } private readonly Dictionary<AstOperand, Instruction> _locals = new(); - private readonly Dictionary<int, Instruction[]> _localForArgs = new(); private readonly Dictionary<int, Instruction> _funcArgs = new(); private readonly Dictionary<int, (StructuredFunction, Instruction)> _functions = new(); @@ -112,7 +111,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv IsMainFunction = isMainFunction; MayHaveReturned = false; _locals.Clear(); - _localForArgs.Clear(); _funcArgs.Clear(); } @@ -169,11 +167,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv _locals.Add(local, spvLocal); } - public void DeclareLocalForArgs(int funcIndex, Instruction[] spvLocals) - { - _localForArgs.Add(funcIndex, spvLocals); - } - public void DeclareArgument(int argIndex, Instruction spvLocal) { _funcArgs.Add(argIndex, spvLocal); @@ -278,11 +271,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv return _locals[local]; } - public Instruction[] GetLocalForArgsPointers(int funcIndex) - { - return _localForArgs[funcIndex]; - } - public Instruction GetArgumentPointer(AstOperand funcArg) { return _funcArgs[funcArg.Value]; diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs index 54767c2f..45933a21 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs @@ -41,28 +41,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv } } - public static void DeclareLocalForArgs(CodeGenContext context, List<StructuredFunction> functions) - { - for (int funcIndex = 0; funcIndex < functions.Count; funcIndex++) - { - StructuredFunction function = functions[funcIndex]; - SpvInstruction[] locals = new SpvInstruction[function.InArguments.Length]; - - for (int i = 0; i < function.InArguments.Length; i++) - { - var type = function.GetArgumentType(i); - var localPointerType = context.TypePointer(StorageClass.Function, context.GetType(type)); - var spvLocal = context.Variable(localPointerType, StorageClass.Function); - - context.AddLocalVariable(spvLocal); - - locals[i] = spvLocal; - } - - context.DeclareLocalForArgs(funcIndex, locals); - } - } - public static void DeclareAll(CodeGenContext context, StructuredProgramInfo info) { DeclareConstantBuffers(context, context.Properties.ConstantBuffers.Values); diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs index 771723c2..56263e79 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs @@ -311,7 +311,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv var (function, spvFunc) = context.GetFunction(funcId.Value); var args = new SpvInstruction[operation.SourcesCount - 1]; - var spvLocals = context.GetLocalForArgsPointers(funcId.Value); for (int i = 0; i < args.Length; i++) { @@ -324,12 +323,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv else { var type = function.GetArgumentType(i); - var value = context.Get(type, operand); - var spvLocal = spvLocals[i]; - context.Store(spvLocal, value); - - args[i] = spvLocal; + args[i] = context.Get(type, operand); } } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs index 0e9e32bb..a1e9054f 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs @@ -161,7 +161,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv context.EnterBlock(function.MainBlock); Declarations.DeclareLocals(context, function); - Declarations.DeclareLocalForArgs(context, info.Functions); Generate(context, function.MainBlock); |
