Simplify shader uniform buffer access codegen

This commit is contained in:
gdk 2019-11-24 14:20:48 -03:00 committed by Thog
parent 16d88c21fc
commit 1df78e7ad6
3 changed files with 18 additions and 25 deletions

View file

@ -116,7 +116,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
offsetExpr = Enclose(offsetExpr, src2, Instruction.ShiftRightS32, isLhs: true);
return OperandManager.GetConstantBufferName(src1, offsetExpr, context.Config.Stage);
// TODO: For now this is assumed to be constant
// (we only use constant slots right now), but we should also
// support non-constant values, necessary for full LDC implementation.
int slot = ((AstOperand)src1).Value;
return OperandManager.GetUniformBufferAccessor(slot, offsetExpr, context.Config.Stage);
}
public static string LoadGlobal(CodeGenContext context, AstOperation operation)
@ -503,7 +508,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
// restrictions.
int ubOffset = GlobalToStorage.GetStorageCbOffset(stage, slot);
string ubName = OperandManager.GetConstantBufferName(0, ubOffset, stage);
string ubName = OperandManager.GetUniformBufferAccessor(0, ubOffset, stage);
offsetExpr = $"{offsetExpr} - int((floatBitsToUint({ubName}) & {mask}) >> 2)";