aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Translation/Optimizations
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation/Optimizations')
-rw-r--r--Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs17
-rw-r--r--Ryujinx.Graphics.Shader/Translation/Optimizations/Optimizer.cs6
2 files changed, 20 insertions, 3 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs b/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs
index 7aabcc9e..ec8fca1d 100644
--- a/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs
+++ b/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs
@@ -8,14 +8,25 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
{
static class GlobalToStorage
{
- public static void RunPass(BasicBlock block, ShaderConfig config)
+ public static void RunPass(BasicBlock block, ShaderConfig config, ref int sbUseMask)
{
int sbStart = GetStorageBaseCbOffset(config.Stage);
-
int sbEnd = sbStart + StorageDescsSize;
for (LinkedListNode<INode> node = block.Operations.First; node != null; node = node.Next)
{
+ for (int index = 0; index < node.Value.SourcesCount; index++)
+ {
+ Operand src = node.Value.GetSource(index);
+
+ int storageIndex = GetStorageIndex(src, sbStart, sbEnd);
+
+ if (storageIndex >= 0)
+ {
+ sbUseMask |= 1 << storageIndex;
+ }
+ }
+
if (!(node.Value is Operation operation))
{
continue;
@@ -52,6 +63,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
}
}
}
+
+ config.SetAccessibleStorageBuffersMask(sbUseMask);
}
private static LinkedListNode<INode> ReplaceGlobalWithStorage(BasicBlock block, LinkedListNode<INode> node, ShaderConfig config, int storageIndex)
diff --git a/Ryujinx.Graphics.Shader/Translation/Optimizations/Optimizer.cs b/Ryujinx.Graphics.Shader/Translation/Optimizations/Optimizer.cs
index 47963eac..a1a2054c 100644
--- a/Ryujinx.Graphics.Shader/Translation/Optimizations/Optimizer.cs
+++ b/Ryujinx.Graphics.Shader/Translation/Optimizations/Optimizer.cs
@@ -11,14 +11,18 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
{
RunOptimizationPasses(blocks);
+ int sbUseMask = 0;
+
// Those passes are looking for specific patterns and only needs to run once.
for (int blkIndex = 0; blkIndex < blocks.Length; blkIndex++)
{
- GlobalToStorage.RunPass(blocks[blkIndex], config);
+ GlobalToStorage.RunPass(blocks[blkIndex], config, ref sbUseMask);
BindlessToIndexed.RunPass(blocks[blkIndex], config);
BindlessElimination.RunPass(blocks[blkIndex], config);
}
+ config.SetAccessibleStorageBuffersMask(sbUseMask);
+
// Run optimizations one last time to remove any code that is now optimizable after above passes.
RunOptimizationPasses(blocks);
}