From 96d1f0da2d10545600d83a88e63cfef9b2785e25 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sun, 28 May 2023 19:24:35 -0300 Subject: [PATCH] Workaround for MoltenVK barrier issues (#5118) --- src/Ryujinx.Graphics.Vulkan/PipelineBase.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index c254d378..688682f4 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -80,6 +80,7 @@ namespace Ryujinx.Graphics.Vulkan private PipelineColorBlendAttachmentState[] _storedBlend; + private ulong _drawCountSinceBarrier; public ulong DrawCount { get; private set; } public bool RenderPassActive { get; private set; } @@ -133,6 +134,18 @@ namespace Ryujinx.Graphics.Vulkan public unsafe void Barrier() { + if (_drawCountSinceBarrier != DrawCount) + { + _drawCountSinceBarrier = DrawCount; + + // Barriers apparently have no effect inside a render pass on MoltenVK. + // As a workaround, end the render pass. + if (Gd.IsMoltenVk) + { + EndRenderPass(); + } + } + MemoryBarrier memoryBarrier = new MemoryBarrier() { SType = StructureType.MemoryBarrier,