daily update on 20240203 by nitloadd youmu. New glhandle setup.

This commit is contained in:
Nitload
2024-02-03 23:20:50 +08:00
parent 8148c10acd
commit 5d778e0f2f
258 changed files with 10025 additions and 1220 deletions
+43 -47
View File
@@ -18,9 +18,16 @@ namespace StgSharp.Graphics
{
internal GLonUpdateInternal glUpdateInternal;
private ConcurrentQueue<IntPtr> glActionQueue;
private ConcurrentQueue<Vec4d> glParamQueue;
private GLparamQueue paramQueue;
private FrameTimeoutException refreshSignal = new();
internal GLonUpdate(GLcontext* context)
{
glUpdateInternal = new GLonUpdateInternal();
paramQueue = glUpdateInternal.paramQueue;
glActionQueue = new ConcurrentQueue<IntPtr>();
}
internal ConcurrentQueue<IntPtr> GLactionQueue
{
get
@@ -28,18 +35,9 @@ namespace StgSharp.Graphics
return glActionQueue;
}
}
internal GLonUpdate(GLcontext* context)
{
glUpdateInternal = new GLonUpdateInternal();
glParamQueue = glUpdateInternal.paramQueue;
glActionQueue = new ConcurrentQueue<IntPtr>();
}
void IglFunc.ActiveTexture(uint type)
{
glParamQueue.Enqueue(new Vec4d(type));
paramQueue.Enqueue(type);
glActionQueue.Enqueue(glUpdateInternal.ActiveTexturePtr);
}
@@ -61,18 +59,17 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.AttachShader(uint program, uint shader)
unsafe void IglFunc.AttachShader(glHandle program, glHandle shader)
{
glActionQueue.Enqueue(
() => api->glAttachShader(program, shader)
);
paramQueue.Enqueue(program[0], shader[0]);
glActionQueue.Enqueue(glUpdateInternal.AttachShaderPtr);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.BindBuffer(BufferType bufferType, uint index)
{
glActionQueue.Enqueue(
() => api->glBindBuffer((uint)bufferType, index)
paramQueue.Enqueue((uint)bufferType, index);
glActionQueue.Enqueue(glUpdateInternal.BindBufferPtr
);
}
@@ -100,7 +97,7 @@ namespace StgSharp.Graphics
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.ClearColor(float R, float G, float B, float A)
{
glActionQueue.Enqueue(
@@ -108,6 +105,7 @@ namespace StgSharp.Graphics
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.ClearGraphicError()
{
glActionQueue.Enqueue(
@@ -119,9 +117,9 @@ namespace StgSharp.Graphics
}
uint IglFunc.CompileShader(string shaderCode, ShaderType shaderType)
glHandle IglFunc.CompileShader(string shaderCode, ShaderType shaderType)
{
int id = -1;
glHandle h = new glHandle(1);
glActionQueue.Enqueue(
() =>
{
@@ -162,14 +160,14 @@ namespace StgSharp.Graphics
Interlocked.Add(ref id, (int)(shaderID + 1));
}
);
while (id < 0) { }
return (uint)id;
return h;
}
uint IglFunc.CreateProgram()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
glHandle IglFunc.CreateProgram()
{
int id = -1;
glHandle h = new glHandle(1);
glActionQueue.Enqueue(
() =>
{
@@ -177,8 +175,13 @@ namespace StgSharp.Graphics
Interlocked.Add(ref id, ret + 1);
}
);
while (id < 0) { }
return (uint)id;
return h;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
glHandle IglFunc.CreateProgram(int count)
{
throw new NotImplementedException();
}
IntPtr IglFunc.CreateWindowHandle(int width, int height, string tittle, IntPtr monitor, Form share)
@@ -207,23 +210,17 @@ namespace StgSharp.Graphics
}
uint IglFunc.CreatGraphicProgram()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
glHandle IglFunc.CreatGraphicProgram()
{
int id = 0;
glHandle h = new glHandle(1);
glActionQueue.Enqueue(
() =>
{
Interlocked.Add(ref id, (int)(api->glCreateProgram() + 1));
}
);
while (id < 0) { }
return (uint)id;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.SetWindowShouldClose(Form form, bool mark)
{
InternalIO.glfw.SetWindowShouldClose(form.windowID, mark ? 1 : 0);
return h;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -238,7 +235,7 @@ namespace StgSharp.Graphics
);
}
unsafe void IglFunc.DeleteBuffers(uint count, uint[] handle)
unsafe void IglFunc.DeleteBuffers(glHandle handle)
{
glActionQueue.Enqueue(
() =>
@@ -252,7 +249,7 @@ namespace StgSharp.Graphics
);
}
unsafe void IglFunc.DeleteVertexArrays(uint count, uint[] arrays)
unsafe void IglFunc.DeleteVertexArrays(glHandle arrays)
{
glActionQueue.Enqueue(
() =>
@@ -293,27 +290,25 @@ namespace StgSharp.Graphics
);
}
unsafe void IglFunc.GenBuffers(uint count, uint* ptr)
unsafe void IglFunc.GenBuffers(uint count, glHandle handle)
{
glActionQueue.Enqueue(
() =>
{
api->glGenBuffers(count, ptr);
}
);
}
unsafe void IglFunc.GenTextures(uint count, uint* ptr)
unsafe void IglFunc.GenTextures(uint count, glHandle handle)
{
glActionQueue.Enqueue(
() =>
{
api->glGenTextures(count, ptr);
}
);
}
unsafe void IglFunc.GenVertexArrays(uint count, uint* ptr)
unsafe void IglFunc.GenVertexArrays(uint count, glHandle ptr)
{
glActionQueue.Enqueue(
() =>
@@ -347,8 +342,6 @@ namespace StgSharp.Graphics
return ret;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
bool IglFunc.GetWindowShouldClose(Form form)
{
@@ -410,14 +403,12 @@ namespace StgSharp.Graphics
);
}
void IglFunc.SetFrameBufferSizeCallback(IntPtr id, FrameBufferSizeHandler handler)
{
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(handler);
InternalIO.glfw.SetFramebufferSizeCallback(id, handlerPtr);
}
void IglFunc.SetVertexAttribute(uint index, int size, Type t, bool normalized, uint stride, int pointer)
{
glActionQueue.Enqueue(
@@ -430,6 +421,11 @@ namespace StgSharp.Graphics
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.SetWindowShouldClose(Form form, bool mark)
{
InternalIO.glfw.SetWindowShouldClose(form.windowID, mark ? 1 : 0);
}
void IglFunc.SwapBuffers(Form form)
{
glActionQueue.Enqueue(