From 0000a7ac9ce7024b4be3144272f9b269438a5151 Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Wed, 22 May 2024 22:05:01 -0700 Subject: [PATCH] Rebased --- src/Ryujinx.Graphics.Vulkan/PipelineBase.cs | 8 +++- src/Ryujinx.Graphics.Vulkan/PipelineState.cs | 48 ++++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 5433f3402e..2ec66ef318 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -1024,14 +1024,18 @@ namespace Ryujinx.Graphics.Vulkan _newState.LogicOp = op.Convert(); } + // AMD has a bug where it enables logical operations even for float formats, + // so we need to force disable them here. + bool logicOpEnable = enable && (Gd.Vendor != Vendor.Amd || _newState.Internal.LogicOpsAllowed); + if (Gd.ExtendedDynamicState3Features.ExtendedDynamicState3LogicOpEnable) { - DynamicState.SetLogicOpEnable(enable); + DynamicState.SetLogicOpEnable(logicOpEnable); } else { - _newState.LogicOpEnable = enable; + _newState.LogicOpEnable = logicOpEnable; } SignalStateChange(); diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs index f8b71ed15c..70fe8bb62a 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -407,6 +407,7 @@ namespace Ryujinx.Graphics.Vulkan bool supportsExtDynamicState = gd.Capabilities.SupportsExtendedDynamicState; bool supportsExtDynamicState2 = gd.Capabilities.SupportsExtendedDynamicState2; + bool supportsExtDynamicState3 = gd.Capabilities.SupportsExtendedDynamicState3; fixed (VertexInputAttributeDescription* pVertexAttributeDescriptions = &Internal.VertexAttributeDescriptions[0]) @@ -445,16 +446,24 @@ namespace Ryujinx.Graphics.Vulkan var tessellationState = new PipelineTessellationStateCreateInfo { SType = StructureType.PipelineTessellationStateCreateInfo, - PatchControlPoints = PatchControlPoints, }; + if (!gd.ExtendedDynamicState2Features.ExtendedDynamicState2PatchControlPoints) + { + tessellationState.PatchControlPoints = PatchControlPoints; + } + var rasterizationState = new PipelineRasterizationStateCreateInfo { SType = StructureType.PipelineRasterizationStateCreateInfo, - DepthClampEnable = DepthClampEnable, PolygonMode = PolygonMode, }; + if (!gd.ExtendedDynamicState3Features.ExtendedDynamicState3DepthClampEnable) + { + rasterizationState.DepthClampEnable = DepthClampEnable; + } + if (isMoltenVk) { //When widelines feature is not supported it must be 1.0f per spec. @@ -490,10 +499,18 @@ namespace Ryujinx.Graphics.Vulkan SampleShadingEnable = false, RasterizationSamples = TextureStorage.ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, SamplesCount), MinSampleShading = 1, - AlphaToCoverageEnable = AlphaToCoverageEnable, - AlphaToOneEnable = AlphaToOneEnable, }; + if (!gd.ExtendedDynamicState3Features.ExtendedDynamicState3AlphaToCoverageEnable) + { + multisampleState.AlphaToCoverageEnable = AlphaToCoverageEnable; + } + + if (!gd.ExtendedDynamicState3Features.ExtendedDynamicState3AlphaToOneEnable) + { + multisampleState.AlphaToOneEnable = AlphaToOneEnable; + } + var depthStencilState = new PipelineDepthStencilStateCreateInfo { SType = StructureType.PipelineDepthStencilStateCreateInfo, @@ -516,19 +533,13 @@ namespace Ryujinx.Graphics.Vulkan StencilFrontFailOp, StencilFrontPassOp, StencilFrontDepthFailOp, - StencilFrontCompareOp, - null, - null, - null); + StencilFrontCompareOp); var stencilBack = new StencilOpState( StencilBackFailOp, StencilBackPassOp, StencilBackDepthFailOp, - StencilBackCompareOp, - null, - null, - null); + StencilBackCompareOp); depthStencilState.Front = stencilFront; depthStencilState.Back = stencilBack; @@ -559,19 +570,27 @@ namespace Ryujinx.Graphics.Vulkan } } + // AMD has a bug where it enables logical operations even for float formats, + // so we need to force disable them here. + bool logicOpEnable = LogicOpEnable && (gd.Vendor != Vendor.Amd || Internal.LogicOpsAllowed); + var colorBlendState = new PipelineColorBlendStateCreateInfo { SType = StructureType.PipelineColorBlendStateCreateInfo, - LogicOpEnable = LogicOpEnable, AttachmentCount = ColorBlendAttachmentStateCount, PAttachments = pColorBlendAttachmentState, }; - if (!(supportsExtDynamicState2 && gd.ExtendedLogicOp)) + if (!gd.ExtendedDynamicState2Features.ExtendedDynamicState2LogicOp) { colorBlendState.LogicOp = LogicOp; } + if (!gd.ExtendedDynamicState3Features.ExtendedDynamicState3LogicOpEnable) + { + colorBlendState.LogicOpEnable = LogicOpEnable; + } + PipelineColorBlendAdvancedStateCreateInfoEXT colorBlendAdvancedState; if (!AdvancedBlendSrcPreMultiplied || @@ -733,6 +752,7 @@ namespace Ryujinx.Graphics.Vulkan PDynamicStates = dynamicStates, }; + var pipelineCreateInfo = new GraphicsPipelineCreateInfo { SType = StructureType.GraphicsPipelineCreateInfo,