mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-18 16:26:44 +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 Ryujinx.Graphics.Shader;
|
||||||
using Silk.NET.Vulkan;
|
using Silk.NET.Vulkan;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
@ -1067,7 +1068,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
primitiveRestartEnable &= topologySupportsRestart;
|
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 ||
|
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.LineStripWithAdjacency ||
|
||||||
_newState.Topology == Silk.NET.Vulkan.PrimitiveTopology.TriangleStripWithAdjacency) && Gd.IsMoltenVk)
|
_newState.Topology == Silk.NET.Vulkan.PrimitiveTopology.TriangleStripWithAdjacency) && Gd.IsMoltenVk)
|
||||||
|
@ -1093,19 +1094,15 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
_topology = topology;
|
_topology = topology;
|
||||||
|
|
||||||
var vkTopology = Gd.TopologyRemap(topology).Convert();
|
var vkTopology = Gd.TopologyRemap(topology).Convert();
|
||||||
|
|
||||||
var currentTopologyClass = GetTopologyClass(_newState.Topology);
|
|
||||||
var newTopologyClass = GetTopologyClass(vkTopology);
|
var newTopologyClass = GetTopologyClass(vkTopology);
|
||||||
|
var currentTopologyClass = GetTopologyClass(_newState.Topology);
|
||||||
|
|
||||||
if (_supportExtDynamic)
|
if (_supportExtDynamic)
|
||||||
{
|
{
|
||||||
DynamicState.SetPrimitiveTopology(vkTopology);
|
DynamicState.SetPrimitiveTopology(vkTopology);
|
||||||
if (currentTopologyClass != newTopologyClass)
|
|
||||||
{
|
|
||||||
_newState.Topology = vkTopology;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (!_supportExtDynamic || currentTopologyClass != newTopologyClass)
|
||||||
{
|
{
|
||||||
_newState.Topology = vkTopology;
|
_newState.Topology = vkTopology;
|
||||||
}
|
}
|
||||||
|
@ -1115,23 +1112,24 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
private TopologyClass GetTopologyClass(Silk.NET.Vulkan.PrimitiveTopology topology)
|
private TopologyClass GetTopologyClass(Silk.NET.Vulkan.PrimitiveTopology topology)
|
||||||
{
|
{
|
||||||
return topology switch
|
return topologyClassMapping.TryGetValue(topology, out var topologyClass) ? topologyClass : throw new ArgumentOutOfRangeException(nameof(topology), topology, null);
|
||||||
{
|
|
||||||
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)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
private enum TopologyClass
|
||||||
{
|
{
|
||||||
Point,
|
Point,
|
||||||
|
|
|
@ -230,12 +230,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
if (gd.Capabilities.SupportsExtendedDynamicState)
|
if (gd.Capabilities.SupportsExtendedDynamicState)
|
||||||
{
|
{
|
||||||
_dirty = DirtyFlags.Standard | DirtyFlags.Extended;
|
_dirty |= DirtyFlags.Extended;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gd.Capabilities.SupportsExtendedDynamicState2)
|
if (gd.Capabilities.SupportsExtendedDynamicState2)
|
||||||
{
|
{
|
||||||
_dirty = DirtyFlags.Standard | DirtyFlags.Extended | DirtyFlags.Extended2;
|
_dirty |= DirtyFlags.Extended2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gd.IsMoltenVk)
|
if (gd.IsMoltenVk)
|
||||||
|
|
|
@ -391,11 +391,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
RenderPass renderPass,
|
RenderPass renderPass,
|
||||||
bool throwOnError = false)
|
bool throwOnError = false)
|
||||||
{
|
{
|
||||||
if (program.TryGetGraphicsPipeline(ref Internal, out var pipeline))
|
|
||||||
{
|
|
||||||
return pipeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Using patches topology without a tessellation shader is invalid.
|
// Using patches topology without a tessellation shader is invalid.
|
||||||
// If we find such a case, return null pipeline to skip the draw.
|
// If we find such a case, return null pipeline to skip the draw.
|
||||||
if (Topology == PrimitiveTopology.PatchList && !HasTessellationControlShader)
|
if (Topology == PrimitiveTopology.PatchList && !HasTessellationControlShader)
|
||||||
|
@ -405,6 +400,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (program.TryGetGraphicsPipeline(ref Internal, out var pipeline))
|
||||||
|
{
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
Pipeline pipelineHandle = default;
|
Pipeline pipelineHandle = default;
|
||||||
|
|
||||||
bool isMoltenVk = gd.IsMoltenVk;
|
bool isMoltenVk = gd.IsMoltenVk;
|
||||||
|
@ -426,6 +426,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
SType = StructureType.PipelineVertexInputStateCreateInfo,
|
SType = StructureType.PipelineVertexInputStateCreateInfo,
|
||||||
VertexAttributeDescriptionCount = VertexAttributeDescriptionsCount,
|
VertexAttributeDescriptionCount = VertexAttributeDescriptionsCount,
|
||||||
|
PVertexAttributeDescriptions = isMoltenVk ? pVertexAttributeDescriptions2 : pVertexAttributeDescriptions,
|
||||||
VertexBindingDescriptionCount = VertexBindingDescriptionsCount,
|
VertexBindingDescriptionCount = VertexBindingDescriptionsCount,
|
||||||
PVertexBindingDescriptions = pVertexBindingDescriptions,
|
PVertexBindingDescriptions = pVertexBindingDescriptions,
|
||||||
};
|
};
|
||||||
|
@ -455,8 +456,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
if (isMoltenVk)
|
if (isMoltenVk)
|
||||||
{
|
{
|
||||||
vertexInputState.PVertexAttributeDescriptions = pVertexAttributeDescriptions2;
|
|
||||||
|
|
||||||
//When widelines feature is not supported it must be 1.0f per spec.
|
//When widelines feature is not supported it must be 1.0f per spec.
|
||||||
rasterizationState.LineWidth = 1.0f;
|
rasterizationState.LineWidth = 1.0f;
|
||||||
}
|
}
|
||||||
|
@ -585,8 +584,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
if (!isMoltenVk)
|
if (!isMoltenVk)
|
||||||
{
|
{
|
||||||
vertexInputState.PVertexAttributeDescriptions = pVertexAttributeDescriptions;
|
|
||||||
|
|
||||||
baseDynamicStatesCount++;
|
baseDynamicStatesCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue