daily update on 20240315 by nitload youmu
This commit is contained in:
@@ -7,22 +7,22 @@ using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
internal sealed class FrameOperationBuffer
|
||||
{
|
||||
private readonly unsafe GLcontext* currentContext;
|
||||
private IntPtr _func;
|
||||
private ConcurrentQueue<IntPtr> _funcQueue;
|
||||
private GLparamQueue _param;
|
||||
internal unsafe GLcontext* context;
|
||||
|
||||
public unsafe bool CallNext()
|
||||
{
|
||||
if (_funcQueue.TryDequeue(out _func))
|
||||
{
|
||||
((delegate*<void>)_func)();
|
||||
((delegate*<FrameOperationBuffer, GLcontext*, void>)_func)(this, currentContext);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -37,148 +37,154 @@ namespace StgSharp.Graphics
|
||||
private ConcurrentQueue<glArrayHandle> streamQueue = new ConcurrentQueue<glArrayHandle>();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(Vec4d v)
|
||||
public void MethodEnqueue(IntPtr p)
|
||||
{
|
||||
_funcQueue.Enqueue(p);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ParamEnqueue(Vec4d v)
|
||||
{
|
||||
paramQueue.Enqueue(v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(M128 m)
|
||||
public void ParamEnqueue(M128 m)
|
||||
{
|
||||
paramQueue.Enqueue(m);
|
||||
Console.WriteLine(paramQueue.Count + streamQueue.Count);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(uint u0)
|
||||
public void ParamEnqueue(uint u0)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<uint>(0, u0);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(uint u0, uint u1)
|
||||
public void ParamEnqueue(uint u0, uint u1)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<uint>(0, u0);
|
||||
m.Write<uint>(1, u1);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(ulong u0, ulong u1)
|
||||
public void ParamEnqueue(ulong u0, ulong u1)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<ulong>(0, u0);
|
||||
m.Write<ulong>(1, u1);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(uint u0, uint u1, uint u2)
|
||||
public void ParamEnqueue(uint u0, uint u1, uint u2)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<uint>(0, u0);
|
||||
m.Write<uint>(1, u1);
|
||||
m.Write<uint>(2, u2);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(float f0, float f1, float f2)
|
||||
public void ParamEnqueue(float f0, float f1, float f2)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<float>(0, f0);
|
||||
m.Write<float>(1, f1);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(float f0, float f1, float f2, float f3)
|
||||
public void ParamEnqueue(float f0, float f1, float f2, float f3)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<float>(0, f0);
|
||||
m.Write<float>(1, f1);
|
||||
m.Write<float>(2, f2);
|
||||
m.Write<float>(3, f3);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(IntPtr p0, IntPtr p1)
|
||||
public void ParamEnqueue(IntPtr p0, IntPtr p1)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<ulong>(0, (ulong)p0);
|
||||
m.Write<ulong>(1, (ulong)p1);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(IntPtr p)
|
||||
public void ParamEnqueue(IntPtr p)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<ulong>(0, (ulong)p);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void Enqueue(glHandle handle)
|
||||
public unsafe void ParamEnqueue(glHandle handle)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<ulong>(0, (ulong)handle.valuePtr);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void Enqueue(glHandle handle, glHandle handle1)
|
||||
public unsafe void ParamEnqueue(glHandle handle, glHandle handle1)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<ulong>(0, (ulong)handle.valuePtr);
|
||||
m.Write<ulong>(1, (ulong)handle1.valuePtr);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(int i0)
|
||||
public void ParamEnqueue(int i0)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<int>(0, i0);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(int i0, int i1)
|
||||
public void ParamEnqueue(int i0, int i1)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<int>(0, i0);
|
||||
m.Write<int>(1, i1);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(int i0, int i1, int i2)
|
||||
public void ParamEnqueue(int i0, int i1, int i2)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<int>(0, i0);
|
||||
m.Write<int>(1, i1);
|
||||
m.Write<int>(2, i2);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(int i0, int i1, int i2, int i3)
|
||||
public void ParamEnqueue(int i0, int i1, int i2, int i3)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<int>(0, i0);
|
||||
m.Write<int>(1, i1);
|
||||
m.Write<int>(2, i2);
|
||||
m.Write<int>(3, i3);
|
||||
this.Enqueue(m);
|
||||
this.ParamEnqueue(m);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(string str)
|
||||
public void ParamEnqueue(string str)
|
||||
{
|
||||
byte[] code = Encoding.UTF8.GetBytes(str);
|
||||
streamQueue.Enqueue(glArrayHandle.Alloc<byte>(code));
|
||||
@@ -186,7 +192,7 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue<T>(T[] array) where T : struct
|
||||
public void ParamEnqueue<T>(T[] array) where T : struct
|
||||
{
|
||||
streamQueue.Enqueue(glArrayHandle.Alloc<T>(array));
|
||||
Console.WriteLine(paramQueue.Count + streamQueue.Count);
|
||||
@@ -452,18 +458,43 @@ namespace StgSharp.Graphics
|
||||
private Thread _thread;
|
||||
private FrameOperationBuffer renderBuffer;
|
||||
private SemaphoreSlim renderCompleteSemaphore = new SemaphoreSlim(1, 1);
|
||||
private int terminateSignal;
|
||||
private SemaphoreSlim renderStartSemaphore;
|
||||
private bool shouldTerminate;
|
||||
private FrameOperationBuffer updateBuffer;
|
||||
|
||||
public FrameThread(IglFunc gl)
|
||||
internal FrameThread(GLonUpdate gl)
|
||||
{
|
||||
updateBuffer = gl.ActivatedOperationBuffer;
|
||||
_thread = new Thread(new ThreadStart(PrivateMain));
|
||||
}
|
||||
|
||||
public bool IsRunning
|
||||
{
|
||||
get { return _thread.IsAlive; }
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_thread.Start();
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
shouldTerminate = true;
|
||||
}
|
||||
|
||||
private void PrivateMain()
|
||||
{
|
||||
while (renderBuffer.CallNext())
|
||||
{
|
||||
}
|
||||
renderStartSemaphore.Wait();
|
||||
while (shouldTerminate && renderBuffer.CallNext())
|
||||
{ }
|
||||
renderCompleteSemaphore.Release();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetNext(FrameThread thread)
|
||||
{
|
||||
renderStartSemaphore = thread.renderCompleteSemaphore;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user