From c474682c19c6c6278d80dce0915f0ee05ee293fd Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 20 Apr 2020 18:19:03 +0200 Subject: [PATCH] Fixed concurrent GPU dispatche glitches --- src/ComputeSharp.Graphics/GraphicsDevice.cs | 22 +++++---------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/ComputeSharp.Graphics/GraphicsDevice.cs b/src/ComputeSharp.Graphics/GraphicsDevice.cs index a4177ccc..9a5165b6 100644 --- a/src/ComputeSharp.Graphics/GraphicsDevice.cs +++ b/src/ComputeSharp.Graphics/GraphicsDevice.cs @@ -18,11 +18,6 @@ namespace ComputeSharp.Graphics /// public const Direct3DFeatureLevel FeatureLevel = Direct3DFeatureLevel.Level_12_1; - /// - /// The instance used to wait for completion when executing commands - /// - private readonly AutoResetEvent AutoResetEvent = new AutoResetEvent(false); - /// /// The instance to use for compute operations /// @@ -126,11 +121,6 @@ namespace ComputeSharp.Graphics /// internal ID3D12Fence NativeDirectFence { get; } - /// - /// The used to lock command list executions - /// - private readonly object Lock = new object(); - /// /// Gets the next fence value for compute operations /// @@ -174,11 +164,11 @@ namespace ComputeSharp.Graphics if (fenceValue <= fence.CompletedValue) return; - lock (Lock) - { - fence.SetEventOnCompletion(fenceValue, AutoResetEvent.SafeWaitHandle.DangerousGetHandle()); - AutoResetEvent.WaitOne(); - } + using ManualResetEvent fenceEvent = new ManualResetEvent(false); + + fence.SetEventOnCompletion(fenceValue, fenceEvent); + + fenceEvent.WaitOne(); } /// @@ -244,8 +234,6 @@ namespace ComputeSharp.Graphics NativeDirectFence.Dispose(); NativeDevice.Dispose(); - - AutoResetEvent.Dispose(); } } }