diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2023-05-28 19:38:04 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-29 00:38:04 +0200 |
| commit | 832a5e885281f6063f7855e92c3cf85eac82e715 (patch) | |
| tree | 027efa0005b63097f7824cb7c91c3c7278f69372 /src/Ryujinx.Graphics.Vulkan/PipelineState.cs | |
| parent | 96d1f0da2d10545600d83a88e63cfef9b2785e25 (diff) | |
Make sure blend is disabled if render target has integer format (#5122)
* Make sure blend is disabled if render target has integer format
* Change approach to avoid permanently mutating state
Diffstat (limited to 'src/Ryujinx.Graphics.Vulkan/PipelineState.cs')
| -rw-r--r-- | src/Ryujinx.Graphics.Vulkan/PipelineState.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs index 1a396b5c..7e803913 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -1,6 +1,7 @@ using Ryujinx.Common.Memory; using Silk.NET.Vulkan; using System; +using System.Numerics; namespace Ryujinx.Graphics.Vulkan { @@ -542,6 +543,27 @@ namespace Ryujinx.Graphics.Vulkan MaxDepthBounds = MaxDepthBounds }; + uint blendEnables = 0; + + if (gd.IsMoltenVk && Internal.AttachmentIntegerFormatMask != 0) + { + // Blend can't be enabled for integer formats, so let's make sure it is disabled. + uint attachmentIntegerFormatMask = Internal.AttachmentIntegerFormatMask; + + while (attachmentIntegerFormatMask != 0) + { + int i = BitOperations.TrailingZeroCount(attachmentIntegerFormatMask); + + if (Internal.ColorBlendAttachmentState[i].BlendEnable) + { + blendEnables |= 1u << i; + } + + Internal.ColorBlendAttachmentState[i].BlendEnable = false; + attachmentIntegerFormatMask &= ~(1u << i); + } + } + var colorBlendState = new PipelineColorBlendStateCreateInfo() { SType = StructureType.PipelineColorBlendStateCreateInfo, @@ -619,6 +641,15 @@ namespace Ryujinx.Graphics.Vulkan }; gd.Api.CreateGraphicsPipelines(device, cache, 1, &pipelineCreateInfo, null, &pipelineHandle).ThrowOnError(); + + // Restore previous blend enable values if we changed it. + while (blendEnables != 0) + { + int i = BitOperations.TrailingZeroCount(blendEnables); + + Internal.ColorBlendAttachmentState[i].BlendEnable = true; + blendEnables &= ~(1u << i); + } } pipeline = new Auto<DisposablePipeline>(new DisposablePipeline(gd.Api, device, pipelineHandle)); |
