From d1ab9fb42c2fd9f018d4410ca619cd66294eafc9 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Thu, 26 Dec 2019 23:09:49 -0700 Subject: 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 --- Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs (limited to 'Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs') 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 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; + } + } +} -- cgit v1.2.3