aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/StructuredIr
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2023-06-15 17:31:53 -0300
committerGitHub <noreply@github.com>2023-06-15 17:31:53 -0300
commitf92921a6d118aa9c6acdb3ecaa3cd61a19fe341e (patch)
tree6cba0d6ad1dc27df5750cf671cd75f709082203d /src/Ryujinx.Graphics.Shader/StructuredIr
parent32d21ddf17ff7d61d8185a79bec3f5d02706109b (diff)
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
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/StructuredIr')
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs18
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs6
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs18
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs22
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs11
5 files changed, 48 insertions, 27 deletions
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs
index c348b5d9..ed910f96 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs
@@ -5,15 +5,13 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
[Flags]
enum HelperFunctionsMask
{
- AtomicMinMaxS32Shared = 1 << 0,
- MultiplyHighS32 = 1 << 2,
- MultiplyHighU32 = 1 << 3,
- Shuffle = 1 << 4,
- ShuffleDown = 1 << 5,
- ShuffleUp = 1 << 6,
- ShuffleXor = 1 << 7,
- StoreSharedSmallInt = 1 << 8,
- SwizzleAdd = 1 << 10,
- FSI = 1 << 11
+ MultiplyHighS32 = 1 << 2,
+ MultiplyHighU32 = 1 << 3,
+ Shuffle = 1 << 4,
+ ShuffleDown = 1 << 5,
+ ShuffleUp = 1 << 6,
+ ShuffleXor = 1 << 7,
+ SwizzleAdd = 1 << 10,
+ FSI = 1 << 11
}
} \ No newline at end of file
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs
index 6e201350..b08478ad 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs
@@ -90,8 +90,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Add(Instruction.ImageAtomic, AggregateType.S32);
Add(Instruction.IsNan, AggregateType.Bool, AggregateType.Scalar);
Add(Instruction.Load, AggregateType.FP32);
- Add(Instruction.LoadLocal, AggregateType.U32, AggregateType.S32);
- Add(Instruction.LoadShared, AggregateType.U32, AggregateType.S32);
Add(Instruction.Lod, AggregateType.FP32);
Add(Instruction.LogarithmB2, AggregateType.Scalar, AggregateType.Scalar);
Add(Instruction.LogicalAnd, AggregateType.Bool, AggregateType.Bool, AggregateType.Bool);
@@ -121,10 +119,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Add(Instruction.Sine, AggregateType.Scalar, AggregateType.Scalar);
Add(Instruction.SquareRoot, AggregateType.Scalar, AggregateType.Scalar);
Add(Instruction.Store, AggregateType.Void);
- Add(Instruction.StoreLocal, AggregateType.Void, AggregateType.S32, AggregateType.U32);
- Add(Instruction.StoreShared, AggregateType.Void, AggregateType.S32, AggregateType.U32);
- Add(Instruction.StoreShared16, AggregateType.Void, AggregateType.S32, AggregateType.U32);
- Add(Instruction.StoreShared8, AggregateType.Void, AggregateType.S32, AggregateType.U32);
Add(Instruction.Subtract, AggregateType.Scalar, AggregateType.Scalar, AggregateType.Scalar);
Add(Instruction.SwizzleAdd, AggregateType.FP32, AggregateType.FP32, AggregateType.FP32, AggregateType.S32);
Add(Instruction.TextureSample, AggregateType.FP32);
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs
new file mode 100644
index 00000000..c0bb750e
--- /dev/null
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs
@@ -0,0 +1,18 @@
+using Ryujinx.Graphics.Shader.Translation;
+
+namespace Ryujinx.Graphics.Shader.StructuredIr
+{
+ readonly struct MemoryDefinition
+ {
+ public string Name { get; }
+ public AggregateType Type { get; }
+ public int ArrayLength { get; }
+
+ public MemoryDefinition(string name, AggregateType type, int arrayLength = 1)
+ {
+ Name = name;
+ Type = type;
+ ArrayLength = arrayLength;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs
index 157c5937..c6132ef8 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs
@@ -6,14 +6,20 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
private readonly Dictionary<int, BufferDefinition> _constantBuffers;
private readonly Dictionary<int, BufferDefinition> _storageBuffers;
+ private readonly Dictionary<int, MemoryDefinition> _localMemories;
+ private readonly Dictionary<int, MemoryDefinition> _sharedMemories;
public IReadOnlyDictionary<int, BufferDefinition> ConstantBuffers => _constantBuffers;
public IReadOnlyDictionary<int, BufferDefinition> StorageBuffers => _storageBuffers;
+ public IReadOnlyDictionary<int, MemoryDefinition> LocalMemories => _localMemories;
+ public IReadOnlyDictionary<int, MemoryDefinition> SharedMemories => _sharedMemories;
public ShaderProperties()
{
_constantBuffers = new Dictionary<int, BufferDefinition>();
_storageBuffers = new Dictionary<int, BufferDefinition>();
+ _localMemories = new Dictionary<int, MemoryDefinition>();
+ _sharedMemories = new Dictionary<int, MemoryDefinition>();
}
public void AddConstantBuffer(int binding, BufferDefinition definition)
@@ -25,5 +31,21 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
_storageBuffers[binding] = definition;
}
+
+ public int AddLocalMemory(MemoryDefinition definition)
+ {
+ int id = _localMemories.Count;
+ _localMemories.Add(id, definition);
+
+ return id;
+ }
+
+ public int AddSharedMemory(MemoryDefinition definition)
+ {
+ int id = _sharedMemories.Count;
+ _sharedMemories.Add(id, definition);
+
+ return id;
+ }
}
} \ No newline at end of file
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
index a8f13276..9d12a73c 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
@@ -274,13 +274,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
// decide which helper functions are needed on the final generated code.
switch (operation.Inst)
{
- case Instruction.AtomicMaxS32:
- case Instruction.AtomicMinS32:
- if (operation.StorageKind == StorageKind.SharedMemory)
- {
- context.Info.HelperFunctionsMask |= HelperFunctionsMask.AtomicMinMaxS32Shared;
- }
- break;
case Instruction.MultiplyHighS32:
context.Info.HelperFunctionsMask |= HelperFunctionsMask.MultiplyHighS32;
break;
@@ -299,10 +292,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
case Instruction.ShuffleXor:
context.Info.HelperFunctionsMask |= HelperFunctionsMask.ShuffleXor;
break;
- case Instruction.StoreShared16:
- case Instruction.StoreShared8:
- context.Info.HelperFunctionsMask |= HelperFunctionsMask.StoreSharedSmallInt;
- break;
case Instruction.SwizzleAdd:
context.Info.HelperFunctionsMask |= HelperFunctionsMask.SwizzleAdd;
break;