aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2022-11-28 22:18:22 +0000
committerGitHub <noreply@github.com>2022-11-28 19:18:22 -0300
commit1fc0f569de518581761ab2f4b751b0dbaf2cd279 (patch)
tree69d356c9aa3dfd352f55d78868d855bfb27661bf
parentdff138229c79483c189be6f3829ed88a5f95575d (diff)
GPU: Always draw polygon topology as triangle fan (#3932)1.1.395
Polygon topology wasn't really supported and would only work on OpenGL on drivers that haven't removed it. As an alternative, this PR makes all cases of polygon topology use triangle fan. The topology type and transform feedback type have not been changed, as I don't think geo shader/tfb should be used with polygons. The OpenGL spec states: Only convex polygons are guaranteed to be drawn correctly by the GL. For convex polygons, triangle fan is equivalent to polygon. I imagine this is probably how it works on device, as this get-out-of-jail-free card is too enticing to pass up. This fixes the stat display in Pokemon S/V.
-rw-r--r--Ryujinx.Graphics.OpenGL/EnumConversion.cs2
-rw-r--r--Ryujinx.Graphics.Vulkan/EnumConversion.cs1
-rw-r--r--Ryujinx.Graphics.Vulkan/PipelineBase.cs6
3 files changed, 6 insertions, 3 deletions
diff --git a/Ryujinx.Graphics.OpenGL/EnumConversion.cs b/Ryujinx.Graphics.OpenGL/EnumConversion.cs
index 4a06e964..f262c584 100644
--- a/Ryujinx.Graphics.OpenGL/EnumConversion.cs
+++ b/Ryujinx.Graphics.OpenGL/EnumConversion.cs
@@ -331,7 +331,7 @@ namespace Ryujinx.Graphics.OpenGL
case PrimitiveTopology.QuadStrip:
return PrimitiveType.QuadStrip;
case PrimitiveTopology.Polygon:
- return PrimitiveType.Polygon;
+ return PrimitiveType.TriangleFan;
case PrimitiveTopology.LinesAdjacency:
return PrimitiveType.LinesAdjacency;
case PrimitiveTopology.LineStripAdjacency:
diff --git a/Ryujinx.Graphics.Vulkan/EnumConversion.cs b/Ryujinx.Graphics.Vulkan/EnumConversion.cs
index 804cd70c..9d9be65e 100644
--- a/Ryujinx.Graphics.Vulkan/EnumConversion.cs
+++ b/Ryujinx.Graphics.Vulkan/EnumConversion.cs
@@ -180,6 +180,7 @@ namespace Ryujinx.Graphics.Vulkan
GAL.PrimitiveTopology.TrianglesAdjacency => Silk.NET.Vulkan.PrimitiveTopology.TriangleListWithAdjacency,
GAL.PrimitiveTopology.TriangleStripAdjacency => Silk.NET.Vulkan.PrimitiveTopology.TriangleStripWithAdjacency,
GAL.PrimitiveTopology.Patches => Silk.NET.Vulkan.PrimitiveTopology.PatchList,
+ GAL.PrimitiveTopology.Polygon => Silk.NET.Vulkan.PrimitiveTopology.TriangleFan,
GAL.PrimitiveTopology.Quads => throw new NotSupportedException("Quad topology is not available in Vulkan."),
GAL.PrimitiveTopology.QuadStrip => throw new NotSupportedException("QuadStrip topology is not available in Vulkan."),
_ => LogInvalidAndReturn(topology, nameof(GAL.PrimitiveTopology), Silk.NET.Vulkan.PrimitiveTopology.TriangleList)
diff --git a/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/Ryujinx.Graphics.Vulkan/PipelineBase.cs
index 87155a0d..594ed5e7 100644
--- a/Ryujinx.Graphics.Vulkan/PipelineBase.cs
+++ b/Ryujinx.Graphics.Vulkan/PipelineBase.cs
@@ -328,7 +328,8 @@ namespace Ryujinx.Graphics.Vulkan
IndexBufferPattern pattern = _topology switch
{
GAL.PrimitiveTopology.Quads => QuadsToTrisPattern,
- GAL.PrimitiveTopology.TriangleFan => TriFanToTrisPattern,
+ GAL.PrimitiveTopology.TriangleFan or
+ GAL.PrimitiveTopology.Polygon => TriFanToTrisPattern,
_ => throw new NotSupportedException($"Unsupported topology: {_topology}")
};
@@ -359,7 +360,8 @@ namespace Ryujinx.Graphics.Vulkan
pattern = _topology switch
{
GAL.PrimitiveTopology.Quads => QuadsToTrisPattern,
- GAL.PrimitiveTopology.TriangleFan => TriFanToTrisPattern,
+ GAL.PrimitiveTopology.TriangleFan or
+ GAL.PrimitiveTopology.Polygon => TriFanToTrisPattern,
_ => throw new NotSupportedException($"Unsupported topology: {_topology}")
};
}