diff --git a/Ryujinx.Graphics.GAL/Capabilities.cs b/Ryujinx.Graphics.GAL/Capabilities.cs index 4a8b7c83b0..8a2dd8b64a 100644 --- a/Ryujinx.Graphics.GAL/Capabilities.cs +++ b/Ryujinx.Graphics.GAL/Capabilities.cs @@ -4,17 +4,20 @@ namespace Ryujinx.Graphics.GAL { public bool SupportsAstcCompression { get; } - public int MaximumViewportDimensions { get; } - public int StorageBufferOffsetAlignment { get; } + public int MaximumViewportDimensions { get; } + public int MaximumComputeSharedMemorySize { get; } + public int StorageBufferOffsetAlignment { get; } public Capabilities( bool supportsAstcCompression, int maximumViewportDimensions, + int maximumComputeSharedMemorySize, int storageBufferOffsetAlignment) { - SupportsAstcCompression = supportsAstcCompression; - MaximumViewportDimensions = maximumViewportDimensions; - StorageBufferOffsetAlignment = storageBufferOffsetAlignment; + SupportsAstcCompression = supportsAstcCompression; + MaximumViewportDimensions = maximumViewportDimensions; + MaximumComputeSharedMemorySize = maximumComputeSharedMemorySize; + StorageBufferOffsetAlignment = storageBufferOffsetAlignment; } } } \ No newline at end of file diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index 6e3a42a238..027757980c 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -352,6 +352,7 @@ namespace Ryujinx.Graphics.Gpu.Shader { return new ShaderCapabilities( _context.Capabilities.MaximumViewportDimensions, + _context.Capabilities.MaximumComputeSharedMemorySize, _context.Capabilities.StorageBufferOffsetAlignment); } } diff --git a/Ryujinx.Graphics.OpenGL/HwCapabilities.cs b/Ryujinx.Graphics.OpenGL/HwCapabilities.cs index 671bd5b20e..7524dc1dda 100644 --- a/Ryujinx.Graphics.OpenGL/HwCapabilities.cs +++ b/Ryujinx.Graphics.OpenGL/HwCapabilities.cs @@ -7,13 +7,15 @@ namespace Ryujinx.Graphics.OpenGL { private static Lazy _supportsAstcCompression = new Lazy(() => HasExtension("GL_KHR_texture_compression_astc_ldr")); - private static Lazy _maximumViewportDimensions = new Lazy(() => GetLimit(All.MaxViewportDims)); - private static Lazy _storageBufferOffsetAlignment = new Lazy(() => GetLimit(All.ShaderStorageBufferOffsetAlignment)); + private static Lazy _maximumViewportDimensions = new Lazy(() => GetLimit(All.MaxViewportDims)); + private static Lazy _maximumComputeSharedMemorySize = new Lazy(() => GetLimit(All.MaxComputeSharedMemorySize)); + private static Lazy _storageBufferOffsetAlignment = new Lazy(() => GetLimit(All.ShaderStorageBufferOffsetAlignment)); public static bool SupportsAstcCompression => _supportsAstcCompression.Value; - public static int MaximumViewportDimensions => _maximumViewportDimensions.Value; - public static int StorageBufferOffsetAlignment => _storageBufferOffsetAlignment.Value; + public static int MaximumViewportDimensions => _maximumViewportDimensions.Value; + public static int MaximumComputeSharedMemorySize => _maximumComputeSharedMemorySize.Value; + public static int StorageBufferOffsetAlignment => _storageBufferOffsetAlignment.Value; private static bool HasExtension(string name) { diff --git a/Ryujinx.Graphics.OpenGL/Renderer.cs b/Ryujinx.Graphics.OpenGL/Renderer.cs index 3007fe5ccc..eec3e320c9 100644 --- a/Ryujinx.Graphics.OpenGL/Renderer.cs +++ b/Ryujinx.Graphics.OpenGL/Renderer.cs @@ -64,6 +64,7 @@ namespace Ryujinx.Graphics.OpenGL return new Capabilities( HwCapabilities.SupportsAstcCompression, HwCapabilities.MaximumViewportDimensions, + HwCapabilities.MaximumComputeSharedMemorySize, HwCapabilities.StorageBufferOffsetAlignment); } diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs index 5a84ff4903..1c3cf2459b 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs @@ -75,7 +75,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl if (context.Config.Stage == ShaderStage.Compute) { - context.AppendLine($"shared uint {DefaultNames.SharedMemoryName}[0x100];"); + string size = NumberFormatter.FormatInt(context.Config.Capabilities.MaximumComputeSharedMemorySize / 4); + + context.AppendLine($"shared uint {DefaultNames.SharedMemoryName}[{size}];"); context.AppendLine(); } diff --git a/Ryujinx.Graphics.Shader/ShaderCapabilities.cs b/Ryujinx.Graphics.Shader/ShaderCapabilities.cs index b5b459a8d8..8e0c95e916 100644 --- a/Ryujinx.Graphics.Shader/ShaderCapabilities.cs +++ b/Ryujinx.Graphics.Shader/ShaderCapabilities.cs @@ -2,19 +2,23 @@ namespace Ryujinx.Graphics.Shader { public struct ShaderCapabilities { - private static readonly ShaderCapabilities _default = new ShaderCapabilities(32768, 16); + // Initialize with default values for Maxwell. + private static readonly ShaderCapabilities _default = new ShaderCapabilities(32768, 49152, 16); public static ShaderCapabilities Default => _default; - public int MaximumViewportDimensions { get; } - public int StorageBufferOffsetAlignment { get; } + public int MaximumViewportDimensions { get; } + public int MaximumComputeSharedMemorySize { get; } + public int StorageBufferOffsetAlignment { get; } public ShaderCapabilities( int maximumViewportDimensions, + int maximumComputeSharedMemorySize, int storageBufferOffsetAlignment) { - MaximumViewportDimensions = maximumViewportDimensions; - StorageBufferOffsetAlignment = storageBufferOffsetAlignment; + MaximumViewportDimensions = maximumViewportDimensions; + MaximumComputeSharedMemorySize = maximumComputeSharedMemorySize; + StorageBufferOffsetAlignment = storageBufferOffsetAlignment; } } } \ No newline at end of file