daily update on 20240610 by nitload youmu

This commit is contained in:
Nitload
2024-06-10 15:11:01 +08:00
parent c0093f7b5c
commit f6963b8e00
96 changed files with 2927 additions and 2290 deletions
-11
View File
@@ -428,17 +428,6 @@ namespace StgSharp.Graphics.GL
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void MakeContextCurrent(ViewModel form)
{
if (form.WindowID == IntPtr.Zero)
{
InternalIO.InternalWriteLog($"From {nameof(form)} is not inited.", LogType.Warning);
return;
}
InternalIO.glfwMakeContextCurrent(form.id);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetBufferData<T>(BufferType bufferType, T bufferData, BufferUsage usage)
where T : struct
@@ -60,14 +60,14 @@ namespace StgSharp.Graphics.GL
}
}
public class Shader : SSDSerializable
public class Shader : ISSDSerializable
{
private readonly IntPtr context;
internal readonly glHandleSet handle;
public readonly ShaderType type;
public override SerializableTypeCode SSDTypeCode => SerializableTypeCode.Shader;
public SerializableTypeCode SSDTypeCode => SerializableTypeCode.Shader;
internal unsafe Shader(glHandleSet handle, ShaderType usage)
{
@@ -126,27 +126,26 @@ namespace StgSharp.Graphics.GL
return $"This is a {type} shader, its shader handles are {handle.ToString()}.";
}
//TODO shader 的序列化究极麻烦,原因是shader的架构问题
public override byte[] GetBytes()
public byte[] GetBytes()
{
throw new NotImplementedException();
return Array.Empty<byte>();
}
public void CheckStatus(int index, ShaderStatus status)
{
string log = glFunc.GetShaderStatus(this,index, (int)status);
if (log != "")
if (!string.IsNullOrEmpty(log))
{
throw new Exception($"Shader Error\n{status}\n" + log);
throw new Exception($"Shader Error \t{status}\n" + log);
}
}
public override byte[] GetBytes(out int length)
public byte[] GetBytes(out int length)
{
throw new NotImplementedException();
}
internal override void BuildFromByteStream(byte[] stream)
public void FromBytes(byte[] stream)
{
throw new NotImplementedException();
}
@@ -175,7 +174,7 @@ namespace StgSharp.Graphics.GL
/// Get a uniform form current shader,
/// the value type of the uniform should be provided.
/// </summary>
/// <param name="name">Name of the Uniform in shader code</param>
/// <param name="name">ContextName of the Uniform in shader code</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe Uniform<T> GetUniform<T>(string name) where T : struct
@@ -187,7 +186,7 @@ namespace StgSharp.Graphics.GL
/// Get a uniform form current shader,
/// the value type of the uniform should be provided.
/// </summary>
/// <param name="name">Name of the Uniform in shader code</param>
/// <param name="name">ContextName of the Uniform in shader code</param>
/// <returns></returns>
public unsafe Uniform<T, U> GetUniform<T, U>(string name)
where T : struct
@@ -200,7 +199,7 @@ namespace StgSharp.Graphics.GL
/// Get a uniform form current shader,
/// the value type of the uniform should be provided.
/// </summary>
/// <param name="name">Name of the Uniform in shader code</param>
/// <param name="name">ContextName of the Uniform in shader code</param>
/// <returns></returns>
public unsafe Uniform<T, U, V> GetUniform<T, U, V>(string name)
where T : struct
@@ -213,7 +212,7 @@ namespace StgSharp.Graphics.GL
/// Get a uniform form current shader,
/// the value type of the uniform should be provided.
/// </summary>
/// <param name="name">Name of the Uniform in shader code</param>
/// <param name="name">ContextName of the Uniform in shader code</param>
/// <returns></returns>
public unsafe Uniform<T, U, V, W> GetUniform<T, U, V, W>(string name)
where T : struct
+25 -25
View File
@@ -56,15 +56,15 @@ namespace StgSharp.Graphics.GL
private static string glExtensionList;
/// <summary>
/// Load all supported OpenGL APIs and bind them to given <see cref="ViewModel"/> context.
/// Load all supported OpenGL APIs and bind them to given <see cref="ViewPort"/> context.
/// </summary>
/// <param name="stream">The <see cref="ViewModel"/> used as current OpenGL context</param>
public static unsafe void LoadGLapi(this glRenderStream stream)
/// <param name="vp">The <see cref="ViewPort"/> used as current OpenGL context</param>
public static unsafe void LoadGLapi(this ViewPort vp)
{
GLcontext* context = (GLcontext*)stream.ContextHandle;
GLcontext* context = (GLcontext*)vp.GraphicHandle;
delegate*<string,IntPtr> loader = &InternalIO.glfwGetProcAddress;
#pragma warning disable CS8909
if (((GLcontext*)stream.ContextHandle)->glGetString != (delegate*<uint, IntPtr>)IntPtr.Zero)
if (context->glGetString != (delegate*<uint, IntPtr>)IntPtr.Zero)
#pragma warning restore CS8909
{
return;
@@ -102,25 +102,25 @@ namespace StgSharp.Graphics.GL
{
#region load_core_gl
LoadGLcore10((GLcontext*)stream.ContextHandle, loader);
LoadGLcore11((GLcontext*)stream.ContextHandle, loader);
LoadGLcore12((GLcontext*)stream.ContextHandle, loader);
LoadGLcore13((GLcontext*)stream.ContextHandle, loader);
LoadGLcore14((GLcontext*)stream.ContextHandle, loader);
LoadGLcore15((GLcontext*)stream.ContextHandle, loader);
LoadGLcore20((GLcontext*)stream.ContextHandle, loader);
LoadGLcore21((GLcontext*)stream.ContextHandle, loader);
LoadGLcore30((GLcontext*)stream.ContextHandle, loader);
LoadGLcore31((GLcontext*)stream.ContextHandle, loader);
LoadGLcore32((GLcontext*)stream.ContextHandle, loader);
LoadGLcore33((GLcontext*)stream.ContextHandle, loader);
LoadGLcore40((GLcontext*)stream.ContextHandle, loader);
LoadGLcore41((GLcontext*)stream.ContextHandle, loader);
LoadGLcore42((GLcontext*)stream.ContextHandle, loader);
LoadGLcore43((GLcontext*)stream.ContextHandle, loader);
LoadGLcore44((GLcontext*)stream.ContextHandle, loader);
LoadGLcore45((GLcontext*)stream.ContextHandle, loader);
LoadGLcore46((GLcontext*)stream.ContextHandle, loader);
LoadGLcore10(context, loader);
LoadGLcore11(context, loader);
LoadGLcore12(context, loader);
LoadGLcore13(context, loader);
LoadGLcore14(context, loader);
LoadGLcore15(context, loader);
LoadGLcore20(context, loader);
LoadGLcore21(context, loader);
LoadGLcore30(context, loader);
LoadGLcore31(context, loader);
LoadGLcore32(context, loader);
LoadGLcore33(context, loader);
LoadGLcore40(context, loader);
LoadGLcore41(context, loader);
LoadGLcore42(context, loader);
LoadGLcore43(context, loader);
LoadGLcore44(context, loader);
LoadGLcore45(context, loader);
LoadGLcore46(context, loader);
#endregion load_core_gl
}
@@ -777,7 +777,7 @@ namespace StgSharp.Graphics.GL
/// <summary>
/// Get the function pointer of given OpenGL api name
/// </summary>
/// <param name="name">Name of the OpenGL api</param>
/// <param name="name">ContextName of the OpenGL api</param>
/// <returns>The funtion pointer of the api in stream of <see cref="IntPtr"/></returns>
public static IntPtr LoadGLfunc(string name)
{
@@ -45,17 +45,14 @@ namespace StgSharp.Graphics.GL
public abstract partial class glRenderStream : RenderStream
{
protected glRenderStream(RenderStreamConstructArgs args) : base(args)
{
}
protected glRenderStream(RenderStreamConstructArgs args,bool isSharing) : base(args,isSharing)
protected glRenderStream(ViewPort v, (int,int,int) cube) : base(v,cube)
{
}
protected IntPtr glContextHandle
{
get { return ContextHandle; }
set { ContextHandle = value; }
}
/// <summary>
@@ -87,14 +84,6 @@ namespace StgSharp.Graphics.GL
InternalIO.glfwSetWindowSizeLimits(this.CanvasHandle, minWidth, minHeight, maxWidth, maxHeight);
}
internal override sealed unsafe void CreateCanvas()
{
byte[] nameCode = Encoding.UTF8.GetBytes(Name);
CanvasHandle = InternalIO.glfwCreateWindow(
Width, Height, nameCode, Monitor, IntPtr.Zero
);
}
internal override sealed void InternalDraw(
in Dictionary<string, BlueprintPipeline> input,
in Dictionary<string, BlueprintPipeline> output)
@@ -106,9 +95,8 @@ namespace StgSharp.Graphics.GL
internal override sealed void InternalInit()
{
CreateCanvas();
MakeAsCurrentContext();
this.LoadGLapi();
this.Port.LoadGLapi();
Init();
}