From 28ba55598df384c4b1e6892c49e95376d2b582fb Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 26 Oct 2022 14:53:11 -0300 Subject: [PATCH] Vulkan: Fix indirect buffer barrier (#3798) --- Ryujinx.Graphics.Vulkan/BufferHolder.cs | 5 ++--- Ryujinx.Graphics.Vulkan/PipelineBase.cs | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Ryujinx.Graphics.Vulkan/BufferHolder.cs b/Ryujinx.Graphics.Vulkan/BufferHolder.cs index fb1332662e..4660765a46 100644 --- a/Ryujinx.Graphics.Vulkan/BufferHolder.cs +++ b/Ryujinx.Graphics.Vulkan/BufferHolder.cs @@ -12,13 +12,12 @@ namespace Ryujinx.Graphics.Vulkan private const int MaxUpdateBufferSize = 0x10000; public const AccessFlags DefaultAccessFlags = + AccessFlags.AccessIndirectCommandReadBit | AccessFlags.AccessShaderReadBit | AccessFlags.AccessShaderWriteBit | AccessFlags.AccessTransferReadBit | AccessFlags.AccessTransferWriteBit | - AccessFlags.AccessUniformReadBit | - AccessFlags.AccessShaderReadBit | - AccessFlags.AccessShaderWriteBit; + AccessFlags.AccessUniformReadBit; private readonly VulkanRenderer _gd; private readonly Device _device; diff --git a/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 7c6234b179..2a376261ee 100644 --- a/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -228,10 +228,26 @@ namespace Ryujinx.Graphics.Vulkan Gd.Api.CmdClearAttachments(CommandBuffer, 1, &attachment, 1, &clearRect); } - public void CommandBufferBarrier() + public unsafe void CommandBufferBarrier() { - // TODO: More specific barrier? - Barrier(); + MemoryBarrier memoryBarrier = new MemoryBarrier() + { + SType = StructureType.MemoryBarrier, + SrcAccessMask = BufferHolder.DefaultAccessFlags, + DstAccessMask = AccessFlags.AccessIndirectCommandReadBit + }; + + Gd.Api.CmdPipelineBarrier( + CommandBuffer, + PipelineStageFlags.PipelineStageAllCommandsBit, + PipelineStageFlags.PipelineStageDrawIndirectBit, + 0, + 1, + memoryBarrier, + 0, + null, + 0, + null); } public void CopyBuffer(BufferHandle source, BufferHandle destination, int srcOffset, int dstOffset, int size) @@ -824,7 +840,7 @@ namespace Ryujinx.Graphics.Vulkan if (range.Handle != BufferHandle.Null) { - _transformFeedbackBuffers[i] = + _transformFeedbackBuffers[i] = new BufferState(Gd.BufferManager.GetBuffer(CommandBuffer, range.Handle, range.Offset, range.Size, true), range.Offset, range.Size); _transformFeedbackBuffers[i].BindTransformFeedbackBuffer(Gd, Cbs, (uint)i); }