Replace constant buffer access on shader with new Load instruction (#4646)

This commit is contained in:
gdkchan 2023-05-20 16:19:26 -03:00 committed by GitHub
parent fb27042e01
commit 402f05b8ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 788 additions and 625 deletions

View file

@ -549,11 +549,31 @@ namespace Ryujinx.Graphics.Shader.Translation
return context.Add(fpType | Instruction.IsNan, Local(), a);
}
public static Operand Load(this EmitterContext context, StorageKind storageKind, int binding)
{
return context.Add(Instruction.Load, storageKind, Local(), Const(binding));
}
public static Operand Load(this EmitterContext context, StorageKind storageKind, int binding, Operand e0)
{
return context.Add(Instruction.Load, storageKind, Local(), Const(binding), e0);
}
public static Operand Load(this EmitterContext context, StorageKind storageKind, int binding, Operand e0, Operand e1)
{
return context.Add(Instruction.Load, storageKind, Local(), Const(binding), e0, e1);
}
public static Operand Load(this EmitterContext context, StorageKind storageKind, int binding, Operand e0, Operand e1, Operand e2)
{
return context.Add(Instruction.Load, storageKind, Local(), Const(binding), e0, e1, e2);
}
public static Operand Load(this EmitterContext context, StorageKind storageKind, IoVariable ioVariable, Operand primVertex = null)
{
return primVertex != null
? context.Add(Instruction.Load, storageKind, Local(), Const((int)ioVariable), primVertex)
: context.Add(Instruction.Load, storageKind, Local(), Const((int)ioVariable));
? context.Load(storageKind, (int)ioVariable, primVertex)
: context.Load(storageKind, (int)ioVariable);
}
public static Operand Load(
@ -564,8 +584,8 @@ namespace Ryujinx.Graphics.Shader.Translation
Operand elemIndex)
{
return primVertex != null
? context.Add(Instruction.Load, storageKind, Local(), Const((int)ioVariable), primVertex, elemIndex)
: context.Add(Instruction.Load, storageKind, Local(), Const((int)ioVariable), elemIndex);
? context.Load(storageKind, (int)ioVariable, primVertex, elemIndex)
: context.Load(storageKind, (int)ioVariable, elemIndex);
}
public static Operand Load(
@ -577,22 +597,8 @@ namespace Ryujinx.Graphics.Shader.Translation
Operand elemIndex)
{
return primVertex != null
? context.Add(Instruction.Load, storageKind, Local(), Const((int)ioVariable), primVertex, arrayIndex, elemIndex)
: context.Add(Instruction.Load, storageKind, Local(), Const((int)ioVariable), arrayIndex, elemIndex);
}
public static Operand LoadConstant(this EmitterContext context, Operand a, Operand b)
{
if (a.Type == OperandType.Constant)
{
context.Config.SetUsedConstantBuffer(a.Value);
}
else
{
context.Config.SetUsedFeature(FeatureFlags.CbIndexing);
}
return context.Add(Instruction.LoadConstant, Local(), a, b);
? context.Load(storageKind, (int)ioVariable, primVertex, arrayIndex, elemIndex)
: context.Load(storageKind, (int)ioVariable, arrayIndex, elemIndex);
}
public static Operand LoadGlobal(this EmitterContext context, Operand a, Operand b)