Check if widelines is supported.

This commit is contained in:
sunshineinabox 2024-05-16 12:48:03 -07:00
parent 33f2a08254
commit cc085bcc92
6 changed files with 40 additions and 13 deletions

View file

@ -46,6 +46,7 @@ namespace Ryujinx.Graphics.Vulkan
public readonly bool SupportsViewportArray2; public readonly bool SupportsViewportArray2;
public readonly bool SupportsHostImportedMemory; public readonly bool SupportsHostImportedMemory;
public readonly bool SupportsDepthClipControl; public readonly bool SupportsDepthClipControl;
public readonly bool SupportsWideLines;
public readonly uint SubgroupSize; public readonly uint SubgroupSize;
public readonly SampleCountFlags SupportedSampleCounts; public readonly SampleCountFlags SupportedSampleCounts;
public readonly PortabilitySubsetFlags PortabilitySubset; public readonly PortabilitySubsetFlags PortabilitySubset;
@ -84,6 +85,7 @@ namespace Ryujinx.Graphics.Vulkan
bool supportsViewportArray2, bool supportsViewportArray2,
bool supportsHostImportedMemory, bool supportsHostImportedMemory,
bool supportsDepthClipControl, bool supportsDepthClipControl,
bool supportsWideLines,
uint subgroupSize, uint subgroupSize,
SampleCountFlags supportedSampleCounts, SampleCountFlags supportedSampleCounts,
PortabilitySubsetFlags portabilitySubset, PortabilitySubsetFlags portabilitySubset,
@ -121,6 +123,7 @@ namespace Ryujinx.Graphics.Vulkan
SupportsViewportArray2 = supportsViewportArray2; SupportsViewportArray2 = supportsViewportArray2;
SupportsHostImportedMemory = supportsHostImportedMemory; SupportsHostImportedMemory = supportsHostImportedMemory;
SupportsDepthClipControl = supportsDepthClipControl; SupportsDepthClipControl = supportsDepthClipControl;
SupportsWideLines = supportsWideLines;
SubgroupSize = subgroupSize; SubgroupSize = subgroupSize;
SupportedSampleCounts = supportedSampleCounts; SupportedSampleCounts = supportedSampleCounts;
PortabilitySubset = portabilitySubset; PortabilitySubset = portabilitySubset;

View file

@ -968,7 +968,8 @@ namespace Ryujinx.Graphics.Vulkan
public void SetLineParameters(float width, bool smooth) public void SetLineParameters(float width, bool smooth)
{ {
_newState.LineWidth = width; DynamicState.SetLineWidth(Gd.Capabilities.SupportsWideLines ? width : 1.0f);
SignalStateChange(); SignalStateChange();
} }

View file

@ -30,6 +30,8 @@ namespace Ryujinx.Graphics.Vulkan
private StencilOp _frontdepthfailop; private StencilOp _frontdepthfailop;
private CompareOp _frontcompareop; private CompareOp _frontcompareop;
private float _linewidth;
public bool _stencilTestEnable; public bool _stencilTestEnable;
public bool _depthtestEnable; public bool _depthtestEnable;
@ -61,7 +63,8 @@ namespace Ryujinx.Graphics.Vulkan
DepthTestCompareOp = 1 << 8, DepthTestCompareOp = 1 << 8,
StencilTestEnable = 1 << 9, StencilTestEnable = 1 << 9,
Toplogy = 1 << 10, Toplogy = 1 << 10,
All = Blend | DepthBias | Scissor | Stencil | Viewport | CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnable | Toplogy, LineWidth = 1 <<11,
All = Blend | DepthBias | Scissor | Stencil | Viewport | CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnable | Toplogy | LineWidth,
} }
private DirtyFlags _dirty; private DirtyFlags _dirty;
@ -194,6 +197,13 @@ namespace Ryujinx.Graphics.Vulkan
_dirty |= DirtyFlags.FrontFace; _dirty |= DirtyFlags.FrontFace;
} }
public void SetLineWidth(float width)
{
_linewidth = width;
_dirty |= DirtyFlags.LineWidth;
}
public void ForceAllDirty() public void ForceAllDirty()
{ {
_dirty = DirtyFlags.All; _dirty = DirtyFlags.All;
@ -256,6 +266,11 @@ namespace Ryujinx.Graphics.Vulkan
RecordPrimitiveTopology(api, commandBuffer); RecordPrimitiveTopology(api, commandBuffer);
} }
if (_dirty.HasFlag(DirtyFlags.LineWidth))
{
RecordLineWidth(api, commandBuffer);
}
_dirty = DirtyFlags.None; _dirty = DirtyFlags.None;
} }
@ -333,5 +348,10 @@ namespace Ryujinx.Graphics.Vulkan
{ {
api.CmdSetPrimitiveTopology(commandBuffer, Topology); api.CmdSetPrimitiveTopology(commandBuffer, Topology);
} }
private void RecordLineWidth(Vk api, CommandBuffer commandBuffer)
{
api.CmdSetLineWidth(commandBuffer, _linewidth);
}
} }
} }

