aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs
diff options
context:
space:
mode:
authorAlex Barney <thealexbarney@gmail.com>2019-12-26 23:09:49 -0700
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commitd1ab9fb42c2fd9f018d4410ca619cd66294eafc9 (patch)
treedcac71560b921f29d73ee6e21f235528184d9f84 /Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs
parent947e14d3be0f7c5e4b6f77df204ec675b8e9e719 (diff)
ASTC optimizations (#845)
* ASTC optimizations * Move code to Ryujinx.Common * Support 3D textures * Address feedback * Remove ASTC logging * Use stackalloc instead of a Buffer20 struct * Code style and cleanup * Respond to feedback * Rearrange public/private property ordering
Diffstat (limited to 'Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs')
-rw-r--r--Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs b/Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs
new file mode 100644
index 00000000..367b6809
--- /dev/null
+++ b/Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace Ryujinx.Graphics.Texture.Astc
+{
+ [StructLayout(LayoutKind.Sequential, Size = IntegerEncoded.StructSize * Capacity + sizeof(int))]
+ internal struct IntegerSequence
+ {
+ private const int Capacity = 100;
+
+ private int _length;
+ private IntegerEncoded _start;
+
+ public Span<IntegerEncoded> List => MemoryMarshal.CreateSpan(ref _start, _length);
+
+ public void Reset() => _length = 0;
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void Add(ref IntegerEncoded item)
+ {
+ Debug.Assert(_length < Capacity);
+
+ int oldLength = _length;
+ _length++;
+
+ List[oldLength] = item;
+ }
+ }
+}