0
0
Fork 0

Use maximum shared memory size supported by hardware

This commit is contained in:
gdkchan 2019-12-08 23:55:22 -03:00 committed by Thog
parent 375ee0ba96
commit 0d9672f3ae
6 changed files with 28 additions and 15 deletions

View file

@ -5,15 +5,18 @@ namespace Ryujinx.Graphics.GAL
public bool SupportsAstcCompression { 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;
MaximumComputeSharedMemorySize = maximumComputeSharedMemorySize;
StorageBufferOffsetAlignment = storageBufferOffsetAlignment;
}
}

View file

@ -352,6 +352,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
{
return new ShaderCapabilities(
_context.Capabilities.MaximumViewportDimensions,
_context.Capabilities.MaximumComputeSharedMemorySize,
_context.Capabilities.StorageBufferOffsetAlignment);
}
}

View file

@ -8,11 +8,13 @@ namespace Ryujinx.Graphics.OpenGL
private static Lazy<bool> _supportsAstcCompression = new Lazy<bool>(() => HasExtension("GL_KHR_texture_compression_astc_ldr"));
private static Lazy<int> _maximumViewportDimensions = new Lazy<int>(() => GetLimit(All.MaxViewportDims));
private static Lazy<int> _maximumComputeSharedMemorySize = new Lazy<int>(() => GetLimit(All.MaxComputeSharedMemorySize));
private static Lazy<int> _storageBufferOffsetAlignment = new Lazy<int>(() => GetLimit(All.ShaderStorageBufferOffsetAlignment));
public static bool SupportsAstcCompression => _supportsAstcCompression.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)

View file

@ -64,6 +64,7 @@ namespace Ryujinx.Graphics.OpenGL
return new Capabilities(
HwCapabilities.SupportsAstcCompression,
HwCapabilities.MaximumViewportDimensions,
HwCapabilities.MaximumComputeSharedMemorySize,
HwCapabilities.StorageBufferOffsetAlignment);
}

View file

@ -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();
}

View file

@ -2,18 +2,22 @@ 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 MaximumComputeSharedMemorySize { get; }
public int StorageBufferOffsetAlignment { get; }
public ShaderCapabilities(
int maximumViewportDimensions,
int maximumComputeSharedMemorySize,
int storageBufferOffsetAlignment)
{
MaximumViewportDimensions = maximumViewportDimensions;
MaximumComputeSharedMemorySize = maximumComputeSharedMemorySize;
StorageBufferOffsetAlignment = storageBufferOffsetAlignment;
}
}