daily update on 20240305 by nitload youmu

This commit is contained in:
YoumuLiu
2024-03-05 10:17:02 +08:00
parent 1f2fca4c8f
commit 6a0cccae79
156 changed files with 23040 additions and 1385 deletions
+5 -11
View File
@@ -1,4 +1,5 @@
using StgSharp.Graphics;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -10,8 +11,6 @@ using System.Threading.Tasks;
namespace StgSharp.Logic
{
[StructLayout(LayoutKind.Explicit, Size = 8)]
internal struct LogSeperator
{
@@ -31,8 +30,6 @@ namespace StgSharp.Logic
}
}
/// <summary>
/// A linear data structure with dynamic length.
/// It contains a <see cref="List{T}"/> of <see cref="Array"/>,
@@ -44,13 +41,16 @@ namespace StgSharp.Logic
private List<T[]> arrayIndexList;
private LogSeperator indexpair;
private int lastMain = 0;
// main index to the last used element
private int lastSub = 0;
private int length;
private int subLength = 1;
// sub index to the last used element
private Queue<int> unusedMainIndex;
private Queue<int> unusedSubIndex;
public DynamicArrayList()
@@ -105,7 +105,6 @@ namespace StgSharp.Logic
/// <param name="instace"></param>
public DynamicArrayList(int count, T instace)
{
arrayIndexList = new List<T[]>();
length = count;
unusedMainIndex = new();
@@ -162,7 +161,6 @@ namespace StgSharp.Logic
}
arrayIndexList[indexpair.high_s][indexpair.low_s] = value;
}
}
public void CopyTo(DynamicArrayList<T> target)
@@ -230,7 +228,6 @@ namespace StgSharp.Logic
public int Count => length;
/// <summary>
/// Length of this <see cref="DynamicArrayList{T}"/>
/// </summary>
@@ -256,7 +253,6 @@ namespace StgSharp.Logic
length++;
subLength = 1;
return length - 1;
}
length++;
@@ -357,8 +353,6 @@ namespace StgSharp.Logic
return false;
}
[Obsolete("This method is not same, you may read data form an empty index.", false)]
public void RemoveAt(int index)
{
@@ -424,4 +418,4 @@ namespace StgSharp.Logic
indexpair.low >>= (int)(32 - mainindex);
}
}
}
}
+171 -92
View File
@@ -1,9 +1,11 @@
using StgSharp.Graphics;
using StgSharp.Math;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
@@ -11,14 +13,23 @@ using System.Threading.Tasks;
namespace StgSharp.Logic
{
internal unsafe class GLparamQueue
{
private string _dequeueLog = "\n";
internal GLcontext* context;
private ConcurrentQueue<M128> paramQueue;
private ConcurrentQueue<glArrayHandle> streamQueue;
public GLparamQueue()
{
paramQueue = new ConcurrentQueue<M128>();
streamQueue = new ConcurrentQueue<glArrayHandle>();
}
internal void ShowDequeueLog()
{
Console.WriteLine(_dequeueLog);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -30,6 +41,7 @@ namespace StgSharp.Logic
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(M128 m)
{
Console.WriteLine(m.ToString(10));
paramQueue.Enqueue(m);
}
@@ -37,134 +49,172 @@ namespace StgSharp.Logic
public void Enqueue(uint u0)
{
M128 m = default;
m.UInt32[0] = u0;
paramQueue.Enqueue(m);
m.Write<uint>(0, u0);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(uint u0, uint u1)
{
M128 m = default;
m.UInt32[0] = u0;
m.UInt32[1] = u1;
paramQueue.Enqueue(m);
m.Write<uint>(0, u0);
m.Write<uint>(1, u1);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(ulong u0, ulong u1)
{
M128 m = default;
m.Write<ulong>(0, u0);
m.Write<ulong>(1, u1);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(uint u0, uint u1, uint u2)
{
M128 m = default;
m.UInt32[0] = u0;
m.UInt32[1] = u1;
m.UInt32[2] = u2;
paramQueue.Enqueue(m);
m.Write<uint>(0, u0);
m.Write<uint>(1, u1);
m.Write<uint>(2, u2);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(float f0, float f1, float f2)
{
M128 m = default;
m.Single[0] = f0;
m.Single[1] = f1;
m.Single[2] = f2;
paramQueue.Enqueue(m);
m.Write<float>(0, f0);
m.Write<float>(1, f1);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(float f0, float f1, float f2, float f3)
{
M128 m = default;
m.Single[0] = f0;
m.Single[1] = f1;
m.Single[2] = f2;
m.Single[3] = f3;
paramQueue.Enqueue(m);
m.Write<float>(0, f0);
m.Write<float>(1, f1);
m.Write<float>(2, f2);
m.Write<float>(3, f3);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(IntPtr p0, IntPtr p1)
{
M128 m = default;
m.UInt64[0] = (ulong)p0;
m.UInt64[1] = (ulong)p1;
paramQueue.Enqueue(m);
m.Write<ulong>(0, (ulong)p0);
m.Write<ulong>(1, (ulong)p1);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(IntPtr p)
{
M128 m = default;
m.UInt64[0] = (ulong)p;
paramQueue.Enqueue(m);
m.Write<ulong>(0, (ulong)p);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(glHandle handle)
{
M128 m = default;
m.UInt64[0] = (ulong)handle.valuePtr;
paramQueue.Enqueue(m);
m.Write<ulong>(0, (ulong)handle.valuePtr);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(glHandle handle, glHandle handle1)
{
M128 m = default;
m.UInt64[0] = (ulong)handle.valuePtr;
m.UInt64[1] = (ulong)handle1.valuePtr;
paramQueue.Enqueue(m);
m.Write<ulong>(0, (ulong)handle.valuePtr);
m.Write<ulong>(1, (ulong)handle1.valuePtr);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(int i0)
{
M128 m = default;
m.Int32[0] = i0;
paramQueue.Enqueue(m);
m.Write<int>(0, i0);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(int i0, int i1)
{
M128 m = default;
m.Int32[0] = i0;
m.Int32[1] = i1;
paramQueue.Enqueue(m);
m.Write<int>(0, i0);
m.Write<int>(1, i1);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(int i0, int i1, int i2)
{
M128 m = default;
m.Int32[0] = i0;
m.Int32[1] = i1;
m.Int32[2] = i2;
paramQueue.Enqueue(m);
m.Write<int>(0, i0);
m.Write<int>(1, i1);
m.Write<int>(2, i2);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(int i0, int i1, int i2, int i3)
{
M128 m = default;
m.Int32[0] = i0;
m.Int32[1] = i1;
m.Int32[2] = i2;
m.Int32[3] = i3;
paramQueue.Enqueue(m);
m.Write<int>(0, i0);
m.Write<int>(1, i1);
m.Write<int>(2, i2);
m.Write<int>(3, i3);
this.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out M128 m)
public void Enqueue(string str)
{
paramQueue.TryDequeue(out m);
byte[] code = Encoding.UTF8.GetBytes(str);
streamQueue.Enqueue(glArrayHandle.Alloc<byte>(code));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue<T>(T[] array) where T : struct
{
streamQueue.Enqueue(glArrayHandle.Alloc<T>(array));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out glArrayHandle arrayHandle)
{
glArrayHandle handle = default;
if (streamQueue.TryDequeue(out handle))
{
arrayHandle = handle;
}
else
{
InternalIO.InternalWriteLog("No param in buffer when calling gl function.", LogType.Error);
throw new Exception();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool TryDequeue(out M128 m)
{
bool ret = paramQueue.TryDequeue(out m);
_dequeueLog += $"{m.ToString(10)}\n";
return ret;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out Vec4d v)
{
M128 m;
if (paramQueue.TryDequeue(out m))
if (this.TryDequeue(out m))
{
v = *(Vec4d*)&m;
}
@@ -175,13 +225,28 @@ namespace StgSharp.Logic
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue<T>(out T[] array)
{
glArrayHandle output = default;
if (streamQueue.TryDequeue(out output))
{
array = output.copy as T[];
}
else
{
InternalIO.InternalWriteLog("No param in buffer when calling gl function.", LogType.Error);
throw new Exception();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out int i0)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
i0 = ret.Int32[0];
i0 = ret.Read<int>(0);
}
else
{
@@ -194,10 +259,10 @@ namespace StgSharp.Logic
public void TryDequeue(out int i0, out int i1)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
i0 = ret.Int32[0];
i1 = ret.Int32[1];
i0 = ret.Read<int>(0);
i1 = ret.Read<int>(1);
}
else
{
@@ -205,15 +270,16 @@ namespace StgSharp.Logic
throw new Exception();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out int i0, out int i1, out int i2)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
i0 = ret.Int32[0];
i1 = ret.Int32[1];
i2 = ret.Int32[2];
i0 = ret.Read<int>(0);
i1 = ret.Read<int>(1);
i2 = ret.Read<int>(2);
}
else
{
@@ -221,16 +287,17 @@ namespace StgSharp.Logic
throw new Exception();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out int i0, out int i1, out int i2, out int i3)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
i0 = ret.Int32[0];
i1 = ret.Int32[1];
i2 = ret.Int32[2];
i3 = ret.Int32[3];
i0 = ret.Read<int>(0);
i1 = ret.Read<int>(1);
i2 = ret.Read<int>(2);
i3 = ret.Read<int>(3);
}
else
{
@@ -243,9 +310,9 @@ namespace StgSharp.Logic
public void TryDequeue(out IntPtr p)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
p = (IntPtr)ret.UInt64[0];
p = (IntPtr)ret.Read<ulong>(0);
}
else
{
@@ -257,12 +324,11 @@ namespace StgSharp.Logic
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out IntPtr p0, out IntPtr p1)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
p0 = (IntPtr)ret.UInt64[0];
p1 = (IntPtr)ret.UInt64[1];
p0 = (IntPtr)ret.Read<ulong>(0);
p1 = (IntPtr)ret.Read<ulong>(1);
}
else
{
@@ -275,12 +341,12 @@ namespace StgSharp.Logic
public void TryDequeue(out float f0, out float f1, out float f2, out float f3)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
f0 = ret.UInt32[0];
f1 = ret.UInt32[1];
f2 = ret.UInt32[2];
f3 = ret.UInt32[3];
f0 = ret.Read<uint>(0);
f1 = ret.Read<uint>(1);
f2 = ret.Read<uint>(2);
f3 = ret.Read<uint>(3);
}
else
{
@@ -293,11 +359,11 @@ namespace StgSharp.Logic
public void TryDequeue(out float f0, out float f1, out float f2)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
f0 = ret.UInt32[0];
f1 = ret.UInt32[1];
f2 = ret.UInt32[2];
f0 = ret.Read<uint>(0);
f1 = ret.Read<uint>(1);
f2 = ret.Read<uint>(2);
}
else
{
@@ -310,9 +376,9 @@ namespace StgSharp.Logic
public void TryDequeue(out uint u0)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
u0 = ret.UInt32[0];
u0 = ret.Read<uint>(0);
}
else
{
@@ -325,10 +391,10 @@ namespace StgSharp.Logic
public void TryDequeue(out uint u0, out uint u1)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
u0 = ret.UInt32[0];
u1 = ret.UInt32[1];
u0 = ret.Read<uint>(0);
u1 = ret.Read<uint>(1);
}
else
{
@@ -341,11 +407,11 @@ namespace StgSharp.Logic
public void TryDequeue(out uint u0, out uint u1, out uint u2)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
u0 = ret.UInt32[0];
u1 = ret.UInt32[1];
u2 = ret.UInt32[2];
u0 = ret.Read<uint>(0);
u1 = ret.Read<uint>(1);
u2 = ret.Read<uint>(2);
}
else
{
@@ -358,12 +424,12 @@ namespace StgSharp.Logic
public void TryDequeue(out uint u0, out uint u1, out uint u2, out uint u3)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
if (this.TryDequeue(out ret))
{
u0 = ret.UInt32[0];
u1 = ret.UInt32[1];
u2 = ret.UInt32[2];
u3 = ret.UInt32[3];
u0 = ret.Read<uint>(0);
u1 = ret.Read<uint>(1);
u2 = ret.Read<uint>(2);
u3 = ret.Read<uint>(3);
}
else
{
@@ -376,6 +442,19 @@ namespace StgSharp.Logic
{
context = p;
}
}
}
internal void TryDequeue(out Array array)
{
glArrayHandle output = default;
if (streamQueue.TryDequeue(out output))
{
array = output.copy;
}
else
{
InternalIO.InternalWriteLog("No param in buffer when calling gl function.", LogType.Error);
throw new Exception();
}
}
}
}