aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Ryujinx.Graphics.Gpu/Engine/Compute.cs1
-rw-r--r--Ryujinx.Graphics.Gpu/Engine/ComputeParams.cs2
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs8
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs11
-rw-r--r--Ryujinx.Graphics.Shader/DefineNames.cs2
5 files changed, 19 insertions, 5 deletions
diff --git a/Ryujinx.Graphics.Gpu/Engine/Compute.cs b/Ryujinx.Graphics.Gpu/Engine/Compute.cs
index f0daac67..61e6b326 100644
--- a/Ryujinx.Graphics.Gpu/Engine/Compute.cs
+++ b/Ryujinx.Graphics.Gpu/Engine/Compute.cs
@@ -22,6 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
ComputeShader cs = _shaderCache.GetComputeShader(
shaderGpuVa,
+ dispatchParams.SharedMemorySize & 0xffff,
dispatchParams.UnpackBlockSizeX(),
dispatchParams.UnpackBlockSizeY(),
dispatchParams.UnpackBlockSizeZ());
diff --git a/Ryujinx.Graphics.Gpu/Engine/ComputeParams.cs b/Ryujinx.Graphics.Gpu/Engine/ComputeParams.cs
index 77e60aa4..5644ca81 100644
--- a/Ryujinx.Graphics.Gpu/Engine/ComputeParams.cs
+++ b/Ryujinx.Graphics.Gpu/Engine/ComputeParams.cs
@@ -39,7 +39,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
public int Unknown14;
public int Unknown15;
public int Unknown16;
- public int Unknown17;
+ public int SharedMemorySize;
public int BlockSizeX;
public int BlockSizeYZ;
public int UniformBuffersConfig;
diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
index 02775798..7b9c20eb 100644
--- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
@@ -32,7 +32,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
_gpPrograms = new Dictionary<ShaderAddresses, List<GraphicsShader>>();
}
- public ComputeShader GetComputeShader(ulong gpuVa, int localSizeX, int localSizeY, int localSizeZ)
+ public ComputeShader GetComputeShader(ulong gpuVa, int sharedMemorySize, int localSizeX, int localSizeY, int localSizeZ)
{
bool isCached = _cpPrograms.TryGetValue(gpuVa, out List<ComputeShader> list);
@@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
- CachedShader shader = TranslateComputeShader(gpuVa, localSizeX, localSizeY, localSizeZ);
+ CachedShader shader = TranslateComputeShader(gpuVa, sharedMemorySize, localSizeX, localSizeY, localSizeZ);
IShader hostShader = _context.Renderer.CompileShader(shader.Program);
@@ -192,7 +192,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
return false;
}
- private CachedShader TranslateComputeShader(ulong gpuVa, int localSizeX, int localSizeY, int localSizeZ)
+ private CachedShader TranslateComputeShader(ulong gpuVa, int sharedMemorySize, int localSizeX, int localSizeY, int localSizeZ)
{
if (gpuVa == 0)
{
@@ -212,6 +212,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
int[] codeCached = MemoryMarshal.Cast<byte, int>(code.Slice(0, program.Size)).ToArray();
+ program.Replace(DefineNames.SharedMemorySize, sharedMemorySize.ToString(CultureInfo.InvariantCulture));
+
program.Replace(DefineNames.LocalSizeX, localSizeX.ToString(CultureInfo.InvariantCulture));
program.Replace(DefineNames.LocalSizeY, localSizeY.ToString(CultureInfo.InvariantCulture));
program.Replace(DefineNames.LocalSizeZ, localSizeZ.ToString(CultureInfo.InvariantCulture));
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
index 1c3cf245..b96aa1ae 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
@@ -75,7 +75,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
if (context.Config.Stage == ShaderStage.Compute)
{
- string size = NumberFormatter.FormatInt(context.Config.Capabilities.MaximumComputeSharedMemorySize / 4);
+ string size;
+
+ if ((context.Config.Flags & TranslationFlags.Unspecialized) != 0)
+ {
+ size = DefineNames.SharedMemorySize;
+ }
+ else
+ {
+ size = NumberFormatter.FormatInt(context.Config.Capabilities.MaximumComputeSharedMemorySize / 4);
+ }
context.AppendLine($"shared uint {DefaultNames.SharedMemoryName}[{size}];");
context.AppendLine();
diff --git a/Ryujinx.Graphics.Shader/DefineNames.cs b/Ryujinx.Graphics.Shader/DefineNames.cs
index f55cbd0c..67e8e1ee 100644
--- a/Ryujinx.Graphics.Shader/DefineNames.cs
+++ b/Ryujinx.Graphics.Shader/DefineNames.cs
@@ -6,6 +6,8 @@ namespace Ryujinx.Graphics.Shader
public const string OutQualifierPrefixName = "S_OUT_QUALIFIER";
+ public const string SharedMemorySize = "S_SHARED_MEMORY_SIZE";
+
public const string LocalSizeX = "S_LOCAL_SIZE_X";
public const string LocalSizeY = "S_LOCAL_SIZE_Y";
public const string LocalSizeZ = "S_LOCAL_SIZE_Z";