aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs')
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs32
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);
}