diff --git a/StgSharp.Common/Collections/NotEnumerableList.cs b/StgSharp.Common/Collections/NotEnumerableList.cs index 0cf0f77a..43b7732a 100644 --- a/StgSharp.Common/Collections/NotEnumerableList.cs +++ b/StgSharp.Common/Collections/NotEnumerableList.cs @@ -30,20 +30,37 @@ using System.Runtime.CompilerServices; namespace StgSharp.Collections { - public sealed class NotEnumerableList(int capacity = 4) + public static class LinearBagBuilder + { + + public static LinearBag FromSpan(ReadOnlySpan values) + { + if (values.IsEmpty || values.Length == 0) { + return new LinearBag(4); + } + LinearBag bag = new(values.Length); + for (int i = 0; i < values.Length; i++) { + bag.Add(values[i]); + } + return bag; + } + + } + + [CollectionBuilder(typeof(LinearBagBuilder), nameof(LinearBagBuilder.FromSpan))] + public class LinearBag(int capacity = 4) { private T[] _items = new T[capacity]; - private int _size = 0; public T this[int index] { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => (uint)index >= (uint)_size ? throw new ArgumentOutOfRangeException(nameof(index)) : _items[index]; + get => (uint)index >= (uint)Count ? throw new ArgumentOutOfRangeException(nameof(index)) : _items[index]; [MethodImpl(MethodImplOptions.AggressiveInlining)] set { - if ((uint)index >= (uint)_size) { + if ((uint)index >= (uint)Count) { throw new ArgumentOutOfRangeException(nameof(index)); } @@ -51,31 +68,67 @@ namespace StgSharp.Collections } } - public int Count => _size; - public int Capacity => _items.Length; + public int Count { get; private set; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Add(T item) { - if (_size == _items.Length) { - EnsureCapacity(_size + 1); + if (Count == _items.Length) { + EnsureCapacity(Count + 1); } - _items[_size++] = item; + _items[Count++] = item; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Span AsSpan() { - return new Span(_items, 0, _size); + return new Span(_items, 0, Count); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Clear() + { + Array.Clear(_items, 0, Count); + Count = 0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void FastClear() { // 只重置size,不清理数组内容 - _size = 0; + Count = 0; + } + + public void Remove(T value) + { + for (int i = 0; i < Count; i++) + { + if (_items[i]?.Equals(value) ?? false) + { + RemoveAt(i); + return; + } + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void RemoveAt(int index) + { + if ((uint)index >= (uint)Count) { + throw new ArgumentOutOfRangeException(nameof(index)); + } + + int last = Count - 1; + if (index != last) + { + _items[index] = _items[last]; // swap back from tail + } + + _items[last] = default!; // clear last slot to avoid ref retention + Count = last; } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/StgSharp.Common/Controlling/KeyEnum.cs b/StgSharp.Common/Controlling/KeyEnum.cs index d36d2ded..5ae32daa 100644 --- a/StgSharp.Common/Controlling/KeyEnum.cs +++ b/StgSharp.Common/Controlling/KeyEnum.cs @@ -2,8 +2,8 @@ // ----------------------------------------------------------------------- // file="KeyEnum" // Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// AuthorGroup: Nitload +// Copyright (c) Nitload. 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 @@ -171,22 +171,22 @@ namespace StgSharp #pragma warning restore CA1027 { - Joystick_1 = Constant.GLFW_JOYSTICK_1, - Joystick_2 = Constant.GLFW_JOYSTICK_2, - Joystick_3 = Constant.GLFW_JOYSTICK_3, - Joystick_4 = Constant.GLFW_JOYSTICK_4, - Joystick_5 = Constant.GLFW_JOYSTICK_5, - Joystick_6 = Constant.GLFW_JOYSTICK_6, - Joystick_7 = Constant.GLFW_JOYSTICK_7, - Joystick_8 = Constant.GLFW_JOYSTICK_8, - Joystick_9 = Constant.GLFW_JOYSTICK_9, - Joystick_10 = Constant.GLFW_JOYSTICK_10, - Joystick_11 = Constant.GLFW_JOYSTICK_11, - Joystick_12 = Constant.GLFW_JOYSTICK_12, - Joystick_13 = Constant.GLFW_JOYSTICK_13, - Joystick_14 = Constant.GLFW_JOYSTICK_14, - Joystick_15 = Constant.GLFW_JOYSTICK_15, - Joystick_16 = Constant.GLFW_JOYSTICK_16, + Joystick_1 = FrameworkConstant.GLFW_JOYSTICK_1, + Joystick_2 = FrameworkConstant.GLFW_JOYSTICK_2, + Joystick_3 = FrameworkConstant.GLFW_JOYSTICK_3, + Joystick_4 = FrameworkConstant.GLFW_JOYSTICK_4, + Joystick_5 = FrameworkConstant.GLFW_JOYSTICK_5, + Joystick_6 = FrameworkConstant.GLFW_JOYSTICK_6, + Joystick_7 = FrameworkConstant.GLFW_JOYSTICK_7, + Joystick_8 = FrameworkConstant.GLFW_JOYSTICK_8, + Joystick_9 = FrameworkConstant.GLFW_JOYSTICK_9, + Joystick_10 = FrameworkConstant.GLFW_JOYSTICK_10, + Joystick_11 = FrameworkConstant.GLFW_JOYSTICK_11, + Joystick_12 = FrameworkConstant.GLFW_JOYSTICK_12, + Joystick_13 = FrameworkConstant.GLFW_JOYSTICK_13, + Joystick_14 = FrameworkConstant.GLFW_JOYSTICK_14, + Joystick_15 = FrameworkConstant.GLFW_JOYSTICK_15, + Joystick_16 = FrameworkConstant.GLFW_JOYSTICK_16, First = Joystick_1, Last = Joystick_16 diff --git a/StgSharp.Common/Entities/BehaviorArgs.cs b/StgSharp.Common/Entities/BehaviorArgs.cs deleted file mode 100644 index 1f0c0aef..00000000 --- a/StgSharp.Common/Entities/BehaviorArgs.cs +++ /dev/null @@ -1,31 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="BehaviorArgs" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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. -// -// ----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -namespace StgSharp.Entities -{ - public abstract class BehaviorArgs { } -} diff --git a/StgSharp.Common/Entities/Enemy.cs b/StgSharp.Common/Entities/Enemy.cs deleted file mode 100644 index 04e2a429..00000000 --- a/StgSharp.Common/Entities/Enemy.cs +++ /dev/null @@ -1,50 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="Enemy" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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. -// -// ----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -namespace StgSharp.Entities -{ - public class Enemy : IEntity - { - - internal Launcher _awardLauncher; - internal Launcher _commonBulletLauncher; - internal Launcher _dieBulletLauncher; - public bool _selectalbe; - - public Launcher AwardLauncher { get; set; } - - public Launcher CommonBulletLauncher { get; set; } - - public Launcher DieBulletLauncher { get; set; } - - public override void OnRenderFrame() - { - CommonBulletLauncher.Launch(); - } - - } -} diff --git a/StgSharp.Common/Entities/EntityPartical.cs b/StgSharp.Common/Entities/EntityPartical.cs deleted file mode 100644 index 3c22673d..00000000 --- a/StgSharp.Common/Entities/EntityPartical.cs +++ /dev/null @@ -1,31 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="EntityPartical" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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. -// -// ----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -namespace StgSharp.Entities -{ - public abstract class EntityPartical : IEntity { } -} diff --git a/StgSharp.Common/Entities/IEntity.cs b/StgSharp.Common/Entities/IEntity.cs deleted file mode 100644 index e7ce6aab..00000000 --- a/StgSharp.Common/Entities/IEntity.cs +++ /dev/null @@ -1,90 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="IEntity" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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.Geometries; -using StgSharp.Mathematics; -using StgSharp.Mathematics.Graphic; - -using System; -using System.Collections.Generic; - -namespace StgSharp -{ - public abstract class IEntity - { - - protected uint _bornTick; - internal Func _movHandler; - internal LinkedList _collisionBox; - internal PlainGeometryCollisionSensor _collisionSensor; - internal Point _basePoint; - internal Point _pos; - internal Point _position; - internal string _texture; - - /// - /// X position of an enenmy entity - /// - public float X { get; set; } - - /// - /// Y position of an enemy entity - /// - public float Y { get; set; } - - public LinkedList CollisionBox - { - get => _collisionBox; - set => _collisionBox = value; - } - - /// - /// A sensor used for checking out if a bullet hit a player or something else - /// - public PlainGeometryCollisionSensor CollisionSensor - { - get => _collisionSensor; - set => _collisionSensor = value; - } - - public string TextureGL { get; set; } - - /// - /// A 2D vector presenting the position of an enemy entity, position can also be visited - /// by X, Y - /// - public Vec2 Location { get; } - - public abstract void OnRenderFrame(); - - public void SetLocation(Point p) - { - _pos = p; - } - - } -} \ No newline at end of file diff --git a/StgSharp.Common/Entities/Launcher.cs b/StgSharp.Common/Entities/Launcher.cs deleted file mode 100644 index 6f8b3f92..00000000 --- a/StgSharp.Common/Entities/Launcher.cs +++ /dev/null @@ -1,56 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="Launcher" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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.Entities; -using StgSharp.Mathematics; -using StgSharp.Mathematics.Graphic; - -namespace StgSharp -{ - public class Launcher where T: IEntity - { - - internal uint[] launchtick; //发射子弹的内部计时 - internal Counter _internalParameter; //发射器的内部计时器 - - internal EntityPartical _bulletSample; //发射的子弹类型 - /* - *用于发射其他的实体,主要是子弹 和 掉落物 - */ - - internal Vec2 _center; //发射器的参考位置,运动轨迹的方程应当基于这个参考点构建 - - public EntityPartical Bullet - { - get => _bulletSample; - set => _bulletSample = value; - } - - internal virtual void Launch() { } - - } -} diff --git a/StgSharp.Common/Entities/Partical.cs b/StgSharp.Common/Entities/Partical.cs deleted file mode 100644 index 8f5ed83f..00000000 --- a/StgSharp.Common/Entities/Partical.cs +++ /dev/null @@ -1,41 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="Partical" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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 System; - -namespace StgSharp -{ - public class Partical : IEntity - { - - public override void OnRenderFrame() - { - throw new NotImplementedException(); - } - - } -} diff --git a/StgSharp.Common/Entities/Player.cs b/StgSharp.Common/Entities/Player.cs deleted file mode 100644 index 691511ec..00000000 --- a/StgSharp.Common/Entities/Player.cs +++ /dev/null @@ -1,38 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="Player" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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. -// -// ----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -namespace StgSharp -{ - public abstract class Player : IEntity - { - - internal float _velocity; - - public float Velocity => _velocity; - - } -} diff --git a/StgSharp.Common/Environment/GlobalSetting.cs b/StgSharp.Common/Environment/GlobalSetting.cs index a4322542..2c68369b 100644 --- a/StgSharp.Common/Environment/GlobalSetting.cs +++ b/StgSharp.Common/Environment/GlobalSetting.cs @@ -44,7 +44,6 @@ namespace StgSharp private static byte[] _currentHash = []; private static bool _inited; - private static int _mainThreadID = -1; public static byte[] CurrentAssemblyHash { @@ -73,6 +72,8 @@ namespace StgSharp internal set => _mainThreadID = value; } + private static int _mainThreadID { get; set; } = -1; + /// /// CustomizeInit an instance of OpenGL program, This method should be called before any /// other World api. diff --git a/StgSharp.Common/Graphics/OpenGL/glClampf.cs b/StgSharp.Common/Environment/IStaticModule.cs similarity index 60% rename from StgSharp.Common/Graphics/OpenGL/glClampf.cs rename to StgSharp.Common/Environment/IStaticModule.cs index 9b4e39db..a2a19bda 100644 --- a/StgSharp.Common/Graphics/OpenGL/glClampf.cs +++ b/StgSharp.Common/Environment/IStaticModule.cs @@ -1,6 +1,6 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="glClampf" +// file="IStaticModule" // Project: StgSharp // AuthorGroup: Nitload // Copyright (c) Nitload. All rights reserved. @@ -26,64 +26,59 @@ // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- using System; +using System.Collections; using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -namespace StgSharp.Internal +namespace StgSharp { - /// - /// OpenGL numeric type. An IEEE-754 floating-point value, clamped to the range [0,1]. - /// - [StructLayout(LayoutKind.Sequential)] - public struct GLclampf + public interface IStaticModule { - public float value; + string ModuleName { get; } - public GLclampf(float a) - { - value = a; - } - - public static explicit operator float(GLclampf v) - { - return v.value; - } - - public static explicit operator GLclampf(float v) - { - return new GLclampf(v); - } + void InitializeModule(); } - /// - /// OpenGL numeric type. An IEEE-754 double precision floating-point value, clamped to the - /// range [0,1]. - /// - [StructLayout(LayoutKind.Sequential)] - public struct GLclampd + public class ModuleToInitializeCollection : IEnumerable, IStaticModule { - public double value; + private readonly List _modules = []; - public GLclampd(double a) + internal ModuleToInitializeCollection(World.Initializer i) { - value = a; + _modules.Add(i); } - public static explicit operator double(GLclampd v) + public IEnumerator GetEnumerator() { - return v.value; + return ((IEnumerable)_modules).GetEnumerator(); } - public static explicit operator GLclampd(double v) + public void InitializeModule() { - return new GLclampd(v); + foreach (IStaticModule module in _modules) { + module.InitializeModule(); + } } + public ModuleToInitializeCollection UseModule() where T: IStaticModule, new() + { + _modules.Add(new T()); + return this; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable)_modules).GetEnumerator(); + } + + void IStaticModule.InitializeModule() + { + throw new NotImplementedException(); + } + + string IStaticModule.ModuleName => "Module Initializer"; + } } diff --git a/StgSharp.Common/Environment/Monitors.cs b/StgSharp.Common/Environment/Monitors.cs index c8e9aec5..0c050c27 100644 --- a/StgSharp.Common/Environment/Monitors.cs +++ b/StgSharp.Common/Environment/Monitors.cs @@ -25,38 +25,32 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using StgSharp.Graphics; - using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace StgSharp { public static partial class World { - private static unsafe IntPtr[] monitorsArray = []; - public static unsafe IntPtr[] MonitorsHandleArray { get { - if (monitorsArray == null) + if (MonitorsArray == null) { int count = 0; - IntPtr* arrayhandle = GraphicFramework.glfwGetMonitors(&count); - monitorsArray = new IntPtr[count]; - Marshal.Copy((IntPtr)arrayhandle, monitorsArray, 0, count); - Marshal.FreeHGlobal((IntPtr)arrayhandle); + IntPtr* arrayHandle = GraphicFramework.glfwGetMonitors(&count); + MonitorsArray = new IntPtr[count]; + Marshal.Copy((IntPtr)arrayHandle, MonitorsArray, 0, count); + Marshal.FreeHGlobal((IntPtr)arrayHandle); } - return monitorsArray; + return MonitorsArray; } } + public static nint[] MonitorsArray { get; set; } = []; + public static IntPtr DefaultMonitor => MonitorsHandleArray[0]; } diff --git a/StgSharp.Common/Environment/Platform.cs b/StgSharp.Common/Environment/Platform.cs index 5b387757..04fba8af 100644 --- a/StgSharp.Common/Environment/Platform.cs +++ b/StgSharp.Common/Environment/Platform.cs @@ -65,26 +65,9 @@ namespace StgSharp _ => 8, }; - public static unsafe void Init() + public static ModuleToInitializeCollection Initialize() { - mainTimeProvider = new StgSharpTime(); - MainTimeProvider.StartProvidingTime(); - GraphicFramework.LoadGlfw(); - if (GraphicFramework.glfwInit() == 0) { - throw new Exception("Failed to init system graphic environment."); - } - DefaultLog.InternalAppendLog("\n\n\n"); - DefaultLog.InternalWriteLog( - $"Program {Assembly.GetEntryAssembly()!.FullName} on {Environment.MachineName} Started.", LogType.Info); - MainThreadID = Environment.CurrentManagedThreadId; - - - Dialogue.LoadDialogue(); - if (Dialogue.NeedShowWhenStartup) { - Dialogue.CreateDialogueProcessIfNotExist(); - } - - NativeIntrinsic.InitIntrinsicContext(); + return new ModuleToInitializeCollection(new Initializer()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -201,5 +184,40 @@ namespace StgSharp } } + internal static unsafe void InternalInitialize() + { + mainTimeProvider = new StgSharpTime(); + MainTimeProvider.StartProvidingTime(); + GraphicFramework.LoadGlfw(); + if (GraphicFramework.glfwInit() == 0) { + throw new Exception("Failed to init system graphic environment."); + } + DefaultLog.InternalAppendLog("\n\n\n"); + DefaultLog.InternalWriteLog( + $"Program {Assembly.GetEntryAssembly()!.FullName} on {Environment.MachineName} Started.", LogType.Info); + MainThreadID = System.Environment.CurrentManagedThreadId; + + + Dialogue.LoadDialogue(); + if (Dialogue.NeedShowWhenStartup) { + Dialogue.CreateDialogueProcessIfNotExist(); + } + + NativeIntrinsic.InitIntrinsicContext(); + } + + internal class Initializer : IStaticModule + { + + public string ModuleName => "StgSharp"; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void InitializeModule() + { + World.InternalInitialize(); + } + + } + } } \ No newline at end of file diff --git a/StgSharp.Common/Geometries/Coordination/CoordinationBase.cs b/StgSharp.Common/Geometries/Coordination/CoordinationBase.cs index 1bbb536e..9d36839c 100644 --- a/StgSharp.Common/Geometries/Coordination/CoordinationBase.cs +++ b/StgSharp.Common/Geometries/Coordination/CoordinationBase.cs @@ -46,26 +46,26 @@ namespace StgSharp.Geometries public virtual Point LocalOrigin { - get => new Point(coordMat.column3.XYZ); - internal set => coordMat.column3.XYZ = value.Coord; + get => new Point(coordMat.column[3].XYZ); + internal set => coordMat.column[3].XYZ = value.Coord; } public virtual Vec3 LocalX { - get => coordMat.column0.XYZ; - internal set => coordMat.column0.XYZ = value; + get => coordMat.column[3].XYZ; + internal set => coordMat.column[3].XYZ = value; } public virtual Vec3 LocalY { - get => coordMat.column1.XYZ; - internal set => coordMat.column1.XYZ = value; + get => coordMat.column[3].XYZ; + internal set => coordMat.column[3].XYZ = value; } public virtual Vec3 LocalZ { - get => coordMat.column2.XYZ; - set => coordMat.column2.XYZ = value; + get => coordMat.column[3].XYZ; + set => coordMat.column[3].XYZ = value; } protected ref Matrix44 CoordMat diff --git a/StgSharp.Common/Geometries/Coordination/PlainCoordinate.cs b/StgSharp.Common/Geometries/Coordination/PlainCoordinate.cs index 062f8f2d..3a482cb8 100644 --- a/StgSharp.Common/Geometries/Coordination/PlainCoordinate.cs +++ b/StgSharp.Common/Geometries/Coordination/PlainCoordinate.cs @@ -43,15 +43,15 @@ namespace StgSharp.Geometries { CoordMat = Matrix44.Unit; - CoordMat.column0 = new Vec4(xAxis, 0); - CoordMat.column1 = new Vec4(yAxis, 0); - CoordMat.column2 = new Vec4(Linear.Normalize(Vec3.Cross(xAxis, yAxis)), 0); + CoordMat.column[0] = new Vec4(xAxis, 0); + CoordMat.column[1] = new Vec4(yAxis, 0); + CoordMat.column[2] = new Vec4(Linear.Normalize(Vec3.Cross(xAxis, yAxis)), 0); LocalOrigin = origin; } - public static PlainCoordinate StandardPlainCoordination { get; } = new( - null, new Point(0, 0, 0), new Vec3(1, 0, 0), new Vec3(0, 1, 0)); + public static PlainCoordinate StandardPlainCoordination { get; } = new(null, new Point(0, 0, 0), + new Vec3(1, 0, 0), new Vec3(0, 1, 0)); } } diff --git a/StgSharp.Common/Graphics/Constant.cs b/StgSharp.Common/Graphics/Constant.cs deleted file mode 100644 index f6cef832..00000000 --- a/StgSharp.Common/Graphics/Constant.cs +++ /dev/null @@ -1,336 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="Constant" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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 System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StgSharp.Graphics -{ - public static class Constant - { - - #region glfw - - public const int GLFW_VERSION_MAJOR = 3; - public const int GLFW_VERSION_MINOR = 3; - public const int GLFW_VERSION_REVISION = 8; - public const int GLFW_TRUE = 1; - public const int GLFW_FALSE = 0; - public const int GLFW_RELEASE = 0; - public const int GLFW_PRESS = 1; - public const int GLFW_REPEAT = 2; - public const int GLFW_HAT_CENTERED = 0; - public const int GLFW_HAT_UP = 1; - public const int GLFW_HAT_RIGHT = 2; - public const int GLFW_HAT_DOWN = 4; - public const int GLFW_HAT_LEFT = 8; - public const int GLFW_HAT_RIGHT_UP = GLFW_HAT_RIGHT | GLFW_HAT_UP; - public const int GLFW_HAT_RIGHT_DOWN = GLFW_HAT_RIGHT | GLFW_HAT_DOWN; - public const int GLFW_HAT_LEFT_UP = GLFW_HAT_LEFT | GLFW_HAT_UP; - public const int GLFW_HAT_LEFT_DOWN = GLFW_HAT_LEFT | GLFW_HAT_DOWN; - public const int GLFW_KEY_UNKNOWN = -1; - public const int GLFW_KEY_SPACE = 32; - public const int GLFW_KEY_APOSTROPHE = 39; - public const int GLFW_KEY_COMMA = 44; - public const int GLFW_KEY_MINUS = 45; - public const int GLFW_KEY_PERIOD = 46; - public const int GLFW_KEY_SLASH = 47; - public const int GLFW_KEY_0 = 48; - public const int GLFW_KEY_1 = 49; - public const int GLFW_KEY_2 = 50; - public const int GLFW_KEY_3 = 51; - public const int GLFW_KEY_4 = 52; - public const int GLFW_KEY_5 = 53; - public const int GLFW_KEY_6 = 54; - public const int GLFW_KEY_7 = 55; - public const int GLFW_KEY_8 = 56; - public const int GLFW_KEY_9 = 57; - public const int GLFW_KEY_SEMICOLON = 59; - public const int GLFW_KEY_EQUAL = 61; - public const int GLFW_KEY_A = 65; - public const int GLFW_KEY_B = 66; - public const int GLFW_KEY_C = 67; - public const int GLFW_KEY_D = 68; - public const int GLFW_KEY_E = 69; - public const int GLFW_KEY_F = 70; - public const int GLFW_KEY_G = 71; - public const int GLFW_KEY_H = 72; - public const int GLFW_KEY_I = 73; - public const int GLFW_KEY_J = 74; - public const int GLFW_KEY_K = 75; - public const int GLFW_KEY_L = 76; - public const int GLFW_KEY_M = 77; - public const int GLFW_KEY_N = 78; - public const int GLFW_KEY_O = 79; - public const int GLFW_KEY_P = 80; - public const int GLFW_KEY_Q = 81; - public const int GLFW_KEY_R = 82; - public const int GLFW_KEY_S = 83; - public const int GLFW_KEY_T = 84; - public const int GLFW_KEY_U = 85; - public const int GLFW_KEY_V = 86; - public const int GLFW_KEY_W = 87; - public const int GLFW_KEY_X = 88; - public const int GLFW_KEY_Y = 89; - public const int GLFW_KEY_Z = 90; - public const int GLFW_KEY_LEFT_BRACKET = 91; - public const int GLFW_KEY_BACKSLASH = 92; - public const int GLFW_KEY_RIGHT_BRACKET = 93; - public const int GLFW_KEY_GRAVE_ACCENT = 96; - public const int GLFW_KEY_WORLD_1 = 161; - public const int GLFW_KEY_WORLD_2 = 162; - public const int GLFW_KEY_ESCAPE = 256; - public const int GLFW_KEY_ENTER = 257; - public const int GLFW_KEY_TAB = 258; - public const int GLFW_KEY_BACKSPACE = 259; - public const int GLFW_KEY_INSERT = 260; - public const int GLFW_KEY_DELETE = 261; - public const int GLFW_KEY_RIGHT = 262; - public const int GLFW_KEY_LEFT = 263; - public const int GLFW_KEY_DOWN = 264; - public const int GLFW_KEY_UP = 265; - public const int GLFW_KEY_PAGE_UP = 266; - public const int GLFW_KEY_PAGE_DOWN = 267; - public const int GLFW_KEY_HOME = 268; - public const int GLFW_KEY_END = 269; - public const int GLFW_KEY_CAPS_LOCK = 280; - public const int GLFW_KEY_SCROLL_LOCK = 281; - public const int GLFW_KEY_NUM_LOCK = 282; - public const int GLFW_KEY_PRINT_SCREEN = 283; - public const int GLFW_KEY_PAUSE = 284; - public const int GLFW_KEY_F1 = 290; - public const int GLFW_KEY_F2 = 291; - public const int GLFW_KEY_F3 = 292; - public const int GLFW_KEY_F4 = 293; - public const int GLFW_KEY_F5 = 294; - public const int GLFW_KEY_F6 = 295; - public const int GLFW_KEY_F7 = 296; - public const int GLFW_KEY_F8 = 297; - public const int GLFW_KEY_F9 = 298; - public const int GLFW_KEY_F10 = 299; - public const int GLFW_KEY_F11 = 300; - public const int GLFW_KEY_F12 = 301; - public const int GLFW_KEY_F13 = 302; - public const int GLFW_KEY_F14 = 303; - public const int GLFW_KEY_F15 = 304; - public const int GLFW_KEY_F16 = 305; - public const int GLFW_KEY_F17 = 306; - public const int GLFW_KEY_F18 = 307; - public const int GLFW_KEY_F19 = 308; - public const int GLFW_KEY_F20 = 309; - public const int GLFW_KEY_F21 = 310; - public const int GLFW_KEY_F22 = 311; - public const int GLFW_KEY_F23 = 312; - public const int GLFW_KEY_F24 = 313; - public const int GLFW_KEY_F25 = 314; - public const int GLFW_KEY_KP_0 = 320; - public const int GLFW_KEY_KP_1 = 321; - public const int GLFW_KEY_KP_2 = 322; - public const int GLFW_KEY_KP_3 = 323; - public const int GLFW_KEY_KP_4 = 324; - public const int GLFW_KEY_KP_5 = 325; - public const int GLFW_KEY_KP_6 = 326; - public const int GLFW_KEY_KP_7 = 327; - public const int GLFW_KEY_KP_8 = 328; - public const int GLFW_KEY_KP_9 = 329; - public const int GLFW_KEY_KP_DECIMAL = 330; - public const int GLFW_KEY_KP_DIVIDE = 331; - public const int GLFW_KEY_KP_MULTIPLY = 332; - public const int GLFW_KEY_KP_SUBTRACT = 333; - public const int GLFW_KEY_KP_ADD = 334; - public const int GLFW_KEY_KP_ENTER = 335; - public const int GLFW_KEY_KP_EQUAL = 336; - public const int GLFW_KEY_LEFT_SHIFT = 340; - public const int GLFW_KEY_LEFT_CONTROL = 341; - public const int GLFW_KEY_LEFT_ALT = 342; - public const int GLFW_KEY_LEFT_SUPER = 343; - public const int GLFW_KEY_RIGHT_SHIFT = 344; - public const int GLFW_KEY_RIGHT_CONTROL = 345; - public const int GLFW_KEY_RIGHT_ALT = 346; - public const int GLFW_KEY_RIGHT_SUPER = 347; - public const int GLFW_KEY_MENU = 348; - public const int GLFW_KEY_LAST = GLFW_KEY_MENU; - public const int GLFW_MOD_SHIFT = 0x0001; - public const int GLFW_MOD_CONTROL = 0x0002; - public const int GLFW_MOD_ALT = 0x0004; - public const int GLFW_MOD_SUPER = 0x0008; - public const int GLFW_MOD_CAPS_LOCK = 0x0010; - public const int GLFW_MOD_NUM_LOCK = 0x0020; - public const int GLFW_MOUSE_BUTTON_1 = 0; - public const int GLFW_MOUSE_BUTTON_2 = 1; - public const int GLFW_MOUSE_BUTTON_3 = 2; - public const int GLFW_MOUSE_BUTTON_4 = 3; - public const int GLFW_MOUSE_BUTTON_5 = 4; - public const int GLFW_MOUSE_BUTTON_6 = 5; - public const int GLFW_MOUSE_BUTTON_7 = 6; - public const int GLFW_MOUSE_BUTTON_8 = 7; - public const int GLFW_MOUSE_BUTTON_LAST = GLFW_MOUSE_BUTTON_8; - public const int GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1; - public const int GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2; - public const int GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3; - public const int GLFW_JOYSTICK_1 = 0; - public const int GLFW_JOYSTICK_2 = 1; - public const int GLFW_JOYSTICK_3 = 2; - public const int GLFW_JOYSTICK_4 = 3; - public const int GLFW_JOYSTICK_5 = 4; - public const int GLFW_JOYSTICK_6 = 5; - public const int GLFW_JOYSTICK_7 = 6; - public const int GLFW_JOYSTICK_8 = 7; - public const int GLFW_JOYSTICK_9 = 8; - public const int GLFW_JOYSTICK_10 = 9; - public const int GLFW_JOYSTICK_11 = 10; - public const int GLFW_JOYSTICK_12 = 11; - public const int GLFW_JOYSTICK_13 = 12; - public const int GLFW_JOYSTICK_14 = 13; - public const int GLFW_JOYSTICK_15 = 14; - public const int GLFW_JOYSTICK_16 = 15; - public const int GLFW_JOYSTICK_LAST = GLFW_JOYSTICK_16; - public const int GLFW_GAMEPAD_BUTTON_A = 0; - public const int GLFW_GAMEPAD_BUTTON_B = 1; - public const int GLFW_GAMEPAD_BUTTON_X = 2; - public const int GLFW_GAMEPAD_BUTTON_Y = 3; - public const int GLFW_GAMEPAD_BUTTON_LEFT_BUMPER = 4; - public const int GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER = 5; - public const int GLFW_GAMEPAD_BUTTON_BACK = 6; - public const int GLFW_GAMEPAD_BUTTON_START = 7; - public const int GLFW_GAMEPAD_BUTTON_GUIDE = 8; - public const int GLFW_GAMEPAD_BUTTON_LEFT_THUMB = 9; - public const int GLFW_GAMEPAD_BUTTON_RIGHT_THUMB = 10; - public const int GLFW_GAMEPAD_BUTTON_DPAD_UP = 11; - public const int GLFW_GAMEPAD_BUTTON_DPAD_RIGHT = 12; - public const int GLFW_GAMEPAD_BUTTON_DPAD_DOWN = 13; - public const int GLFW_GAMEPAD_BUTTON_DPAD_LEFT = 14; - public const int GLFW_GAMEPAD_BUTTON_LAST = GLFW_GAMEPAD_BUTTON_DPAD_LEFT; - public const int GLFW_GAMEPAD_BUTTON_CROSS = GLFW_GAMEPAD_BUTTON_A; - public const int GLFW_GAMEPAD_BUTTON_CIRCLE = GLFW_GAMEPAD_BUTTON_B; - public const int GLFW_GAMEPAD_BUTTON_SQUARE = GLFW_GAMEPAD_BUTTON_X; - public const int GLFW_GAMEPAD_BUTTON_TRIANGLE = GLFW_GAMEPAD_BUTTON_Y; - public const int GLFW_GAMEPAD_AXIS_LEFT_X = 0; - public const int GLFW_GAMEPAD_AXIS_LEFT_Y = 1; - public const int GLFW_GAMEPAD_AXIS_RIGHT_X = 2; - public const int GLFW_GAMEPAD_AXIS_RIGHT_Y = 3; - public const int GLFW_GAMEPAD_AXIS_LEFT_TRIGGER = 4; - public const int GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER = 5; - public const int GLFW_GAMEPAD_AXIS_LAST = GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER; - public const int GLFW_NO_ERROR = 0; - public const int GLFW_NOT_INITIALIZED = 0x00010001; - public const int GLFW_NO_CURRENT_CONTEXT = 0x00010002; - public const int GLFW_INVALID_ENUM = 0x00010003; - public const int GLFW_INVALID_VALUE = 0x00010004; - public const int GLFW_OUT_OF_MEMORY = 0x00010005; - public const int GLFW_API_UNAVAILABLE = 0x00010006; - public const int GLFW_VERSION_UNAVAILABLE = 0x00010007; - public const int GLFW_PLATFORM_ERROR = 0x00010008; - public const int GLFW_FORMAT_UNAVAILABLE = 0x00010009; - public const int GLFW_NO_WINDOW_CONTEXT = 0x0001000A; - public const int GLFW_FOCUSED = 0x00020001; - public const int GLFW_ICONIFIED = 0x00020002; - public const int GLFW_RESIZABLE = 0x00020003; - public const int GLFW_VISIBLE = 0x00020004; - public const int GLFW_DECORATED = 0x00020005; - public const int GLFW_AUTO_ICONIFY = 0x00020006; - public const int GLFW_FLOATING = 0x00020007; - public const int GLFW_MAXIMIZED = 0x00020008; - public const int GLFW_CENTER_CURSOR = 0x00020009; - public const int GLFW_TRANSPARENT_FRAMEBUFFER = 0x0002000A; - public const int GLFW_HOVERED = 0x0002000B; - public const int GLFW_FOCUS_ON_SHOW = 0x0002000C; - public const int GLFW_RED_BITS = 0x00021001; - public const int GLFW_GREEN_BITS = 0x00021002; - public const int GLFW_BLUE_BITS = 0x00021003; - public const int GLFW_ALPHA_BITS = 0x00021004; - public const int GLFW_DEPTH_BITS = 0x00021005; - public const int GLFW_STENCIL_BITS = 0x00021006; - public const int GLFW_ACCUM_RED_BITS = 0x00021007; - public const int GLFW_ACCUM_GREEN_BITS = 0x00021008; - public const int GLFW_ACCUM_BLUE_BITS = 0x00021009; - public const int GLFW_ACCUM_ALPHA_BITS = 0x0002100A; - public const int GLFW_AUX_BUFFERS = 0x0002100B; - public const int GLFW_STEREO = 0x0002100C; - public const int GLFW_SAMPLES = 0x0002100D; - public const int GLFW_SRGB_CAPABLE = 0x0002100E; - public const int GLFW_REFRESH_RATE = 0x0002100F; - public const int GLFW_DOUBLEBUFFER = 0x00021010; - public const int GLFW_CLIENT_API = 0x00022001; - public const int GLFW_CONTEXT_VERSION_MAJOR = 0x00022002; - public const int GLFW_CONTEXT_VERSION_MINOR = 0x00022003; - public const int GLFW_CONTEXT_REVISION = 0x00022004; - public const int GLFW_CONTEXT_ROBUSTNESS = 0x00022005; - public const int GLFW_OPENGL_FORWARD_COMPAT = 0x00022006; - public const int GLFW_OPENGL_DEBUG_CONTEXT = 0x00022007; - public const int GLFW_OPENGL_PROFILE = 0x00022008; - public const int GLFW_CONTEXT_RELEASE_BEHAVIOR = 0x00022009; - public const int GLFW_CONTEXT_NO_ERROR = 0x0002200A; - public const int GLFW_CONTEXT_CREATION_API = 0x0002200B; - public const int GLFW_SCALE_TO_MONITOR = 0x0002200C; - public const int GLFW_COCOA_RETINA_FRAMEBUFFER = 0x00023001; - public const int GLFW_COCOA_FRAME_NAME = 0x00023002; - public const int GLFW_COCOA_GRAPHICS_SWITCHING = 0x00023003; - public const int GLFW_X11_CLASS_NAME = 0x00024001; - public const int GLFW_X11_INSTANCE_NAME = 0x00024002; - public const int GLFW_NO_API = 0; - public const int GLFW_OPENGL_API = 0x00030001; - public const int GLFW_OPENGL_ES_API = 0x00030002; - public const int GLFW_NO_ROBUSTNESS = 0; - public const int GLFW_NO_RESET_NOTIFICATION = 0x00031001; - public const int GLFW_LOSE_CONTEXT_ON_RESET = 0x00031002; - public const int GLFW_OPENGL_ANY_PROFILE = 0; - public const int GLFW_OPENGL_CORE_PROFILE = 0x00032001; - public const int GLFW_OPENGL_COMPAT_PROFILE = 0x00032002; - public const int GLFW_CURSOR = 0x00033001; - public const int GLFW_STICKY_KEYS = 0x00033002; - public const int GLFW_STICKY_MOUSE_BUTTONS = 0x00033003; - public const int GLFW_LOCK_KEY_MODS = 0x00033004; - public const int GLFW_RAW_MOUSE_MOTION = 0x00033005; - public const int GLFW_CURSOR_NORMAL = 0x00034001; - public const int GLFW_CURSOR_HIDDEN = 0x00034002; - public const int GLFW_CURSOR_DISABLED = 0x00034003; - public const int GLFW_ANY_RELEASE_BEHAVIOR = 0; - public const int GLFW_RELEASE_BEHAVIOR_FLUSH = 0x00035001; - public const int GLFW_RELEASE_BEHAVIOR_NONE = 0x00035002; - public const int GLFW_NATIVE_CONTEXT_API = 0x00036001; - public const int GLFW_EGL_CONTEXT_API = 0x00036002; - public const int GLFW_OSMESA_CONTEXT_API = 0x00036003; - public const int GLFW_ARROW_CURSOR = 0x00036001; - public const int GLFW_IBEAM_CURSOR = 0x00036002; - public const int GLFW_CROSSHAIR_CURSOR = 0x00036003; - public const int GLFW_HAND_CURSOR = 0x00036004; - public const int GLFW_HRESIZE_CURSOR = 0x00036005; - public const int GLFW_VRESIZE_CURSOR = 0x00036006; - public const int GLFW_CONNECTED = 0x00040001; - public const int GLFW_DISCONNECTED = 0x00040002; - public const int GLFW_JOYSTICK_HAT_BUTTONS = 0x00050001; - public const int GLFW_COCOA_CHDIR_RESOURCES = 0x00051001; - public const int GLFW_COCOA_MENUBAR = 0x00051002; - public const int GLFW_DONT_CARE = -1; - - #endregion - } -} diff --git a/StgSharp.Common/Graphics/Define/BufferObjectBase.cs b/StgSharp.Common/Graphics/Define/BufferObjectBase.cs index 5d65f090..54ad2d78 100644 --- a/StgSharp.Common/Graphics/Define/BufferObjectBase.cs +++ b/StgSharp.Common/Graphics/Define/BufferObjectBase.cs @@ -25,8 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using StgSharp.Graphics.OpenGL; - +using StgSharp.Graphics; using System; using System.Collections.Generic; using System.Linq; diff --git a/StgSharp.Common/Graphics/FrameworkConstant.cs b/StgSharp.Common/Graphics/FrameworkConstant.cs new file mode 100644 index 00000000..2cc3d08a --- /dev/null +++ b/StgSharp.Common/Graphics/FrameworkConstant.cs @@ -0,0 +1,336 @@ +//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// file="FrameworkConstant" +// Project: StgSharp +// AuthorGroup: Nitload +// Copyright (c) Nitload. 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 System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StgSharp.Graphics +{ + public static class FrameworkConstant + { + + #region glfw + + public const int VERSION_MAJOR = 3; + public const int VERSION_MINOR = 3; + public const int VERSION_REVISION = 8; + public const int TRUE = 1; + public const int FALSE = 0; + public const int RELEASE = 0; + public const int PRESS = 1; + public const int REPEAT = 2; + public const int HAT_CENTERED = 0; + public const int HAT_UP = 1; + public const int HAT_RIGHT = 2; + public const int HAT_DOWN = 4; + public const int HAT_LEFT = 8; + public const int HAT_RIGHT_UP = HAT_RIGHT | HAT_UP; + public const int HAT_RIGHT_DOWN = HAT_RIGHT | HAT_DOWN; + public const int HAT_LEFT_UP = HAT_LEFT | HAT_UP; + public const int HAT_LEFT_DOWN = HAT_LEFT | HAT_DOWN; + public const int KEY_UNKNOWN = -1; + public const int KEY_SPACE = 32; + public const int KEY_APOSTROPHE = 39; + public const int KEY_COMMA = 44; + public const int KEY_MINUS = 45; + public const int KEY_PERIOD = 46; + public const int KEY_SLASH = 47; + public const int KEY_0 = 48; + public const int KEY_1 = 49; + public const int KEY_2 = 50; + public const int KEY_3 = 51; + public const int KEY_4 = 52; + public const int KEY_5 = 53; + public const int KEY_6 = 54; + public const int KEY_7 = 55; + public const int KEY_8 = 56; + public const int KEY_9 = 57; + public const int KEY_SEMICOLON = 59; + public const int KEY_EQUAL = 61; + public const int KEY_A = 65; + public const int KEY_B = 66; + public const int KEY_C = 67; + public const int KEY_D = 68; + public const int KEY_E = 69; + public const int KEY_F = 70; + public const int KEY_G = 71; + public const int KEY_H = 72; + public const int KEY_I = 73; + public const int KEY_J = 74; + public const int KEY_K = 75; + public const int KEY_L = 76; + public const int KEY_M = 77; + public const int KEY_N = 78; + public const int KEY_O = 79; + public const int KEY_P = 80; + public const int KEY_Q = 81; + public const int KEY_R = 82; + public const int KEY_S = 83; + public const int KEY_T = 84; + public const int KEY_U = 85; + public const int KEY_V = 86; + public const int KEY_W = 87; + public const int KEY_X = 88; + public const int KEY_Y = 89; + public const int KEY_Z = 90; + public const int KEY_LEFT_BRACKET = 91; + public const int KEY_BACKSLASH = 92; + public const int KEY_RIGHT_BRACKET = 93; + public const int KEY_GRAVE_ACCENT = 96; + public const int KEY_WORLD_1 = 161; + public const int KEY_WORLD_2 = 162; + public const int KEY_ESCAPE = 256; + public const int KEY_ENTER = 257; + public const int KEY_TAB = 258; + public const int KEY_BACKSPACE = 259; + public const int KEY_INSERT = 260; + public const int KEY_DELETE = 261; + public const int KEY_RIGHT = 262; + public const int KEY_LEFT = 263; + public const int KEY_DOWN = 264; + public const int KEY_UP = 265; + public const int KEY_PAGE_UP = 266; + public const int KEY_PAGE_DOWN = 267; + public const int KEY_HOME = 268; + public const int KEY_END = 269; + public const int KEY_CAPS_LOCK = 280; + public const int KEY_SCROLL_LOCK = 281; + public const int KEY_NUM_LOCK = 282; + public const int KEY_PRINT_SCREEN = 283; + public const int KEY_PAUSE = 284; + public const int KEY_F1 = 290; + public const int KEY_F2 = 291; + public const int KEY_F3 = 292; + public const int KEY_F4 = 293; + public const int KEY_F5 = 294; + public const int KEY_F6 = 295; + public const int KEY_F7 = 296; + public const int KEY_F8 = 297; + public const int KEY_F9 = 298; + public const int KEY_F10 = 299; + public const int KEY_F11 = 300; + public const int KEY_F12 = 301; + public const int KEY_F13 = 302; + public const int KEY_F14 = 303; + public const int KEY_F15 = 304; + public const int KEY_F16 = 305; + public const int KEY_F17 = 306; + public const int KEY_F18 = 307; + public const int KEY_F19 = 308; + public const int KEY_F20 = 309; + public const int KEY_F21 = 310; + public const int KEY_F22 = 311; + public const int KEY_F23 = 312; + public const int KEY_F24 = 313; + public const int KEY_F25 = 314; + public const int KEY_KP_0 = 320; + public const int KEY_KP_1 = 321; + public const int KEY_KP_2 = 322; + public const int KEY_KP_3 = 323; + public const int KEY_KP_4 = 324; + public const int KEY_KP_5 = 325; + public const int KEY_KP_6 = 326; + public const int KEY_KP_7 = 327; + public const int KEY_KP_8 = 328; + public const int KEY_KP_9 = 329; + public const int KEY_KP_DECIMAL = 330; + public const int KEY_KP_DIVIDE = 331; + public const int KEY_KP_MULTIPLY = 332; + public const int KEY_KP_SUBTRACT = 333; + public const int KEY_KP_ADD = 334; + public const int KEY_KP_ENTER = 335; + public const int KEY_KP_EQUAL = 336; + public const int KEY_LEFT_SHIFT = 340; + public const int KEY_LEFT_CONTROL = 341; + public const int KEY_LEFT_ALT = 342; + public const int KEY_LEFT_SUPER = 343; + public const int KEY_RIGHT_SHIFT = 344; + public const int KEY_RIGHT_CONTROL = 345; + public const int KEY_RIGHT_ALT = 346; + public const int KEY_RIGHT_SUPER = 347; + public const int KEY_MENU = 348; + public const int KEY_LAST = KEY_MENU; + public const int MOD_SHIFT = 0x0001; + public const int MOD_CONTROL = 0x0002; + public const int MOD_ALT = 0x0004; + public const int MOD_SUPER = 0x0008; + public const int MOD_CAPS_LOCK = 0x0010; + public const int MOD_NUM_LOCK = 0x0020; + public const int MOUSE_BUTTON_1 = 0; + public const int MOUSE_BUTTON_2 = 1; + public const int MOUSE_BUTTON_3 = 2; + public const int MOUSE_BUTTON_4 = 3; + public const int MOUSE_BUTTON_5 = 4; + public const int MOUSE_BUTTON_6 = 5; + public const int MOUSE_BUTTON_7 = 6; + public const int MOUSE_BUTTON_8 = 7; + public const int MOUSE_BUTTON_LAST = MOUSE_BUTTON_8; + public const int MOUSE_BUTTON_LEFT = MOUSE_BUTTON_1; + public const int MOUSE_BUTTON_RIGHT = MOUSE_BUTTON_2; + public const int MOUSE_BUTTON_MIDDLE = MOUSE_BUTTON_3; + public const int JOYSTICK_1 = 0; + public const int JOYSTICK_2 = 1; + public const int JOYSTICK_3 = 2; + public const int JOYSTICK_4 = 3; + public const int JOYSTICK_5 = 4; + public const int JOYSTICK_6 = 5; + public const int JOYSTICK_7 = 6; + public const int JOYSTICK_8 = 7; + public const int JOYSTICK_9 = 8; + public const int JOYSTICK_10 = 9; + public const int JOYSTICK_11 = 10; + public const int JOYSTICK_12 = 11; + public const int JOYSTICK_13 = 12; + public const int JOYSTICK_14 = 13; + public const int JOYSTICK_15 = 14; + public const int JOYSTICK_16 = 15; + public const int JOYSTICK_LAST = JOYSTICK_16; + public const int GAMEPAD_BUTTON_A = 0; + public const int GAMEPAD_BUTTON_B = 1; + public const int GAMEPAD_BUTTON_X = 2; + public const int GAMEPAD_BUTTON_Y = 3; + public const int GAMEPAD_BUTTON_LEFT_BUMPER = 4; + public const int GAMEPAD_BUTTON_RIGHT_BUMPER = 5; + public const int GAMEPAD_BUTTON_BACK = 6; + public const int GAMEPAD_BUTTON_START = 7; + public const int GAMEPAD_BUTTON_GUIDE = 8; + public const int GAMEPAD_BUTTON_LEFT_THUMB = 9; + public const int GAMEPAD_BUTTON_RIGHT_THUMB = 10; + public const int GAMEPAD_BUTTON_DPAD_UP = 11; + public const int GAMEPAD_BUTTON_DPAD_RIGHT = 12; + public const int GAMEPAD_BUTTON_DPAD_DOWN = 13; + public const int GAMEPAD_BUTTON_DPAD_LEFT = 14; + public const int GAMEPAD_BUTTON_LAST = GAMEPAD_BUTTON_DPAD_LEFT; + public const int GAMEPAD_BUTTON_CROSS = GAMEPAD_BUTTON_A; + public const int GAMEPAD_BUTTON_CIRCLE = GAMEPAD_BUTTON_B; + public const int GAMEPAD_BUTTON_SQUARE = GAMEPAD_BUTTON_X; + public const int GAMEPAD_BUTTON_TRIANGLE = GAMEPAD_BUTTON_Y; + public const int GAMEPAD_AXIS_LEFT_X = 0; + public const int GAMEPAD_AXIS_LEFT_Y = 1; + public const int GAMEPAD_AXIS_RIGHT_X = 2; + public const int GAMEPAD_AXIS_RIGHT_Y = 3; + public const int GAMEPAD_AXIS_LEFT_TRIGGER = 4; + public const int GAMEPAD_AXIS_RIGHT_TRIGGER = 5; + public const int GAMEPAD_AXIS_LAST = GAMEPAD_AXIS_RIGHT_TRIGGER; + public const int NO_ERROR = 0; + public const int NOT_INITIALIZED = 0x00010001; + public const int NO_CURRENT_CONTEXT = 0x00010002; + public const int INVALID_ENUM = 0x00010003; + public const int INVALID_VALUE = 0x00010004; + public const int OUT_OF_MEMORY = 0x00010005; + public const int API_UNAVAILABLE = 0x00010006; + public const int VERSION_UNAVAILABLE = 0x00010007; + public const int PLATFORM_ERROR = 0x00010008; + public const int FORMAT_UNAVAILABLE = 0x00010009; + public const int NO_WINDOW_CONTEXT = 0x0001000A; + public const int FOCUSED = 0x00020001; + public const int ICONIFIED = 0x00020002; + public const int RESIZABLE = 0x00020003; + public const int VISIBLE = 0x00020004; + public const int DECORATED = 0x00020005; + public const int AUTO_ICONIFY = 0x00020006; + public const int FLOATING = 0x00020007; + public const int MAXIMIZED = 0x00020008; + public const int CENTER_CURSOR = 0x00020009; + public const int TRANSPARENT_FRAMEBUFFER = 0x0002000A; + public const int HOVERED = 0x0002000B; + public const int FOCUS_ON_SHOW = 0x0002000C; + public const int RED_BITS = 0x00021001; + public const int GREEN_BITS = 0x00021002; + public const int BLUE_BITS = 0x00021003; + public const int ALPHA_BITS = 0x00021004; + public const int DEPTH_BITS = 0x00021005; + public const int STENCIL_BITS = 0x00021006; + public const int ACCUM_RED_BITS = 0x00021007; + public const int ACCUM_GREEN_BITS = 0x00021008; + public const int ACCUM_BLUE_BITS = 0x00021009; + public const int ACCUM_ALPHA_BITS = 0x0002100A; + public const int AUX_BUFFERS = 0x0002100B; + public const int STEREO = 0x0002100C; + public const int SAMPLES = 0x0002100D; + public const int SRGB_CAPABLE = 0x0002100E; + public const int REFRESH_RATE = 0x0002100F; + public const int DOUBLEBUFFER = 0x00021010; + public const int CLIENT_API = 0x00022001; + public const int CONTEXT_VERSION_MAJOR = 0x00022002; + public const int CONTEXT_VERSION_MINOR = 0x00022003; + public const int CONTEXT_REVISION = 0x00022004; + public const int CONTEXT_ROBUSTNESS = 0x00022005; + public const int OPENGL_FORWARD_COMPAT = 0x00022006; + public const int OPENGL_DEBUG_CONTEXT = 0x00022007; + public const int OPENGL_PROFILE = 0x00022008; + public const int CONTEXT_RELEASE_BEHAVIOR = 0x00022009; + public const int CONTEXT_NO_ERROR = 0x0002200A; + public const int CONTEXT_CREATION_API = 0x0002200B; + public const int SCALE_TO_MONITOR = 0x0002200C; + public const int COCOA_RETINA_FRAMEBUFFER = 0x00023001; + public const int COCOA_FRAME_NAME = 0x00023002; + public const int COCOA_GRAPHICS_SWITCHING = 0x00023003; + public const int X11_CLASS_NAME = 0x00024001; + public const int X11_INSTANCE_NAME = 0x00024002; + public const int NO_API = 0; + public const int OPENGL_API = 0x00030001; + public const int OPENGL_ES_API = 0x00030002; + public const int NO_ROBUSTNESS = 0; + public const int NO_RESET_NOTIFICATION = 0x00031001; + public const int LOSE_CONTEXT_ON_RESET = 0x00031002; + public const int OPENGL_ANY_PROFILE = 0; + public const int OPENGL_CORE_PROFILE = 0x00032001; + public const int OPENGL_COMPAT_PROFILE = 0x00032002; + public const int CURSOR = 0x00033001; + public const int STICKY_KEYS = 0x00033002; + public const int STICKY_MOUSE_BUTTONS = 0x00033003; + public const int LOCK_KEY_MODS = 0x00033004; + public const int RAW_MOUSE_MOTION = 0x00033005; + public const int CURSOR_NORMAL = 0x00034001; + public const int CURSOR_HIDDEN = 0x00034002; + public const int CURSOR_DISABLED = 0x00034003; + public const int ANY_RELEASE_BEHAVIOR = 0; + public const int RELEASE_BEHAVIOR_FLUSH = 0x00035001; + public const int RELEASE_BEHAVIOR_NONE = 0x00035002; + public const int NATIVE_CONTEXT_API = 0x00036001; + public const int EGL_CONTEXT_API = 0x00036002; + public const int OSMESA_CONTEXT_API = 0x00036003; + public const int ARROW_CURSOR = 0x00036001; + public const int IBEAM_CURSOR = 0x00036002; + public const int CROSSHAIR_CURSOR = 0x00036003; + public const int HAND_CURSOR = 0x00036004; + public const int HRESIZE_CURSOR = 0x00036005; + public const int VRESIZE_CURSOR = 0x00036006; + public const int CONNECTED = 0x00040001; + public const int DISCONNECTED = 0x00040002; + public const int JOYSTICK_HAT_BUTTONS = 0x00050001; + public const int COCOA_CHDIR_RESOURCES = 0x00051001; + public const int COCOA_MENUBAR = 0x00051002; + public const int DONT_CARE = -1; + + #endregion + } +} diff --git a/StgSharp.Common/Graphics/Image.cs b/StgSharp.Common/Graphics/Image.cs index b8649e87..102a4350 100644 --- a/StgSharp.Common/Graphics/Image.cs +++ b/StgSharp.Common/Graphics/Image.cs @@ -26,18 +26,9 @@ // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- using StgSharp.Graphics.OpenGL; -using StgSharp.Internal; -using StgSharp.Mathematics; using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace StgSharp.Graphics { @@ -56,13 +47,14 @@ namespace StgSharp.Graphics internal Image(ImageInfo information) { _rawInfo = information; - _data = Array.Empty(); + _data = []; // int length = _rawInfo.width * _rawInfo.height * _rawInfo.channel; } public (int width, int height) Size { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get => (_rawInfo.Width, _rawInfo.Height); } @@ -175,7 +167,10 @@ namespace StgSharp.Graphics return _data; } - public Image ProvideImage() => this; + public Image ProvideImage() + { + return this; + } internal static Image FromMemory(ImageInfo info, byte[] data, int operationCount) { @@ -193,9 +188,4 @@ namespace StgSharp.Graphics } } -} - -namespace StgSharp.Graphics.OpenGL -{ - public static partial class GlHelper { } } \ No newline at end of file diff --git a/StgSharp.Common/Graphics/ImageInfo.cs b/StgSharp.Common/Graphics/ImageInfo.cs index 963fe35e..9bd73916 100644 --- a/StgSharp.Common/Graphics/ImageInfo.cs +++ b/StgSharp.Common/Graphics/ImageInfo.cs @@ -90,9 +90,9 @@ namespace StgSharp.Graphics public override int GetHashCode() { int hash = 17; - hash = hash * 17 + width; - hash = hash * 17 + height; - hash = hash * 17 + (int)channel; + hash = (hash * 17) + width; + hash = (hash * 17) + height; + hash = (hash * 17) + (int)channel; return hash; } diff --git a/StgSharp.Common/Graphics/OpenGL/Buffer/AutoTexture.cs b/StgSharp.Common/Graphics/OpenGL/Buffer/AutoTexture.cs index 0ded6e79..3119cb3a 100644 --- a/StgSharp.Common/Graphics/OpenGL/Buffer/AutoTexture.cs +++ b/StgSharp.Common/Graphics/OpenGL/Buffer/AutoTexture.cs @@ -26,6 +26,7 @@ // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- using StgSharp.Collections; +using StgSharp.Graphics; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; diff --git a/StgSharp.Common/Graphics/OpenGL/Buffer/FBO.cs b/StgSharp.Common/Graphics/OpenGL/Buffer/FBO.cs index 9d9d7443..cbc9383e 100644 --- a/StgSharp.Common/Graphics/OpenGL/Buffer/FBO.cs +++ b/StgSharp.Common/Graphics/OpenGL/Buffer/FBO.cs @@ -25,8 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using StgSharp.Graphics.OpenGL; - +using StgSharp.Graphics; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/StgSharp.Common/Graphics/OpenGL/Buffer/RBO.cs b/StgSharp.Common/Graphics/OpenGL/Buffer/RBO.cs index c2810b67..13868597 100644 --- a/StgSharp.Common/Graphics/OpenGL/Buffer/RBO.cs +++ b/StgSharp.Common/Graphics/OpenGL/Buffer/RBO.cs @@ -25,8 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using StgSharp.Graphics.OpenGL; - +using StgSharp.Graphics; using System; using System.Collections.Generic; using System.Security.Principal; diff --git a/StgSharp.Common/Graphics/OpenGL/Buffer/TextureGL.cs b/StgSharp.Common/Graphics/OpenGL/Buffer/TextureGL.cs index a3ebe0cf..23058ecb 100644 --- a/StgSharp.Common/Graphics/OpenGL/Buffer/TextureGL.cs +++ b/StgSharp.Common/Graphics/OpenGL/Buffer/TextureGL.cs @@ -25,6 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- +using StgSharp.Graphics; using StgSharp.HighPerformance; using System; diff --git a/StgSharp.Common/Graphics/OpenGL/Buffer/VAO.cs b/StgSharp.Common/Graphics/OpenGL/Buffer/VAO.cs index 0efbd93a..b9cab902 100644 --- a/StgSharp.Common/Graphics/OpenGL/Buffer/VAO.cs +++ b/StgSharp.Common/Graphics/OpenGL/Buffer/VAO.cs @@ -25,6 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- +using StgSharp.Graphics; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; diff --git a/StgSharp.Common/Graphics/OpenGL/Buffer/VBO.cs b/StgSharp.Common/Graphics/OpenGL/Buffer/VBO.cs index 97da5169..1797a163 100644 --- a/StgSharp.Common/Graphics/OpenGL/Buffer/VBO.cs +++ b/StgSharp.Common/Graphics/OpenGL/Buffer/VBO.cs @@ -25,6 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- +using StgSharp.Graphics; using StgSharp.Mathematics; using StgSharp.Mathematics.Numeric; diff --git a/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Shader.cs b/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Shader.cs index 5a63db4f..fa2b7fd7 100644 --- a/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Shader.cs +++ b/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Shader.cs @@ -26,6 +26,7 @@ // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- using StgSharp; +using StgSharp.Graphics; using StgSharp.Internal; using System; diff --git a/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Uniform.cs b/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Uniform.cs index b0c8f421..209a21de 100644 --- a/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Uniform.cs +++ b/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Uniform.cs @@ -25,6 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- +using StgSharp.Graphics; using StgSharp.Mathematics.Graphic; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; diff --git a/StgSharp.Common/Graphics/OpenGL/glAPICalling.cs b/StgSharp.Common/Graphics/OpenGL/glAPICalling.cs deleted file mode 100644 index 943ec6f1..00000000 --- a/StgSharp.Common/Graphics/OpenGL/glAPICalling.cs +++ /dev/null @@ -1,41 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="glAPICalling" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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 System; -using System.Collections.Generic; -using System.Text; - -namespace StgSharp.Graphics.OpenGL -{ - [AttributeUsage(AttributeTargets.Method)] - public sealed class OpenGLAPICallingAttribute : Attribute - { - - public OpenGLAPICallingAttribute() { } - - } -} diff --git a/StgSharp.Common/Graphics/OpenGL/glContext.cs b/StgSharp.Common/Graphics/OpenGL/glContext.cs index 2e23581b..53cb8614 100644 --- a/StgSharp.Common/Graphics/OpenGL/glContext.cs +++ b/StgSharp.Common/Graphics/OpenGL/glContext.cs @@ -65,7 +65,7 @@ namespace StgSharp.Graphics.OpenGL #region glapi - internal unsafe delegate* glAccumxOES; + internal unsafe delegate* glAccumxOES; internal unsafe delegate* glAcquireKeyedMutexWin32EXT; internal unsafe delegate* glActiveProgramEXT; internal unsafe delegate* glActiveShaderProgram; @@ -76,7 +76,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glAlphaFragmentOp1ATI; internal unsafe delegate* glAlphaFragmentOp2ATI; internal unsafe delegate* glAlphaFragmentOp3ATI; - internal unsafe delegate* glAlphaFuncxOES; + internal unsafe delegate* glAlphaFuncxOES; internal unsafe delegate* glAlphaToCoverageDitherControlNV; internal unsafe delegate* glApplyFramebufferAttachmentCMAAINTEL; internal unsafe delegate* glApplyTextureEXT; @@ -165,12 +165,12 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glBinormal3sEXT; internal unsafe delegate* glBinormal3svEXT; internal unsafe delegate* glBinormalPointerEXT; - internal unsafe delegate* glBitmapxOES; + internal unsafe delegate* glBitmapxOES; internal unsafe delegate* glBlendBarrierKHR; internal unsafe delegate* glBlendBarrierNV; internal unsafe delegate* glBlendColor; internal unsafe delegate* glBlendColorEXT; - internal unsafe delegate* glBlendColorxOES; + internal unsafe delegate* glBlendColorxOES; internal unsafe delegate* glBlendEquation; internal unsafe delegate* glBlendEquationEXT; internal unsafe delegate* glBlendEquationIndexedAMD; @@ -217,7 +217,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glClampColor; internal unsafe delegate* glClampColorARB; internal unsafe delegate* glClear; - internal unsafe delegate* glClearAccumxOES; + internal unsafe delegate* glClearAccumxOES; internal unsafe delegate* glClearBufferData; internal unsafe delegate* glClearBufferSubData; internal unsafe delegate* glClearBufferfi; @@ -227,12 +227,12 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glClearColor; internal unsafe delegate* glClearColorIiEXT; internal unsafe delegate* glClearColorIuiEXT; - internal unsafe delegate* glClearColorxOES; + internal unsafe delegate* glClearColorxOES; internal unsafe delegate* glClearDepth; internal unsafe delegate* glClearDepthdNV; internal unsafe delegate* glClearDepthf; - internal unsafe delegate* glClearDepthfOES; - internal unsafe delegate* glClearDepthxOES; + internal unsafe delegate* glClearDepthfOES; + internal unsafe delegate* glClearDepthxOES; internal unsafe delegate* glClearNamedBufferData; internal unsafe delegate* glClearNamedBufferDataEXT; internal unsafe delegate* glClearNamedBufferSubData; @@ -251,23 +251,23 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glClientWaitSync; internal unsafe delegate* glClipControl; internal unsafe delegate* glClipPlanefOES; - internal unsafe delegate* glClipPlanexOES; + internal unsafe delegate* glClipPlanexOES; internal unsafe delegate* glColor3fVertex3fSUN; internal unsafe delegate* glColor3fVertex3fvSUN; - internal unsafe delegate* glColor3hNV; - internal unsafe delegate* glColor3hvNV; - internal unsafe delegate* glColor3xOES; - internal unsafe delegate* glColor3xvOES; + internal unsafe delegate* glColor3hNV; + internal unsafe delegate* glColor3hvNV; + internal unsafe delegate* glColor3xOES; + internal unsafe delegate* glColor3xvOES; internal unsafe delegate* glColor4fNormal3fVertex3fSUN; internal unsafe delegate* glColor4fNormal3fVertex3fvSUN; - internal unsafe delegate* glColor4hNV; - internal unsafe delegate* glColor4hvNV; + internal unsafe delegate* glColor4hNV; + internal unsafe delegate* glColor4hvNV; internal unsafe delegate* glColor4ubVertex2fSUN; internal unsafe delegate* glColor4ubVertex2fvSUN; internal unsafe delegate* glColor4ubVertex3fSUN; internal unsafe delegate* glColor4ubVertex3fvSUN; - internal unsafe delegate* glColor4xOES; - internal unsafe delegate* glColor4xvOES; + internal unsafe delegate* glColor4xOES; + internal unsafe delegate* glColor4xvOES; internal unsafe delegate* glColorFormatNV; internal unsafe delegate* glColorFragmentOp1ATI; internal unsafe delegate* glColorFragmentOp2ATI; @@ -330,8 +330,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glConvolutionParameterfvEXT; internal unsafe delegate* glConvolutionParameteriEXT; internal unsafe delegate* glConvolutionParameterivEXT; - internal unsafe delegate* glConvolutionParameterxOES; - internal unsafe delegate* glConvolutionParameterxvOES; + internal unsafe delegate* glConvolutionParameterxOES; + internal unsafe delegate* glConvolutionParameterxvOES; internal unsafe delegate* glCopyBufferSubData; internal unsafe delegate* glCopyColorSubTableEXT; internal unsafe delegate* glCopyColorTableSGI; @@ -446,7 +446,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glDeleteVertexArrays; internal unsafe delegate* glDeleteVertexArraysAPPLE; internal unsafe delegate* glDeleteVertexShaderEXT; - internal unsafe delegate* glDepthBoundsEXT; + internal unsafe delegate* glDepthBoundsEXT; internal unsafe delegate* glDepthBoundsdNV; internal unsafe delegate* glDepthFunc; internal unsafe delegate* glDepthMask; @@ -457,8 +457,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glDepthRangeIndexeddNV; internal unsafe delegate* glDepthRangedNV; internal unsafe delegate* glDepthRangef; - internal unsafe delegate* glDepthRangefOES; - internal unsafe delegate* glDepthRangexOES; + internal unsafe delegate* glDepthRangefOES; + internal unsafe delegate* glDepthRangexOES; internal unsafe delegate* glDetachObjectARB; internal unsafe delegate* glDetachShader; internal unsafe delegate* glDetailTexFuncSGIS; @@ -552,15 +552,15 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glEndTransformFeedbackNV; internal unsafe delegate* glEndVertexShaderEXT; internal unsafe delegate* glEndVideoCaptureNV; - internal unsafe delegate* glEvalCoord1xOES; - internal unsafe delegate* glEvalCoord1xvOES; - internal unsafe delegate* glEvalCoord2xOES; - internal unsafe delegate* glEvalCoord2xvOES; + internal unsafe delegate* glEvalCoord1xOES; + internal unsafe delegate* glEvalCoord1xvOES; + internal unsafe delegate* glEvalCoord2xOES; + internal unsafe delegate* glEvalCoord2xvOES; internal unsafe delegate* glEvalMapsNV; internal unsafe delegate* glEvaluateDepthValuesARB; internal unsafe delegate* glExecuteProgramNV; internal unsafe delegate* glExtractComponentEXT; - internal unsafe delegate* glFeedbackBufferxOES; + internal unsafe delegate* glFeedbackBufferxOES; internal unsafe delegate* glFenceSync; internal unsafe delegate* glFinalCombinerInputNV; internal unsafe delegate* glFinish; @@ -586,11 +586,11 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glFogCoorddvEXT; internal unsafe delegate* glFogCoordfEXT; internal unsafe delegate* glFogCoordfvEXT; - internal unsafe delegate* glFogCoordhNV; - internal unsafe delegate* glFogCoordhvNV; + internal unsafe delegate* glFogCoordhNV; + internal unsafe delegate* glFogCoordhvNV; internal unsafe delegate* glFogFuncSGIS; - internal unsafe delegate* glFogxOES; - internal unsafe delegate* glFogxvOES; + internal unsafe delegate* glFogxOES; + internal unsafe delegate* glFogxvOES; internal unsafe delegate* glFragmentColorMaterialSGIX; internal unsafe delegate* glFragmentCoverageColorNV; internal unsafe delegate* glFragmentLightModelfSGIX; @@ -636,7 +636,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glFreeObjectBufferATI; internal unsafe delegate* glFrontFace; internal unsafe delegate* glFrustumfOES; - internal unsafe delegate* glFrustumxOES; + internal unsafe delegate* glFrustumxOES; internal unsafe delegate* glGenAsyncMarkersSGIX; internal unsafe delegate* glGenBuffers; internal unsafe delegate* glGenBuffersARB; @@ -703,7 +703,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glGetBufferSubData; internal unsafe delegate* glGetBufferSubDataARB; internal unsafe delegate* glGetClipPlanefOES; - internal unsafe delegate* glGetClipPlanexOES; + internal unsafe delegate* glGetClipPlanexOES; internal unsafe delegate* glGetColorTableEXT; internal unsafe delegate* glGetColorTableParameterfvEXT; internal unsafe delegate* glGetColorTableParameterfvSGI; @@ -725,7 +725,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glGetConvolutionFilterEXT; internal unsafe delegate* glGetConvolutionParameterfvEXT; internal unsafe delegate* glGetConvolutionParameterivEXT; - internal unsafe delegate* glGetConvolutionParameterxvOES; + internal unsafe delegate* glGetConvolutionParameterxvOES; internal unsafe delegate* glGetCoverageModulationTableNV; internal unsafe delegate* glGetDebugMessageLog; internal unsafe delegate* glGetDebugMessageLogAMD; @@ -740,7 +740,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glGetFinalCombinerInputParameterfvNV; internal unsafe delegate* glGetFinalCombinerInputParameterivNV; internal unsafe delegate* glGetFirstPerfQueryIdINTEL; - internal unsafe delegate* glGetFixedvOES; + internal unsafe delegate* glGetFixedvOES; internal unsafe delegate* glGetFloatIndexedvEXT; internal unsafe delegate* glGetFloati_v; internal unsafe delegate* glGetFloati_vEXT; @@ -765,7 +765,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glGetHistogramEXT; internal unsafe delegate* glGetHistogramParameterfvEXT; internal unsafe delegate* glGetHistogramParameterivEXT; - internal unsafe delegate* glGetHistogramParameterxvOES; + internal unsafe delegate* glGetHistogramParameterxvOES; internal unsafe delegate* glGetImageHandleARB; internal unsafe delegate* glGetImageHandleNV; internal unsafe delegate* glGetImageTransformParameterfvHP; @@ -785,7 +785,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glGetInvariantBooleanvEXT; internal unsafe delegate* glGetInvariantFloatvEXT; internal unsafe delegate* glGetInvariantIntegervEXT; - internal unsafe delegate* glGetLightxOES; + internal unsafe delegate* glGetLightxOES; internal unsafe delegate* glGetListParameterfvSGIX; internal unsafe delegate* glGetListParameterivSGIX; internal unsafe delegate* glGetLocalConstantBooleanvEXT; @@ -796,8 +796,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glGetMapControlPointsNV; internal unsafe delegate* glGetMapParameterfvNV; internal unsafe delegate* glGetMapParameterivNV; - internal unsafe delegate* glGetMapxvOES; - internal unsafe delegate* glGetMaterialxOES; + internal unsafe delegate* glGetMapxvOES; + internal unsafe delegate* glGetMaterialxOES; internal unsafe delegate* glGetMemoryObjectDetachedResourcesuivNV; internal unsafe delegate* glGetMemoryObjectParameterivEXT; internal unsafe delegate* glGetMinmaxEXT; @@ -870,7 +870,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glGetPerfQueryDataINTEL; internal unsafe delegate* glGetPerfQueryIdByNameINTEL; internal unsafe delegate* glGetPerfQueryInfoINTEL; - internal unsafe delegate* glGetPixelMapxv; + internal unsafe delegate* glGetPixelMapxv; internal unsafe delegate* glGetPixelTexGenParameterfvSGIS; internal unsafe delegate* glGetPixelTexGenParameterivSGIS; internal unsafe delegate* glGetPixelTransformParameterfvEXT; @@ -949,13 +949,13 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glGetSynciv; internal unsafe delegate* glGetTexBumpParameterfvATI; internal unsafe delegate* glGetTexBumpParameterivATI; - internal unsafe delegate* glGetTexEnvxvOES; + internal unsafe delegate* glGetTexEnvxvOES; internal unsafe delegate* glGetTexFilterFuncSGIS; - internal unsafe delegate* glGetTexGenxvOES; + internal unsafe delegate* glGetTexGenxvOES; internal unsafe delegate* glGetTexImage; internal unsafe delegate* glGetTexLevelParameterfv; internal unsafe delegate* glGetTexLevelParameteriv; - internal unsafe delegate* glGetTexLevelParameterxvOES; + internal unsafe delegate* glGetTexLevelParameterxvOES; internal unsafe delegate* glGetTexParameterIiv; internal unsafe delegate* glGetTexParameterIivEXT; internal unsafe delegate* glGetTexParameterIuiv; @@ -963,7 +963,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glGetTexParameterPointervAPPLE; internal unsafe delegate* glGetTexParameterfv; internal unsafe delegate* glGetTexParameteriv; - internal unsafe delegate* glGetTexParameterxvOES; + internal unsafe delegate* glGetTexParameterxvOES; internal unsafe delegate* glGetTextureHandleARB; internal unsafe delegate* glGetTextureHandleNV; internal unsafe delegate* glGetTextureImage; @@ -1094,12 +1094,12 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glImportSemaphoreWin32NameEXT; internal unsafe delegate* glImportSyncEXT; internal unsafe delegate* glIndexFormatNV; - internal unsafe delegate* glIndexFuncEXT; + internal unsafe delegate* glIndexFuncEXT; internal unsafe delegate* glIndexMaterialEXT; internal unsafe delegate* glIndexPointerEXT; internal unsafe delegate* glIndexPointerListIBM; - internal unsafe delegate* glIndexxOES; - internal unsafe delegate* glIndexxvOES; + internal unsafe delegate* glIndexxOES; + internal unsafe delegate* glIndexxvOES; internal unsafe delegate* glInsertComponentEXT; internal unsafe delegate* glInsertEventMarkerEXT; internal unsafe delegate* glInstrumentsBufferSGIX; @@ -1163,12 +1163,12 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glLGPUNamedBufferSubDataNVX; internal unsafe delegate* glLabelObjectEXT; internal unsafe delegate* glLightEnviSGIX; - internal unsafe delegate* glLightModelxOES; - internal unsafe delegate* glLightModelxvOES; - internal unsafe delegate* glLightxOES; - internal unsafe delegate* glLightxvOES; + internal unsafe delegate* glLightModelxOES; + internal unsafe delegate* glLightModelxvOES; + internal unsafe delegate* glLightxOES; + internal unsafe delegate* glLightxvOES; internal unsafe delegate* glLineWidth; - internal unsafe delegate* glLineWidthxOES; + internal unsafe delegate* glLineWidthxOES; internal unsafe delegate* glLinkProgram; internal unsafe delegate* glLinkProgramARB; internal unsafe delegate* glListDrawCommandsStatesClientNV; @@ -1177,11 +1177,11 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glListParameteriSGIX; internal unsafe delegate* glListParameterivSGIX; internal unsafe delegate* glLoadIdentityDeformationMapSGIX; - internal unsafe delegate* glLoadMatrixxOES; + internal unsafe delegate* glLoadMatrixxOES; internal unsafe delegate* glLoadProgramNV; internal unsafe delegate* glLoadTransposeMatrixdARB; internal unsafe delegate* glLoadTransposeMatrixfARB; - internal unsafe delegate* glLoadTransposeMatrixxOES; + internal unsafe delegate* glLoadTransposeMatrixxOES; internal unsafe delegate* glLockArraysEXT; internal unsafe delegate* glLogicOp; internal unsafe delegate* glMakeBufferNonResidentNV; @@ -1196,14 +1196,14 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glMakeTextureHandleNonResidentNV; internal unsafe delegate* glMakeTextureHandleResidentARB; internal unsafe delegate* glMakeTextureHandleResidentNV; - internal unsafe delegate* glMap1xOES; - internal unsafe delegate* glMap2xOES; + internal unsafe delegate* glMap1xOES; + internal unsafe delegate* glMap2xOES; internal unsafe delegate* glMapBuffer; internal unsafe delegate* glMapBufferARB; internal unsafe delegate* glMapBufferRange; internal unsafe delegate* glMapControlPointsNV; - internal unsafe delegate* glMapGrid1xOES; - internal unsafe delegate* glMapGrid2xOES; + internal unsafe delegate* glMapGrid1xOES; + internal unsafe delegate* glMapGrid2xOES; internal unsafe delegate* glMapNamedBuffer; internal unsafe delegate* glMapNamedBufferEXT; internal unsafe delegate* glMapNamedBufferRange; @@ -1216,8 +1216,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glMapVertexAttrib1fAPPLE; internal unsafe delegate* glMapVertexAttrib2dAPPLE; internal unsafe delegate* glMapVertexAttrib2fAPPLE; - internal unsafe delegate* glMaterialxOES; - internal unsafe delegate* glMaterialxvOES; + internal unsafe delegate* glMaterialxOES; + internal unsafe delegate* glMaterialxvOES; internal unsafe delegate* glMatrixFrustumEXT; internal unsafe delegate* glMatrixIndexPointerARB; internal unsafe delegate* glMatrixIndexubvARB; @@ -1256,10 +1256,10 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glMinSampleShading; internal unsafe delegate* glMinSampleShadingARB; internal unsafe delegate* glMinmaxEXT; - internal unsafe delegate* glMultMatrixxOES; + internal unsafe delegate* glMultMatrixxOES; internal unsafe delegate* glMultTransposeMatrixdARB; internal unsafe delegate* glMultTransposeMatrixfARB; - internal unsafe delegate* glMultTransposeMatrixxOES; + internal unsafe delegate* glMultTransposeMatrixxOES; internal unsafe delegate* glMultiDrawArrays; internal unsafe delegate* glMultiDrawArraysEXT; internal unsafe delegate* glMultiDrawArraysIndirect; @@ -1290,56 +1290,56 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glMultiTexCoord1dvARB; internal unsafe delegate* glMultiTexCoord1fARB; internal unsafe delegate* glMultiTexCoord1fvARB; - internal unsafe delegate* glMultiTexCoord1hNV; - internal unsafe delegate* glMultiTexCoord1hvNV; + internal unsafe delegate* glMultiTexCoord1hNV; + internal unsafe delegate* glMultiTexCoord1hvNV; internal unsafe delegate* glMultiTexCoord1iARB; internal unsafe delegate* glMultiTexCoord1ivARB; internal unsafe delegate* glMultiTexCoord1sARB; internal unsafe delegate* glMultiTexCoord1svARB; - internal unsafe delegate* glMultiTexCoord1xOES; - internal unsafe delegate* glMultiTexCoord1xvOES; + internal unsafe delegate* glMultiTexCoord1xOES; + internal unsafe delegate* glMultiTexCoord1xvOES; internal unsafe delegate* glMultiTexCoord2bOES; internal unsafe delegate* glMultiTexCoord2bvOES; internal unsafe delegate* glMultiTexCoord2dARB; internal unsafe delegate* glMultiTexCoord2dvARB; internal unsafe delegate* glMultiTexCoord2fARB; internal unsafe delegate* glMultiTexCoord2fvARB; - internal unsafe delegate* glMultiTexCoord2hNV; - internal unsafe delegate* glMultiTexCoord2hvNV; + internal unsafe delegate* glMultiTexCoord2hNV; + internal unsafe delegate* glMultiTexCoord2hvNV; internal unsafe delegate* glMultiTexCoord2iARB; internal unsafe delegate* glMultiTexCoord2ivARB; internal unsafe delegate* glMultiTexCoord2sARB; internal unsafe delegate* glMultiTexCoord2svARB; - internal unsafe delegate* glMultiTexCoord2xOES; - internal unsafe delegate* glMultiTexCoord2xvOES; + internal unsafe delegate* glMultiTexCoord2xOES; + internal unsafe delegate* glMultiTexCoord2xvOES; internal unsafe delegate* glMultiTexCoord3bOES; internal unsafe delegate* glMultiTexCoord3bvOES; internal unsafe delegate* glMultiTexCoord3dARB; internal unsafe delegate* glMultiTexCoord3dvARB; internal unsafe delegate* glMultiTexCoord3fARB; internal unsafe delegate* glMultiTexCoord3fvARB; - internal unsafe delegate* glMultiTexCoord3hNV; - internal unsafe delegate* glMultiTexCoord3hvNV; + internal unsafe delegate* glMultiTexCoord3hNV; + internal unsafe delegate* glMultiTexCoord3hvNV; internal unsafe delegate* glMultiTexCoord3iARB; internal unsafe delegate* glMultiTexCoord3ivARB; internal unsafe delegate* glMultiTexCoord3sARB; internal unsafe delegate* glMultiTexCoord3svARB; - internal unsafe delegate* glMultiTexCoord3xOES; - internal unsafe delegate* glMultiTexCoord3xvOES; + internal unsafe delegate* glMultiTexCoord3xOES; + internal unsafe delegate* glMultiTexCoord3xvOES; internal unsafe delegate* glMultiTexCoord4bOES; internal unsafe delegate* glMultiTexCoord4bvOES; internal unsafe delegate* glMultiTexCoord4dARB; internal unsafe delegate* glMultiTexCoord4dvARB; internal unsafe delegate* glMultiTexCoord4fARB; internal unsafe delegate* glMultiTexCoord4fvARB; - internal unsafe delegate* glMultiTexCoord4hNV; - internal unsafe delegate* glMultiTexCoord4hvNV; + internal unsafe delegate* glMultiTexCoord4hNV; + internal unsafe delegate* glMultiTexCoord4hvNV; internal unsafe delegate* glMultiTexCoord4iARB; internal unsafe delegate* glMultiTexCoord4ivARB; internal unsafe delegate* glMultiTexCoord4sARB; internal unsafe delegate* glMultiTexCoord4svARB; - internal unsafe delegate* glMultiTexCoord4xOES; - internal unsafe delegate* glMultiTexCoord4xvOES; + internal unsafe delegate* glMultiTexCoord4xOES; + internal unsafe delegate* glMultiTexCoord4xvOES; internal unsafe delegate* glMultiTexCoordPointerEXT; internal unsafe delegate* glMultiTexEnvfEXT; internal unsafe delegate* glMultiTexEnvfvEXT; @@ -1431,10 +1431,10 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glNewObjectBufferATI; internal unsafe delegate* glNormal3fVertex3fSUN; internal unsafe delegate* glNormal3fVertex3fvSUN; - internal unsafe delegate* glNormal3hNV; - internal unsafe delegate* glNormal3hvNV; - internal unsafe delegate* glNormal3xOES; - internal unsafe delegate* glNormal3xvOES; + internal unsafe delegate* glNormal3hNV; + internal unsafe delegate* glNormal3hvNV; + internal unsafe delegate* glNormal3xOES; + internal unsafe delegate* glNormal3xvOES; internal unsafe delegate* glNormalFormatNV; internal unsafe delegate* glNormalPointerEXT; internal unsafe delegate* glNormalPointerListIBM; @@ -1454,11 +1454,11 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glObjectPurgeableAPPLE; internal unsafe delegate* glObjectUnpurgeableAPPLE; internal unsafe delegate* glOrthofOES; - internal unsafe delegate* glOrthoxOES; + internal unsafe delegate* glOrthoxOES; internal unsafe delegate* glPNTrianglesfATI; internal unsafe delegate* glPNTrianglesiATI; internal unsafe delegate* glPassTexCoordATI; - internal unsafe delegate* glPassThroughxOES; + internal unsafe delegate* glPassThroughxOES; internal unsafe delegate* glPatchParameterfv; internal unsafe delegate* glPatchParameteri; internal unsafe delegate* glPathCommandsNV; @@ -1482,21 +1482,21 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glPauseTransformFeedback; internal unsafe delegate* glPauseTransformFeedbackNV; internal unsafe delegate* glPixelDataRangeNV; - internal unsafe delegate* glPixelMapx; + internal unsafe delegate* glPixelMapx; internal unsafe delegate* glPixelStoref; internal unsafe delegate* glPixelStorei; - internal unsafe delegate* glPixelStorex; + internal unsafe delegate* glPixelStorex; internal unsafe delegate* glPixelTexGenParameterfSGIS; internal unsafe delegate* glPixelTexGenParameterfvSGIS; internal unsafe delegate* glPixelTexGenParameteriSGIS; internal unsafe delegate* glPixelTexGenParameterivSGIS; internal unsafe delegate* glPixelTexGenSGIX; - internal unsafe delegate* glPixelTransferxOES; + internal unsafe delegate* glPixelTransferxOES; internal unsafe delegate* glPixelTransformParameterfEXT; internal unsafe delegate* glPixelTransformParameterfvEXT; internal unsafe delegate* glPixelTransformParameteriEXT; internal unsafe delegate* glPixelTransformParameterivEXT; - internal unsafe delegate* glPixelZoomxOES; + internal unsafe delegate* glPixelZoomxOES; internal unsafe delegate* glPointAlongPathNV; internal unsafe delegate* glPointParameterf; internal unsafe delegate* glPointParameterfARB; @@ -1510,9 +1510,9 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glPointParameteriNV; internal unsafe delegate* glPointParameteriv; internal unsafe delegate* glPointParameterivNV; - internal unsafe delegate* glPointParameterxvOES; + internal unsafe delegate* glPointParameterxvOES; internal unsafe delegate* glPointSize; - internal unsafe delegate* glPointSizexOES; + internal unsafe delegate* glPointSizexOES; internal unsafe delegate* glPollAsyncSGIX; internal unsafe delegate* glPollInstrumentsSGIX; internal unsafe delegate* glPolygonMode; @@ -1520,7 +1520,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glPolygonOffsetClamp; internal unsafe delegate* glPolygonOffsetClampEXT; internal unsafe delegate* glPolygonOffsetEXT; - internal unsafe delegate* glPolygonOffsetxOES; + internal unsafe delegate* glPolygonOffsetxOES; internal unsafe delegate* glPopDebugGroup; internal unsafe delegate* glPopGroupMarkerEXT; internal unsafe delegate* glPresentFrameDualFillNV; @@ -1529,8 +1529,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glPrimitiveRestartIndex; internal unsafe delegate* glPrimitiveRestartIndexNV; internal unsafe delegate* glPrimitiveRestartNV; - internal unsafe delegate* glPrioritizeTexturesEXT; - internal unsafe delegate* glPrioritizeTexturesxOES; + internal unsafe delegate* glPrioritizeTexturesEXT; + internal unsafe delegate* glPrioritizeTexturesxOES; internal unsafe delegate* glProgramBinary; internal unsafe delegate* glProgramBufferParametersIivNV; internal unsafe delegate* glProgramBufferParametersIuivNV; @@ -1718,24 +1718,24 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glPushDebugGroup; internal unsafe delegate* glPushGroupMarkerEXT; internal unsafe delegate* glQueryCounter; - internal unsafe delegate* glQueryMatrixxOES; + internal unsafe delegate* glQueryMatrixxOES; internal unsafe delegate* glQueryObjectParameteruiAMD; internal unsafe delegate* glQueryResourceNV; internal unsafe delegate* glQueryResourceTagNV; - internal unsafe delegate* glRasterPos2xOES; - internal unsafe delegate* glRasterPos2xvOES; - internal unsafe delegate* glRasterPos3xOES; - internal unsafe delegate* glRasterPos3xvOES; - internal unsafe delegate* glRasterPos4xOES; - internal unsafe delegate* glRasterPos4xvOES; + internal unsafe delegate* glRasterPos2xOES; + internal unsafe delegate* glRasterPos2xvOES; + internal unsafe delegate* glRasterPos3xOES; + internal unsafe delegate* glRasterPos3xvOES; + internal unsafe delegate* glRasterPos4xOES; + internal unsafe delegate* glRasterPos4xvOES; internal unsafe delegate* glRasterSamplesEXT; internal unsafe delegate* glReadBuffer; internal unsafe delegate* glReadInstrumentsSGIX; internal unsafe delegate* glReadPixels; internal unsafe delegate* glReadnPixels; internal unsafe delegate* glReadnPixelsARB; - internal unsafe delegate* glRectxOES; - internal unsafe delegate* glRectxvOES; + internal unsafe delegate* glRectxOES; + internal unsafe delegate* glRectxvOES; internal unsafe delegate* glReferencePlaneSGIX; internal unsafe delegate* glReleaseKeyedMutexWin32EXT; internal unsafe delegate* glReleaseShaderCompiler; @@ -1777,13 +1777,13 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glResolveDepthValuesNV; internal unsafe delegate* glResumeTransformFeedback; internal unsafe delegate* glResumeTransformFeedbackNV; - internal unsafe delegate* glRotatexOES; + internal unsafe delegate* glRotatexOES; internal unsafe delegate* glSampleCoverage; internal unsafe delegate* glSampleCoverageARB; internal unsafe delegate* glSampleMapATI; - internal unsafe delegate* glSampleMaskEXT; + internal unsafe delegate* glSampleMaskEXT; internal unsafe delegate* glSampleMaskIndexedNV; - internal unsafe delegate* glSampleMaskSGIS; + internal unsafe delegate* glSampleMaskSGIS; internal unsafe delegate* glSampleMaski; internal unsafe delegate* glSamplePatternEXT; internal unsafe delegate* glSamplePatternSGIS; @@ -1793,7 +1793,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glSamplerParameterfv; internal unsafe delegate* glSamplerParameteri; internal unsafe delegate* glSamplerParameteriv; - internal unsafe delegate* glScalexOES; + internal unsafe delegate* glScalexOES; internal unsafe delegate* glScissor; internal unsafe delegate* glScissorArrayv; internal unsafe delegate* glScissorExclusiveArrayvNV; @@ -1806,8 +1806,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glSecondaryColor3dvEXT; internal unsafe delegate* glSecondaryColor3fEXT; internal unsafe delegate* glSecondaryColor3fvEXT; - internal unsafe delegate* glSecondaryColor3hNV; - internal unsafe delegate* glSecondaryColor3hvNV; + internal unsafe delegate* glSecondaryColor3hNV; + internal unsafe delegate* glSecondaryColor3hvNV; internal unsafe delegate* glSecondaryColor3iEXT; internal unsafe delegate* glSecondaryColor3ivEXT; internal unsafe delegate* glSecondaryColor3sEXT; @@ -1905,10 +1905,10 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glTexBumpParameterivATI; internal unsafe delegate* glTexCoord1bOES; internal unsafe delegate* glTexCoord1bvOES; - internal unsafe delegate* glTexCoord1hNV; - internal unsafe delegate* glTexCoord1hvNV; - internal unsafe delegate* glTexCoord1xOES; - internal unsafe delegate* glTexCoord1xvOES; + internal unsafe delegate* glTexCoord1hNV; + internal unsafe delegate* glTexCoord1hvNV; + internal unsafe delegate* glTexCoord1xOES; + internal unsafe delegate* glTexCoord1xvOES; internal unsafe delegate* glTexCoord2bOES; internal unsafe delegate* glTexCoord2bvOES; internal unsafe delegate* glTexCoord2fColor3fVertex3fSUN; @@ -1921,35 +1921,35 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glTexCoord2fNormal3fVertex3fvSUN; internal unsafe delegate* glTexCoord2fVertex3fSUN; internal unsafe delegate* glTexCoord2fVertex3fvSUN; - internal unsafe delegate* glTexCoord2hNV; - internal unsafe delegate* glTexCoord2hvNV; - internal unsafe delegate* glTexCoord2xOES; - internal unsafe delegate* glTexCoord2xvOES; + internal unsafe delegate* glTexCoord2hNV; + internal unsafe delegate* glTexCoord2hvNV; + internal unsafe delegate* glTexCoord2xOES; + internal unsafe delegate* glTexCoord2xvOES; internal unsafe delegate* glTexCoord3bOES; internal unsafe delegate* glTexCoord3bvOES; - internal unsafe delegate* glTexCoord3hNV; - internal unsafe delegate* glTexCoord3hvNV; - internal unsafe delegate* glTexCoord3xOES; - internal unsafe delegate* glTexCoord3xvOES; + internal unsafe delegate* glTexCoord3hNV; + internal unsafe delegate* glTexCoord3hvNV; + internal unsafe delegate* glTexCoord3xOES; + internal unsafe delegate* glTexCoord3xvOES; internal unsafe delegate* glTexCoord4bOES; internal unsafe delegate* glTexCoord4bvOES; internal unsafe delegate* glTexCoord4fColor4fNormal3fVertex4fSUN; internal unsafe delegate* glTexCoord4fColor4fNormal3fVertex4fvSUN; internal unsafe delegate* glTexCoord4fVertex4fSUN; internal unsafe delegate* glTexCoord4fVertex4fvSUN; - internal unsafe delegate* glTexCoord4hNV; - internal unsafe delegate* glTexCoord4hvNV; - internal unsafe delegate* glTexCoord4xOES; - internal unsafe delegate* glTexCoord4xvOES; + internal unsafe delegate* glTexCoord4hNV; + internal unsafe delegate* glTexCoord4hvNV; + internal unsafe delegate* glTexCoord4xOES; + internal unsafe delegate* glTexCoord4xvOES; internal unsafe delegate* glTexCoordFormatNV; internal unsafe delegate* glTexCoordPointerEXT; internal unsafe delegate* glTexCoordPointerListIBM; internal unsafe delegate* glTexCoordPointervINTEL; - internal unsafe delegate* glTexEnvxOES; - internal unsafe delegate* glTexEnvxvOES; + internal unsafe delegate* glTexEnvxOES; + internal unsafe delegate* glTexEnvxvOES; internal unsafe delegate* glTexFilterFuncSGIS; - internal unsafe delegate* glTexGenxOES; - internal unsafe delegate* glTexGenxvOES; + internal unsafe delegate* glTexGenxOES; + internal unsafe delegate* glTexGenxvOES; internal unsafe delegate* glTexImage1D; internal unsafe delegate* glTexImage2D; internal unsafe delegate* glTexImage2DMultisample; @@ -1969,8 +1969,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glTexParameterfv; internal unsafe delegate* glTexParameteri; internal unsafe delegate* glTexParameteriv; - internal unsafe delegate* glTexParameterxOES; - internal unsafe delegate* glTexParameterxvOES; + internal unsafe delegate* glTexParameterxOES; + internal unsafe delegate* glTexParameterxvOES; internal unsafe delegate* glTexRenderbufferNV; internal unsafe delegate* glTexStorage1D; internal unsafe delegate* glTexStorage1DEXT; @@ -2059,7 +2059,7 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glTransformFeedbackVaryingsEXT; internal unsafe delegate* glTransformFeedbackVaryingsNV; internal unsafe delegate* glTransformPathNV; - internal unsafe delegate* glTranslatexOES; + internal unsafe delegate* glTranslatexOES; internal unsafe delegate* glUniform1d; internal unsafe delegate* glUniform1dv; internal unsafe delegate* glUniform1f; @@ -2217,22 +2217,22 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glVariantusvEXT; internal unsafe delegate* glVertex2bOES; internal unsafe delegate* glVertex2bvOES; - internal unsafe delegate* glVertex2hNV; - internal unsafe delegate* glVertex2hvNV; - internal unsafe delegate* glVertex2xOES; - internal unsafe delegate* glVertex2xvOES; + internal unsafe delegate* glVertex2hNV; + internal unsafe delegate* glVertex2hvNV; + internal unsafe delegate* glVertex2xOES; + internal unsafe delegate* glVertex2xvOES; internal unsafe delegate* glVertex3bOES; internal unsafe delegate* glVertex3bvOES; - internal unsafe delegate* glVertex3hNV; - internal unsafe delegate* glVertex3hvNV; - internal unsafe delegate* glVertex3xOES; - internal unsafe delegate* glVertex3xvOES; + internal unsafe delegate* glVertex3hNV; + internal unsafe delegate* glVertex3hvNV; + internal unsafe delegate* glVertex3xOES; + internal unsafe delegate* glVertex3xvOES; internal unsafe delegate* glVertex4bOES; internal unsafe delegate* glVertex4bvOES; - internal unsafe delegate* glVertex4hNV; - internal unsafe delegate* glVertex4hvNV; - internal unsafe delegate* glVertex4xOES; - internal unsafe delegate* glVertex4xvOES; + internal unsafe delegate* glVertex4hNV; + internal unsafe delegate* glVertex4hvNV; + internal unsafe delegate* glVertex4xOES; + internal unsafe delegate* glVertex4xvOES; internal unsafe delegate* glVertexArrayAttribBinding; internal unsafe delegate* glVertexArrayAttribFormat; internal unsafe delegate* glVertexArrayAttribIFormat; @@ -2275,8 +2275,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glVertexAttrib1fv; internal unsafe delegate* glVertexAttrib1fvARB; internal unsafe delegate* glVertexAttrib1fvNV; - internal unsafe delegate* glVertexAttrib1hNV; - internal unsafe delegate* glVertexAttrib1hvNV; + internal unsafe delegate* glVertexAttrib1hNV; + internal unsafe delegate* glVertexAttrib1hvNV; internal unsafe delegate* glVertexAttrib1s; internal unsafe delegate* glVertexAttrib1sARB; internal unsafe delegate* glVertexAttrib1sNV; @@ -2295,8 +2295,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glVertexAttrib2fv; internal unsafe delegate* glVertexAttrib2fvARB; internal unsafe delegate* glVertexAttrib2fvNV; - internal unsafe delegate* glVertexAttrib2hNV; - internal unsafe delegate* glVertexAttrib2hvNV; + internal unsafe delegate* glVertexAttrib2hNV; + internal unsafe delegate* glVertexAttrib2hvNV; internal unsafe delegate* glVertexAttrib2s; internal unsafe delegate* glVertexAttrib2sARB; internal unsafe delegate* glVertexAttrib2sNV; @@ -2315,8 +2315,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glVertexAttrib3fv; internal unsafe delegate* glVertexAttrib3fvARB; internal unsafe delegate* glVertexAttrib3fvNV; - internal unsafe delegate* glVertexAttrib3hNV; - internal unsafe delegate* glVertexAttrib3hvNV; + internal unsafe delegate* glVertexAttrib3hNV; + internal unsafe delegate* glVertexAttrib3hvNV; internal unsafe delegate* glVertexAttrib3s; internal unsafe delegate* glVertexAttrib3sARB; internal unsafe delegate* glVertexAttrib3sNV; @@ -2351,8 +2351,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glVertexAttrib4fv; internal unsafe delegate* glVertexAttrib4fvARB; internal unsafe delegate* glVertexAttrib4fvNV; - internal unsafe delegate* glVertexAttrib4hNV; - internal unsafe delegate* glVertexAttrib4hvNV; + internal unsafe delegate* glVertexAttrib4hNV; + internal unsafe delegate* glVertexAttrib4hvNV; internal unsafe delegate* glVertexAttrib4iv; internal unsafe delegate* glVertexAttrib4ivARB; internal unsafe delegate* glVertexAttrib4s; @@ -2471,19 +2471,19 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glVertexAttribPointerNV; internal unsafe delegate* glVertexAttribs1dvNV; internal unsafe delegate* glVertexAttribs1fvNV; - internal unsafe delegate* glVertexAttribs1hvNV; + internal unsafe delegate* glVertexAttribs1hvNV; internal unsafe delegate* glVertexAttribs1svNV; internal unsafe delegate* glVertexAttribs2dvNV; internal unsafe delegate* glVertexAttribs2fvNV; - internal unsafe delegate* glVertexAttribs2hvNV; + internal unsafe delegate* glVertexAttribs2hvNV; internal unsafe delegate* glVertexAttribs2svNV; internal unsafe delegate* glVertexAttribs3dvNV; internal unsafe delegate* glVertexAttribs3fvNV; - internal unsafe delegate* glVertexAttribs3hvNV; + internal unsafe delegate* glVertexAttribs3hvNV; internal unsafe delegate* glVertexAttribs3svNV; internal unsafe delegate* glVertexAttribs4dvNV; internal unsafe delegate* glVertexAttribs4fvNV; - internal unsafe delegate* glVertexAttribs4hvNV; + internal unsafe delegate* glVertexAttribs4hvNV; internal unsafe delegate* glVertexAttribs4svNV; internal unsafe delegate* glVertexAttribs4ubvNV; internal unsafe delegate* glVertexBindingDivisor; @@ -2529,8 +2529,8 @@ namespace StgSharp.Graphics.OpenGL internal unsafe delegate* glVertexWeightPointerEXT; internal unsafe delegate* glVertexWeightfEXT; internal unsafe delegate* glVertexWeightfvEXT; - internal unsafe delegate* glVertexWeighthNV; - internal unsafe delegate* glVertexWeighthvNV; + internal unsafe delegate* glVertexWeighthNV; + internal unsafe delegate* glVertexWeighthvNV; internal unsafe delegate* glVideoCaptureNV; internal unsafe delegate* glVideoCaptureStreamParameterdvNV; internal unsafe delegate* glVideoCaptureStreamParameterfvNV; diff --git a/StgSharp.Common/Graphics/OpenGL/glEnum.cs b/StgSharp.Common/Graphics/OpenGL/glEnum.cs index 82014a9b..9ab945b4 100644 --- a/StgSharp.Common/Graphics/OpenGL/glEnum.cs +++ b/StgSharp.Common/Graphics/OpenGL/glEnum.cs @@ -72,7 +72,7 @@ namespace StgSharp.Graphics.OpenGL IncompleteDrawBuffer = glConst.FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER, // GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER IncompleteReadBuffer = glConst.FRAMEBUFFER_INCOMPLETE_READ_BUFFER, // GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER Unsupported = glConst.FRAMEBUFFER_UNSUPPORTED, // GL_FRAMEBUFFER_UNSUPPORTED - IncompleteMultisample = glConst.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, // GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE + IncompleteMultiSample = glConst.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, // GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE IncompleteLayerTargets = glConst.FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS // GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS } diff --git a/StgSharp.Common/Graphics/OpenGL/glFucntionSourceManager.cs b/StgSharp.Common/Graphics/OpenGL/glFucntionSourceManager.cs index e913b18d..5d967a96 100644 --- a/StgSharp.Common/Graphics/OpenGL/glFucntionSourceManager.cs +++ b/StgSharp.Common/Graphics/OpenGL/glFucntionSourceManager.cs @@ -30,24 +30,26 @@ using StgSharp; using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Runtime.CompilerServices; namespace StgSharp.Graphics.OpenGL { public partial class OpenGLFunction { - private Lazy textureUnitCountGetter; - private Lazy> unusedTextureImageUintInitilizing; + private readonly int textureUnitCountGetter; public int TextureUnitCount { - get => textureUnitCountGetter.Value; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => textureUnitCountGetter; } private ConcurrentQueue UnusedTextureImageUint { - get => unusedTextureImageUintInitilizing.Value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get; + } = []; internal void ReturnAvailableUnit(IEnumerable source) { diff --git a/StgSharp.Common/Graphics/OpenGL/glFunction.cs b/StgSharp.Common/Graphics/OpenGL/glFunction.cs index d2fa560b..947e13db 100644 --- a/StgSharp.Common/Graphics/OpenGL/glFunction.cs +++ b/StgSharp.Common/Graphics/OpenGL/glFunction.cs @@ -26,6 +26,7 @@ // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- using StgSharp.Graphics; +using StgSharp.Graphics; using StgSharp.Internal; using StgSharp.Mathematics; using StgSharp.Mathematics.Numeric; @@ -46,32 +47,32 @@ namespace StgSharp.Graphics.OpenGL public unsafe partial class OpenGLFunction { - private static Dictionary contextToGLMap = new Dictionary( - ); - private static ThreadLocal _currentGL = new ThreadLocal(); + private static readonly Dictionary contextToGLMap = []; + private static readonly ThreadLocal _currentGL = new ThreadLocal(); private OpenglContext* _context; private Lazy _attachmentColorRange; private OpenGLFunction() { - textureUnitCountGetter = new Lazy( - () => GetMaskInteger(glConst.MAX_TEXTURE_IMAGE_UNITS)); - unusedTextureImageUintInitilizing = new Lazy>( - InitializeUnusedTextureImageUint); + textureUnitCountGetter = glConst.MAX_TEXTURE_IMAGE_UNITS; + UnusedTextureImageUint = []; _attachmentColorRange = new Lazy( () => { return GetMaskInteger((uint)glConst.MAX_COLOR_ATTACHMENTS); }); } public int AttachmentColorRange { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get => _attachmentColorRange.Value; } public static OpenGLFunction CurrentGL { - get { return _currentGL.Value; } - internal set { _currentGL.Value = value; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => _currentGL.Value!; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal set => _currentGL.Value = value; } internal IntPtr ContextHandle => (IntPtr)_context; @@ -122,7 +123,7 @@ namespace StgSharp.Graphics.OpenGL /// /// Bind a frame BufferHandle to a frame BufferHandle target Same function as glBindFramebuffer . + /// href="https://docs._gl/gl3/glBindFramebuffer">glBindFramebuffer. /// /// /// The frame BufferHandle target of the binding operation. @@ -200,8 +201,8 @@ namespace StgSharp.Graphics.OpenGL [MethodImpl(MethodImplOptions.AggressiveInlining)] public void CombineFrameBufferRenderBuffer(FrameBufferAttachment attachment, GlHandle rboHandle) { - Context.glFramebufferRenderbuffer( - glConst.FRAMEBUFFER, (uint)attachment, glConst.RENDERBUFFER, rboHandle.Value); + Context.glFramebufferRenderbuffer(glConst.FRAMEBUFFER, (uint)attachment, glConst.RENDERBUFFER, + rboHandle.Value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -213,13 +214,13 @@ namespace StgSharp.Graphics.OpenGL [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GlHandle CreateGraphicProgram() { - return GlHandle.Alloc(Context.glCreateProgram()); + return GlHandle.Create(Context.glCreateProgram()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public GlHandle CreateProgram() { - return GlHandle.Alloc(Context.glCreateProgram()); + return GlHandle.Create(Context.glCreateProgram()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -245,7 +246,7 @@ namespace StgSharp.Graphics.OpenGL uint error = Context.glGetError(); throw new InvalidOperationException($"Failed in creating shader: {error}"); } - ret[i] = GlHandle.Alloc(id); + ret[i] = GlHandle.Create(id); } return ret; } @@ -273,9 +274,8 @@ namespace StgSharp.Graphics.OpenGL /// /// Delete a render BufferHandle object Very simlilar function as glDeleteRenderbuffers . The - /// only deifference is that this mehtod can only delete one renderbuffer at the same - /// time. + /// href="https://docs.gl/gl3/glDeleteRenderbuffers">glDeleteRenderbuffers. The only + /// deifference is that this mehtod can only delete one renderbuffer at the same time. /// /// /// Handle to BufferHandle to delete. @@ -369,8 +369,7 @@ namespace StgSharp.Graphics.OpenGL GlHandle textureHandle, int level) { - Context.glFramebufferTexture2D( - (uint)target, attachment, (uint)texTarget, textureHandle.Value, level); + Context.glFramebufferTexture2D((uint)target, attachment, (uint)texTarget, textureHandle.Value, level); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -446,8 +445,7 @@ namespace StgSharp.Graphics.OpenGL public string GetShaderStatus(Shader s, int index, int key) { IntPtr sptr = IntPtr.Zero; - if (GraphicFramework.glCheckShaderStatus(ref Context, s.handle[index].Value, key, - ref sptr) == 0) { + if (GraphicFramework.glCheckShaderStatus(ref Context, s.handle[index].Value, key, ref sptr) == 0) { return Marshal.PtrToStringAnsi(sptr); } return string.Empty; @@ -462,13 +460,9 @@ namespace StgSharp.Graphics.OpenGL T[] dataStream) where T: unmanaged,INumber { - #pragma warning disable CS8500 - fixed (T* tptr = dataStream) - { - Context.glGetTexImage((uint)target, level, (uint)channel, (uint)channelLayout, - tptr); + fixed (T* tptr = dataStream) { + Context.glGetTexImage((uint)target, level, (uint)channel, (uint)channelLayout, tptr); } - #pragma warning restore CS8500 } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -495,7 +489,7 @@ namespace StgSharp.Graphics.OpenGL throw new UniformEmptyReferenceException(nameof(program), name); } #endif - return GlHandle.SignedAlloc(ret); + return GlHandle.CreateSigned(ret); } } @@ -546,8 +540,8 @@ namespace StgSharp.Graphics.OpenGL ref byte[] stream) { fixed (byte* bptr = stream) { - Context.glReadPixels - (beginPosition.X, beginPosition.Y, size.width, size.height, (uint)format, (uint)dataType, bptr); + Context.glReadPixels(beginPosition.X, beginPosition.Y, size.width, size.height, (uint)format, + (uint)dataType, bptr); } } @@ -562,8 +556,8 @@ namespace StgSharp.Graphics.OpenGL throw new GlArrayFormatException(dataType, "i.PixelArray"); } fixed (byte* bptr = pixels) { - Context.glReadPixels - (beginPosition.X, beginPosition.Y, i.Width, i.Height, (uint)format, (uint)dataType, bptr); + Context.glReadPixels(beginPosition.X, beginPosition.Y, i.Width, i.Height, (uint)format, (uint)dataType, + bptr); } i.PixelUpdateCount++; } @@ -573,9 +567,9 @@ namespace StgSharp.Graphics.OpenGL where T: unmanaged,INumber { int size = Marshal.SizeOf(); - #pragma warning disable CS8500 + T* p = &bufferData; - #pragma warning restore CS8500 + Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)p, (uint)usage); } @@ -587,12 +581,9 @@ namespace StgSharp.Graphics.OpenGL if (bufferArray == null) { return; } - #pragma warning disable CS8500 - fixed (void* bufferPtr = bufferArray) - #pragma warning restore CS8500 - { - Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, - (uint)usage); + + fixed (void* bufferPtr = bufferArray) { + Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, (uint)usage); } } @@ -604,12 +595,9 @@ namespace StgSharp.Graphics.OpenGL if (bufferSpan == null) { return; } - #pragma warning disable CS8500 - fixed (void* bufferPtr = bufferSpan) - #pragma warning restore CS8500 - { - Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, - (uint)usage); + + fixed (void* bufferPtr = bufferSpan) { + Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, (uint)usage); } } @@ -622,12 +610,9 @@ namespace StgSharp.Graphics.OpenGL return; } - #pragma warning disable CS8500 - fixed (void* bufferPtr = bufferArray) - #pragma warning restore CS8500 - { - Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, - (uint)usage); + + fixed (void* bufferPtr = bufferArray) { + Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, (uint)usage); } } @@ -636,12 +621,9 @@ namespace StgSharp.Graphics.OpenGL where T: unmanaged, IUnmanagedVector { int size = bufferSpan.Length * Marshal.SizeOf(typeof(T)); - #pragma warning disable CS8500 - fixed (void* bufferPtr = bufferSpan) - #pragma warning restore CS8500 - { - Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, - (uint)usage); + + fixed (void* bufferPtr = bufferSpan) { + Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, (uint)usage); } } @@ -653,12 +635,8 @@ namespace StgSharp.Graphics.OpenGL if (bufferArray == null) { return; } - #pragma warning disable CS8500 - fixed (void* bufferPtr = bufferArray) - #pragma warning restore CS8500 - { - Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, - (uint)usage); + fixed (void* bufferPtr = bufferArray) { + Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, (uint)usage); } } @@ -667,8 +645,7 @@ namespace StgSharp.Graphics.OpenGL RenderBufferInternalFormat internalFormat, (int width, int height) size) { - Context.glRenderbufferStorage( - glConst.RENDERBUFFER, (uint)internalFormat, size.width, size.height); + Context.glRenderbufferStorage(glConst.RENDERBUFFER, (uint)internalFormat, size.width, size.height); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -676,8 +653,8 @@ namespace StgSharp.Graphics.OpenGL RenderBufferInternalFormat internalFormat, (uint width, uint height) size) { - Context.glRenderbufferStorage( - glConst.RENDERBUFFER, (uint)internalFormat, (int)size.width, (int)size.height); + Context.glRenderbufferStorage(glConst.RENDERBUFFER, (uint)internalFormat, (int)size.width, + (int)size.height); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -700,14 +677,12 @@ namespace StgSharp.Graphics.OpenGL T[] pixels) where T: unmanaged, INumber { - #pragma warning disable CS8500 fixed (T* tptr = pixels) { T* ptr = ((pixels == null) || (pixels.Length == 0)) ? (T*)IntPtr.Zero : tptr; - Context.glTexImage2D - ((uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, (uint)type, tptr); + Context.glTexImage2D((uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, + (uint)type, tptr); } - #pragma warning restore CS8500 } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -722,13 +697,10 @@ namespace StgSharp.Graphics.OpenGL Span pixelSpan) where T: unmanaged, INumber { - #pragma warning disable CS8500 - fixed (T* tptr = pixelSpan) - { - Context.glTexImage2D - ((uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, (uint)type, tptr); + fixed (T* tPtr = pixelSpan) { + Context.glTexImage2D((uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, + (uint)type, tPtr); } - #pragma warning restore CS8500 } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -768,8 +740,7 @@ namespace StgSharp.Graphics.OpenGL internal static OpenGLFunction BuildGlFunctionPackage(IntPtr handle) { - OpenGLFunction pack; - if (contextToGLMap.TryGetValue(handle, out pack)) { + if (contextToGLMap.TryGetValue(handle, out OpenGLFunction pack)) { return pack; } pack = new OpenGLFunction @@ -782,7 +753,7 @@ namespace StgSharp.Graphics.OpenGL ~OpenGLFunction() { - contextToGLMap.Remove(ContextHandle); + _ = contextToGLMap.Remove(ContextHandle); } } diff --git a/StgSharp.Common/Graphics/OpenGL/glHalfNV.cs b/StgSharp.Common/Graphics/OpenGL/glHalfNV.cs deleted file mode 100644 index 48928ad1..00000000 --- a/StgSharp.Common/Graphics/OpenGL/glHalfNV.cs +++ /dev/null @@ -1,69 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="glHalfNV" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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 System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -namespace StgSharp.Graphics.OpenGL -{ - [StructLayout(LayoutKind.Explicit, Size = 16)] - public struct glHalfNV - { - - [FieldOffset(0)] public short binary; - - public glHalfNV(short bin) - { - binary = bin; - } - - public static glHalfNV FromInt16(short x) - { - return new glHalfNV(x); - } - - public static short ToInt16(glHalfNV half) - { - return half.binary; - } - - public static explicit operator glHalfNV(short x) - { - return new glHalfNV(x); - } - - public static explicit operator short(glHalfNV x) - { - return x.binary; - } - - } -} diff --git a/StgSharp.Common/Graphics/OpenGL/glHandle.cs b/StgSharp.Common/Graphics/OpenGL/glHandle.cs index 3d0f3674..c751ac04 100644 --- a/StgSharp.Common/Graphics/OpenGL/glHandle.cs +++ b/StgSharp.Common/Graphics/OpenGL/glHandle.cs @@ -48,6 +48,7 @@ namespace StgSharp.Graphics.OpenGL public static GlHandle Zero { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new GlHandle { Value = 0 @@ -55,7 +56,7 @@ namespace StgSharp.Graphics.OpenGL } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static GlHandle Alloc(uint value) + public static GlHandle Create(uint value) { return new GlHandle { @@ -64,7 +65,7 @@ namespace StgSharp.Graphics.OpenGL } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static GlHandle SignedAlloc(int value) + public static GlHandle CreateSigned(int value) { return new GlHandle { diff --git a/StgSharp.Common/Graphics/OpenGL/glRenderThreadSecurity.cs b/StgSharp.Common/Graphics/OpenGL/glRenderStream.ThreadSecurity.cs similarity index 97% rename from StgSharp.Common/Graphics/OpenGL/glRenderThreadSecurity.cs rename to StgSharp.Common/Graphics/OpenGL/glRenderStream.ThreadSecurity.cs index 53b6fe5b..4476103d 100644 --- a/StgSharp.Common/Graphics/OpenGL/glRenderThreadSecurity.cs +++ b/StgSharp.Common/Graphics/OpenGL/glRenderStream.ThreadSecurity.cs @@ -39,7 +39,7 @@ namespace StgSharp.Graphics.OpenGL { private static ConcurrentDictionary threadLocalIndex - = new ConcurrentDictionary(); + = new(); private readonly SynchronizationContext mainThreadContext = SynchronizationContext.Current; } diff --git a/StgSharp.Common/Graphics/OpenGL/glType.cs b/StgSharp.Common/Graphics/OpenGL/glType.cs index cd48064d..f4d5dff4 100644 --- a/StgSharp.Common/Graphics/OpenGL/glType.cs +++ b/StgSharp.Common/Graphics/OpenGL/glType.cs @@ -35,40 +35,60 @@ namespace StgSharp.Internal.OpenGL { internal delegate void GLVULKANPROCNV(); - public unsafe struct glHandleARB + public unsafe struct glHandleARB(IntPtr value) { } + + /// + /// OpenGL numeric type. An IEEE-754 floating-point value, clamped to the range [0,1]. + /// + [StructLayout(LayoutKind.Sequential)] + public struct GlClampF { - private dynamic value; + public float value; - public unsafe glHandleARB(dynamic value) + public GlClampF(float a) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - if (value.GetType().Name != "Uint32") - { - goto errorLog; - } - this.value = value; - } else - { - if (value.GetType().Name != "IntPtr") - { - goto errorLog; - } - this.value = value; - } - - errorLog: - { - DefaultLog.InternalWriteLog( - $"{value.GetType().Name} does not match definination of GLhandlARB on OS {Environment.OSVersion.Platform} ", - LogType.Error); - } + value = a; } - public static implicit operator uint(glHandleARB value) + } + + [StructLayout(LayoutKind.Explicit, Size = 16)] + public struct glHalfNv(Half bin) + { + + [FieldOffset(0)] public Half binary = bin; + + public float ToSingle() { - return (uint)value; + return (float)binary; + } + + } + + [StructLayout(LayoutKind.Explicit, Size = 8)] + public struct GlFixed + { + + [FieldOffset(0)] public int All; + [FieldOffset(0)] public short Decimals; + [FieldOffset(4)] public short Integer; + + } + + /// + /// OpenGL numeric type. An IEEE-754 double precision floating-point value, clamped to the + /// range [0,1]. + /// + [StructLayout(LayoutKind.Sequential)] + public struct GlClampD + { + + public double value; + + public GlClampD(double a) + { + value = a; } } diff --git a/StgSharp.Common/Graphics/ShaderEdit/ShaderStruct.cs b/StgSharp.Common/Graphics/ShaderEdit/ShaderStruct.cs index a7892f8b..bc75b401 100644 --- a/StgSharp.Common/Graphics/ShaderEdit/ShaderStruct.cs +++ b/StgSharp.Common/Graphics/ShaderEdit/ShaderStruct.cs @@ -25,6 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- +using StgSharp.Graphics; using StgSharp.Graphics.OpenGL; using System; diff --git a/StgSharp.Common/Graphics/TextureProvider.cs b/StgSharp.Common/Graphics/TextureProvider.cs index 535de4c6..019a75f5 100644 --- a/StgSharp.Common/Graphics/TextureProvider.cs +++ b/StgSharp.Common/Graphics/TextureProvider.cs @@ -29,6 +29,7 @@ using StgSharp.Mathematics.Graphic; using System; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; namespace StgSharp.Graphics { @@ -46,11 +47,13 @@ namespace StgSharp.Graphics public ref Vec2 this[int index] { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get => ref _texCoord[index]; } public Span TextureCoordinate { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Span(_texCoord); } diff --git a/StgSharp.Common/Graphics/framework.cs b/StgSharp.Common/Graphics/framework.cs index 788f2f45..e661c183 100644 --- a/StgSharp.Common/Graphics/framework.cs +++ b/StgSharp.Common/Graphics/framework.cs @@ -25,15 +25,8 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using StgSharp.Graphics; - using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Text; #if Windows // using Windows.Win32; diff --git a/StgSharp.Common/Graphics/frameworkSyncContext.cs b/StgSharp.Common/Graphics/frameworkSyncContext.cs index d8fcfb06..6644605c 100644 --- a/StgSharp.Common/Graphics/frameworkSyncContext.cs +++ b/StgSharp.Common/Graphics/frameworkSyncContext.cs @@ -30,6 +30,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -39,22 +40,19 @@ namespace StgSharp.Threading public class FrameworkSyncContext : SynchronizationContext { - private static readonly FrameworkSyncContext _mainThreadContext = new FrameworkSyncContext(); - - private readonly BlockingCollection _syncContexts = new BlockingCollection( - ); + private readonly BlockingCollection _syncContexts = []; private readonly Thread _mainThread = Thread.CurrentThread; public FrameworkSyncContext() { - _syncContexts = new BlockingCollection(); _mainThread = Thread.CurrentThread; } public static FrameworkSyncContext MainThreadContext { - get => _mainThreadContext; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get; + } = new FrameworkSyncContext(); public override void Post(SendOrPostCallback d, object state) { diff --git a/StgSharp.Common/HighPerformance/M128.cs b/StgSharp.Common/HighPerformance/M128.cs index 53d1b251..61066ab5 100644 --- a/StgSharp.Common/HighPerformance/M128.cs +++ b/StgSharp.Common/HighPerformance/M128.cs @@ -70,7 +70,7 @@ namespace StgSharp.HighPerformance public void BroadCastFrom(T value) where T: unmanaged, INumber { - Vec = Vector128.CreateScalarUnsafe(value).As(); + Vec = Vector128.Create(value).AsSingle(); } public override readonly bool Equals([NotNullWhen(true)] object obj) diff --git a/StgSharp.Common/HighPerformance/M256.cs b/StgSharp.Common/HighPerformance/M256.cs index 4683700c..3746e2ed 100644 --- a/StgSharp.Common/HighPerformance/M256.cs +++ b/StgSharp.Common/HighPerformance/M256.cs @@ -52,7 +52,7 @@ namespace StgSharp.HighPerformance public void BroadCastFrom(T value) where T: unmanaged, INumber { - Vec = Vector256.CreateScalarUnsafe(value).As(); + Vec = Vector256.Create(value).AsSingle(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/StgSharp.Common/HighPerformance/M512.cs b/StgSharp.Common/HighPerformance/M512.cs index e68cf449..6db9a3e7 100644 --- a/StgSharp.Common/HighPerformance/M512.cs +++ b/StgSharp.Common/HighPerformance/M512.cs @@ -51,7 +51,7 @@ namespace StgSharp.HighPerformance public void BroadCastFrom(T value) where T: unmanaged, INumber { - Vec = Vector512.CreateScalarUnsafe(value).As(); + Vec = Vector512.Create(value).AsSingle(); } public ref T Member(int index) where T: unmanaged, INumber diff --git a/StgSharp.Common/HighPerformance/M64.cs b/StgSharp.Common/HighPerformance/M64.cs index 19412588..13b4a67e 100644 --- a/StgSharp.Common/HighPerformance/M64.cs +++ b/StgSharp.Common/HighPerformance/M64.cs @@ -28,6 +28,7 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; namespace StgSharp.HighPerformance { @@ -37,6 +38,7 @@ namespace StgSharp.HighPerformance [FieldOffset(0)] private fixed byte buffer[8]; [FieldOffset(0)] private ulong value; + [FieldOffset(0)] private Vector64 vec; public M64() { @@ -49,12 +51,17 @@ namespace StgSharp.HighPerformance return ref Unsafe.As(ref buffer[0]); } + public void BroadCastFrom(T value) where T: unmanaged, INumber + { + vec = Vector64.Create(value).AsSingle(); + } + public override bool Equals(object obj) { return obj is M64 m64 && this == m64; } - public override int GetHashCode() + public override readonly int GetHashCode() { return value.GetHashCode(); } diff --git a/StgSharp.Common/Internal/Graphic/glfw.cs b/StgSharp.Common/Internal/Graphic/glfw.cs index 4379aa9b..1744e077 100644 --- a/StgSharp.Common/Internal/Graphic/glfw.cs +++ b/StgSharp.Common/Internal/Graphic/glfw.cs @@ -32,10 +32,23 @@ using System.Text; namespace StgSharp.Internal { + public class GraphicModule : IStaticModule + { + + public string ModuleName => "Graphic"; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void InitializeModule() + { + GraphicFramework.LoadGlfw(); + } + + } + internal static unsafe partial class GraphicFramework { - private static readonly GLFWFunction _glfw = new GLFWFunction(); + private static GLFWFunction _glfw ; public static GLFWFunction glfwContext => _glfw; @@ -44,6 +57,7 @@ namespace StgSharp.Internal internal static unsafe void LoadGlfw() { + _glfw = new GLFWFunction(); fixed (GLFWFunction* func = &_glfw) { glfwLoadLibrary(func); } diff --git a/StgSharp.Common/Internal/StructDefine.cs b/StgSharp.Common/Internal/StructDefine.cs index 53fdd0fc..eb3c8ab0 100644 --- a/StgSharp.Common/Internal/StructDefine.cs +++ b/StgSharp.Common/Internal/StructDefine.cs @@ -287,8 +287,8 @@ namespace StgSharp.Internal private IntPtr cursor; // _GLFWcursor* cursor; // glfwVideomode videoMode; // 根据GLFWvidmode的定义转换 private IntPtr monitor; // _GLFWmonitor* monitor; - public fixed byte keys[Constant.GLFW_KEY_LAST + 1]; - public fixed byte mouseButtons[Constant.GLFW_MOUSE_BUTTON_LAST + 1]; + public fixed byte keys[FrameworkConstant.GLFW_KEY_LAST + 1]; + public fixed byte mouseButtons[FrameworkConstant.GLFW_MOUSE_BUTTON_LAST + 1]; // _GLFWcontext viewPortDisplay; // 根据_GLFWcontext的定义转换 @@ -497,8 +497,8 @@ namespace StgSharp.Internal internal unsafe struct GLFWlibrary { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = Constant.GLFW_JOYSTICK_LAST + 1)] - private GLFWjoystick[] joysticks = new GLFWjoystick[Constant.GLFW_JOYSTICK_LAST + 1]; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = FrameworkConstant.GLFW_JOYSTICK_LAST + 1)] + private GLFWjoystick[] joysticks = new GLFWjoystick[FrameworkConstant.GLFW_JOYSTICK_LAST + 1]; private GLFWallocator allocator; diff --git a/StgSharp.Common/Mathematics/Graphic/Camera.cs b/StgSharp.Common/Mathematics/Graphic/Camera.cs index cfdcf701..94652013 100644 --- a/StgSharp.Common/Mathematics/Graphic/Camera.cs +++ b/StgSharp.Common/Mathematics/Graphic/Camera.cs @@ -79,7 +79,7 @@ namespace StgSharp.Mathematics.Graphic return _lookAt; } Matrix44 move = Matrix44.Unit; - move.column3.vec -= cameraAtt.column3.vec; + move.column[3].vec -= cameraAtt.column[3].vec; _lookAt = rotationAtt.Transpose * move; _isLookAtAvailable = true; return _lookAt; @@ -120,19 +120,19 @@ namespace StgSharp.Mathematics.Graphic public void MoveNear(float distance) { - cameraAtt.column3.Z -= distance; + cameraAtt.column[3].Z -= distance; _isLookAtAvailable = false; } public void MoveRight(float distance) { - cameraAtt.column3.X -= distance; + cameraAtt.column[3].X -= distance; _isLookAtAvailable = false; } public void MoveUp(float distance) { - cameraAtt.column3.Y -= distance; + cameraAtt.column[3].Y -= distance; _isLookAtAvailable = false; } @@ -145,7 +145,9 @@ namespace StgSharp.Mathematics.Graphic public void SetViewDirection(Vec3 position, Vec3 target, Vec3 up) { Vec3 direction = position - target; - if ((position.reg == cameraAtt.column3.reg) && (this.up == up) && (cameraAtt.column2.reg == direction.reg)) { + if ((position.reg == cameraAtt.column[3].reg) && + (this.up == up) && + (cameraAtt.column[3].reg == direction.reg)) { return; } if (direction.GetLength() == 0) @@ -165,10 +167,10 @@ namespace StgSharp.Mathematics.Graphic Vec3 right = Linear.Orthogonalize(Linear.Cross(up, direction)); - cameraAtt.column0.reg = right.reg; - cameraAtt.column1.reg = up.reg; - cameraAtt.column2.reg = direction.reg; - cameraAtt.column3.reg = position.reg; + cameraAtt.column[0].reg = right.reg; + cameraAtt.column[1].reg = up.reg; + cameraAtt.column[2].reg = direction.reg; + cameraAtt.column[3].reg = position.reg; InternalPitch(); InternalRow(); @@ -186,13 +188,13 @@ namespace StgSharp.Mathematics.Graphic width = Scaler.Abs(GeometryScaler.Tan(fovRadius / 2) * near * 2), height = width * size.Y / size.X; - _projection.column0.X = 2 * near / width; - _projection.column1.Y = 2 * near / height; - _projection.column2.X = 2 * offsetX / width; - _projection.column2.Y = 2 * offsetY / height; - _projection.column2.Z = (far + near) / (near - far); - _projection.column2.W = -1; - _projection.column3.Z = 2 * near * far / (near - far); + _projection.column[0].X = 2 * near / width; + _projection.column[1].Y = 2 * near / height; + _projection.column[2].X = 2 * offsetX / width; + _projection.column[2].Y = 2 * offsetY / height; + _projection.column[2].Z = (far + near) / (near - far); + _projection.column[2].W = -1; + _projection.column[3].Z = 2 * near * far / (near - far); } public void Test(params Vec4[] vec) diff --git a/StgSharp.Common/Mathematics/Graphic/Matrix44.cs b/StgSharp.Common/Mathematics/Graphic/Matrix44.cs index dc37b507..7ff55d95 100644 --- a/StgSharp.Common/Mathematics/Graphic/Matrix44.cs +++ b/StgSharp.Common/Mathematics/Graphic/Matrix44.cs @@ -41,13 +41,10 @@ namespace StgSharp.Mathematics.Graphic { [FieldOffset(2 * 64 * sizeof(float))] internal bool isTransposed; + [FieldOffset(0 * sizeof(float))] internal Column column; [FieldOffset(0)] internal ColumnSet4 mat; [FieldOffset(16 * sizeof(float))] internal ColumnSet4 transpose; - [FieldOffset(0 * sizeof(float))] internal Vec4 column0; - [FieldOffset(4 * sizeof(float))] internal Vec4 column1; - [FieldOffset(8 * sizeof(float))] internal Vec4 column2; - [FieldOffset(12 * sizeof(float))] internal Vec4 column3; internal Matrix44(ColumnSet4 mat) { @@ -273,11 +270,18 @@ namespace StgSharp.Mathematics.Graphic IEnumerator IEnumerable.GetEnumerator() { - ref Vec4 col0 = ref column0; for (int i = 0; i < 4; i++) { - yield return Unsafe.Add(ref col0, i); + yield return column[i]; } } + [InlineArray(4)] + internal struct Column + { + + private Vec4 value; + + } + } } diff --git a/StgSharp.Common/Mathematics/Graphic/Vec4.cs b/StgSharp.Common/Mathematics/Graphic/Vec4.cs index 44edf4ae..1629f1ec 100644 --- a/StgSharp.Common/Mathematics/Graphic/Vec4.cs +++ b/StgSharp.Common/Mathematics/Graphic/Vec4.cs @@ -38,7 +38,7 @@ namespace StgSharp.Mathematics.Graphic { [CollectionBuilder(builderType:typeof(Vec4), methodName: nameof(Vec4.FromSpan))] [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)] - public unsafe struct Vec4 : IEquatable, IUnmanagedVector + public unsafe struct Vec4 : IEquatable, IUnmanagedVector { [FieldOffset(0)] internal unsafe fixed float num[4]; diff --git a/StgSharp.Common/PlainGeometryCollisionSensor.cs b/StgSharp.Common/PlainGeometryCollisionSensor.cs deleted file mode 100644 index 442c53f3..00000000 --- a/StgSharp.Common/PlainGeometryCollisionSensor.cs +++ /dev/null @@ -1,81 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="PlainGeometryCollisionSensor" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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.Geometries; - -using System; -using System.Runtime.CompilerServices; - -namespace StgSharp -{ - public class CollisionEventArgs : EventArgs - { - - public CollisionEventArgs(IGeometry target, IGeometry boarder) - { - Target = target; - Boarder = boarder; - } - - public IGeometry Target { get; set; } - - public IGeometry Boarder { get; set; } - - } - - public class PlainGeometryCollisionSensor where TBoarder: IGeometry where TTarget: IGeometry - { - - internal EventHandler _rule; - internal PlainGeometry _boarder; - internal PlainGeometry _target; - - public event EventHandler Rule - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - add => _rule += value; - remove - { - if (value == null) { - return; - } -#pragma warning disable CS8601 - _rule -= value; -#pragma warning restore CS8601 - } - } - - public PlainGeometry boarder => _boarder; - - public PlainGeometry target - { - get => _target; - set => _target = value; - } - - } -} diff --git a/StgSharp.Common/StateMachine.cs b/StgSharp.Common/StateMachine.cs deleted file mode 100644 index c3ac794e..00000000 --- a/StgSharp.Common/StateMachine.cs +++ /dev/null @@ -1,59 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="StateMachine" -// Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. 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 System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StgSharp -{ - public interface IStateMachine where T: Enum - { - - public T LastStableState { get; } - - public bool TryEnterState(); - - public bool TryExitState(); - - public bool TrySwitchState(); - - } - - public interface IStateMachineWithSwitchSpan : IStateMachine where TState: Enum - { - - public bool IsInStabelState { get; } - - public TState NextStableState { get; } - - public bool TrySwitchState(); - - } -} diff --git a/StgSharp.Common/Timing/TimeFunction.cs b/StgSharp.Common/Timing/TimeFunction.cs index 0fbd2000..087cb14e 100644 --- a/StgSharp.Common/Timing/TimeFunction.cs +++ b/StgSharp.Common/Timing/TimeFunction.cs @@ -27,6 +27,7 @@ // ----------------------------------------------------------------------- using System; using System.Collections.Generic; +using System.Runtime.CompilerServices; using System.Text; namespace StgSharp.Timing @@ -53,24 +54,31 @@ namespace StgSharp.Timing public virtual bool IsComplete { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get => _timeProvider.CurrentSecond > _ending; } public Func TimeRelatedCalculation { - get { return _timeRelatedCalculation; } - set { _timeRelatedCalculation = value; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => _timeRelatedCalculation; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set => _timeRelatedCalculation = value; } public static TimeFunction One { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new TimeFunctionOne(); } public TimeSpanProvider TimeSpanProvider { - get { return _timeProvider; } - set { _timeProvider = value; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => _timeProvider; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set => _timeProvider = value; } public virtual float Calculate() @@ -96,7 +104,7 @@ namespace StgSharp.Timing return new TimeFunction(_timeProvider, func, range); } - public void Reset() + public virtual void Reset() { float range = _ending - _beginning; _beginning = _timeProvider.CurrentSecond; @@ -117,10 +125,7 @@ namespace StgSharp.Timing internal TimeFunctionOne() : base() { } - public override bool IsComplete - { - get => true; - } + public override bool IsComplete => true; public override float Calculate() { @@ -138,9 +143,9 @@ namespace StgSharp.Timing } #pragma warning disable CA1822 - public new void Reset() + public override void Reset() + { + } #pragma warning restore CA1822 - { } - } } diff --git a/StgSharp.Common/Timing/TimeProvider.cs b/StgSharp.Common/Timing/TimeProvider.cs index cedae21c..fe4d687b 100644 --- a/StgSharp.Common/Timing/TimeProvider.cs +++ b/StgSharp.Common/Timing/TimeProvider.cs @@ -25,6 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- +using StgSharp.Collections; using StgSharp.Timing; using System; @@ -48,7 +49,7 @@ namespace StgSharp public sealed class StgSharpTime : TimeSourceProviderBase { - private static List subscriberList = []; + private static readonly LinearBag _subscribers = new(); private static long accuracy; private static readonly Stopwatch mainProvider = new(); private static Thread timeProvideThread; @@ -65,21 +66,21 @@ namespace StgSharp mainProvider.Start(); // speed test - long totalMS, internalFrequncy = Stopwatch.Frequency; + long totalMS, internalFrequency = Stopwatch.Frequency; for (int i = 0; i < 100; i++) { - totalMS = mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L)); + totalMS = mainProvider.ElapsedTicks / (internalFrequency / (1000L * 1000L)); for (int t = 0; t < 10; t++) { if (totalMS < 1000) { - subscriberList.Add( + _subscribers.Add( new TimeSpanProvider(100L, TimeSpanProvider.DefaultProvider)); } } } mainProvider.Stop(); - subscriberList.Clear(); - totalMS = mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L)) / 100L; + _subscribers.Clear(); + totalMS = mainProvider.ElapsedTicks / (internalFrequency / (1000L * 1000L)) / 100L; accuracy = totalMS * 2 / 3; mainProvider.Reset(); timeProvideThread = new Thread(new ThreadStart(ProvideTime)); @@ -102,44 +103,36 @@ namespace StgSharp protected sealed override void AddSubscriberUnsynced(TimeSpanProvider subscriber) { - subscriberList.Add(subscriber); + _subscribers.Add(subscriber); } protected sealed override void RemoveSubscriberUnsynced(TimeSpanProvider subscriber) { - _ = subscriberList.Remove(subscriber); + _subscribers.Remove(subscriber); } private void ProvideTime() { - long totalMS, internalFrequncy = Stopwatch.Frequency; + long totalMS, internalFrequency = Stopwatch.Frequency; lock (mainProvider) { mainProvider.Restart(); } while (mainProvider.IsRunning) { - totalMS = mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L)); - if (subscriberList.Count == 0) + totalMS = mainProvider.ElapsedTicks / (internalFrequency / (1000L * 1000L)); + if (_subscribers.Count == 0) { continue; } lock (SubscribeLock) { - List toRemoveList = []; - foreach (TimeSpanProvider subscriber in subscriberList) + for (int i = 0; i < _subscribers.Count; i++) { - if (!subscriber.CheckTime(totalMS)) + if (!_subscribers[i].CheckTime(totalMS)) { - toRemoveList.Add(subscriber); + _subscribers.RemoveAt(i); DefaultLog.InternalWriteLog( - $"Time subscriber {subscriber} is to be removed.", LogType.Info); - } - ; - } - if (toRemoveList.Count != 0) - { - foreach (TimeSpanProvider subscriber in toRemoveList) { - _ = subscriberList.Remove(subscriber); + $"Time subscriber {_subscribers[i]} is to be removed.", LogType.Info); } } } diff --git a/StgSharp.Common/Timing/TimeSourceProvider.cs b/StgSharp.Common/Timing/TimeSourceProvider.cs index 49897242..5d6f98d3 100644 --- a/StgSharp.Common/Timing/TimeSourceProvider.cs +++ b/StgSharp.Common/Timing/TimeSourceProvider.cs @@ -36,20 +36,18 @@ namespace StgSharp.Timing public abstract class TimeSourceProviderBase { - private readonly object _subscriberLock = new(); - - protected object SubscribeLock => _subscriberLock; + protected object SubscribeLock { get; } = new(); public void AddSubscriber(TimeSpanProvider subscriber) { - lock (_subscriberLock) { + lock (SubscribeLock) { AddSubscriberUnsynced(subscriber); } } public void RemoveSubscriber(TimeSpanProvider subscriber) { - lock (_subscriberLock) { + lock (SubscribeLock) { RemoveSubscriberUnsynced(subscriber); } } diff --git a/StgSharp.Common/Timing/TimeSpanProvider.cs b/StgSharp.Common/Timing/TimeSpanProvider.cs index 4eb4bfa2..947dc4c2 100644 --- a/StgSharp.Common/Timing/TimeSpanProvider.cs +++ b/StgSharp.Common/Timing/TimeSpanProvider.cs @@ -30,6 +30,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; @@ -43,11 +44,10 @@ namespace StgSharp.Timing private bool _subscribed; - private ConcurrentQueue _tokenToAdd = new ConcurrentQueue( - ); - private ConcurrentQueue _tokenToQuit; - private Counter timeSpanCount = new Counter(-1, 1, 1); - private HashSet _awaitingTokens; + private readonly ConcurrentQueue _tokenToAdd = new(); + private readonly ConcurrentQueue _tokenToQuit; + private Counter timeSpanCount = new(-1, 1, 1); + private readonly HashSet _awaitingTokens; private long _maxSpanCount; private long _spanBegin; private readonly long _spanLength; @@ -71,7 +71,7 @@ namespace StgSharp.Timing _maxSpanCount = int.MaxValue; provider.AddSubscriber(this); _subscribed = true; - _awaitingTokens = new HashSet(); + _awaitingTokens = []; _tokenToQuit = new ConcurrentQueue(); } @@ -94,7 +94,7 @@ namespace StgSharp.Timing _maxSpanCount = long.MaxValue; provider.AddSubscriber(this); _subscribed = true; - _awaitingTokens = new HashSet(); + _awaitingTokens = []; _tokenToQuit = new ConcurrentQueue(); } @@ -128,21 +128,25 @@ namespace StgSharp.Timing public double SpanLength { - get => (_spanLength * 1.0) / (1000L * 1000L); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => _spanLength * 1.0 / (1000L * 1000L); } public float CurrentSecond { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get => timeSpanCount.Value * SpanLengthLowPrecession; } public float SpanLengthLowPrecession { - get => (_spanLength * 1.0f) / (1000 * 1000); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => _spanLength * 1.0f / (1000 * 1000); } public int CurrentSpan { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get => timeSpanCount.Value; } @@ -153,7 +157,7 @@ namespace StgSharp.Timing public TimeSpanAwaitingToken ParticipantSpanAwaiting(int count) { - TimeSpanAwaitingToken token = new TimeSpanAwaitingToken(this, count); + TimeSpanAwaitingToken token = new(this, count); _tokenToAdd.Enqueue(token); return token; } @@ -165,7 +169,7 @@ namespace StgSharp.Timing public void StopSpanProviding() { - Interlocked.Exchange(ref _maxSpanCount, 0); + _ = Interlocked.Exchange(ref _maxSpanCount, 0); } public void SubscribeToTimeSource(TimeSourceProviderBase serviceHandler) @@ -207,7 +211,7 @@ namespace StgSharp.Timing { if (item.AwaitingSemaphoreSlim.CurrentCount == 0) { - item.AwaitingSemaphoreSlim.Release(); + _ = item.AwaitingSemaphoreSlim.Release(); item.Refresh(); } else { diff --git a/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs b/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs index b7599d40..c09ab6e9 100644 --- a/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs +++ b/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs @@ -106,8 +106,8 @@ namespace StgSharp.Mathematics.Numeric } MatrixParallel.ReturnParallelResources(ref pool); } - MatrixParallelHandle taskGroup = MatrixParallel.PublicTask(left.GetColumnEnumeration(), - (delegate**, MatrixKernel*, MatrixKernel*, void>)NativeIntrinsic.Intrinsic.f32_add); + MatrixParallelHandle taskGroup = MatrixParallel.PublicNoAnswerTask(left.GetColumnEnumeration(), scaler, + (delegate* unmanaged[Cdecl]*, ScalarPacket*, void>)NativeIntrinsic.Intrinsic.f32_add); MatrixParallel.LaunchParallel(taskGroup, SleepMode.DeepSleep); /* diff --git a/StgSharp.Mathematics/Numeric/MatrixComputeModel.cs b/StgSharp.Mathematics/Numeric/MatrixComputeModel.cs index acef2dab..d16f2df1 100644 --- a/StgSharp.Mathematics/Numeric/MatrixComputeModel.cs +++ b/StgSharp.Mathematics/Numeric/MatrixComputeModel.cs @@ -2,8 +2,8 @@ // ----------------------------------------------------------------------- // file="MatrixComputeModel" // Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// AuthorGroup: Nitload +// Copyright (c) Nitload. 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 @@ -25,6 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- +using StgSharp.HighPerformance; using System; using System.Runtime.CompilerServices; diff --git a/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs b/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs index 8b191f0e..e98b5dd9 100644 --- a/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs +++ b/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs @@ -40,6 +40,27 @@ namespace StgSharp.Mathematics.Numeric public static partial class MatrixParallel { + public static unsafe MatrixParallelHandle PublicNoAnswerTask( + MatrixSegmentEnumeration source, + ScalarPacket* additional, + delegate* unmanaged[Cdecl]*, ScalarPacket*, void> computeHandle) + where T: unmanaged, INumber + { + MatrixParallelTaskPackage* package = MatrixParallelFactory.CreateBaseTask(); + package->Scalar = additional; + package->Right = source.Source; + package->RightPrimOffset = source.PrimOffset; + package->RightPrimStride = source.PrimStride; + package->RightSecOffset = source.SecondaryOffset; + package->RightSecStride = source.SecondaryStride; + package->PrimCount = source.PrimSize; + package->SecCount = source.SecondarySize; + package->ElementSize = sizeof(T); + package->ComputeHandle = (nint)computeHandle; + package->ComputeMode = 6; // no ans + return PublicTaskPrivate(package); + } + public static unsafe MatrixParallelHandle PublicTask( MatrixSegmentEnumeration source, MatrixSegmentEnumeration ans, diff --git a/StgSharp.Mathematics/Numeric/MatrixParallel.cs b/StgSharp.Mathematics/Numeric/MatrixParallel.cs index 2d48becf..81981676 100644 --- a/StgSharp.Mathematics/Numeric/MatrixParallel.cs +++ b/StgSharp.Mathematics/Numeric/MatrixParallel.cs @@ -59,7 +59,16 @@ namespace StgSharp.Mathematics.Numeric Monitor.Exit(_lock); } - public static void Init() + public static void LaunchParallel(MatrixParallelHandle handle, SleepMode afterWork) + { + RemainThreadCount = _threads.Count; + _AfterWork = (ThreadPriority)afterWork; + foreach (MatrixParallelWrap w in handle.Wraps) { + w.SchedulerReset.Set(); + } + } + + internal static void Init() { if (IsInitialized) { return; @@ -79,14 +88,5 @@ namespace StgSharp.Mathematics.Numeric IsInitialized = true; } - public static void LaunchParallel(MatrixParallelHandle handle, SleepMode afterWork) - { - RemainThreadCount = _threads.Count; - _AfterWork = (ThreadPriority)afterWork; - foreach (MatrixParallelWrap w in handle.Wraps) { - w.SchedulerReset.Set(); - } - } - } } \ No newline at end of file diff --git a/StgSharp.Mathematics/Numeric/MatrixParallelHandle.cs b/StgSharp.Mathematics/Numeric/MatrixParallelHandle.cs index 2de055e7..0f7c3ce6 100644 --- a/StgSharp.Mathematics/Numeric/MatrixParallelHandle.cs +++ b/StgSharp.Mathematics/Numeric/MatrixParallelHandle.cs @@ -1,9 +1,9 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="MatrixParallelHandle" +// file="MatrixParallelPool" // Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. All rights reserved. +// 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 @@ -25,181 +25,153 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using StgSharp.HighPerformance; - +using StgSharp.Collections; using System; -using System.Numerics; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; namespace StgSharp.Mathematics.Numeric { - [StructLayout(LayoutKind.Sequential)] - internal unsafe struct MatrixParallelTaskPackageNonGeneric + public struct MatrixParallelHandle : IDisposable { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe void Copy( - MatrixParallelTaskPackageNonGeneric* source, - MatrixParallelTaskPackageNonGeneric* target) + private static readonly (int a, int b)[] LookupTable = [ (1, 1), // 7 + (0, 2), // 8 (no non-zero solution) + (3, 0), // 9 (no non-zero solution) + (2, 1), // 10 + (1, 2), // 11 + (0, 3), // 12 (no non-zero solution) + (3, 1), // 13 + (2, 2), // 14 + (1, 3), // 15 + (4, 1), // 16 + (3, 2), // 17 + (2, 3), // 18 + (1, 4), // 19 + (4, 2), // 20 + ]; + + private MatrixParallelThread[] _threads; + private bool _disposed = false; + private CapacityFixedStack _wraps; + + internal MatrixParallelHandle(MatrixParallelThread[] threadArray) { - Buffer.MemoryCopy(source, target, sizeof(MatrixParallelTaskPackageNonGeneric), - sizeof(MatrixParallelTaskPackageNonGeneric)); + _threads = threadArray; + IsMultithread = threadArray.Length > 1; + SliceToWraps(); } - #region source - - // Group 1: Left/Right matrix kernel base address - public IntPtr Left; // 8 - public IntPtr Right; // 8 - - #endregion - - #region ans - - // Group 2: Result kernel base address + reserved - public IntPtr Result; // 8 - public int ElementSize; - public int ReservedPtr0; // 4 (extension/reserved) - - #endregion - - #region left enum - - public int LeftPrimOffset; // 4 - public int LeftPrimStride; // 4 - public int LeftSecOffset; // 4 - public int LeftSecStride; // 4 - - #endregion - - #region right enum - - public int RightPrimOffset; // 4 - public int RightPrimStride; // 4 - public int RightSecOffset; // 4 - public int RightSecStride; // 4 - - #endregion - - #region ans enum - - public int ResultPrimOffset; // 4 - public int ResultPrimStride; // 4 - public int ResultSecOffset; // 4 - public int ResultSecStride; // 4 - - #endregion - - #region scalar/compute - - public ScalarPacket* Scalar; // 8 - public IntPtr ComputeHandle; // 8 - - #endregion - - #region global profile - - public int PrimCount; // 4 - public int ComputeMode; // 4 - public int SecCount; // 4 - private int ReservedInt0; // 4 - - #endregion - - #region count offset - - public int PrimTileOffset; // 4 - public int SecTileOffset; // 4 - public int PrimCountInTile; // 4 - public int SecCountInTile; // 4 - - #endregion - } - - [StructLayout(LayoutKind.Sequential)] - internal unsafe struct MatrixParallelTaskPackage where T: unmanaged, INumber - { - - public MatrixParallelTaskPackage() + public ReadOnlySpan Threads { - Unsafe.SkipInit(out this); + get + { + if (_disposed) { + throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name); + } + return _threads; + } + } + + internal IEnumerable Wraps + { + get + { + if (_disposed) { + throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name); + } + return _wraps; + } + } + + internal ReadOnlySpan ThreadsUnsafe + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => _threads; + } + + private bool IsMultithread { get; init; } + + public void Dispose() + { + if (_disposed) { + return; + } + MatrixParallel.ReturnParallelResources(ref _threads); + _disposed = true; + } + + public MatrixParallelThread GetLeader() + { + Threads[0].Role = 2; + return Threads[0]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe void Copy(MatrixParallelTaskPackage* source, MatrixParallelTaskPackage* target) + private static (int count_3, int count_4) FastDecompose(int c) { - Buffer.MemoryCopy(source, target, sizeof(MatrixParallelTaskPackage), - sizeof(MatrixParallelTaskPackage)); + /* + * Thread wrapping to accelerate matrix operations by dividing threads into groups (pool). + * For M pool, each containing an average of N threads, we satisfy the condition M * N = T - 4, + * where T is the total thread _count of the CPU. Typically, for modern consumer CPUs, T is around 16. + * For simplicity, let M * N = 16. + * + * The total time complexity for publishing tasks is O(M + N): + * - O(M) accounts for distributing tasks across M pool. + * - O(N) accounts for threads within each wrap fetching tasks from the wrap queue. + * + * Using the inequality Sqrt(M * N) <= (M + N) / 2 (derived from the arithmetic-geometric mean inequality), + * the optimal configuration occurs when M = N. For M * N = 16, this gives M = N = 4. + * + * To ensure compatibility across a wide range of CPU architectures, + * we allow each wrap to contain either 3 or 4 threads, providing flexibility while maintaining efficiency. + */ + if (c < 7) + { + return (0, 0); + } + + int t = c - 7; + int k = t / 14; + int d = t % 14; + + (int a0, int b0) = LookupTable[d]; + + return (a0 + (2 * k), b0 + (2 * k)); } - #region source + private void SliceToWraps() + { + if (_disposed) { + throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name); + } + if (_wraps is not null) { + return; + } + int count = _threads.Length; + if (count < 6) + { + MatrixParallelWrap wrap = new MatrixParallelWrap(_threads, 0, count); + _wraps = [ wrap ]; + } + (int c3,int c4) = FastDecompose(_threads.Length); + _wraps = new(c3 + c4); + int begin = 0; + for (int i = 0; i < c3; i++) + { + _wraps.Push(new MatrixParallelWrap(_threads, begin, 3)); + begin += 3; + } + for (int i = 0; i < c4; i++) + { + _wraps.Push(new MatrixParallelWrap(_threads, begin, 4)); + begin += 4; + } + } - // Group 1: Left/Right matrix kernel base address - public MatrixKernel* Left; // 8 - public MatrixKernel* Right; // 8 - - #endregion - - #region ans - - // Group 2: Result kernel base address + reserved - public MatrixKernel* Result; // 8 - public int ElementSize = sizeof(T); - public int ReservedPtr0; // 4 (extension/reserved) - - #endregion - - #region left enum - - public int LeftPrimOffset; // 4 - public int LeftPrimStride; // 4 - public int LeftSecOffset; // 4 - public int LeftSecStride; // 4 - - #endregion - - #region right enum - - public int RightPrimOffset; // 4 - public int RightPrimStride; // 4 - public int RightSecOffset; // 4 - public int RightSecStride; // 4 - - #endregion - - #region ans enum - - public int ResultPrimOffset; // 4 - public int ResultPrimStride; // 4 - public int ResultSecOffset; // 4 - public int ResultSecStride; // 4 - - #endregion - - #region scalar/compute - - public ScalarPacket* Scalar; // 8 - public IntPtr ComputeHandle; // 8 - - #endregion - - #region global profile - - public int PrimCount; // 4 - public int ComputeMode; // 4 - public int SecCount; // 4 - private readonly int ReservedInt0; // 4 - - #endregion - - #region count offset - - public int PrimTileOffset; // 4 - public int SecTileOffset; // 4 - public int PrimColumnCountInTile; // 4 - public int SecColumnCountInTile; // 4 - - #endregion } -} \ No newline at end of file +} diff --git a/StgSharp.Mathematics/Numeric/MatrixParallelPool.cs b/StgSharp.Mathematics/Numeric/MatrixParallelPool.cs deleted file mode 100644 index 0f7c3ce6..00000000 --- a/StgSharp.Mathematics/Numeric/MatrixParallelPool.cs +++ /dev/null @@ -1,177 +0,0 @@ -//----------------------------------------------------------------------- -// ----------------------------------------------------------------------- -// file="MatrixParallelPool" -// 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.Collections; -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; - -namespace StgSharp.Mathematics.Numeric -{ - public struct MatrixParallelHandle : IDisposable - { - - private static readonly (int a, int b)[] LookupTable = [ (1, 1), // 7 - (0, 2), // 8 (no non-zero solution) - (3, 0), // 9 (no non-zero solution) - (2, 1), // 10 - (1, 2), // 11 - (0, 3), // 12 (no non-zero solution) - (3, 1), // 13 - (2, 2), // 14 - (1, 3), // 15 - (4, 1), // 16 - (3, 2), // 17 - (2, 3), // 18 - (1, 4), // 19 - (4, 2), // 20 - ]; - - private MatrixParallelThread[] _threads; - private bool _disposed = false; - private CapacityFixedStack _wraps; - - internal MatrixParallelHandle(MatrixParallelThread[] threadArray) - { - _threads = threadArray; - IsMultithread = threadArray.Length > 1; - SliceToWraps(); - } - - public ReadOnlySpan Threads - { - get - { - if (_disposed) { - throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name); - } - return _threads; - } - } - - internal IEnumerable Wraps - { - get - { - if (_disposed) { - throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name); - } - return _wraps; - } - } - - internal ReadOnlySpan ThreadsUnsafe - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => _threads; - } - - private bool IsMultithread { get; init; } - - public void Dispose() - { - if (_disposed) { - return; - } - MatrixParallel.ReturnParallelResources(ref _threads); - _disposed = true; - } - - public MatrixParallelThread GetLeader() - { - Threads[0].Role = 2; - return Threads[0]; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static (int count_3, int count_4) FastDecompose(int c) - { - /* - * Thread wrapping to accelerate matrix operations by dividing threads into groups (pool). - * For M pool, each containing an average of N threads, we satisfy the condition M * N = T - 4, - * where T is the total thread _count of the CPU. Typically, for modern consumer CPUs, T is around 16. - * For simplicity, let M * N = 16. - * - * The total time complexity for publishing tasks is O(M + N): - * - O(M) accounts for distributing tasks across M pool. - * - O(N) accounts for threads within each wrap fetching tasks from the wrap queue. - * - * Using the inequality Sqrt(M * N) <= (M + N) / 2 (derived from the arithmetic-geometric mean inequality), - * the optimal configuration occurs when M = N. For M * N = 16, this gives M = N = 4. - * - * To ensure compatibility across a wide range of CPU architectures, - * we allow each wrap to contain either 3 or 4 threads, providing flexibility while maintaining efficiency. - */ - if (c < 7) - { - return (0, 0); - } - - int t = c - 7; - int k = t / 14; - int d = t % 14; - - (int a0, int b0) = LookupTable[d]; - - return (a0 + (2 * k), b0 + (2 * k)); - } - - private void SliceToWraps() - { - if (_disposed) { - throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name); - } - if (_wraps is not null) { - return; - } - int count = _threads.Length; - if (count < 6) - { - MatrixParallelWrap wrap = new MatrixParallelWrap(_threads, 0, count); - _wraps = [ wrap ]; - } - (int c3,int c4) = FastDecompose(_threads.Length); - _wraps = new(c3 + c4); - int begin = 0; - for (int i = 0; i < c3; i++) - { - _wraps.Push(new MatrixParallelWrap(_threads, begin, 3)); - begin += 3; - } - for (int i = 0; i < c4; i++) - { - _wraps.Push(new MatrixParallelWrap(_threads, begin, 4)); - begin += 4; - } - } - - } -} diff --git a/StgSharp.Mathematics/Numeric/MatrixParallelTaskPackage.cs b/StgSharp.Mathematics/Numeric/MatrixParallelTaskPackage.cs new file mode 100644 index 00000000..2de055e7 --- /dev/null +++ b/StgSharp.Mathematics/Numeric/MatrixParallelTaskPackage.cs @@ -0,0 +1,205 @@ +//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// file="MatrixParallelHandle" +// Project: StgSharp +// AuthorGroup: Nitload +// Copyright (c) Nitload. 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.HighPerformance; + +using System; +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace StgSharp.Mathematics.Numeric +{ + [StructLayout(LayoutKind.Sequential)] + internal unsafe struct MatrixParallelTaskPackageNonGeneric + { + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe void Copy( + MatrixParallelTaskPackageNonGeneric* source, + MatrixParallelTaskPackageNonGeneric* target) + { + Buffer.MemoryCopy(source, target, sizeof(MatrixParallelTaskPackageNonGeneric), + sizeof(MatrixParallelTaskPackageNonGeneric)); + } + + #region source + + // Group 1: Left/Right matrix kernel base address + public IntPtr Left; // 8 + public IntPtr Right; // 8 + + #endregion + + #region ans + + // Group 2: Result kernel base address + reserved + public IntPtr Result; // 8 + public int ElementSize; + public int ReservedPtr0; // 4 (extension/reserved) + + #endregion + + #region left enum + + public int LeftPrimOffset; // 4 + public int LeftPrimStride; // 4 + public int LeftSecOffset; // 4 + public int LeftSecStride; // 4 + + #endregion + + #region right enum + + public int RightPrimOffset; // 4 + public int RightPrimStride; // 4 + public int RightSecOffset; // 4 + public int RightSecStride; // 4 + + #endregion + + #region ans enum + + public int ResultPrimOffset; // 4 + public int ResultPrimStride; // 4 + public int ResultSecOffset; // 4 + public int ResultSecStride; // 4 + + #endregion + + #region scalar/compute + + public ScalarPacket* Scalar; // 8 + public IntPtr ComputeHandle; // 8 + + #endregion + + #region global profile + + public int PrimCount; // 4 + public int ComputeMode; // 4 + public int SecCount; // 4 + private int ReservedInt0; // 4 + + #endregion + + #region count offset + + public int PrimTileOffset; // 4 + public int SecTileOffset; // 4 + public int PrimCountInTile; // 4 + public int SecCountInTile; // 4 + + #endregion + } + + [StructLayout(LayoutKind.Sequential)] + internal unsafe struct MatrixParallelTaskPackage where T: unmanaged, INumber + { + + public MatrixParallelTaskPackage() + { + Unsafe.SkipInit(out this); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe void Copy(MatrixParallelTaskPackage* source, MatrixParallelTaskPackage* target) + { + Buffer.MemoryCopy(source, target, sizeof(MatrixParallelTaskPackage), + sizeof(MatrixParallelTaskPackage)); + } + + #region source + + // Group 1: Left/Right matrix kernel base address + public MatrixKernel* Left; // 8 + public MatrixKernel* Right; // 8 + + #endregion + + #region ans + + // Group 2: Result kernel base address + reserved + public MatrixKernel* Result; // 8 + public int ElementSize = sizeof(T); + public int ReservedPtr0; // 4 (extension/reserved) + + #endregion + + #region left enum + + public int LeftPrimOffset; // 4 + public int LeftPrimStride; // 4 + public int LeftSecOffset; // 4 + public int LeftSecStride; // 4 + + #endregion + + #region right enum + + public int RightPrimOffset; // 4 + public int RightPrimStride; // 4 + public int RightSecOffset; // 4 + public int RightSecStride; // 4 + + #endregion + + #region ans enum + + public int ResultPrimOffset; // 4 + public int ResultPrimStride; // 4 + public int ResultSecOffset; // 4 + public int ResultSecStride; // 4 + + #endregion + + #region scalar/compute + + public ScalarPacket* Scalar; // 8 + public IntPtr ComputeHandle; // 8 + + #endregion + + #region global profile + + public int PrimCount; // 4 + public int ComputeMode; // 4 + public int SecCount; // 4 + private readonly int ReservedInt0; // 4 + + #endregion + + #region count offset + + public int PrimTileOffset; // 4 + public int SecTileOffset; // 4 + public int PrimColumnCountInTile; // 4 + public int SecColumnCountInTile; // 4 + + #endregion + } +} \ No newline at end of file diff --git a/StgSharp.Common/Graphics/OpenGL/GLfixed.cs b/StgSharp.Mathematics/Numeric/NumericalModule.cs similarity index 84% rename from StgSharp.Common/Graphics/OpenGL/GLfixed.cs rename to StgSharp.Mathematics/Numeric/NumericalModule.cs index 82a106ff..6fc5aeb5 100644 --- a/StgSharp.Common/Graphics/OpenGL/GLfixed.cs +++ b/StgSharp.Mathematics/Numeric/NumericalModule.cs @@ -1,6 +1,6 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="GLfixed" +// file="NumericalModule" // Project: StgSharp // AuthorGroup: Nitload // Copyright (c) Nitload. All rights reserved. @@ -28,19 +28,20 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; -namespace StgSharp.Internal +namespace StgSharp.Mathematics.Numeric { - [StructLayout(LayoutKind.Explicit, Size = 8)] - public struct GLfixed + public class NumericalModule : IStaticModule { - [FieldOffset(0)] public int All; - [FieldOffset(0)] public short Decimals; - [FieldOffset(4)] public short Inertger; + public string ModuleName => "Math.Numerical"; + + public void InitializeModule() + { + MatrixParallel.Init(); + } } } diff --git a/StgSharpDebug/RenderStream/Partical.cs b/StgSharpDebug/RenderStream/Partical.cs index d339b8b2..5f4a91d2 100644 --- a/StgSharpDebug/RenderStream/Partical.cs +++ b/StgSharpDebug/RenderStream/Partical.cs @@ -2,8 +2,8 @@ // ----------------------------------------------------------------------- // file="Partical" // Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// AuthorGroup: Nitload +// Copyright (c) Nitload. 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 @@ -25,6 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- +using StgSharp.Common.Graphics; using StgSharp.Controls; using StgSharp.Geometries; using StgSharp.Graphics; @@ -122,9 +123,8 @@ namespace StgSharp /**/ - GL.TextureImage2d( - Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, (uint)Height, - ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null); + GL.TextureImage2d(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, + (uint)Height, ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null); /**/ // GL.Assert(false); @@ -164,9 +164,8 @@ namespace StgSharp // GL.ClearError(); // Console.Write($"Size set to {Height},{Width}"); // Console.WriteLine($"Image resized to {i.Height} {i.Width}"); - GL.GetTextureImage( - Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, - PixelChannelLayout.Byte, i.PixelBuffer); + GL.GetTextureImage(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, + i.PixelBuffer); /* for (int num = 0; num < i.PixelBuffer.Length; num+=10000) { @@ -287,7 +286,19 @@ namespace StgSharp vbo.Unbind(); GL.BindVertexArray(GlHandle.Zero); - NativeCameraViewTarget([ 0f, 0f, -100f ], [ 0f, 0f, 0f ], [ 0f, 1f, 0f ]); + NativeCameraViewTarget([ + 0f, + 0f, + -100f + ], [ + 0f, + 0f, + 0f + ], [ + 0f, + 1f, + 0f + ]); NativeCameraViewRange(new Degree(1.5f), Vec2.Zero, (50, 50)); NativeCameraUniform(s, "Camera"); @@ -301,15 +312,13 @@ namespace StgSharp // GL.Assert(true); t = CreateTexture(1); t.Bind2D(0); - GL.TextureImage2d( - Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, (uint)Height, - ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null!); + GL.TextureImage2d(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, + (uint)Height, ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null!); t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat); t.Set2dFilterProperty(0, TextureFilter.Linear, TextureFilter.Linear); // GL.Assert(true); - GL.FrameBufferTexture2d( - FrameBufferTarget.All, glAttachment.Color(0), Texture2DTarget.Texture2D, t[0], 0); + GL.FrameBufferTexture2d(FrameBufferTarget.All, glAttachment.Color(0), Texture2DTarget.Texture2D, t[0], 0); GL.SetRenderBufferStorage(RenderBufferInternalFormat.Depth24_Stencil8, this.Size); GL.CombineFrameBufferRenderBuffer(FrameBufferAttachment.DepthAndStencil, rbo[0]); @@ -360,9 +369,8 @@ namespace StgSharp // GL.Assert(true); autoT = CreateAutoTexture(4); - autoT.DefaultTextureProperty = new TextureProperty( - TextureFilter.Nearest, TextureFilter.Nearest, TextureWrap.Repeat, - TextureWrap.Repeat); + autoT.DefaultTextureProperty = new TextureProperty(TextureFilter.Nearest, TextureFilter.Nearest, + TextureWrap.Repeat, TextureWrap.Repeat); f_t = CreateTexture(1); f_t.Bind2D(0);