aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Shader
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-08-11 18:01:06 -0300
committerGitHub <noreply@github.com>2021-08-11 23:01:06 +0200
commitc3e2646f9e330633b0ed5e0038a976e33054a819 (patch)
tree81bb78df5933bc6875a8f489985e275817e9ea71 /Ryujinx.Graphics.Gpu/Shader
parent0a80a837cb30402cad1f41293134edbaeeec6451 (diff)
Workaround for Intel FrontFacing built-in variable bug (#2540)
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Shader')
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/CachedGpuAccessor.cs22
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs33
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs55
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs2
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs6
5 files changed, 65 insertions, 53 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/CachedGpuAccessor.cs b/Ryujinx.Graphics.Gpu/Shader/CachedGpuAccessor.cs
index 452dfd83..625b8bac 100644
--- a/Ryujinx.Graphics.Gpu/Shader/CachedGpuAccessor.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/CachedGpuAccessor.cs
@@ -9,7 +9,6 @@ namespace Ryujinx.Graphics.Gpu.Shader
{
class CachedGpuAccessor : TextureDescriptorCapableGpuAccessor, IGpuAccessor
{
- private readonly GpuContext _context;
private readonly ReadOnlyMemory<byte> _data;
private readonly ReadOnlyMemory<byte> _cb1Data;
private readonly GuestGpuAccessorHeader _header;
@@ -28,9 +27,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
ReadOnlyMemory<byte> data,
ReadOnlyMemory<byte> cb1Data,
GuestGpuAccessorHeader header,
- Dictionary<int, GuestTextureDescriptor> guestTextureDescriptors)
+ IReadOnlyDictionary<int, GuestTextureDescriptor> guestTextureDescriptors) : base(context)
{
- _context = context;
_data = data;
_cb1Data = cb1Data;
_header = header;
@@ -137,24 +135,6 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
/// <summary>
- /// Queries host storage buffer alignment required.
- /// </summary>
- /// <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>
- /// <returns>True if the GPU and driver supports non-constant texture offsets, false otherwise</returns>
- public bool QuerySupportsNonConstantTextureOffset() => _context.Capabilities.SupportsNonConstantTextureOffset;
-
- /// <summary>
/// Gets the texture descriptor for a given texture on the pool.
/// </summary>
/// <param name="handle">Index of the texture (this is the word offset of the handle in the constant buffer)</param>
diff --git a/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs b/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
index 6254b1c2..65c8c287 100644
--- a/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
@@ -7,9 +7,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary>
/// Represents a GPU state and memory accessor.
/// </summary>
- class GpuAccessor : TextureDescriptorCapableGpuAccessor, IGpuAccessor
+ class GpuAccessor : TextureDescriptorCapableGpuAccessor
{
- private readonly GpuContext _context;
private readonly GpuChannel _channel;
private readonly GpuAccessorState _state;
private readonly int _stageIndex;
@@ -29,9 +28,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <param name="channel">GPU channel</param>
/// <param name="state">Current GPU state</param>
/// <param name="stageIndex">Graphics shader stage index (0 = Vertex, 4 = Fragment)</param>
- public GpuAccessor(GpuContext context, GpuChannel channel, GpuAccessorState state, int stageIndex)
+ public GpuAccessor(GpuContext context, GpuChannel channel, GpuAccessorState state, int stageIndex) : base(context)
{
- _context = context;
_channel = channel;
_state = state;
_stageIndex = stageIndex;
@@ -56,9 +54,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
int localSizeY,
int localSizeZ,
int localMemorySize,
- int sharedMemorySize)
+ int sharedMemorySize) : base(context)
{
- _context = context;
_channel = channel;
_state = state;
_compute = true;
@@ -183,30 +180,6 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
/// <summary>
- /// Queries host storage buffer alignment required.
- /// </summary>
- /// <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>
- /// <returns>True if the GPU and driver supports non-constant texture offsets, false otherwise</returns>
- public bool QuerySupportsNonConstantTextureOffset() => _context.Capabilities.SupportsNonConstantTextureOffset;
-
- /// <summary>
- /// Queries host GPU texture shadow LOD support.
- /// </summary>
- /// <returns>True if the GPU and driver supports texture shadow LOD, false otherwise</returns>
- public bool QuerySupportsTextureShadowLod() => _context.Capabilities.SupportsTextureShadowLod;
-
- /// <summary>
/// Gets the texture descriptor for a given texture on the pool.
/// </summary>
/// <param name="handle">Index of the texture (this is the word offset of the handle in the constant buffer)</param>
diff --git a/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs b/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
new file mode 100644
index 00000000..fb990cfe
--- /dev/null
+++ b/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
@@ -0,0 +1,55 @@
+namespace Ryujinx.Graphics.Gpu.Shader
+{
+ /// <summary>
+ /// Represents a GPU state and memory accessor.
+ /// </summary>
+ class GpuAccessorBase
+ {
+ private readonly GpuContext _context;
+
+ /// <summary>
+ /// Creates a new instance of the GPU state accessor.
+ /// </summary>
+ /// <param name="context">GPU context</param>
+ public GpuAccessorBase(GpuContext context)
+ {
+ _context = context;
+ }
+
+ /// <summary>
+ /// Queries host about the presence of the FrontFacing built-in variable bug.
+ /// </summary>
+ /// <returns>True if the bug is present on the host device used, false otherwise</returns>
+ public bool QueryHostHasFrontFacingBug() => _context.Capabilities.HasFrontFacingBug;
+
+ /// <summary>
+ /// Queries host about the presence of the vector indexing bug.
+ /// </summary>
+ /// <returns>True if the bug is present on the host device used, false otherwise</returns>
+ public bool QueryHostHasVectorIndexingBug() => _context.Capabilities.HasVectorIndexingBug;
+
+ /// <summary>
+ /// Queries host storage buffer alignment required.
+ /// </summary>
+ /// <returns>Host storage buffer alignment in bytes</returns>
+ public int QueryHostStorageBufferOffsetAlignment() => _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 QueryHostSupportsImageLoadFormatted() => _context.Capabilities.SupportsImageLoadFormatted;
+
+ /// <summary>
+ /// Queries host GPU non-constant texture offset support.
+ /// </summary>
+ /// <returns>True if the GPU and driver supports non-constant texture offsets, false otherwise</returns>
+ public bool QueryHostSupportsNonConstantTextureOffset() => _context.Capabilities.SupportsNonConstantTextureOffset;
+
+ /// <summary>
+ /// Queries host GPU texture shadow LOD support.
+ /// </summary>
+ /// <returns>True if the GPU and driver supports texture shadow LOD, false otherwise</returns>
+ public bool QueryHostSupportsTextureShadowLod() => _context.Capabilities.SupportsTextureShadowLod;
+ }
+}
diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
index 2c1fb084..fada667c 100644
--- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
@@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary>
/// Version of the codegen (to be changed when codegen or guest format change).
/// </summary>
- private const ulong ShaderCodeGenVersion = 2538;
+ private const ulong ShaderCodeGenVersion = 2540;
// Progress reporting helpers
private volatile int _shaderCount;
diff --git a/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs b/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs
index 904a0fd4..35507449 100644
--- a/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs
@@ -4,8 +4,12 @@ using Ryujinx.Graphics.Shader;
namespace Ryujinx.Graphics.Gpu.Shader
{
- abstract class TextureDescriptorCapableGpuAccessor : IGpuAccessor
+ abstract class TextureDescriptorCapableGpuAccessor : GpuAccessorBase, IGpuAccessor
{
+ public TextureDescriptorCapableGpuAccessor(GpuContext context) : base(context)
+ {
+ }
+
public abstract T MemoryRead<T>(ulong address) where T : unmanaged;
public abstract ITextureDescriptor GetTextureDescriptor(int handle, int cbufSlot);