diff options
author | riperiperi <rhy3756547@hotmail.com> | 2023-05-08 11:45:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-08 12:45:12 +0200 |
commit | 1b28ecd63eb49917e3711eb7e06739ebe87e8f41 (patch) | |
tree | 4259bbedb1fc4d2ae9f4e0dbac30d42c41d6ddc9 /src/Ryujinx.Graphics.Vulkan/FenceHolder.cs | |
parent | 895d9b53bc37507fed6829a7f91a1b8e3237ab0b (diff) |
Vulkan: Simplify MultiFenceHolder and managing them (#4845)1.1.770
* 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
Diffstat (limited to 'src/Ryujinx.Graphics.Vulkan/FenceHolder.cs')
-rw-r--r-- | src/Ryujinx.Graphics.Vulkan/FenceHolder.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Vulkan/FenceHolder.cs b/src/Ryujinx.Graphics.Vulkan/FenceHolder.cs index 1c1e6240..39d22698 100644 --- a/src/Ryujinx.Graphics.Vulkan/FenceHolder.cs +++ b/src/Ryujinx.Graphics.Vulkan/FenceHolder.cs @@ -32,6 +32,25 @@ namespace Ryujinx.Graphics.Vulkan return _fence; } + public bool TryGet(out Fence fence) + { + int lastValue; + do + { + lastValue = _referenceCount; + + if (lastValue == 0) + { + fence = default; + return false; + } + } + while (Interlocked.CompareExchange(ref _referenceCount, lastValue + 1, lastValue) != lastValue); + + fence = _fence; + return true; + } + public Fence Get() { Interlocked.Increment(ref _referenceCount); |