diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 406372dc8..5d00a30ca 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -674,9 +674,9 @@ namespace Ryujinx.Graphics.Vulkan if (_supportExtDynamic) { - if (oldTopology.ConvertToClass() != _newState.Topology.ConvertToClass()) + if (oldTopology != _newState.Topology.ConvertToClass()) { - _newState.Topology = oldTopology.ConvertToClass(); + _newState.Topology = oldTopology; } DynamicState.SetCullMode(oldCullMode); @@ -971,7 +971,7 @@ namespace Ryujinx.Graphics.Vulkan // so we need to force disable them here. bool logicOpEnable = enable && (Gd.Vendor == Vendor.Nvidia || _newState.Internal.LogicOpsAllowed); - _newState.LogicOpEnable = logicOpEnable; + _newState.LogicOpEnable = enable; if (Gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2LogicOp) { @@ -979,7 +979,6 @@ namespace Ryujinx.Graphics.Vulkan { DynamicState.SetLogicOp(op.Convert()); } - } else { @@ -1041,8 +1040,6 @@ namespace Ryujinx.Graphics.Vulkan public void SetPrimitiveTopology(PrimitiveTopology topology) { - topology = _newState.HasTessellationControlShader ? PrimitiveTopology.Patches : topology; - _topology = topology; var vkTopology = Gd.TopologyRemap(topology).Convert(); @@ -1402,7 +1399,7 @@ namespace Ryujinx.Graphics.Vulkan _newState.Internal.VertexBindingDescriptions[descriptorIndex] = new VertexInputBindingDescription( (uint)binding, - _supportExtDynamic && !Gd.IsMoltenVk ? 0 : (uint)vertexBuffer.Stride, + _supportExtDynamic && !Gd.IsMoltenVk ? default : (uint)vertexBuffer.Stride, inputRate); int vbSize = vertexBuffer.Buffer.Size; diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs index 27f1c047b..4c1c1dad2 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs @@ -229,6 +229,8 @@ namespace Ryujinx.Graphics.Vulkan pipeline.Topology = topology; + pipeline.LogicOpEnable = state.LogicOpEnable; + int vaCount = Math.Min(Constants.MaxVertexAttributes, state.VertexAttribCount); int vbCount = Math.Min(Constants.MaxVertexBuffers, state.VertexBufferCount); @@ -272,7 +274,7 @@ namespace Ryujinx.Graphics.Vulkan // TODO: Support divisor > 1 pipeline.Internal.VertexBindingDescriptions[descriptorIndex++] = new VertexInputBindingDescription( (uint)i + 1, - extendedDynamicState && !gd.IsMoltenVk ? 0 : (uint)alignedStride, + extendedDynamicState && !gd.IsMoltenVk ? default : (uint)alignedStride, inputRate); } } @@ -336,9 +338,7 @@ namespace Ryujinx.Graphics.Vulkan pipeline.Internal.LogicOpsAllowed = attachmentCount == 0 || !allFormatsFloatOrSrgb; bool logicOpEnable = state.LogicOpEnable && - (gd.Vendor == Vendor.Nvidia || (attachmentCount == 0 || !allFormatsFloatOrSrgb)); - - pipeline.LogicOpEnable = logicOpEnable; + (gd.Vendor == Vendor.Nvidia || pipeline.Internal.LogicOpsAllowed); if (!extendedDynamicState2.ExtendedDynamicState2LogicOp) { diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs index 66dfc1b3e..8a3fa7f82 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineDynamicState.cs @@ -276,8 +276,6 @@ namespace Ryujinx.Graphics.Vulkan public void ReplayIfDirty(VulkanRenderer gd, CommandBuffer commandBuffer) { - _ = gd.Api; - if (_dirty.HasFlag(DirtyFlags.Blend)) { RecordBlend(gd.Api, commandBuffer); diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs index 8739aaec5..a3b60e74c 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -420,10 +420,12 @@ namespace Ryujinx.Graphics.Vulkan PVertexBindingDescriptions = pVertexBindingDescriptions, }; + var topology = HasTessellationControlShader ? PrimitiveTopology.PatchList : Topology; + var inputAssemblyState = new PipelineInputAssemblyStateCreateInfo { SType = StructureType.PipelineInputAssemblyStateCreateInfo, - Topology = Topology, + Topology = topology, }; PipelineTessellationStateCreateInfo tessellationState; @@ -554,12 +556,16 @@ namespace Ryujinx.Graphics.Vulkan } } + // Vendors other than NVIDIA have 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.Nvidia || Internal.LogicOpsAllowed); + var colorBlendState = new PipelineColorBlendStateCreateInfo { SType = StructureType.PipelineColorBlendStateCreateInfo, AttachmentCount = ColorBlendAttachmentStateCount, PAttachments = pColorBlendAttachmentState, - LogicOpEnable = LogicOpEnable, + LogicOpEnable = logicOpEnable, }; if (!gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2LogicOp)