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/Instructions/InstEmitMemory.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'Ryujinx.Graphics.Shader/Instructions') diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs index 24ba9a06..2a2c8927 100644 --- a/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs +++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs @@ -112,7 +112,7 @@ namespace Ryujinx.Graphics.Shader.Instructions res = context.FPMultiply(res, Attribute(AttributeConsts.PositionW)); } } - + if (op.Mode == InterpolationMode.Default) { Operand srcB = GetSrcB(context); @@ -152,7 +152,17 @@ namespace Ryujinx.Graphics.Shader.Instructions int count = op.Size == IntegerSize.B64 ? 2 : 1; - Operand addr = context.IAdd(GetSrcA(context), Const(op.Offset)); + Operand slot = Const(op.Slot); + Operand srcA = GetSrcA(context); + + if (op.IndexMode == CbIndexMode.Is || + op.IndexMode == CbIndexMode.Isl) + { + slot = context.IAdd(slot, context.BitfieldExtractU32(srcA, Const(16), Const(16))); + srcA = context.BitwiseAnd(srcA, Const(0xffff)); + } + + Operand addr = context.IAdd(srcA, Const(op.Offset)); Operand wordOffset = context.ShiftRightU32(addr, Const(2)); @@ -169,7 +179,7 @@ namespace Ryujinx.Graphics.Shader.Instructions Operand offset = context.IAdd(wordOffset, Const(index)); - Operand value = context.LoadConstant(Const(op.Slot), offset); + Operand value = context.LoadConstant(slot, offset); if (isSmallInt) { -- cgit v1.2.3