aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
diff options
context:
space:
mode:
authorgdk <gab.dark.100@gmail.com>2019-11-30 23:53:09 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commit6a98c643cabeea25dc42e19fe475a687a034a532 (patch)
treeccb1ecbfc5b79852be8a1f52e241015142a8a7a9 /Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
parent396768f3b4494c7dcb0c03942eeb50ef4d47adde (diff)
Add a pass to turn global memory access into storage access, and do all storage related transformations on IR
Diffstat (limited to 'Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs')
-rw-r--r--Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs29
1 files changed, 23 insertions, 6 deletions
diff --git a/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs b/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
index a81b3d12..a85fbae3 100644
--- a/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
+++ b/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
@@ -1,4 +1,5 @@
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
+using Ryujinx.Graphics.Shader.Translation;
using System;
using System.Collections.Generic;
@@ -80,7 +81,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
else if (UsesStorage(inst))
{
- context.Info.SBuffers.Add(operation.Index);
+ AddSBufferUse(context.Info.SBuffers, operation);
}
AstAssignment assignment;
@@ -159,7 +160,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
if (UsesStorage(inst))
{
- context.Info.SBuffers.Add(operation.Index);
+ AddSBufferUse(context.Info.SBuffers, operation);
}
context.AddNode(new AstOperation(inst, operation.Index, sources));
@@ -170,10 +171,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
// decide which helper functions are needed on the final generated code.
switch (operation.Inst)
{
- case Instruction.LoadGlobal:
- case Instruction.StoreGlobal:
- context.Info.HelperFunctionsMask |= HelperFunctionsMask.GlobalMemory;
- break;
case Instruction.Shuffle:
context.Info.HelperFunctionsMask |= HelperFunctionsMask.Shuffle;
break;
@@ -192,6 +189,26 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
}
+ private static void AddSBufferUse(HashSet<int> sBuffers, Operation operation)
+ {
+ Operand slot = operation.GetSource(0);
+
+ if (slot.Type == OperandType.Constant)
+ {
+ sBuffers.Add(slot.Value);
+ }
+ else
+ {
+ // If the value is not constant, then we don't know
+ // how many storage buffers are used, so we assume
+ // all of them are used.
+ for (int index = 0; index < GlobalMemory.StorageMaxCount; index++)
+ {
+ sBuffers.Add(index);
+ }
+ }
+ }
+
private static VariableType GetVarTypeFromUses(Operand dest)
{
HashSet<Operand> visited = new HashSet<Operand>();