From 1b28ecd63eb49917e3711eb7e06739ebe87e8f41 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Mon, 8 May 2023 11:45:12 +0100 Subject: Vulkan: Simplify MultiFenceHolder and managing them (#4845) * Vulkan: Simplify waitable add/remove Removal of unnecessary hashset and dictionary * Thread safety for GetBufferData in PersistentFlushBuffer * Fix WaitForFencesImpl thread safety * Proper methods for risky reference increments * Wrong type of CB. * Address feedback --- src/Ryujinx.Graphics.Vulkan/Auto.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/Ryujinx.Graphics.Vulkan/Auto.cs') diff --git a/src/Ryujinx.Graphics.Vulkan/Auto.cs b/src/Ryujinx.Graphics.Vulkan/Auto.cs index 77261de9..fdce7232 100644 --- a/src/Ryujinx.Graphics.Vulkan/Auto.cs +++ b/src/Ryujinx.Graphics.Vulkan/Auto.cs @@ -105,6 +105,23 @@ namespace Ryujinx.Graphics.Vulkan } } + public bool TryIncrementReferenceCount() + { + int lastValue; + do + { + lastValue = _referenceCount; + + if (lastValue == 0) + { + return false; + } + } + while (Interlocked.CompareExchange(ref _referenceCount, lastValue + 1, lastValue) != lastValue); + + return true; + } + public void IncrementReferenceCount() { if (Interlocked.Increment(ref _referenceCount) == 1) -- cgit v1.2.3