daily update on 20240207 by nitload youmu

This commit is contained in:
Nitload
2024-02-07 13:47:12 +08:00
parent 8548757bbf
commit 6fe6b3b3cf
37 changed files with 231 additions and 196 deletions
+42 -3
View File
@@ -21,20 +21,57 @@ namespace System
public unsafe struct glHandle
{
internal uint* valuePtr;
internal glHandleSet source;
public glHandle()
{
throw new InvalidOperationException();
}
internal glHandle(uint* val)
public static glHandle Alloc(uint value)
{
glHandle ret = default;
ret.source = new glHandleSet(1);
*ret.valuePtr = value;
return ret;
}
internal glHandle(uint* val, glHandleSet set)
{
source = set;
valuePtr = val;
}
public IntPtr Handle
{
get
{
if (source.handle == (uint*)0)
{
throw new InvalidOperationException($"Handle set {nameof(source)} is not pinned.");
}
return (IntPtr)valuePtr;
}
}
public uint Value
{
get { return *valuePtr; }
get
{
if (source.handle == (uint*)0)
{
throw new InvalidOperationException($"Handle set {nameof(source)} is not pinned.");
}
return *valuePtr;
}
set
{
if (source.handle == (uint*)0)
{
throw new InvalidOperationException($"Handle set {nameof(source)} is not pinned.");
}
*valuePtr = value;
}
}
}
@@ -56,10 +93,11 @@ namespace System
{
throw new IndexOutOfRangeException();
}
return new glHandle(handle + index);
return new glHandle(handle + index, this);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetValue(int index, uint value)
{
@@ -85,6 +123,7 @@ namespace System
}
GCHandle h = GCHandle.FromIntPtr((IntPtr)handle);
h.Free();
handle = (uint*)0;
}
public void Pin()