mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-26 18:43:04 +00:00
Use dictionary instead for clarity and rework some logic.
This commit is contained in:
parent
7ac2cd44d0
commit
4a3932ed54
3 changed files with 29 additions and 34 deletions
|
@ -2,6 +2,7 @@ using Ryujinx.Graphics.GAL;
|
|||
using Ryujinx.Graphics.Shader;
|
||||
using Silk.NET.Vulkan;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
@ -1067,7 +1068,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
primitiveRestartEnable &= topologySupportsRestart;
|
||||
|
||||
//Cannot disable primitveRestartEnable for these Topoligies on MacOS
|
||||
//Cannot disable primitiveRestartEnable for these Topologies on MacOS
|
||||
if ((_newState.Topology == Silk.NET.Vulkan.PrimitiveTopology.LineStrip || _newState.Topology == Silk.NET.Vulkan.PrimitiveTopology.TriangleStrip ||
|
||||
_newState.Topology == Silk.NET.Vulkan.PrimitiveTopology.LineStripWithAdjacency ||
|
||||
_newState.Topology == Silk.NET.Vulkan.PrimitiveTopology.TriangleStripWithAdjacency) && Gd.IsMoltenVk)
|
||||
|
@ -1093,19 +1094,15 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
_topology = topology;
|
||||
|
||||
var vkTopology = Gd.TopologyRemap(topology).Convert();
|
||||
|
||||
var currentTopologyClass = GetTopologyClass(_newState.Topology);
|
||||
var newTopologyClass = GetTopologyClass(vkTopology);
|
||||
var currentTopologyClass = GetTopologyClass(_newState.Topology);
|
||||
|
||||
if (_supportExtDynamic)
|
||||
{
|
||||
DynamicState.SetPrimitiveTopology(vkTopology);
|
||||
if (currentTopologyClass != newTopologyClass)
|
||||
{
|
||||
_newState.Topology = vkTopology;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (!_supportExtDynamic || currentTopologyClass != newTopologyClass)
|
||||
{
|
||||
_newState.Topology = vkTopology;
|
||||
}
|
||||
|
@ -1115,23 +1112,24 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
private TopologyClass GetTopologyClass(Silk.NET.Vulkan.PrimitiveTopology topology)
|
||||
{
|
||||
return topology switch
|
||||
{
|
||||
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,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(topology), topology, null)
|
||||
};
|
||||
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,
|
||||
|
|
|
@ -230,12 +230,12 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
if (gd.Capabilities.SupportsExtendedDynamicState)
|
||||
{
|
||||
_dirty = DirtyFlags.Standard | DirtyFlags.Extended;
|
||||
_dirty |= DirtyFlags.Extended;
|
||||
}
|
||||
|
||||
if (gd.Capabilities.SupportsExtendedDynamicState2)
|
||||
{
|
||||
_dirty = DirtyFlags.Standard | DirtyFlags.Extended | DirtyFlags.Extended2;
|
||||
_dirty |= DirtyFlags.Extended2;
|
||||
}
|
||||
|
||||
if (gd.IsMoltenVk)
|
||||
|
|
|
@ -391,11 +391,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
RenderPass renderPass,
|
||||
bool throwOnError = false)
|
||||
{
|
||||
if (program.TryGetGraphicsPipeline(ref Internal, out var pipeline))
|
||||
{
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
// Using patches topology without a tessellation shader is invalid.
|
||||
// If we find such a case, return null pipeline to skip the draw.
|
||||
if (Topology == PrimitiveTopology.PatchList && !HasTessellationControlShader)
|
||||
|
@ -405,6 +400,11 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
return null;
|
||||
}
|
||||
|
||||
if (program.TryGetGraphicsPipeline(ref Internal, out var pipeline))
|
||||
{
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
Pipeline pipelineHandle = default;
|
||||
|
||||
bool isMoltenVk = gd.IsMoltenVk;
|
||||
|
@ -426,6 +426,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
{
|
||||
SType = StructureType.PipelineVertexInputStateCreateInfo,
|
||||
VertexAttributeDescriptionCount = VertexAttributeDescriptionsCount,
|
||||
PVertexAttributeDescriptions = isMoltenVk ? pVertexAttributeDescriptions2 : pVertexAttributeDescriptions,
|
||||
VertexBindingDescriptionCount = VertexBindingDescriptionsCount,
|
||||
PVertexBindingDescriptions = pVertexBindingDescriptions,
|
||||
};
|
||||
|
@ -455,8 +456,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
if (isMoltenVk)
|
||||
{
|
||||
vertexInputState.PVertexAttributeDescriptions = pVertexAttributeDescriptions2;
|
||||
|
||||
//When widelines feature is not supported it must be 1.0f per spec.
|
||||
rasterizationState.LineWidth = 1.0f;
|
||||
}
|
||||
|
@ -585,8 +584,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
if (!isMoltenVk)
|
||||
{
|
||||
vertexInputState.PVertexAttributeDescriptions = pVertexAttributeDescriptions;
|
||||
|
||||
baseDynamicStatesCount++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue