diff options
author | gdkchan <gab.dark.100@gmail.com> | 2023-05-20 16:19:26 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-20 16:19:26 -0300 |
commit | 402f05b8ef013807997589ecc0a8ff50267dcd23 (patch) | |
tree | 8e3b06c2ce3e3ccd4b443a4c68365251acc668fa /src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs | |
parent | fb27042e01b0fa110184673d436ec96ec8cf20c7 (diff) |
Replace constant buffer access on shader with new Load instruction (#4646)1.1.811
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs')
-rw-r--r-- | src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs index 68bbdeb1..c5ad3683 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs @@ -298,6 +298,33 @@ namespace Ryujinx.Graphics.Shader.StructuredIr return newTemp; } + public IAstNode GetOperandOrCbLoad(Operand operand) + { + if (operand.Type == OperandType.ConstantBuffer) + { + int cbufSlot = operand.GetCbufSlot(); + int cbufOffset = operand.GetCbufOffset(); + + int binding = Config.ResourceManager.GetConstantBufferBinding(cbufSlot); + int vecIndex = cbufOffset >> 2; + int elemIndex = cbufOffset & 3; + + Config.ResourceManager.SetUsedConstantBufferBinding(binding); + + IAstNode[] sources = new IAstNode[] + { + new AstOperand(OperandType.Constant, binding), + new AstOperand(OperandType.Constant, 0), + new AstOperand(OperandType.Constant, vecIndex), + new AstOperand(OperandType.Constant, elemIndex) + }; + + return new AstOperation(Instruction.Load, StorageKind.ConstantBuffer, sources, sources.Length); + } + + return GetOperand(operand); + } + public AstOperand GetOperand(Operand operand) { if (operand == null) @@ -307,11 +334,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr if (operand.Type != OperandType.LocalVariable) { - if (operand.Type == OperandType.ConstantBuffer) - { - Config.SetUsedConstantBuffer(operand.GetCbufSlot()); - } - return new AstOperand(operand); } |