View file

@ -479,7 +479,6 @@ namespace Ryujinx.Graphics.Vulkan
DepthClampEnable = DepthClampEnable, DepthClampEnable = DepthClampEnable,
RasterizerDiscardEnable = RasterizerDiscardEnable, RasterizerDiscardEnable = RasterizerDiscardEnable,
PolygonMode = PolygonMode, PolygonMode = PolygonMode,
LineWidth = LineWidth,
DepthBiasEnable = DepthBiasEnable, DepthBiasEnable = DepthBiasEnable,
}; };
@ -600,7 +599,7 @@ namespace Ryujinx.Graphics.Vulkan
colorBlendState.PNext = &colorBlendAdvancedState; colorBlendState.PNext = &colorBlendAdvancedState;
} }
int dynamicStatesCount = supportsExtDynamicState ? (isMoltenVk ? 15 : 16) : 7; int dynamicStatesCount = supportsExtDynamicState ? (isMoltenVk ? 16 : 17) : 8;
DynamicState* dynamicStates = stackalloc DynamicState[dynamicStatesCount]; DynamicState* dynamicStates = stackalloc DynamicState[dynamicStatesCount];
@ -611,21 +610,23 @@ namespace Ryujinx.Graphics.Vulkan
dynamicStates[4] = DynamicState.StencilWriteMask; dynamicStates[4] = DynamicState.StencilWriteMask;
dynamicStates[5] = DynamicState.StencilReference; dynamicStates[5] = DynamicState.StencilReference;
dynamicStates[6] = DynamicState.BlendConstants; dynamicStates[6] = DynamicState.BlendConstants;
dynamicStates[7] = DynamicState.LineWidth;
if (supportsExtDynamicState) if (supportsExtDynamicState)
{ {
int index = 7; int index = 8;
if (!isMoltenVk) { if (!isMoltenVk) {
dynamicStates[index++] = DynamicState.VertexInputBindingStrideExt; dynamicStates[index++] = DynamicState.VertexInputBindingStrideExt;
} }
dynamicStates[index++] = DynamicState.CullMode; dynamicStates[index++] = DynamicState.CullModeExt;
dynamicStates[index++] = DynamicState.FrontFace; dynamicStates[index++] = DynamicState.FrontFaceExt;
dynamicStates[index++] = DynamicState.DepthTestEnable; dynamicStates[index++] = DynamicState.DepthTestEnableExt;
dynamicStates[index++] = DynamicState.DepthWriteEnable; dynamicStates[index++] = DynamicState.DepthWriteEnableExt;
dynamicStates[index++] = DynamicState.DepthCompareOp; dynamicStates[index++] = DynamicState.DepthCompareOpExt;
dynamicStates[index++] = DynamicState.StencilTestEnable; dynamicStates[index++] = DynamicState.StencilTestEnableExt;
dynamicStates[index++] = DynamicState.PrimitiveTopology; dynamicStates[index++] = DynamicState.PrimitiveTopologyExt;
dynamicStates[index] = DynamicState.StencilOp; dynamicStates[index] = DynamicState.StencilOpExt;
} }
var pipelineDynamicStateCreateInfo = new PipelineDynamicStateCreateInfo var pipelineDynamicStateCreateInfo = new PipelineDynamicStateCreateInfo

View file

@ -382,6 +382,7 @@ namespace Ryujinx.Graphics.Vulkan
TessellationShader = supportedFeatures.TessellationShader, TessellationShader = supportedFeatures.TessellationShader,
VertexPipelineStoresAndAtomics = supportedFeatures.VertexPipelineStoresAndAtomics, VertexPipelineStoresAndAtomics = supportedFeatures.VertexPipelineStoresAndAtomics,
RobustBufferAccess = useRobustBufferAccess, RobustBufferAccess = useRobustBufferAccess,
WideLines = supportedFeatures.WideLines,
}; };
void* pExtendedFeatures = null; void* pExtendedFeatures = null;

View file

@ -397,6 +397,7 @@ namespace Ryujinx.Graphics.Vulkan
_physicalDevice.IsDeviceExtensionPresent("VK_NV_viewport_array2"), _physicalDevice.IsDeviceExtensionPresent("VK_NV_viewport_array2"),
_physicalDevice.IsDeviceExtensionPresent(ExtExternalMemoryHost.ExtensionName), _physicalDevice.IsDeviceExtensionPresent(ExtExternalMemoryHost.ExtensionName),
supportsDepthClipControl && featuresDepthClipControl.DepthClipControl, supportsDepthClipControl && featuresDepthClipControl.DepthClipControl,
_physicalDevice.PhysicalDeviceFeatures.WideLines,
propertiesSubgroup.SubgroupSize, propertiesSubgroup.SubgroupSize,
supportedSampleCounts, supportedSampleCounts,
portabilityFlags, portabilityFlags,