From b066cfc1a3e31bf7197ddbd0f4d774b886cd9d65 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Mon, 12 Oct 2020 21:40:50 -0300 Subject: Add support for shader constant buffer slot indexing (#1608) * Add support for shader constant buffer slot indexing * Fix typo --- Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs | 2 +- .../CodeGen/Glsl/Instructions/InstGenMemory.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions') diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs index 551fb229..f1c741e6 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs @@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions } else if (node is AstOperand operand) { - return context.OperandManager.GetExpression(operand, context.Config); + return context.OperandManager.GetExpression(operand, context.Config, context.CbIndexable); } throw new ArgumentException($"Invalid node type \"{node?.GetType().Name ?? "null"}\"."); diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs index 8866cd25..cb339f05 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs @@ -125,7 +125,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions offsetExpr = Enclose(offsetExpr, src2, Instruction.ShiftRightS32, isLhs: true); - return OperandManager.GetConstantBufferName(src1, offsetExpr, context.Config.Stage); + if (src1 is AstOperand oper && oper.Type == OperandType.Constant) + { + return OperandManager.GetConstantBufferName(oper.Value, offsetExpr, context.Config.Stage, context.CbIndexable); + } + else + { + string slotExpr = GetSoureExpr(context, src1, GetSrcVarType(operation.Inst, 0)); + + return OperandManager.GetConstantBufferName(slotExpr, offsetExpr, context.Config.Stage); + } } public static string LoadLocal(CodeGenContext context, AstOperation operation) -- cgit v1.2.3