diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 5433f3402..2ec66ef31 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 f8b71ed15..70fe8bb62 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,