From cee712105850ac3385cd0091a923438167433f9f Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Sat, 8 Apr 2023 01:22:00 +0200 Subject: Move solution and projects to src --- .../Multithreading/Model/SpanRef.cs | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/Ryujinx.Graphics.GAL/Multithreading/Model/SpanRef.cs (limited to 'src/Ryujinx.Graphics.GAL/Multithreading/Model/SpanRef.cs') diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Model/SpanRef.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Model/SpanRef.cs new file mode 100644 index 00000000..7dbebc76 --- /dev/null +++ b/src/Ryujinx.Graphics.GAL/Multithreading/Model/SpanRef.cs @@ -0,0 +1,39 @@ +using System; + +namespace Ryujinx.Graphics.GAL.Multithreading.Model +{ + struct SpanRef where T : unmanaged + { + private int _packedLengthId; + + public SpanRef(ThreadedRenderer renderer, T[] data) + { + _packedLengthId = -(renderer.AddTableRef(data) + 1); + } + + public SpanRef(int length) + { + _packedLengthId = length; + } + + public Span Get(ThreadedRenderer renderer) + { + if (_packedLengthId >= 0) + { + return renderer.SpanPool.Get(_packedLengthId); + } + else + { + return new Span((T[])renderer.RemoveTableRef(-(_packedLengthId + 1))); + } + } + + public void Dispose(ThreadedRenderer renderer) + { + if (_packedLengthId > 0) + { + renderer.SpanPool.Dispose(_packedLengthId); + } + } + } +} -- cgit v1.2.3