This commit is contained in:
sunshineinabox 2024-05-22 22:05:01 -07:00
parent 74a1ab031d
commit 0000a7ac9c
2 changed files with 40 additions and 16 deletions

View file

@ -1024,14 +1024,18 @@ namespace Ryujinx.Graphics.Vulkan
_newState.LogicOp = op.Convert(); _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) if (Gd.ExtendedDynamicState3Features.ExtendedDynamicState3LogicOpEnable)
{ {
DynamicState.SetLogicOpEnable(enable); DynamicState.SetLogicOpEnable(logicOpEnable);
} }
else else
{ {
_newState.LogicOpEnable = enable; _newState.LogicOpEnable = logicOpEnable;
} }
SignalStateChange(); SignalStateChange();

View file

@ -407,6 +407,7 @@ namespace Ryujinx.Graphics.Vulkan
bool supportsExtDynamicState = gd.Capabilities.SupportsExtendedDynamicState; bool supportsExtDynamicState = gd.Capabilities.SupportsExtendedDynamicState;
bool supportsExtDynamicState2 = gd.Capabilities.SupportsExtendedDynamicState2; bool supportsExtDynamicState2 = gd.Capabilities.SupportsExtendedDynamicState2;
bool supportsExtDynamicState3 = gd.Capabilities.SupportsExtendedDynamicState3;
fixed (VertexInputAttributeDescription* pVertexAttributeDescriptions = &Internal.VertexAttributeDescriptions[0]) fixed (VertexInputAttributeDescription* pVertexAttributeDescriptions = &Internal.VertexAttributeDescriptions[0])
@ -445,16 +446,24 @@ namespace Ryujinx.Graphics.Vulkan
var tessellationState = new PipelineTessellationStateCreateInfo var tessellationState = new PipelineTessellationStateCreateInfo
{ {
SType = StructureType.PipelineTessellationStateCreateInfo, SType = StructureType.PipelineTessellationStateCreateInfo,
PatchControlPoints = PatchControlPoints,
}; };
if (!gd.ExtendedDynamicState2Features.ExtendedDynamicState2PatchControlPoints)
{
tessellationState.PatchControlPoints = PatchControlPoints;
}
var rasterizationState = new PipelineRasterizationStateCreateInfo var rasterizationState = new PipelineRasterizationStateCreateInfo
{ {
SType = StructureType.PipelineRasterizationStateCreateInfo, SType = StructureType.PipelineRasterizationStateCreateInfo,
DepthClampEnable = DepthClampEnable,
PolygonMode = PolygonMode, PolygonMode = PolygonMode,
}; };
if (!gd.ExtendedDynamicState3Features.ExtendedDynamicState3DepthClampEnable)
{
rasterizationState.DepthClampEnable = DepthClampEnable;
}
if (isMoltenVk) if (isMoltenVk)
{ {
//When widelines feature is not supported it must be 1.0f per spec. //When widelines feature is not supported it must be 1.0f per spec.
@ -490,10 +499,18 @@ namespace Ryujinx.Graphics.Vulkan
SampleShadingEnable = false, SampleShadingEnable = false,
RasterizationSamples = TextureStorage.ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, SamplesCount), RasterizationSamples = TextureStorage.ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, SamplesCount),
MinSampleShading = 1, MinSampleShading = 1,
AlphaToCoverageEnable = AlphaToCoverageEnable,
AlphaToOneEnable = AlphaToOneEnable,
}; };
if (!gd.ExtendedDynamicState3Features.ExtendedDynamicState3AlphaToCoverageEnable)
{
multisampleState.AlphaToCoverageEnable = AlphaToCoverageEnable;
}
if (!gd.ExtendedDynamicState3Features.ExtendedDynamicState3AlphaToOneEnable)
{
multisampleState.AlphaToOneEnable = AlphaToOneEnable;
}
var depthStencilState = new PipelineDepthStencilStateCreateInfo var depthStencilState = new PipelineDepthStencilStateCreateInfo
{ {
SType = StructureType.PipelineDepthStencilStateCreateInfo, SType = StructureType.PipelineDepthStencilStateCreateInfo,
@ -516,19 +533,13 @@ namespace Ryujinx.Graphics.Vulkan
StencilFrontFailOp, StencilFrontFailOp,
StencilFrontPassOp, StencilFrontPassOp,
StencilFrontDepthFailOp, StencilFrontDepthFailOp,
StencilFrontCompareOp, StencilFrontCompareOp);
null,
null,
null);
var stencilBack = new StencilOpState( var stencilBack = new StencilOpState(
StencilBackFailOp, StencilBackFailOp,
StencilBackPassOp, StencilBackPassOp,
StencilBackDepthFailOp, StencilBackDepthFailOp,
StencilBackCompareOp, StencilBackCompareOp);
null,
null,
null);
depthStencilState.Front = stencilFront; depthStencilState.Front = stencilFront;
depthStencilState.Back = stencilBack; 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 var colorBlendState = new PipelineColorBlendStateCreateInfo
{ {
SType = StructureType.PipelineColorBlendStateCreateInfo, SType = StructureType.PipelineColorBlendStateCreateInfo,
LogicOpEnable = LogicOpEnable,
AttachmentCount = ColorBlendAttachmentStateCount, AttachmentCount = ColorBlendAttachmentStateCount,
PAttachments = pColorBlendAttachmentState, PAttachments = pColorBlendAttachmentState,
}; };
if (!(supportsExtDynamicState2 && gd.ExtendedLogicOp)) if (!gd.ExtendedDynamicState2Features.ExtendedDynamicState2LogicOp)
{ {
colorBlendState.LogicOp = LogicOp; colorBlendState.LogicOp = LogicOp;
} }
if (!gd.ExtendedDynamicState3Features.ExtendedDynamicState3LogicOpEnable)
{
colorBlendState.LogicOpEnable = LogicOpEnable;
}
PipelineColorBlendAdvancedStateCreateInfoEXT colorBlendAdvancedState; PipelineColorBlendAdvancedStateCreateInfoEXT colorBlendAdvancedState;
if (!AdvancedBlendSrcPreMultiplied || if (!AdvancedBlendSrcPreMultiplied ||
@ -733,6 +752,7 @@ namespace Ryujinx.Graphics.Vulkan
PDynamicStates = dynamicStates, PDynamicStates = dynamicStates,
}; };
var pipelineCreateInfo = new GraphicsPipelineCreateInfo var pipelineCreateInfo = new GraphicsPipelineCreateInfo
{ {
SType = StructureType.GraphicsPipelineCreateInfo, SType = StructureType.GraphicsPipelineCreateInfo,