Check if widelines is supported.

This commit is contained in:
sunshineinabox 2024-05-16 12:48:03 -07:00
parent 5894ef043b
commit 1befb5bd8f
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 SupportsHostImportedMemory;
public readonly bool SupportsDepthClipControl;
public readonly bool SupportsWideLines;
public readonly uint SubgroupSize;
public readonly SampleCountFlags SupportedSampleCounts;
public readonly PortabilitySubsetFlags PortabilitySubset;
@ -84,6 +85,7 @@ namespace Ryujinx.Graphics.Vulkan
bool supportsViewportArray2,
bool supportsHostImportedMemory,
bool supportsDepthClipControl,
bool supportsWideLines,
uint subgroupSize,
SampleCountFlags supportedSampleCounts,
PortabilitySubsetFlags portabilitySubset,
@ -121,6 +123,7 @@ namespace Ryujinx.Graphics.Vulkan
SupportsViewportArray2 = supportsViewportArray2;
SupportsHostImportedMemory = supportsHostImportedMemory;
SupportsDepthClipControl = supportsDepthClipControl;
SupportsWideLines = supportsWideLines;
SubgroupSize = subgroupSize;
SupportedSampleCounts = supportedSampleCounts;
PortabilitySubset = portabilitySubset;

View file

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

View file

@ -30,6 +30,8 @@ namespace Ryujinx.Graphics.Vulkan
private StencilOp _frontdepthfailop;
private CompareOp _frontcompareop;
private float _linewidth;
public bool _stencilTestEnable;
public bool _depthtestEnable;
@ -61,7 +63,8 @@ namespace Ryujinx.Graphics.Vulkan
DepthTestCompareOp = 1 << 8,
StencilTestEnable = 1 << 9,
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;
@ -194,6 +197,13 @@ namespace Ryujinx.Graphics.Vulkan
_dirty |= DirtyFlags.FrontFace;
}
public void SetLineWidth(float width)
{
_linewidth = width;
_dirty |= DirtyFlags.LineWidth;
}
public void ForceAllDirty()
{
_dirty = DirtyFlags.All;
@ -256,6 +266,11 @@ namespace Ryujinx.Graphics.Vulkan
RecordPrimitiveTopology(api, commandBuffer);
}
if (_dirty.HasFlag(DirtyFlags.LineWidth))
{
RecordLineWidth(api, commandBuffer);
}
_dirty = DirtyFlags.None;
}
@ -333,5 +348,10 @@ namespace Ryujinx.Graphics.Vulkan
{
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,
RasterizerDiscardEnable = RasterizerDiscardEnable,
PolygonMode = PolygonMode,
LineWidth = LineWidth,
DepthBiasEnable = DepthBiasEnable,
};
@ -604,7 +603,7 @@ namespace Ryujinx.Graphics.Vulkan
colorBlendState.PNext = &colorBlendAdvancedState;
}
int dynamicStatesCount = supportsExtDynamicState ? (isMoltenVk ? 15 : 16) : 7;
int dynamicStatesCount = supportsExtDynamicState ? (isMoltenVk ? 16 : 17) : 8;
DynamicState* dynamicStates = stackalloc DynamicState[dynamicStatesCount];
@ -615,21 +614,23 @@ namespace Ryujinx.Graphics.Vulkan
dynamicStates[4] = DynamicState.StencilWriteMask;
dynamicStates[5] = DynamicState.StencilReference;
dynamicStates[6] = DynamicState.BlendConstants;
dynamicStates[7] = DynamicState.LineWidth;
if (supportsExtDynamicState)
{
int index = 7;
int index = 8;
if (!isMoltenVk) {
dynamicStates[index++] = DynamicState.VertexInputBindingStrideExt;
}
dynamicStates[index++] = DynamicState.CullMode;
dynamicStates[index++] = DynamicState.FrontFace;
dynamicStates[index++] = DynamicState.DepthTestEnable;
dynamicStates[index++] = DynamicState.DepthWriteEnable;
dynamicStates[index++] = DynamicState.DepthCompareOp;
dynamicStates[index++] = DynamicState.StencilTestEnable;
dynamicStates[index++] = DynamicState.PrimitiveTopology;
dynamicStates[index] = DynamicState.StencilOp;
dynamicStates[index++] = DynamicState.CullModeExt;
dynamicStates[index++] = DynamicState.FrontFaceExt;
dynamicStates[index++] = DynamicState.DepthTestEnableExt;
dynamicStates[index++] = DynamicState.DepthWriteEnableExt;
dynamicStates[index++] = DynamicState.DepthCompareOpExt;
dynamicStates[index++] = DynamicState.StencilTestEnableExt;
dynamicStates[index++] = DynamicState.PrimitiveTopologyExt;
dynamicStates[index] = DynamicState.StencilOpExt;
}
var pipelineDynamicStateCreateInfo = new PipelineDynamicStateCreateInfo

View file

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

View file

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