diff --git a/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 08d7b0aa5b0d..6bcbd67172a0 100644 --- a/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -45,6 +45,7 @@ class PipelineBase : IDisposable protected FramebufferParams FramebufferParams; private Auto _framebuffer; private Auto _renderPass; + private int _writtenAttachmentCount; private bool _renderPassActive; private readonly DescriptorSetUpdater _descriptorSetUpdater; @@ -605,10 +606,9 @@ public void SetProgram(IProgram program) stages.CopyTo(_newState.Stages.ToSpan().Slice(0, stages.Length)); SignalStateChange(); - SignalProgramChange(); } - protected virtual void SignalProgramChange() + protected virtual void SignalAttachmentChange() { } @@ -621,15 +621,27 @@ public void SetRasterizerDiscard(bool discard) public void SetRenderTargetColorMasks(ReadOnlySpan componentMask) { int count = Math.Min(Constants.MaxRenderTargets, componentMask.Length); + int writtenAttachments = 0; for (int i = 0; i < count; i++) { ref var vkBlend = ref _newState.Internal.ColorBlendAttachmentState[i]; vkBlend.ColorWriteMask = (ColorComponentFlags)componentMask[i]; + + if (componentMask[i] != 0) + { + writtenAttachments++; + } } SignalStateChange(); + + if (writtenAttachments != _writtenAttachmentCount) + { + SignalAttachmentChange(); + _writtenAttachmentCount = writtenAttachments; + } } public void SetRenderTargets(ITexture[] colors, ITexture depthStencil) @@ -638,6 +650,7 @@ public void SetRenderTargets(ITexture[] colors, ITexture depthStencil) CreateFramebuffer(colors, depthStencil); CreateRenderPass(); SignalStateChange(); + SignalAttachmentChange(); } public void SetRenderTargetScale(float scale) diff --git a/Ryujinx.Graphics.Vulkan/PipelineFull.cs b/Ryujinx.Graphics.Vulkan/PipelineFull.cs index 4dac49dd7a3e..f674e436bad3 100644 --- a/Ryujinx.Graphics.Vulkan/PipelineFull.cs +++ b/Ryujinx.Graphics.Vulkan/PipelineFull.cs @@ -384,7 +384,7 @@ public void CopyQueryResults(BufferedQuery query) _hasPendingQuery = true; } - protected override void SignalProgramChange() + protected override void SignalAttachmentChange() { FlushPendingQuery(); }