aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Shader
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Shader')
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs21
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/Cache/Definition/GuestGpuAccessorHeader.cs7
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/CachedGpuAccessor.cs27
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs23
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs11
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs2
6 files changed, 87 insertions, 4 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs b/Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs
index 33da42db..09107346 100644
--- a/Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs
@@ -350,6 +350,26 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
}
/// <summary>
+ /// Packs the tessellation parameters from the gpu accessor.
+ /// </summary>
+ /// <param name="gpuAccessor">The gpu accessor</param>
+ /// <returns>The packed tessellation parameters</returns>
+ private static byte GetTessellationModePacked(IGpuAccessor gpuAccessor)
+ {
+ byte value;
+
+ value = (byte)((int)gpuAccessor.QueryTessPatchType() & 3);
+ value |= (byte)(((int)gpuAccessor.QueryTessSpacing() & 3) << 2);
+
+ if (gpuAccessor.QueryTessCw())
+ {
+ value |= 0x10;
+ }
+
+ return value;
+ }
+
+ /// <summary>
/// Create a new instance of <see cref="GuestGpuAccessorHeader"/> from an gpu accessor.
/// </summary>
/// <param name="gpuAccessor">The gpu accessor</param>
@@ -364,6 +384,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
ComputeLocalMemorySize = gpuAccessor.QueryComputeLocalMemorySize(),
ComputeSharedMemorySize = gpuAccessor.QueryComputeSharedMemorySize(),
PrimitiveTopology = gpuAccessor.QueryPrimitiveTopology(),
+ TessellationModePacked = GetTessellationModePacked(gpuAccessor),
StateFlags = GetGpuStateFlags(gpuAccessor)
};
}
diff --git a/Ryujinx.Graphics.Gpu/Shader/Cache/Definition/GuestGpuAccessorHeader.cs b/Ryujinx.Graphics.Gpu/Shader/Cache/Definition/GuestGpuAccessorHeader.cs
index 610b2da1..2e044750 100644
--- a/Ryujinx.Graphics.Gpu/Shader/Cache/Definition/GuestGpuAccessorHeader.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/Cache/Definition/GuestGpuAccessorHeader.cs
@@ -50,9 +50,14 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache.Definition
public InputTopology PrimitiveTopology;
/// <summary>
+ /// Tessellation parameters (packed to fit on a byte).
+ /// </summary>
+ public byte TessellationModePacked;
+
+ /// <summary>
/// Unused/reserved.
/// </summary>
- public ushort Reserved2;
+ public byte Reserved2;
/// <summary>
/// GPU boolean state that can influence shader compilation.
diff --git a/Ryujinx.Graphics.Gpu/Shader/CachedGpuAccessor.cs b/Ryujinx.Graphics.Gpu/Shader/CachedGpuAccessor.cs
index 3a52b2fe..21d08823 100644
--- a/Ryujinx.Graphics.Gpu/Shader/CachedGpuAccessor.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/CachedGpuAccessor.cs
@@ -135,6 +135,33 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
/// <summary>
+ /// Queries the tessellation evaluation shader primitive winding order.
+ /// </summary>
+ /// <returns>True if the primitive winding order is clockwise, false if counter-clockwise</returns>
+ public bool QueryTessCw()
+ {
+ return (_header.TessellationModePacked & 0x10) != 0;
+ }
+
+ /// <summary>
+ /// Queries the tessellation evaluation shader abstract patch type.
+ /// </summary>
+ /// <returns>Abstract patch type</returns>
+ public TessPatchType QueryTessPatchType()
+ {
+ return (TessPatchType)(_header.TessellationModePacked & 3);
+ }
+
+ /// <summary>
+ /// Queries the tessellation evaluation shader spacing between tessellated vertices of the patch.
+ /// </summary>
+ /// <returns>Spacing between tessellated vertices of the patch</returns>
+ public TessSpacing QueryTessSpacing()
+ {
+ return (TessSpacing)((_header.TessellationModePacked >> 2) & 3);
+ }
+
+ /// <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 50e24b97..64604a99 100644
--- a/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
@@ -168,11 +168,32 @@ namespace Ryujinx.Graphics.Gpu.Shader
PrimitiveTopology.TriangleFan => InputTopology.Triangles,
PrimitiveTopology.TrianglesAdjacency or
PrimitiveTopology.TriangleStripAdjacency => InputTopology.TrianglesAdjacency,
- _ => InputTopology.Points,
+ PrimitiveTopology.Patches => _state.TessellationMode.UnpackPatchType() == TessPatchType.Isolines
+ ? InputTopology.Lines
+ : InputTopology.Triangles,
+ _ => InputTopology.Points
};
}
/// <summary>
+ /// Queries the tessellation evaluation shader primitive winding order.
+ /// </summary>
+ /// <returns>True if the primitive winding order is clockwise, false if counter-clockwise</returns>
+ public bool QueryTessCw() => _state.TessellationMode.UnpackCw();
+
+ /// <summary>
+ /// Queries the tessellation evaluation shader abstract patch type.
+ /// </summary>
+ /// <returns>Abstract patch type</returns>
+ public TessPatchType QueryTessPatchType() => _state.TessellationMode.UnpackPatchType();
+
+ /// <summary>
+ /// Queries the tessellation evaluation shader spacing between tessellated vertices of the patch.
+ /// </summary>
+ /// <returns>Spacing between tessellated vertices of the patch</returns>
+ public TessSpacing QueryTessSpacing() => _state.TessellationMode.UnpackSpacing();
+
+ /// <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/GpuAccessorState.cs b/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs
index 8d817113..ebbf3b69 100644
--- a/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs
@@ -1,4 +1,5 @@
using Ryujinx.Graphics.GAL;
+using Ryujinx.Graphics.Gpu.Engine.Threed;
namespace Ryujinx.Graphics.Gpu.Shader
{
@@ -33,6 +34,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
public PrimitiveTopology Topology { get; }
/// <summary>
+ /// Tessellation mode.
+ /// </summary>
+ public TessMode TessellationMode { get; }
+
+ /// <summary>
/// Creates a new instance of the GPU accessor state.
/// </summary>
/// <param name="texturePoolGpuVa">GPU virtual address of the texture pool</param>
@@ -40,18 +46,21 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <param name="textureBufferIndex">Constant buffer slot where the texture handles are located</param>
/// <param name="earlyZForce">Early Z force enable</param>
/// <param name="topology">Primitive topology</param>
+ /// <param name="tessellationMode">Tessellation mode</param>
public GpuAccessorState(
ulong texturePoolGpuVa,
int texturePoolMaximumId,
int textureBufferIndex,
bool earlyZForce,
- PrimitiveTopology topology)
+ PrimitiveTopology topology,
+ TessMode tessellationMode)
{
TexturePoolGpuVa = texturePoolGpuVa;
TexturePoolMaximumId = texturePoolMaximumId;
TextureBufferIndex = textureBufferIndex;
EarlyZForce = earlyZForce;
Topology = topology;
+ TessellationMode = tessellationMode;
}
}
} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
index e69e7dcb..f2180820 100644
--- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
@@ -40,7 +40,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 = 2702;
+ private const ulong ShaderCodeGenVersion = 2534;
// Progress reporting helpers
private volatile int _shaderCount;