daily update on 2024.03.18 by itload youmu
This commit is contained in:
@@ -1,4 +1,34 @@
|
||||
using StgSharp.Math;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Uniform.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -11,8 +41,14 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
public class Uniform<T> where T : struct
|
||||
{
|
||||
internal glSHandle id;
|
||||
|
||||
private IglFunc GL;
|
||||
internal glSHandle id;
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
internal unsafe Uniform(
|
||||
ShaderProgram program, string name, IglFunc gl)
|
||||
@@ -21,18 +57,20 @@ namespace StgSharp.Graphics
|
||||
id = GL.GetUniformLocation(program.handle, name);
|
||||
}
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
public class Uniform<T, U>
|
||||
where T : struct
|
||||
where U : struct
|
||||
{
|
||||
internal glSHandle id;
|
||||
|
||||
private IglFunc GL;
|
||||
internal glSHandle id;
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
internal unsafe Uniform(
|
||||
ShaderProgram program, string name, IglFunc gl)
|
||||
@@ -41,10 +79,6 @@ namespace StgSharp.Graphics
|
||||
id = GL.GetUniformLocation(program.handle, name);
|
||||
}
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
public class Uniform<T, U, V>
|
||||
@@ -52,8 +86,14 @@ namespace StgSharp.Graphics
|
||||
where U : struct
|
||||
where V : struct
|
||||
{
|
||||
internal glSHandle id;
|
||||
|
||||
private IglFunc GL;
|
||||
internal glSHandle id;
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public unsafe Uniform(ShaderProgram program, string name, IglFunc gl)
|
||||
{
|
||||
@@ -61,10 +101,6 @@ namespace StgSharp.Graphics
|
||||
id = GL.GetUniformLocation(program.handle, name);
|
||||
}
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
public class Uniform<T, U, V, W>
|
||||
@@ -73,8 +109,14 @@ namespace StgSharp.Graphics
|
||||
where V : struct
|
||||
where W : struct
|
||||
{
|
||||
internal glSHandle id;
|
||||
|
||||
private IglFunc GL;
|
||||
internal glSHandle id;
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
internal unsafe Uniform(ShaderProgram program, string name, IglFunc gl)
|
||||
{
|
||||
@@ -82,14 +124,23 @@ namespace StgSharp.Graphics
|
||||
id = GL.GetUniformLocation(program.handle, name);
|
||||
}
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
internal partial class GLonRender : IglFunc
|
||||
{
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetValue(Uniform<float, float, float, float> uniform, Vec4d vec)
|
||||
{
|
||||
api->glUniform1fv(uniform.id.DirectValue, 4, &vec);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetValue(Uniform<Vec4d> uniform, Vec4d vec)
|
||||
{
|
||||
api->glUniform1fv(uniform.id.DirectValue, 4, &vec);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.SetValue(Uniform<float> uniform, float v0)
|
||||
{
|
||||
@@ -120,21 +171,11 @@ namespace StgSharp.Graphics
|
||||
api->glUniform4f(uniform.id.DirectValue, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetValue(Uniform<float, float, float, float> uniform, Vec4d vec)
|
||||
{
|
||||
api->glUniform1fv(uniform.id.DirectValue, 4, &vec);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetValue(Uniform<Vec4d> uniform, Vec4d vec)
|
||||
{
|
||||
api->glUniform1fv(uniform.id.DirectValue, 4, &vec);
|
||||
}
|
||||
}
|
||||
|
||||
internal unsafe partial class GLonUpdate
|
||||
{
|
||||
|
||||
private IntPtr UniformVal1fPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&UniformVal1f;
|
||||
private IntPtr UniformVal1fvPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&UniformVal1fv;
|
||||
private IntPtr UniformVal1iPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&UniformVal1i;
|
||||
@@ -142,6 +183,53 @@ namespace StgSharp.Graphics
|
||||
private IntPtr UniformVal3fPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&UniformVal3f;
|
||||
private IntPtr UniformVal4fPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&UniformVal4f;
|
||||
|
||||
private static void UniformVal1f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform1f(*(int*)m.Read<ulong>(0), m.Read<uint>(2));
|
||||
}
|
||||
|
||||
private static unsafe void UniformVal1fv(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default, v = default;
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
frameOpBuffer.TryDequeue(out v);
|
||||
activatedContext->glUniform1fv(*(int*)m.Read<ulong>(0), 4, (Vec4d*)&v);
|
||||
}
|
||||
|
||||
private static void UniformVal1i(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform1i(*(int*)m.Read<ulong>(0), m.Read<int>(2));
|
||||
}
|
||||
|
||||
private static void UniformVal2f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform2f(*(int*)m.Read<ulong>(0), m.Read<float>(2), m.Read<float>(3));
|
||||
}
|
||||
|
||||
private static void UniformVal3f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
M128 m = default;
|
||||
frameOpBuffer.TryDequeue(out handle);
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform3f(*(int*)handle, m.Read<float>(0), m.Read<float>(1), m.Read<float>(2));
|
||||
}
|
||||
|
||||
private static void UniformVal4f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
M128 m = default;
|
||||
frameOpBuffer.TryDequeue(out handle);
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform4f(*(int*)handle, m.Read<float>(0), m.Read<float>(1), m.Read<float>(2), m.Read<float>(3));
|
||||
}
|
||||
|
||||
unsafe void IglFunc.SetValue(Uniform<float, float, float> uniform, float f0, float f1, float f2)
|
||||
{
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)uniform.id.valuePtr);
|
||||
@@ -194,55 +282,9 @@ namespace StgSharp.Graphics
|
||||
unsafe void IglFunc.SetValue(Uniform<Vec4d> uniform, Vec4d vec)
|
||||
{
|
||||
Vec4d m = vec;
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)uniform.id.valuePtr, (IntPtr)(Vec4d*)&m);
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)uniform.id.valuePtr, (IntPtr)(&m));
|
||||
frameOpBuffer.MethodEnqueue(UniformVal1fvPtr);
|
||||
}
|
||||
|
||||
private static void UniformVal1f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform1f(*(int*)m.Read<ulong>(0), m.Read<uint>(2));
|
||||
}
|
||||
|
||||
private static unsafe void UniformVal1fv(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default, v = default;
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
frameOpBuffer.TryDequeue(out v);
|
||||
activatedContext->glUniform1fv(*(int*)m.Read<ulong>(0), 4, (Vec4d*)&v);
|
||||
}
|
||||
|
||||
private static void UniformVal1i(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform1i(*(int*)m.Read<ulong>(0), m.Read<int>(2));
|
||||
}
|
||||
|
||||
private static void UniformVal2f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform2f(*(int*)m.Read<ulong>(0), m.Read<float>(2), m.Read<float>(3));
|
||||
}
|
||||
|
||||
private static void UniformVal3f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
M128 m = default;
|
||||
frameOpBuffer.TryDequeue(out handle);
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform3f(*(int*)handle, m.Read<float>(0), m.Read<float>(1), m.Read<float>(2));
|
||||
}
|
||||
|
||||
private static void UniformVal4f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
M128 m = default;
|
||||
frameOpBuffer.TryDequeue(out handle);
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform4f(*(int*)handle, m.Read<float>(0), m.Read<float>(1), m.Read<float>(2), m.Read<float>(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user