daily update on 20240226 by nitload youmu

This commit is contained in:
YoumuLiu
2024-02-27 00:43:29 +08:00
parent a2241a5a58
commit 06e39f7a31
543 changed files with 230273 additions and 21423 deletions
+93 -84
View File
@@ -9,41 +9,8 @@ using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
namespace System
{
public unsafe struct glSHandle
{
internal int* valuePtr;
internal glHandleSet source;
public static glSHandle Zero
{
get { return Alloc(1); }
}
public static glSHandle Alloc(int value)
{
glSHandle ret = default;
ret.source = new glHandleSet(1);
ret.valuePtr = (int*)ret.source.handle;
*ret.valuePtr = (int)value;
return ret;
}
internal int DirectValue
{
get { return *valuePtr; }
}
internal glSHandle(int* val, glHandleSet set)
{
source = set;
valuePtr = val;
}
}
/// <summary>
/// A handle to an OpenGL object,
/// must be indexed from a <see cref="glHandleSet"/>.
@@ -51,26 +18,12 @@ namespace System
/// </summary>
public unsafe struct glHandle
{
internal uint* valuePtr;
internal glHandleSet source;
internal uint* valuePtr;
public static glHandle Zero
{
get { return Alloc(0); }
}
[Obsolete("Cannot init instance of this type", true)]
public glHandle()
{
throw new InvalidOperationException();
}
public static glHandle Alloc(uint value)
{
glHandle ret = default;
ret.source = new glHandleSet(1);
ret.valuePtr = ret.source.handle;
*ret.valuePtr = value;
return ret;
}
internal glHandle(uint* val, glHandleSet set)
@@ -79,6 +32,17 @@ namespace System
valuePtr = val;
}
private glHandle(IntPtr handle)
{
this.valuePtr = (uint*)handle;
source = null;
}
public static glHandle Zero
{
get { return Alloc(0); }
}
public IntPtr Handle
{
get
@@ -91,14 +55,6 @@ namespace System
}
}
internal uint DirectValue
{
get
{
return *valuePtr;
}
}
public uint Value
{
get
@@ -118,6 +74,60 @@ namespace System
*valuePtr = value;
}
}
internal uint DirectValue
{
get
{
return *valuePtr;
}
}
public static glHandle Alloc(uint value)
{
glHandle ret = default;
ret.source = new glHandleSet(1);
ret.valuePtr = ret.source.handle;
*ret.valuePtr = value;
return ret;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static glHandle Alloc(IntPtr handle)
{
return new glHandle(handle);
}
}
public unsafe struct glSHandle
{
internal glHandleSet source;
internal int* valuePtr;
internal glSHandle(int* val, glHandleSet set)
{
source = set;
valuePtr = val;
}
public static glSHandle Zero
{
get { return Alloc(1); }
}
internal int DirectValue
{
get { return *valuePtr; }
}
public static glSHandle Alloc(int value)
{
glSHandle ret = default;
ret.source = new glHandleSet(1);
ret.valuePtr = (int*)ret.source.handle;
*ret.valuePtr = (int)value;
return ret;
}
}
/// <summary>
@@ -125,24 +135,15 @@ namespace System
/// </summary>
public unsafe class glHandleSet
{
private readonly uint[] _value;
internal int length;
internal uint* handle;
internal int length;
private readonly uint[] _value;
public static void Copy(in glHandleSet source, glHandleSet target)
public glHandleSet(int count)
{
if (source == null || target == null)
{
throw new NullReferenceException();
}
if (source.length != target.length)
{
throw new Exception($"Lengths of {nameof(source)} and {nameof(target)} are not equal.");
}
for (int i = 0; i < source.length; i++)
{
target._value[i] = source._value[i];
}
_value = new uint[count];
length = count;
handle = (uint*)GCHandle.Alloc(_value, GCHandleType.Pinned).AddrOfPinnedObject();
}
public glHandle this[int index]
@@ -169,17 +170,20 @@ namespace System
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetValue(int index, uint value)
public static void Copy(in glHandleSet source, glHandleSet target)
{
_value[index] = value;
}
public glHandleSet(int count)
{
_value = new uint[count];
length = count;
handle = (uint*)GCHandle.Alloc(_value, GCHandleType.Pinned).AddrOfPinnedObject();
if (source == null || target == null)
{
throw new NullReferenceException();
}
if (source.length != target.length)
{
throw new Exception($"Lengths of {nameof(source)} and {nameof(target)} are not equal.");
}
for (int i = 0; i < source.length; i++)
{
target._value[i] = source._value[i];
}
}
/// <summary>
@@ -207,7 +211,7 @@ namespace System
}
/// <summary>
/// Realse all resource in this handle.
/// Realse all resource in this handle.
/// This will release all resource in this <see cref="glHandle"/>.
/// This <see langword="glHandle"/> will be not usable.
/// </summary>
@@ -224,5 +228,10 @@ namespace System
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetValue(int index, uint value)
{
_value[index] = value;
}
}
}
}