Ryujinx/src/Ryujinx.Graphics.Shader
riperiperi 76b53e018a
GPU: Add fallback when textureGatherOffsets is not supported (#5792)
* 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
2023-10-20 15:05:09 +02:00
..
CodeGen Strings should not be concatenated using '+' in a loop (#5664) 2023-10-05 12:41:00 +02:00
Decoders Geometry shader emulation for macOS (#5551) 2023-08-29 21:10:34 -03:00
Instructions Implement textureSamples texture query shader instruction (#5750) 2023-10-03 22:43:11 +00:00
IntermediateRepresentation Implement textureSamples texture query shader instruction (#5750) 2023-10-03 22:43:11 +00:00
StructuredIr Fix SPIR-V call out arguments regression (#5767) 2023-10-06 00:18:30 -03:00
Translation GPU: Add fallback when textureGatherOffsets is not supported (#5792) 2023-10-20 15:05:09 +02:00
AlphaTestOp.cs [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) 2023-06-28 08:59:13 +02:00
AttributeType.cs Geometry shader emulation for macOS (#5551) 2023-08-29 21:10:34 -03:00
BufferDescriptor.cs Add workflow to automatically check code style issues for PRs (#4670) 2023-07-24 18:35:04 +02:00
BufferUsageFlags.cs [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) 2023-06-28 08:59:13 +02:00
Constants.cs Geometry shader emulation for macOS (#5551) 2023-08-29 21:10:34 -03:00
GpuGraphicsState.cs Delete ShaderConfig and organize shader resources/definitions better (#5509) 2023-08-13 22:26:42 -03:00
IGpuAccessor.cs GPU: Add fallback when textureGatherOffsets is not supported (#5792) 2023-10-20 15:05:09 +02:00
ILogger.cs Delete ShaderConfig and organize shader resources/definitions better (#5509) 2023-08-13 22:26:42 -03:00
InputTopology.cs Geometry shader emulation for macOS (#5551) 2023-08-29 21:10:34 -03:00
OutputTopology.cs [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) 2023-06-28 08:59:13 +02:00
ResourceReservationCounts.cs Geometry shader emulation for macOS (#5551) 2023-08-29 21:10:34 -03:00
Ryujinx.Graphics.Shader.csproj Fix vote and shuffle shader instructions on AMD GPUs (#5540) 2023-08-16 21:31:07 -03:00
SamplerType.cs [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) 2023-06-28 08:59:13 +02:00
ShaderProgram.cs [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) 2023-06-28 08:59:13 +02:00
ShaderProgramInfo.cs Geometry shader emulation for macOS (#5551) 2023-08-29 21:10:34 -03:00
ShaderStage.cs Declare and use gl_PerVertex block for VTG per-vertex built-ins (#5576) 2023-08-16 23:16:25 +02:00
SupportBuffer.cs Geometry shader emulation for macOS (#5551) 2023-08-29 21:10:34 -03:00
TessPatchType.cs [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) 2023-06-28 08:59:13 +02:00
TessSpacing.cs [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) 2023-06-28 08:59:13 +02:00
TextureDescriptor.cs Add workflow to automatically check code style issues for PRs (#4670) 2023-07-24 18:35:04 +02:00
TextureFormat.cs [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) 2023-06-28 08:59:13 +02:00
TextureHandle.cs [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) 2023-06-28 08:59:13 +02:00
TextureUsageFlags.cs [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) 2023-06-28 08:59:13 +02:00
VertexInfoBuffer.cs Geometry shader emulation for macOS (#5551) 2023-08-29 21:10:34 -03:00