Implement Load/Store Local/Shared and Atomic shared using new instructions (#5241)
* Implement Load/Store Local/Shared and Atomic shared using new instructions * Remove now unused code * Fix base offset register overwrite * Fix missing storage buffer set index when generating GLSL for Vulkan * Shader cache version bump * Remove more unused code * Some PR feedback
This commit is contained in:
parent
32d21ddf17
commit
f92921a6d1
30 changed files with 475 additions and 567 deletions
|
@ -1,6 +1,8 @@
|
|||
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
||||
using Ryujinx.Graphics.Shader.StructuredIr;
|
||||
using Ryujinx.Graphics.Shader.Translation.Optimizations;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
|
||||
|
@ -70,6 +72,15 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
node = InsertSharedStoreSmallInt(hfm, node);
|
||||
|
||||
if (config.Options.TargetLanguage != TargetLanguage.Spirv)
|
||||
{
|
||||
node = InsertSharedAtomicSigned(hfm, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,6 +182,87 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
operation.TurnIntoCopy(result);
|
||||
}
|
||||
|
||||
private static LinkedListNode<INode> InsertSharedStoreSmallInt(HelperFunctionManager hfm, LinkedListNode<INode> node)
|
||||
{
|
||||
Operation operation = (Operation)node.Value;
|
||||
HelperFunctionName name;
|
||||
|
||||
if (operation.StorageKind == StorageKind.SharedMemory8)
|
||||
{
|
||||
name = HelperFunctionName.SharedStore8;
|
||||
}
|
||||
else if (operation.StorageKind == StorageKind.SharedMemory16)
|
||||
{
|
||||
name = HelperFunctionName.SharedStore16;
|
||||
}
|
||||
else
|
||||
{
|
||||
return node;
|
||||
}
|
||||
|
||||
if (operation.Inst != Instruction.Store)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
|
||||
Operand memoryId = operation.GetSource(0);
|
||||
Operand byteOffset = operation.GetSource(1);
|
||||
Operand value = operation.GetSource(2);
|
||||
|
||||
Debug.Assert(memoryId.Type == OperandType.Constant);
|
||||
|
||||
int functionId = hfm.GetOrCreateFunctionId(name, memoryId.Value);
|
||||
|
||||
Operand[] callArgs = new Operand[] { Const(functionId), byteOffset, value };
|
||||
|
||||
LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, (Operand)null, callArgs));
|
||||
|
||||
Utils.DeleteNode(node, operation);
|
||||
|
||||
return newNode;
|
||||
}
|
||||
|
||||
private static LinkedListNode<INode> InsertSharedAtomicSigned(HelperFunctionManager hfm, LinkedListNode<INode> node)
|
||||
{
|
||||
Operation operation = (Operation)node.Value;
|
||||
HelperFunctionName name;
|
||||
|
||||
if (operation.Inst == Instruction.AtomicMaxS32)
|
||||
{
|
||||
name = HelperFunctionName.SharedAtomicMaxS32;
|
||||
}
|
||||
else if (operation.Inst == Instruction.AtomicMinS32)
|
||||
{
|
||||
name = HelperFunctionName.SharedAtomicMinS32;
|
||||
}
|
||||
else
|
||||
{
|
||||
return node;
|
||||
}
|
||||
|
||||
if (operation.StorageKind != StorageKind.SharedMemory)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
|
||||
Operand result = operation.Dest;
|
||||
Operand memoryId = operation.GetSource(0);
|
||||
Operand byteOffset = operation.GetSource(1);
|
||||
Operand value = operation.GetSource(2);
|
||||
|
||||
Debug.Assert(memoryId.Type == OperandType.Constant);
|
||||
|
||||
int functionId = hfm.GetOrCreateFunctionId(name, memoryId.Value);
|
||||
|
||||
Operand[] callArgs = new Operand[] { Const(functionId), byteOffset, value };
|
||||
|
||||
LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, result, callArgs));
|
||||
|
||||
Utils.DeleteNode(node, operation);
|
||||
|
||||
return newNode;
|
||||
}
|
||||
|
||||
private static LinkedListNode<INode> InsertTexelFetchScale(HelperFunctionManager hfm, LinkedListNode<INode> node, ShaderConfig config)
|
||||
{
|
||||
TextureOperation texOp = (TextureOperation)node.Value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue