mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-19 15:22:02 +00:00
76b53e018a
* GPU: Add fallback when textureGatherOffsets is not supported. This PR adds a fallback for GPUs or APIs that don't support an equivalent to the method `textureGatherOffsets`, where each of the 4 gathered texels has an individual offset. This is done by reusing the existing code to handle non-const offsets for texture instructions, though it has also been corrected as there were a few implementation issues. MoltenVK reports support for this capability, and it didn't error when we initially released the MacOS build, but that has since changed. MVK still reports support, but spirv-cross has been fixed in a way that it _attempts_ to use this capability, but the metal compiler errors since it doesn't exist. Some other fixes: - textureGatherOffsets emulation has been changed significantly. It now uses 4 texture sample instructions (not gather), calculates a base texel (i=0 j=0) and adds the offsets onto it before converting into a tex coord. The final result is offset into a texel center, so it shouldn't be subject to interpolation, though this isn't perfect and could have some error with floating point formats with linear sampling. It is subject to texture wrap mode as it should be, which is why texelFetch was not used. - Maybe gather should be used here with component `w` (i=0, j=0), though this multiplies number of texels fetched by 4... The way it was doing this before _was_ wrong_, but doing it right would avoid issues with texel center precision. - textureGatherOffset (singular) now performs textureGather with the offset applied to the coords, rather than the slower fallback where each texel is fetched individually. * Increment shader cache version, remove unused arg * Use base texture size for gather coord offset. Implicit LOD for gather is not supported. * Use 4 texture gathers for offsets emulation Avoids issues with interpolation at cost of performance (not sure how bad this is) * Address Feedback
167 lines
8.3 KiB
C#
167 lines
8.3 KiB
C#
using Ryujinx.Graphics.Shader.Translation;
|
|
|
|
namespace Ryujinx.Graphics.GAL
|
|
{
|
|
public readonly struct Capabilities
|
|
{
|
|
public readonly TargetApi Api;
|
|
public readonly string VendorName;
|
|
|
|
public readonly bool HasFrontFacingBug;
|
|
public readonly bool HasVectorIndexingBug;
|
|
public readonly bool NeedsFragmentOutputSpecialization;
|
|
public readonly bool ReduceShaderPrecision;
|
|
|
|
public readonly bool SupportsAstcCompression;
|
|
public readonly bool SupportsBc123Compression;
|
|
public readonly bool SupportsBc45Compression;
|
|
public readonly bool SupportsBc67Compression;
|
|
public readonly bool SupportsEtc2Compression;
|
|
public readonly bool Supports3DTextureCompression;
|
|
public readonly bool SupportsBgraFormat;
|
|
public readonly bool SupportsR4G4Format;
|
|
public readonly bool SupportsR4G4B4A4Format;
|
|
public readonly bool SupportsScaledVertexFormats;
|
|
public readonly bool SupportsSnormBufferTextureFormat;
|
|
public readonly bool Supports5BitComponentFormat;
|
|
public readonly bool SupportsBlendEquationAdvanced;
|
|
public readonly bool SupportsFragmentShaderInterlock;
|
|
public readonly bool SupportsFragmentShaderOrderingIntel;
|
|
public readonly bool SupportsGeometryShader;
|
|
public readonly bool SupportsGeometryShaderPassthrough;
|
|
public readonly bool SupportsTransformFeedback;
|
|
public readonly bool SupportsImageLoadFormatted;
|
|
public readonly bool SupportsLayerVertexTessellation;
|
|
public readonly bool SupportsMismatchingViewFormat;
|
|
public readonly bool SupportsCubemapView;
|
|
public readonly bool SupportsNonConstantTextureOffset;
|
|
public readonly bool SupportsShaderBallot;
|
|
public readonly bool SupportsShaderBarrierDivergence;
|
|
public readonly bool SupportsShaderFloat64;
|
|
public readonly bool SupportsTextureGatherOffsets;
|
|
public readonly bool SupportsTextureShadowLod;
|
|
public readonly bool SupportsVertexStoreAndAtomics;
|
|
public readonly bool SupportsViewportIndexVertexTessellation;
|
|
public readonly bool SupportsViewportMask;
|
|
public readonly bool SupportsViewportSwizzle;
|
|
public readonly bool SupportsIndirectParameters;
|
|
public readonly bool SupportsDepthClipControl;
|
|
|
|
public readonly uint MaximumUniformBuffersPerStage;
|
|
public readonly uint MaximumStorageBuffersPerStage;
|
|
public readonly uint MaximumTexturesPerStage;
|
|
public readonly uint MaximumImagesPerStage;
|
|
|
|
public readonly int MaximumComputeSharedMemorySize;
|
|
public readonly float MaximumSupportedAnisotropy;
|
|
public readonly int ShaderSubgroupSize;
|
|
public readonly int StorageBufferOffsetAlignment;
|
|
public readonly int TextureBufferOffsetAlignment;
|
|
|
|
public readonly int GatherBiasPrecision;
|
|
|
|
public Capabilities(
|
|
TargetApi api,
|
|
string vendorName,
|
|
bool hasFrontFacingBug,
|
|
bool hasVectorIndexingBug,
|
|
bool needsFragmentOutputSpecialization,
|
|
bool reduceShaderPrecision,
|
|
bool supportsAstcCompression,
|
|
bool supportsBc123Compression,
|
|
bool supportsBc45Compression,
|
|
bool supportsBc67Compression,
|
|
bool supportsEtc2Compression,
|
|
bool supports3DTextureCompression,
|
|
bool supportsBgraFormat,
|
|
bool supportsR4G4Format,
|
|
bool supportsR4G4B4A4Format,
|
|
bool supportsScaledVertexFormats,
|
|
bool supportsSnormBufferTextureFormat,
|
|
bool supports5BitComponentFormat,
|
|
bool supportsBlendEquationAdvanced,
|
|
bool supportsFragmentShaderInterlock,
|
|
bool supportsFragmentShaderOrderingIntel,
|
|
bool supportsGeometryShader,
|
|
bool supportsGeometryShaderPassthrough,
|
|
bool supportsTransformFeedback,
|
|
bool supportsImageLoadFormatted,
|
|
bool supportsLayerVertexTessellation,
|
|
bool supportsMismatchingViewFormat,
|
|
bool supportsCubemapView,
|
|
bool supportsNonConstantTextureOffset,
|
|
bool supportsShaderBallot,
|
|
bool supportsShaderBarrierDivergence,
|
|
bool supportsShaderFloat64,
|
|
bool supportsTextureGatherOffsets,
|
|
bool supportsTextureShadowLod,
|
|
bool supportsVertexStoreAndAtomics,
|
|
bool supportsViewportIndexVertexTessellation,
|
|
bool supportsViewportMask,
|
|
bool supportsViewportSwizzle,
|
|
bool supportsIndirectParameters,
|
|
bool supportsDepthClipControl,
|
|
uint maximumUniformBuffersPerStage,
|
|
uint maximumStorageBuffersPerStage,
|
|
uint maximumTexturesPerStage,
|
|
uint maximumImagesPerStage,
|
|
int maximumComputeSharedMemorySize,
|
|
float maximumSupportedAnisotropy,
|
|
int shaderSubgroupSize,
|
|
int storageBufferOffsetAlignment,
|
|
int textureBufferOffsetAlignment,
|
|
int gatherBiasPrecision)
|
|
{
|
|
Api = api;
|
|
VendorName = vendorName;
|
|
HasFrontFacingBug = hasFrontFacingBug;
|
|
HasVectorIndexingBug = hasVectorIndexingBug;
|
|
NeedsFragmentOutputSpecialization = needsFragmentOutputSpecialization;
|
|
ReduceShaderPrecision = reduceShaderPrecision;
|
|
SupportsAstcCompression = supportsAstcCompression;
|
|
SupportsBc123Compression = supportsBc123Compression;
|
|
SupportsBc45Compression = supportsBc45Compression;
|
|
SupportsBc67Compression = supportsBc67Compression;
|
|
SupportsEtc2Compression = supportsEtc2Compression;
|
|
Supports3DTextureCompression = supports3DTextureCompression;
|
|
SupportsBgraFormat = supportsBgraFormat;
|
|
SupportsR4G4Format = supportsR4G4Format;
|
|
SupportsR4G4B4A4Format = supportsR4G4B4A4Format;
|
|
SupportsScaledVertexFormats = supportsScaledVertexFormats;
|
|
SupportsSnormBufferTextureFormat = supportsSnormBufferTextureFormat;
|
|
Supports5BitComponentFormat = supports5BitComponentFormat;
|
|
SupportsBlendEquationAdvanced = supportsBlendEquationAdvanced;
|
|
SupportsFragmentShaderInterlock = supportsFragmentShaderInterlock;
|
|
SupportsFragmentShaderOrderingIntel = supportsFragmentShaderOrderingIntel;
|
|
SupportsGeometryShader = supportsGeometryShader;
|
|
SupportsGeometryShaderPassthrough = supportsGeometryShaderPassthrough;
|
|
SupportsTransformFeedback = supportsTransformFeedback;
|
|
SupportsImageLoadFormatted = supportsImageLoadFormatted;
|
|
SupportsLayerVertexTessellation = supportsLayerVertexTessellation;
|
|
SupportsMismatchingViewFormat = supportsMismatchingViewFormat;
|
|
SupportsCubemapView = supportsCubemapView;
|
|
SupportsNonConstantTextureOffset = supportsNonConstantTextureOffset;
|
|
SupportsShaderBallot = supportsShaderBallot;
|
|
SupportsShaderBarrierDivergence = supportsShaderBarrierDivergence;
|
|
SupportsShaderFloat64 = supportsShaderFloat64;
|
|
SupportsTextureGatherOffsets = supportsTextureGatherOffsets;
|
|
SupportsTextureShadowLod = supportsTextureShadowLod;
|
|
SupportsVertexStoreAndAtomics = supportsVertexStoreAndAtomics;
|
|
SupportsViewportIndexVertexTessellation = supportsViewportIndexVertexTessellation;
|
|
SupportsViewportMask = supportsViewportMask;
|
|
SupportsViewportSwizzle = supportsViewportSwizzle;
|
|
SupportsIndirectParameters = supportsIndirectParameters;
|
|
SupportsDepthClipControl = supportsDepthClipControl;
|
|
MaximumUniformBuffersPerStage = maximumUniformBuffersPerStage;
|
|
MaximumStorageBuffersPerStage = maximumStorageBuffersPerStage;
|
|
MaximumTexturesPerStage = maximumTexturesPerStage;
|
|
MaximumImagesPerStage = maximumImagesPerStage;
|
|
MaximumComputeSharedMemorySize = maximumComputeSharedMemorySize;
|
|
MaximumSupportedAnisotropy = maximumSupportedAnisotropy;
|
|
ShaderSubgroupSize = shaderSubgroupSize;
|
|
StorageBufferOffsetAlignment = storageBufferOffsetAlignment;
|
|
TextureBufferOffsetAlignment = textureBufferOffsetAlignment;
|
|
GatherBiasPrecision = gatherBiasPrecision;
|
|
}
|
|
}
|
|
}
|