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/CircularSpanPool.cs | 89 ----------------------
.../Multithreading/Model/ResultBox.cs | 7 --
.../Multithreading/Model/SpanRef.cs | 39 ----------
.../Multithreading/Model/TableRef.cs | 22 ------
4 files changed, 157 deletions(-)
delete mode 100644 Ryujinx.Graphics.GAL/Multithreading/Model/CircularSpanPool.cs
delete mode 100644 Ryujinx.Graphics.GAL/Multithreading/Model/ResultBox.cs
delete mode 100644 Ryujinx.Graphics.GAL/Multithreading/Model/SpanRef.cs
delete mode 100644 Ryujinx.Graphics.GAL/Multithreading/Model/TableRef.cs
(limited to 'Ryujinx.Graphics.GAL/Multithreading/Model')
diff --git a/Ryujinx.Graphics.GAL/Multithreading/Model/CircularSpanPool.cs b/Ryujinx.Graphics.GAL/Multithreading/Model/CircularSpanPool.cs
deleted file mode 100644
index 4ea1a2c7..00000000
--- a/Ryujinx.Graphics.GAL/Multithreading/Model/CircularSpanPool.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using System;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Threading;
-
-namespace Ryujinx.Graphics.GAL.Multithreading.Model
-{
- ///
- /// A memory pool for passing through Span resources with one producer and consumer.
- /// Data is copied on creation to part of the pool, then that region is reserved until it is disposed by the consumer.
- /// Similar to the command queue, this pool assumes that data is created and disposed in the same order.
- ///
- class CircularSpanPool
- {
- private ThreadedRenderer _renderer;
- private byte[] _pool;
- private int _size;
-
- private int _producerPtr;
- private int _producerSkipPosition = -1;
- private int _consumerPtr;
-
- public CircularSpanPool(ThreadedRenderer renderer, int size)
- {
- _renderer = renderer;
- _size = size;
- _pool = new byte[size];
- }
-
- public SpanRef Insert(ReadOnlySpan data) where T : unmanaged
- {
- int size = data.Length * Unsafe.SizeOf();
-
- // Wrapping aware circular queue.
- // If there's no space at the end of the pool for this span, we can't fragment it.
- // So just loop back around to the start. Remember the last skipped position.
-
- bool wraparound = _producerPtr + size >= _size;
- int index = wraparound ? 0 : _producerPtr;
-
- // _consumerPtr is from another thread, and we're taking it without a lock, so treat this as a snapshot in the past.
- // We know that it will always be before or equal to the producer pointer, and it cannot pass it.
- // This is enough to reason about if there is space in the queue for the data, even if we're checking against an outdated value.
-
- int consumer = _consumerPtr;
- bool beforeConsumer = _producerPtr < consumer;
-
- if (size > _size - 1 || (wraparound && beforeConsumer) || ((index < consumer || wraparound) && index + size >= consumer))
- {
- // Just get an array in the following situations:
- // - The data is too large to fit in the pool.
- // - A wraparound would happen but the consumer would be covered by it.
- // - The producer would catch up to the consumer as a result.
-
- return new SpanRef(_renderer, data.ToArray());
- }
-
- data.CopyTo(MemoryMarshal.Cast(new Span(_pool).Slice(index, size)));
-
- if (wraparound)
- {
- _producerSkipPosition = _producerPtr;
- }
-
- _producerPtr = index + size;
-
- return new SpanRef(data.Length);
- }
-
- public Span Get(int length) where T : unmanaged
- {
- int size = length * Unsafe.SizeOf();
-
- if (_consumerPtr == Interlocked.CompareExchange(ref _producerSkipPosition, -1, _consumerPtr))
- {
- _consumerPtr = 0;
- }
-
- return MemoryMarshal.Cast(new Span(_pool).Slice(_consumerPtr, size));
- }
-
- public void Dispose(int length) where T : unmanaged
- {
- int size = length * Unsafe.SizeOf();
-
- _consumerPtr = _consumerPtr + size;
- }
- }
-}
diff --git a/Ryujinx.Graphics.GAL/Multithreading/Model/ResultBox.cs b/Ryujinx.Graphics.GAL/Multithreading/Model/ResultBox.cs
deleted file mode 100644
index 7a0be785..00000000
--- a/Ryujinx.Graphics.GAL/Multithreading/Model/ResultBox.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Ryujinx.Graphics.GAL.Multithreading.Model
-{
- public class ResultBox
- {
- public T Result;
- }
-}
diff --git a/Ryujinx.Graphics.GAL/Multithreading/Model/SpanRef.cs b/Ryujinx.Graphics.GAL/Multithreading/Model/SpanRef.cs
deleted file mode 100644
index 7dbebc76..00000000
--- a/Ryujinx.Graphics.GAL/Multithreading/Model/SpanRef.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-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);
- }
- }
- }
-}
diff --git a/Ryujinx.Graphics.GAL/Multithreading/Model/TableRef.cs b/Ryujinx.Graphics.GAL/Multithreading/Model/TableRef.cs
deleted file mode 100644
index 166aa71a..00000000
--- a/Ryujinx.Graphics.GAL/Multithreading/Model/TableRef.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace Ryujinx.Graphics.GAL.Multithreading.Model
-{
- struct TableRef
- {
- private int _index;
-
- public TableRef(ThreadedRenderer renderer, T reference)
- {
- _index = renderer.AddTableRef(reference);
- }
-
- public T Get(ThreadedRenderer renderer)
- {
- return (T)renderer.RemoveTableRef(_index);
- }
-
- public T2 GetAs(ThreadedRenderer renderer) where T2 : T
- {
- return (T2)renderer.RemoveTableRef(_index);
- }
- }
-}
--
cgit v1.2.3