Move TopologyClass conversoin to EnumConversion.cs
This commit is contained in:
parent
34ac6f33ad
commit
2cba50a9ed
2 changed files with 28 additions and 35 deletions
|
@ -310,6 +310,28 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
};
|
||||
}
|
||||
|
||||
public static PrimitiveTopology ConvertToClass(this GAL.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),
|
||||
};
|
||||
}
|
||||
|
||||
public static StencilOp Convert(this GAL.StencilOp op)
|
||||
{
|
||||
return op switch
|
||||
|
|
|
@ -640,6 +640,7 @@ 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;
|
||||
|
||||
|
@ -669,9 +670,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
if (_supportExtDynamic)
|
||||
{
|
||||
var oldTopologyClass = GetTopologyClass(oldTopology);
|
||||
|
||||
if (oldTopologyClass != TopologyClass.Triangle)
|
||||
if (oldTopologyClass != Silk.NET.Vulkan.PrimitiveTopology.TriangleList)
|
||||
{
|
||||
_newState.TopologyClass = oldTopology;
|
||||
}
|
||||
|
@ -1070,12 +1069,12 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
if (_supportExtDynamic)
|
||||
{
|
||||
var newTopologyClass = GetTopologyClass(vkTopology);
|
||||
var currentTopologyClass = GetTopologyClass(_newState.TopologyClass);
|
||||
var oldTopologyClass = _newState.TopologyClass;
|
||||
var newTopologyClass = Gd.TopologyRemap(topology).ConvertToClass();
|
||||
|
||||
if ((currentTopologyClass != newTopologyClass))
|
||||
if ((oldTopologyClass != newTopologyClass))
|
||||
{
|
||||
_newState.TopologyClass = vkTopology;
|
||||
_newState.TopologyClass = newTopologyClass;
|
||||
}
|
||||
|
||||
DynamicState.SetPrimitiveTopology(vkTopology);
|
||||
|
@ -1086,34 +1085,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
SignalStateChange();
|
||||
}
|
||||
|
||||
private TopologyClass GetTopologyClass(Silk.NET.Vulkan.PrimitiveTopology topology)
|
||||
{
|
||||
return _topologyClassMapping.TryGetValue(topology, out var topologyClass) ? topologyClass : throw new ArgumentOutOfRangeException(nameof(topology), topology, null);
|
||||
}
|
||||
|
||||
private static readonly Dictionary<Silk.NET.Vulkan.PrimitiveTopology, TopologyClass> _topologyClassMapping = new()
|
||||
{
|
||||
{ Silk.NET.Vulkan.PrimitiveTopology.PointList, TopologyClass.Point },
|
||||
{ Silk.NET.Vulkan.PrimitiveTopology.LineList, TopologyClass.Line },
|
||||
{ Silk.NET.Vulkan.PrimitiveTopology.LineStrip, TopologyClass.Line },
|
||||
{ Silk.NET.Vulkan.PrimitiveTopology.LineListWithAdjacency, TopologyClass.Line },
|
||||
{ Silk.NET.Vulkan.PrimitiveTopology.LineStripWithAdjacency, TopologyClass.Line },
|
||||
{ Silk.NET.Vulkan.PrimitiveTopology.TriangleList, TopologyClass.Triangle },
|
||||
{ Silk.NET.Vulkan.PrimitiveTopology.TriangleStrip, TopologyClass.Triangle },
|
||||
{ Silk.NET.Vulkan.PrimitiveTopology.TriangleFan, TopologyClass.Triangle },
|
||||
{ Silk.NET.Vulkan.PrimitiveTopology.TriangleListWithAdjacency, TopologyClass.Triangle },
|
||||
{ Silk.NET.Vulkan.PrimitiveTopology.TriangleStripWithAdjacency, TopologyClass.Triangle },
|
||||
{ Silk.NET.Vulkan.PrimitiveTopology.PatchList, TopologyClass.Patch }
|
||||
};
|
||||
|
||||
private enum TopologyClass
|
||||
{
|
||||
Point,
|
||||
Line,
|
||||
Triangle,
|
||||
Patch
|
||||
}
|
||||
|
||||
public void SetProgram(IProgram program)
|
||||
{
|
||||
var internalProgram = (ShaderCollection)program;
|
||||
|
|
Loading…
Reference in a new issue