mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-10-01 12:30:00 +02:00
Omit image format if possible, and fix BA bit (#1280)
* Omit image format if possible, and fix BA bit * Match extension name
This commit is contained in:
parent
b663cd22c8
commit
0b6d206daa
8 changed files with 27 additions and 2 deletions
|
@ -3,6 +3,7 @@ namespace Ryujinx.Graphics.GAL
|
|||
public struct Capabilities
|
||||
{
|
||||
public bool SupportsAstcCompression { get; }
|
||||
public bool SupportsImageLoadFormatted { get; }
|
||||
public bool SupportsNonConstantTextureOffset { get; }
|
||||
|
||||
public int MaximumComputeSharedMemorySize { get; }
|
||||
|
@ -12,12 +13,14 @@ namespace Ryujinx.Graphics.GAL
|
|||
|
||||
public Capabilities(
|
||||
bool supportsAstcCompression,
|
||||
bool supportsImageLoadFormatted,
|
||||
bool supportsNonConstantTextureOffset,
|
||||
int maximumComputeSharedMemorySize,
|
||||
int storageBufferOffsetAlignment,
|
||||
float maxSupportedAnisotropy)
|
||||
{
|
||||
SupportsAstcCompression = supportsAstcCompression;
|
||||
SupportsImageLoadFormatted = supportsImageLoadFormatted;
|
||||
SupportsNonConstantTextureOffset = supportsNonConstantTextureOffset;
|
||||
MaximumComputeSharedMemorySize = maximumComputeSharedMemorySize;
|
||||
StorageBufferOffsetAlignment = storageBufferOffsetAlignment;
|
||||
|
|
|
@ -175,6 +175,12 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <returns>Host storage buffer alignment in bytes</returns>
|
||||
public int QueryStorageBufferOffsetAlignment() => _context.Capabilities.StorageBufferOffsetAlignment;
|
||||
|
||||
/// <summary>
|
||||
/// Queries host support for readable images without a explicit format declaration on the shader.
|
||||
/// </summary>
|
||||
/// <returns>True if formatted image load is supported, false otherwise</returns>
|
||||
public bool QuerySupportsImageLoadFormatted() => _context.Capabilities.SupportsImageLoadFormatted;
|
||||
|
||||
/// <summary>
|
||||
/// Queries host GPU non-constant texture offset support.
|
||||
/// </summary>
|
||||
|
|
|
@ -5,7 +5,8 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
{
|
||||
static class HwCapabilities
|
||||
{
|
||||
private static readonly Lazy<bool> _supportsAstcCompression = new Lazy<bool>(() => HasExtension("GL_KHR_texture_compression_astc_ldr"));
|
||||
private static readonly Lazy<bool> _supportsAstcCompression = new Lazy<bool>(() => HasExtension("GL_KHR_texture_compression_astc_ldr"));
|
||||
private static readonly Lazy<bool> _supportsImageLoadFormatted = new Lazy<bool>(() => HasExtension("GL_EXT_shader_image_load_formatted"));
|
||||
|
||||
private static readonly Lazy<int> _maximumComputeSharedMemorySize = new Lazy<int>(() => GetLimit(All.MaxComputeSharedMemorySize));
|
||||
private static readonly Lazy<int> _storageBufferOffsetAlignment = new Lazy<int>(() => GetLimit(All.ShaderStorageBufferOffsetAlignment));
|
||||
|
@ -25,6 +26,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
private static Lazy<float> _maxSupportedAnisotropy = new Lazy<float>(GL.GetFloat((GetPName)All.MaxTextureMaxAnisotropy));
|
||||
|
||||
public static bool SupportsAstcCompression => _supportsAstcCompression.Value;
|
||||
public static bool SupportsImageLoadFormatted => _supportsImageLoadFormatted.Value;
|
||||
public static bool SupportsNonConstantTextureOffset => _gpuVendor.Value == GpuVendor.Nvidia;
|
||||
|
||||
public static int MaximumComputeSharedMemorySize => _maximumComputeSharedMemorySize.Value;
|
||||
|
|
|
@ -73,6 +73,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
{
|
||||
return new Capabilities(
|
||||
HwCapabilities.SupportsAstcCompression,
|
||||
HwCapabilities.SupportsImageLoadFormatted,
|
||||
HwCapabilities.SupportsNonConstantTextureOffset,
|
||||
HwCapabilities.MaximumComputeSharedMemorySize,
|
||||
HwCapabilities.StorageBufferOffsetAlignment,
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
|||
context.AppendLine("#extension GL_ARB_gpu_shader_int64 : enable");
|
||||
context.AppendLine("#extension GL_ARB_shader_ballot : enable");
|
||||
context.AppendLine("#extension GL_ARB_shader_group_vote : enable");
|
||||
context.AppendLine("#extension GL_EXT_shader_image_load_formatted : enable");
|
||||
|
||||
if (context.Config.Stage == ShaderStage.Compute)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
|||
Size = (IntegerSize)opCode.Extract(20, 4);
|
||||
}
|
||||
|
||||
ByteAddress = !opCode.Extract(23);
|
||||
ByteAddress = opCode.Extract(23);
|
||||
|
||||
Dimensions = (ImageDimensions)opCode.Extract(33, 3);
|
||||
|
||||
|
|
|
@ -54,6 +54,11 @@
|
|||
return 16;
|
||||
}
|
||||
|
||||
public bool QuerySupportsImageLoadFormatted()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool QuerySupportsNonConstantTextureOffset()
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -1217,6 +1217,13 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
|
||||
private static TextureFormat GetTextureFormat(EmitterContext context, int handle)
|
||||
{
|
||||
// When the formatted load extension is supported, we don't need to
|
||||
// specify a format, we can just declare it without a format and the GPU will handle it.
|
||||
if (context.Config.GpuAccessor.QuerySupportsImageLoadFormatted())
|
||||
{
|
||||
return TextureFormat.Unknown;
|
||||
}
|
||||
|
||||
var format = context.Config.GpuAccessor.QueryTextureFormat(handle);
|
||||
|
||||
if (format == TextureFormat.Unknown)
|
||||
|
|
Loading…
Reference in a new issue