From 9b02fd6dc06b34e83305dae9feb7870acaa4eb6a Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Thu, 1 Aug 2024 08:19:11 -0700 Subject: [PATCH] Conver to TopologyClass from Vulkan Topology --- src/Ryujinx.Graphics.Vulkan/EnumConversion.cs | 29 +++++++++---------- src/Ryujinx.Graphics.Vulkan/PipelineBase.cs | 7 ++--- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/EnumConversion.cs b/src/Ryujinx.Graphics.Vulkan/EnumConversion.cs index d58603cd6..7e5207d39 100644 --- a/src/Ryujinx.Graphics.Vulkan/EnumConversion.cs +++ b/src/Ryujinx.Graphics.Vulkan/EnumConversion.cs @@ -310,25 +310,22 @@ namespace Ryujinx.Graphics.Vulkan }; } - public static PrimitiveTopology ConvertToClass(this GAL.PrimitiveTopology topology) + public static PrimitiveTopology ConvertToClass(this PrimitiveTopology topology) { return topology switch { - GAL.PrimitiveTopology.Points => PrimitiveTopology.PointList, - GAL.PrimitiveTopology.Lines or - GAL.PrimitiveTopology.LineStrip or - GAL.PrimitiveTopology.LinesAdjacency or - GAL.PrimitiveTopology.LineStripAdjacency => PrimitiveTopology.LineList, - GAL.PrimitiveTopology.Triangles or - GAL.PrimitiveTopology.TriangleStrip or - GAL.PrimitiveTopology.TriangleFan or - GAL.PrimitiveTopology.TrianglesAdjacency or - GAL.PrimitiveTopology.TriangleStripAdjacency or - GAL.PrimitiveTopology.Polygon => PrimitiveTopology.TriangleList, - GAL.PrimitiveTopology.Patches => PrimitiveTopology.PatchList, - 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), PrimitiveTopology.TriangleList), + PrimitiveTopology.PointList => PrimitiveTopology.PointList, + PrimitiveTopology.LineList or + PrimitiveTopology.LineStrip or + PrimitiveTopology.LineListWithAdjacency or + PrimitiveTopology.LineStripWithAdjacency => PrimitiveTopology.LineList, + PrimitiveTopology.TriangleList or + PrimitiveTopology.TriangleStrip or + PrimitiveTopology.TriangleFan or + PrimitiveTopology.TriangleListWithAdjacency or + PrimitiveTopology.TriangleStripWithAdjacency => PrimitiveTopology.TriangleList, + PrimitiveTopology.PatchList => PrimitiveTopology.PatchList, + _ => LogInvalidAndReturn(topology, nameof(PrimitiveTopology), PrimitiveTopology.TriangleList), }; } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 9e3cf76bd..257a22fd9 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -640,7 +640,6 @@ namespace Ryujinx.Graphics.Vulkan var oldDepthTestEnable = _supportExtDynamic ? DynamicState.DepthTestEnable : _newState.DepthTestEnable; var oldDepthWriteEnable = _supportExtDynamic ? DynamicState.DepthWriteEnable : _newState.DepthWriteEnable; var oldTopology = _newState.Topology; - var oldTopologyClass = _newState.TopologyClass; var oldViewports = DynamicState.Viewports; var oldViewportsCount = _supportExtDynamic ? DynamicState.ViewportsCount : _newState.ViewportsCount; @@ -670,9 +669,9 @@ namespace Ryujinx.Graphics.Vulkan if (_supportExtDynamic) { - if (oldTopologyClass != Silk.NET.Vulkan.PrimitiveTopology.TriangleList) + if (oldTopology.ConvertToClass() != _newState.TopologyClass.ConvertToClass()) { - _newState.TopologyClass = oldTopology; + _newState.TopologyClass = _newState.TopologyClass.ConvertToClass(); } DynamicState.SetCullMode(oldCullMode); @@ -1071,7 +1070,7 @@ namespace Ryujinx.Graphics.Vulkan if (_supportExtDynamic) { - var newTopologyClass = Gd.TopologyRemap(topology).ConvertToClass(); + var newTopologyClass = vkTopology.ConvertToClass(); if ((_newState.TopologyClass != newTopologyClass)) {