aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs
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/Translation/ResourceManager.cs
parent32d21ddf17ff7d61d8185a79bec3f5d02706109b (diff)
Implement Load/Store Local/Shared and Atomic shared using new instructions (#5241)1.1.896
* 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/Translation/ResourceManager.cs')
-rw-r--r--src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs b/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs
index 2d19a5a7..c58e4828 100644
--- a/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs
+++ b/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs
@@ -1,3 +1,4 @@
+using Ryujinx.Common;
using Ryujinx.Graphics.Shader.StructuredIr;
using System;
using System.Collections.Generic;
@@ -22,9 +23,12 @@ namespace Ryujinx.Graphics.Shader.Translation
private readonly HashSet<int> _usedConstantBufferBindings;
+ public int LocalMemoryId { get; }
+ public int SharedMemoryId { get; }
+
public ShaderProperties Properties => _properties;
- public ResourceManager(ShaderStage stage, IGpuAccessor gpuAccessor, ShaderProperties properties)
+ public ResourceManager(ShaderStage stage, IGpuAccessor gpuAccessor, ShaderProperties properties, int localMemorySize)
{
_gpuAccessor = gpuAccessor;
_properties = properties;
@@ -41,6 +45,25 @@ namespace Ryujinx.Graphics.Shader.Translation
_usedConstantBufferBindings = new HashSet<int>();
properties.AddConstantBuffer(0, new BufferDefinition(BufferLayout.Std140, 0, 0, "support_buffer", SupportBuffer.GetStructureType()));
+
+ LocalMemoryId = -1;
+ SharedMemoryId = -1;
+
+ if (localMemorySize != 0)
+ {
+ var lmem = new MemoryDefinition("local_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(localMemorySize, sizeof(uint)));
+
+ LocalMemoryId = properties.AddLocalMemory(lmem);
+ }
+
+ int sharedMemorySize = stage == ShaderStage.Compute ? gpuAccessor.QueryComputeSharedMemorySize() : 0;
+
+ if (sharedMemorySize != 0)
+ {
+ var smem = new MemoryDefinition("shared_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(sharedMemorySize, sizeof(uint)));
+
+ SharedMemoryId = properties.AddSharedMemory(smem);
+ }
}
public int GetConstantBufferBinding(int slot)