aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedCounterEvent.cs
diff options
context:
space:
mode:
authorTSR Berry <20988865+TSRBerry@users.noreply.github.com>2023-04-08 01:22:00 +0200
committerMary <thog@protonmail.com>2023-04-27 23:51:14 +0200
commitcee712105850ac3385cd0091a923438167433f9f (patch)
tree4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedCounterEvent.cs
parentcd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff)
Move solution and projects to src
Diffstat (limited to 'Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedCounterEvent.cs')
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedCounterEvent.cs80
1 files changed, 0 insertions, 80 deletions
diff --git a/Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedCounterEvent.cs b/Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedCounterEvent.cs
deleted file mode 100644
index 4b7471d6..00000000
--- a/Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedCounterEvent.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using Ryujinx.Graphics.GAL.Multithreading.Commands.CounterEvent;
-using Ryujinx.Graphics.GAL.Multithreading.Model;
-using System.Threading;
-
-namespace Ryujinx.Graphics.GAL.Multithreading.Resources
-{
- class ThreadedCounterEvent : ICounterEvent
- {
- private ThreadedRenderer _renderer;
- public ICounterEvent Base;
-
- public bool Invalid { get; set; }
-
- public CounterType Type { get; }
- public bool ClearCounter { get; }
-
- private bool _reserved;
- private int _createLock;
-
- public ThreadedCounterEvent(ThreadedRenderer renderer, CounterType type, bool clearCounter)
- {
- _renderer = renderer;
- Type = type;
- ClearCounter = clearCounter;
- }
-
- private TableRef<T> Ref<T>(T reference)
- {
- return new TableRef<T>(_renderer, reference);
- }
-
- public void Dispose()
- {
- _renderer.New<CounterEventDisposeCommand>().Set(Ref(this));
- _renderer.QueueCommand();
- }
-
- public void Flush()
- {
- ThreadedHelpers.SpinUntilNonNull(ref Base);
-
- Base.Flush();
- }
-
- public bool ReserveForHostAccess()
- {
- if (Base != null)
- {
- return Base.ReserveForHostAccess();
- }
- else
- {
- bool result = true;
-
- // A very light lock, as this case is uncommon.
- ThreadedHelpers.SpinUntilExchange(ref _createLock, 1, 0);
-
- if (Base != null)
- {
- result = Base.ReserveForHostAccess();
- }
- else
- {
- _reserved = true;
- }
-
- Volatile.Write(ref _createLock, 0);
-
- return result;
- }
- }
-
- public void Create(IRenderer renderer, CounterType type, System.EventHandler<ulong> eventHandler, bool hostReserved)
- {
- ThreadedHelpers.SpinUntilExchange(ref _createLock, 1, 0);
- Base = renderer.ReportCounter(type, eventHandler, hostReserved || _reserved);
- Volatile.Write(ref _createLock, 0);
- }
- }
-}