mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-10-01 12:30:00 +02:00
Revert "Simplify shader uniform buffer access codegen"
This reverts commit 2fe9ebaf118d690be8d0cb302529dd359d7c402b.
This commit is contained in:
parent
1df78e7ad6
commit
73e68edd09
3 changed files with 25 additions and 18 deletions
|
@ -206,13 +206,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
|||
|
||||
context.CBufferDescriptors.Add(new BufferDescriptor(ubName, cbufSlot));
|
||||
|
||||
context.AppendLine("uniform " + ubName);
|
||||
context.AppendLine("layout (std140) uniform " + ubName);
|
||||
|
||||
context.EnterScope();
|
||||
|
||||
string ubSize = "[" + NumberFormatter.FormatInt(Constants.ConstantBufferSize / 4) + "]";
|
||||
string ubSize = "[" + NumberFormatter.FormatInt(Constants.ConstantBufferSize / 16) + "]";
|
||||
|
||||
context.AppendLine("precise float " + OperandManager.GetUbName(context.Config.Stage, cbufSlot) + ubSize + ";");
|
||||
context.AppendLine("vec4 " + OperandManager.GetUbName(context.Config.Stage, cbufSlot) + ubSize + ";");
|
||||
|
||||
context.LeaveScope(";");
|
||||
}
|
||||
|
|
|
@ -116,12 +116,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
|||
|
||||
offsetExpr = Enclose(offsetExpr, src2, Instruction.ShiftRightS32, isLhs: true);
|
||||
|
||||
// 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);
|
||||
return OperandManager.GetConstantBufferName(src1, offsetExpr, context.Config.Stage);
|
||||
}
|
||||
|
||||
public static string LoadGlobal(CodeGenContext context, AstOperation operation)
|
||||
|
@ -508,7 +503,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
|||
// restrictions.
|
||||
int ubOffset = GlobalToStorage.GetStorageCbOffset(stage, slot);
|
||||
|
||||
string ubName = OperandManager.GetUniformBufferAccessor(0, ubOffset, stage);
|
||||
string ubName = OperandManager.GetConstantBufferName(0, ubOffset, stage);
|
||||
|
||||
offsetExpr = $"{offsetExpr} - int((floatBitsToUint({ubName}) & {mask}) >> 2)";
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
|||
return NumberFormatter.FormatInt(operand.Value);
|
||||
|
||||
case OperandType.ConstantBuffer:
|
||||
return GetUniformBufferAccessor(operand.CbufSlot, operand.CbufOffset, stage);
|
||||
return GetConstantBufferName(operand.CbufSlot, operand.CbufOffset, stage);
|
||||
|
||||
case OperandType.LocalVariable:
|
||||
return _locals[operand];
|
||||
|
@ -105,16 +105,28 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
|||
throw new ArgumentException($"Invalid operand type \"{operand.Type}\".");
|
||||
}
|
||||
|
||||
public static string GetUniformBufferAccessor(int slot, int offset, ShaderStage stage)
|
||||
{
|
||||
return GetUniformBufferAccessor(slot, NumberFormatter.FormatInt(offset), stage);
|
||||
}
|
||||
|
||||
public static string GetUniformBufferAccessor(int slot, string offsetExpr, ShaderStage stage)
|
||||
public static string GetConstantBufferName(int slot, int offset, ShaderStage stage)
|
||||
{
|
||||
string ubName = GetUbName(stage, slot);
|
||||
|
||||
return $"{ubName}[{offsetExpr}]";
|
||||
ubName += "[" + (offset >> 2) + "]";
|
||||
|
||||
return ubName + "." + GetSwizzleMask(offset & 3);
|
||||
}
|
||||
|
||||
public static string GetConstantBufferName(IAstNode slot, string offsetExpr, ShaderStage stage)
|
||||
{
|
||||
// Non-constant slots are not supported.
|
||||
// It is expected that upstream stages are never going to generate non-constant
|
||||
// slot access.
|
||||
AstOperand operand = (AstOperand)slot;
|
||||
|
||||
string ubName = GetUbName(stage, operand.Value);
|
||||
|
||||
string index0 = "[" + offsetExpr + " >> 2]";
|
||||
string index1 = "[" + offsetExpr + " & 3]";
|
||||
|
||||
return ubName + index0 + index1;
|
||||
}
|
||||
|
||||
public static string GetOutAttributeName(AstOperand attr, ShaderStage stage)
|
||||
|
|
Loading…
Reference in a new issue