daily update on 20241002 by nitload youmu, intrinsic function rebuild, syntax style arrange

This commit is contained in:
Nitload
2024-10-03 04:03:06 +08:00
parent 0979123ac0
commit 6e2f93b053
265 changed files with 26732 additions and 19058 deletions
+63 -33
View File
@@ -40,31 +40,55 @@ namespace StgSharp
{
internal static partial class InternalIO
{
#region ssgc api define
[DllImport(SSC_libName, EntryPoint = "initGL",
CallingConvention = CallingConvention.Cdecl)]
internal static extern void InternalInitGL(int majorVersion, int minorVersion);
[DllImport(
SSC_libName,
EntryPoint = "initGL",
CallingConvention = CallingConvention.Cdecl )]
internal static extern void InternalInitGL(
int majorVersion,
int minorVersion );
[DllImport(SSC_libName, EntryPoint = "loadGlfuncDefault",
CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
internal static extern IntPtr InternalLoadGlfuncDefault(string name);
[DllImport(
SSC_libName,
EntryPoint = "loadGlfuncDefault",
CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi )]
internal static extern IntPtr InternalLoadGlfuncDefault( string name );
[DllImport(SSC_libName, EntryPoint = "linkShaderProgram",
CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe uint InternalLinkShaderProgram(OpenglContext* context, uint shaderProgram);
[DllImport(
SSC_libName,
EntryPoint = "linkShaderProgram",
CallingConvention = CallingConvention.Cdecl )]
internal static extern unsafe uint InternalLinkShaderProgram(
OpenglContext* context,
uint shaderProgram );
[DllImport(SSC_libName, EntryPoint = "readLog",
CallingConvention = CallingConvention.Cdecl)]
[DllImport(
SSC_libName,
EntryPoint = "readLog",
CallingConvention = CallingConvention.Cdecl )]
internal static extern unsafe IntPtr InternalReadSSCLog();
[DllImport(SSC_libName, EntryPoint = "loadImageData",
CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
internal static extern unsafe void InternalLoadImage(string fileName, ImageInfo* output, ImageLoader loader);
[DllImport(
SSC_libName,
EntryPoint = "loadImageData",
CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi )]
internal static extern unsafe void InternalLoadImage(
string fileName,
ImageInfo* output,
ImageLoader loader );
[DllImport(SSC_libName, EntryPoint = "unloadImageData",
CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
internal static extern unsafe void InternalUnloadImage(ImageInfo* output);
[DllImport(
SSC_libName,
EntryPoint = "unloadImageData",
CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi )]
internal static extern unsafe void InternalUnloadImage(
ImageInfo* output );
#endregion ssgc api define
}
@@ -72,34 +96,42 @@ namespace StgSharp
namespace StgSharp.Graphics
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public delegate IntPtr ImageLoader(string name, ref int width, ref int height, ref int definedChannel, int desiredChannel);
[UnmanagedFunctionPointer( CallingConvention.Cdecl, CharSet = CharSet.Ansi )]
public delegate IntPtr ImageLoader(
string name,
ref int width,
ref int height,
ref int definedChannel,
int desiredChannel );
[StructLayout(LayoutKind.Sequential)]
[StructLayout( LayoutKind.Sequential )]
public struct OpenglContext
{
public override bool Equals(object obj)
public override bool Equals( object obj )
{
return false;
}
public override unsafe int GetHashCode()
{
fixed (OpenglContext* sptr = &this)
{
fixed( OpenglContext* sptr = &this ) {
return sptr->GetHashCode();
}
}
public static bool operator !=(OpenglContext left, OpenglContext right)
public static bool operator !=(
OpenglContext left,
OpenglContext right )
{
return !(left == right);
return !( left == right );
}
public static bool operator ==(OpenglContext left, OpenglContext right)
public static bool operator ==(
OpenglContext left,
OpenglContext right )
{
return left.Equals(right);
return left.Equals( right );
}
#region glapi
@@ -244,7 +276,7 @@ namespace StgSharp.Graphics
internal unsafe delegate*<uint, IntPtr, UIntPtr, uint, ulong, bool, void> glBufferPageCommitmentMemNV;
internal unsafe delegate*<uint, uint, int, void> glBufferParameteriAPPLE;
internal unsafe delegate*<uint, UIntPtr, void*, uint, void> glBufferStorage;
[Obsolete("Param type uncertain", true)] internal unsafe delegate*<uint, IntPtr, UIntPtr, int, uint, void> glBufferStorageExternalEXT;
[Obsolete( "Param type uncertain", true )] internal unsafe delegate*<uint, IntPtr, UIntPtr, int, uint, void> glBufferStorageExternalEXT;
internal unsafe delegate*<uint, UIntPtr, uint, ulong, void> glBufferStorageMemEXT;
internal unsafe delegate*<uint, IntPtr, UIntPtr, void*, void> glBufferSubData;
internal unsafe delegate*<uint, IntPtr, UIntPtr, void*, void> glBufferSubDataARB;
@@ -1425,7 +1457,7 @@ namespace StgSharp.Graphics
internal unsafe delegate*<uint, IntPtr, UIntPtr, uint, ulong, bool, void> glNamedBufferPageCommitmentMemNV;
internal unsafe delegate*<uint, UIntPtr, void*, uint, void> glNamedBufferStorage;
internal unsafe delegate*<uint, UIntPtr, void*, uint, void> glNamedBufferStorageEXT;
[Obsolete("Param type uncertain", true)] internal unsafe delegate*<uint, IntPtr, UIntPtr, int, uint, void> glNamedBufferStorageExternalEXT;
[Obsolete( "Param type uncertain", true )] internal unsafe delegate*<uint, IntPtr, UIntPtr, int, uint, void> glNamedBufferStorageExternalEXT;
internal unsafe delegate*<uint, UIntPtr, uint, ulong, void> glNamedBufferStorageMemEXT;
internal unsafe delegate*<uint, IntPtr, UIntPtr, void*, void> glNamedBufferSubData;
internal unsafe delegate*<uint, IntPtr, UIntPtr, void*, void> glNamedBufferSubDataEXT;
@@ -2103,7 +2135,7 @@ namespace StgSharp.Graphics
internal unsafe delegate*<int, uint, double*, void> glUniform1dv;
internal unsafe delegate*<int, float, void> glUniform1f;
internal unsafe delegate*<int, float, void> glUniform1fARB;
internal unsafe delegate*<int, uint, vec4d*, void> glUniform1fv;
internal unsafe delegate*<int, uint, Vec4*, void> glUniform1fv;
internal unsafe delegate*<int, uint, float*, void> glUniform1fvARB;
internal unsafe delegate*<int, int, void> glUniform1i;
internal unsafe delegate*<int, long, void> glUniform1i64ARB;
@@ -2637,8 +2669,6 @@ namespace StgSharp.Graphics
internal unsafe delegate*<uint, uint, int*, void> glWindowRectanglesEXT;
internal unsafe delegate*<uint, uint, uint, uint, uint, uint, void> glWriteMaskEXT;
#endregion glapi
#endregion glapi
}
}
+48 -41
View File
@@ -28,12 +28,14 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Data.Intrinsic;
using StgSharp.Geometries;
using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -47,11 +49,13 @@ namespace StgSharp
{
public enum LogType
{
Error,
Warning,
Info,
InfoError,
InfoWarning,
}
internal static unsafe partial class InternalIO
@@ -67,42 +71,45 @@ namespace StgSharp
new Dictionary<TypeCode, uint>();
internal static readonly GCHandle ssc_logHandle =
GCHandle.Alloc(new byte[512], GCHandleType.Pinned);
GCHandle.Alloc( new byte[512], GCHandleType.Pinned );
internal static IntPtr SSClibPtr = IntPtr.Zero;
internal static SemaphoreSlim logSyncSemaphore = new SemaphoreSlim(1, 1);
internal static SemaphoreSlim logSyncSemaphore = new SemaphoreSlim(
1, 1 );
static InternalIO()
{
GLtype.Add(TypeCode.Single, GLconst.FLOAT);
GLtype.Add(TypeCode.Int32, GLconst.INT);
GLtype.Add(TypeCode.UInt32, GLconst.UNSIGNED_INT);
GLtype.Add(TypeCode.Int16, GLconst.SHORT);
GLtype.Add(TypeCode.UInt16, GLconst.UNSIGNED_SHORT);
GLtype.Add(TypeCode.SByte, GLconst.BYTE);
GLtype.Add(TypeCode.Byte, GLconst.UNSIGNED_BYTE);
GLtype.Add( TypeCode.Single, GLconst.FLOAT );
GLtype.Add( TypeCode.Int32, GLconst.INT );
GLtype.Add( TypeCode.UInt32, GLconst.UNSIGNED_INT );
GLtype.Add( TypeCode.Int16, GLconst.SHORT );
GLtype.Add( TypeCode.UInt16, GLconst.UNSIGNED_SHORT );
GLtype.Add( TypeCode.SByte, GLconst.BYTE );
GLtype.Add( TypeCode.Byte, GLconst.UNSIGNED_BYTE );
fixed( IntrinsicContext* cptr = &_intrinsicContext ) {
LoadIntrinsicFunction( cptr );
}
}
internal static void InternalAppendLog(string log)
internal static void InternalAppendLog( string log )
{
if (!File.Exists(SS_errorLog))
{
FileStream stream = File.Create(SS_errorLog);
if( !File.Exists( SS_errorLog ) ) {
FileStream stream = File.Create( SS_errorLog );
stream.Close();
}
using (StreamWriter logStream = File.AppendText(SS_errorLog))
{
logStream.WriteLine(log);
using( StreamWriter logStream = File.AppendText( SS_errorLog ) ) {
logStream.WriteLine( log );
}
}
[Obsolete("Not completed", true)]
internal static IntPtr InternalLoadProc<T>(IntPtr lib, string name) where T : Delegate
[Obsolete( "Not completed", true )]
internal static IntPtr InternalLoadProc<T>( IntPtr lib, string name )
where T: Delegate
{
try
{
try {
IntPtr procPtr =
#if WINDOWS
IntPtr.Zero;
@@ -110,48 +117,48 @@ namespace StgSharp
#else
IntPtr.Zero;
#endif
#endif
return procPtr;
}
catch (Exception)
{
catch( Exception ) {
throw;
}
}
internal static void InternalWriteLog(string logLine, LogType logType)
internal static void InternalWriteLog( string logLine, LogType logType )
{
logSyncSemaphore.Wait();
if (!File.Exists(SS_errorLog))
{
FileStream stream = File.Create(SS_errorLog);
if( !File.Exists( SS_errorLog ) ) {
FileStream stream = File.Create( SS_errorLog );
stream.Close();
}
using (StreamWriter logStream = File.AppendText(SS_errorLog))
{
logStream.WriteLine($"{logType}\t{DateTime.Now.ToString("o")}");
logStream.WriteLine(logLine);
using( StreamWriter logStream = File.AppendText( SS_errorLog ) ) {
logStream.WriteLine(
$"{logType}\t{DateTime.Now.ToString("o")}" );
logStream.WriteLine( logLine );
}
logSyncSemaphore.Release();
}
internal static void InternalWriteLog(string beforeTime, string logLine, LogType logType)
internal static void InternalWriteLog(
string beforeTime,
string logLine,
LogType logType )
{
logSyncSemaphore.Wait();
if (!File.Exists(InternalIO.SS_errorLog))
{
FileStream stream = File.Create(InternalIO.SS_errorLog);
if( !File.Exists( InternalIO.SS_errorLog ) ) {
FileStream stream = File.Create( InternalIO.SS_errorLog );
stream.Close();
}
using (StreamWriter logStream = File.AppendText(SS_errorLog))
{
logStream.WriteLine(beforeTime);
logStream.WriteLine($"{logType}\t@\t{DateTime.Now.ToString("o")}");
logStream.WriteLine(logLine);
using( StreamWriter logStream = File.AppendText( SS_errorLog ) ) {
logStream.WriteLine( beforeTime );
logStream.WriteLine(
$"{logType}\t@\t{DateTime.Now.ToString("o")}" );
logStream.WriteLine( logLine );
}
logSyncSemaphore.Release(1);
logSyncSemaphore.Release( 1 );
}
}