[Internal] Seperate InternalIO into different static classes. [Matrix] Fix logic error of compute model.

This commit is contained in:
Youmu Liu
2025-10-27 19:59:12 +08:00
parent 1c9b820531
commit e1ec761e83
46 changed files with 2572 additions and 2310 deletions
@@ -2,5 +2,7 @@
<Root Type="DevExpress.CodeRush.VisualizePlugins.RightMarginLine.Options.RightMarginLineOptions">
<Options Language="Neutral">
<Enabled>True</Enabled>
<Style>DashDot</Style>
<Width>2</Width>
</Options>
</Root>
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Root Type="DevExpress.CodeRush.Formatting.UI.Options.WrappingOptionsContainer">
<Options Language="C#">
<Options>
<Item Id="{48f3f6c0-b3c2-4567-b071-33af7480c9a3}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.QueryExpressionFormattingOption" />
<Item Id="{a2c75ad7-ba6a-49ca-8070-6d9e3c52e3c6}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.BinaryExpressionFormattingOption" />
<Item Id="{0e2d0391-24ba-4ed8-aeb4-1b3e9f26be55}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.RelationalExpressionFormattingOption" />
<Item Id="{fea50ebc-99c9-4599-9b55-bf2961b9cc95}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.BitwiseExpressionFormattingOption" />
<Item Id="{4246b900-cbb3-44f4-b59e-b3055fb4f7bc}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.LogicalExpressionFormattingOption" />
<Item Id="{cd721fc1-23fb-4d88-a9f0-42d6b318a32b}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.TernaryExpressionFormattingOption" />
<Item Id="{10e904ea-f51d-4c32-9320-1b93fa557564}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.AssignmentExpressionFormattingOption" />
<Item Id="{25746bdc-0a43-4741-a740-20784691314b}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.InvocationArgumentListFormattingOption">
<WrapOpenParen>
<Option>WrapIfLong</Option>
</WrapOpenParen>
<WrapArgSeparator>
<Option>SimpleWrap</Option>
</WrapArgSeparator>
</Item>
<Item Id="{D5EE2ECB-9FA6-47F7-A11F-007FC45E872D}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.AttributeArgumentsFormattingOption" />
<Item Id="{5A186AB9-03A5-4BFE-83B1-B99B3B8408BC}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.DeclarationParameterListFormattingOption" />
<Item Id="{8739877d-3674-40ae-90c4-38b2b160e92b}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.ArrayInitializerFormattingOption" />
<Item Id="{a940ae15-f98a-4b7d-8357-2214eb421250}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.CollectionInitializerFormattingOption" />
<Item Id="{0414181a-3915-4d0c-81d3-3bc7718da90f}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.ObjectInitializerFormattingOption" />
<Item Id="{ea60e2ab-d67a-45e8-ab42-36d747c494c}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.ChainedMethodCallsFormattingOption" />
<Item Id="{5f4ed422-88b9-4e95-8401-cef404d645d6}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.LambdaExpressionFormattingOption" />
<Item Id="{0531de5e-ff20-4043-a67c-eeef76a8f3c3}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.ArrowExpressionFormattingOption" />
<Item Id="{08fa5953-cc71-4ded-bd41-ef5d5b690585}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.TypeParameterListFormattingOption" />
<Item Id="{dc060d33-cfc0-411e-9508-8d27b84934e8}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.CoalesceExpressionFormattingOption" />
<Item Id="{b25d25a0-dd92-45ed-88ef-51953e28222c}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.BaseListWrappingFormattingOption" />
<Item Id="{4db5e14f-8f4c-416f-9b59-7e9239f2150e}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.CtorInitWrappingFormattingOption" />
<Item Id="{be0c2117-5732-40fd-9b4a-0fe749356e87}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.SwitchExpressionWrappingFormattingOption" />
<Item Id="{099d9359-1af3-40a2-8841-50f6cc9527e1}" Type="DevExpress.CodeRush.Formatting.UI.Options.Conversion.CollectionExpressionWrappingFormattingOption" />
</Options>
</Options>
</Root>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Root Type="DevExpress.CodeRush.VisualizePlugins.RightMarginLine.Options.RightMarginLineOptions">
<Options Language="Neutral">
<Column>120</Column>
</Options>
</Root>
@@ -71,7 +71,7 @@ namespace StgSharp.Collections
{
int hash;
fixed (char* cPtr = obj.AsSpan()) {
hash = InternalIO.Intrinsic.city_hash_simplify(cPtr, obj.Length);
hash = NativeIntrinsic.Intrinsic.city_hash_simplify(cPtr, obj.Length);
}
return hash;
}
@@ -129,21 +129,21 @@ namespace StgSharp.Collections
public void ExtendCache(int count)
{
_multiplexers.Value.ExtendCache(count);
_multiplexers.Value!.ExtendCache(count);
}
public unsafe int ForceComputeHash([NotNull] string obj)
{
int hash;
fixed (char* cPtr = obj.AsSpan()) {
hash = InternalIO.Intrinsic.city_hash_simplify(cPtr, obj.Length);
hash = NativeIntrinsic.Intrinsic.city_hash_simplify(cPtr, obj.Length);
}
return hash;
}
public int GetHashCode(string obj)
{
return _multiplexers.Value.GetHashCode(obj);
return _multiplexers.Value!.GetHashCode(obj);
}
private void Dispose(bool disposing)
+2 -2
View File
@@ -85,7 +85,7 @@ namespace StgSharp
if (API != GraphicAPI.GL) {
return;
}
InternalIO.InternalInitGL(majorVersion, minorVersion);
GraphicFramework.InternalInitGL(majorVersion, minorVersion);
}
public static class GlobalSetting
@@ -98,7 +98,7 @@ namespace StgSharp
get => vsyncActivated;
set
{
InternalIO.glfwSwapInterval(value ? 1 : 0);
GraphicFramework.glfwSwapInterval(value ? 1 : 0);
vsyncActivated = value;
}
}
+1 -1
View File
@@ -48,7 +48,7 @@ namespace StgSharp
if (monitorsArray == null)
{
int count = 0;
IntPtr* arrayhandle = InternalIO.glfwGetMonitors(&count);
IntPtr* arrayhandle = GraphicFramework.glfwGetMonitors(&count);
monitorsArray = new IntPtr[count];
Marshal.Copy((IntPtr)arrayhandle, monitorsArray, 0, count);
Marshal.FreeHGlobal((IntPtr)arrayhandle);
+14 -13
View File
@@ -55,7 +55,7 @@ namespace StgSharp
private static uint markCount = 0;
internal static GraphicAPI API = default;
public static int DefaultSIMDAlignment => InternalIO.IntrinsicLevel switch
public static int DefaultSIMDAlignment => NativeIntrinsic.IntrinsicLevel switch
{
IntrinsicLevel.SSE => 16,
IntrinsicLevel.AVX2 => 32,
@@ -69,12 +69,12 @@ namespace StgSharp
{
mainTimeProvider = new StgSharpTime();
MainTimeProvider.StartProvidingTime();
InternalIO.LoadGlfw();
if (InternalIO.glfwInit() == 0) {
GraphicFramework.LoadGlfw();
if (GraphicFramework.glfwInit() == 0) {
throw new Exception("Failed to init system graphic environment.");
}
InternalIO.InternalAppendLog("\n\n\n");
InternalIO.InternalWriteLog(
DefaultLog.InternalAppendLog("\n\n\n");
DefaultLog.InternalWriteLog(
$"Program {Assembly.GetEntryAssembly()!.FullName} on {Environment.MachineName} Started.", LogType.Info);
MainThreadID = Environment.CurrentManagedThreadId;
@@ -84,30 +84,31 @@ namespace StgSharp
Dialogue.CreateDialogueProcessIfNotExist();
}
InternalIO.InitIntrinsicContext();
NativeIntrinsic.InitIntrinsicContext();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogError(Exception ex)
{
InternalIO.InternalWriteLog(ex.Message, LogType.Error);
DefaultLog.InternalWriteLog(ex.Message, LogType.Error);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogInfo(string log)
{
InternalIO.InternalWriteLog(log, LogType.Info);
DefaultLog.InternalWriteLog(log, LogType.Info);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogWarning(string log)
{
InternalIO.InternalWriteLog(log, LogType.Warning);
DefaultLog.InternalWriteLog(log, LogType.Warning);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogWarning(Exception notVerySeriesException)
{
InternalIO.InternalWriteLog(notVerySeriesException.Message, LogType.Warning);
DefaultLog.InternalWriteLog(notVerySeriesException.Message, LogType.Warning);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -122,7 +123,7 @@ namespace StgSharp
public static void Terminate(int exitCode)
{
MainTimeProvider.StopProvidingTime();
InternalIO.glfwTerminate();
GraphicFramework.glfwTerminate();
Environment.Exit(exitCode);
}
@@ -149,7 +150,7 @@ namespace StgSharp
Console.WriteLine(log);
} else
{
InternalIO.InternalWriteLog(log, LogType.Info);
DefaultLog.InternalWriteLog(log, LogType.Info);
}
}
@@ -165,7 +166,7 @@ namespace StgSharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void WriteLog(string message, LogType logType)
{
InternalIO.InternalWriteLog(message, logType);
DefaultLog.InternalWriteLog(message, logType);
}
internal static TDele ConvertAPI<TDele>(IntPtr funcPtr)
@@ -35,8 +35,7 @@ namespace StgSharp.Geometries
public class Parallelogram : Polygon4
{
internal readonly Func<int, Vec3> movCenterOperation =
new Func<int, Vec3>(GeometryOperation.DefaultMotion);
internal readonly Func<int, Vec3> movCenterOperation = GeometryOperation.DefaultMotion;
internal Point center;
@@ -46,7 +45,7 @@ namespace StgSharp.Geometries
#if DEBUG
if (this[0].Coord + this[2].Coord != this[1].Coord + this[3].Coord)
{
InternalIO.InternalWriteLog(
DefaultLog.InternalWriteLog(
"Init of geometry item failed, because four vertices cannot form a rectangle.",
LogType.Warning);
}
@@ -68,7 +67,7 @@ namespace StgSharp.Geometries
#if DEBUG
if (this[0].Coord + this[2].Coord != this[1].Coord + this[3].Coord)
{
InternalIO.InternalWriteLog(
DefaultLog.InternalWriteLog(
"Init of geometry item failed, because four vertices cannot form a rectangle.",
LogType.Warning);
}
+336
View File
@@ -0,0 +1,336 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// 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
}
}
+3 -6
View File
@@ -114,10 +114,7 @@ namespace StgSharp.Graphics
public SerializableTypeCode SSDTypeCode => SerializableTypeCode.PixelImage;
internal ref byte[] Data
{
get => ref _data;
}
internal ref byte[] Data => ref _data;
public void FromBytes(byte[] stream) { }
@@ -125,7 +122,7 @@ namespace StgSharp.Graphics
{
Image ret = new Image();
fixed (ImageInfo* iptr = &ret._rawInfo) {
InternalIO.InternalLoadImage(route, iptr, loader);
GraphicFramework.InternalLoadImage(route, iptr, loader);
}
return ret;
}
@@ -171,7 +168,7 @@ namespace StgSharp.Graphics
int size = Width * Height * ImageInfo.GetPixelSize(PixelLayout, Channel);
_data = new Span<byte>((byte*)_rawInfo.StreamPtr, size).ToArray();
fixed (ImageInfo* pptr = &_rawInfo) {
InternalIO.InternalUnloadImage(pptr);
GraphicFramework.InternalUnloadImage(pptr);
}
_rawInfo.StreamPtr = IntPtr.Zero;
}
@@ -245,21 +245,21 @@ namespace StgSharp.Graphics.OpenGL
/// </summary>
public unsafe void Link()
{
if (InternalIO.InternalLinkShaderProgram(
if (GraphicFramework.InternalLinkShaderProgram(
(OpenglContext*)this.GL.ContextHandle, handle.Value) == 0)
{
IntPtr logPtr = InternalIO.InternalReadSSCLog();
IntPtr logPtr = GraphicFramework.InternalReadSSCLog();
try
{
byte[] logByte = new byte[512];
Marshal.Copy(logPtr, logByte, 0, 512);
string log = Encoding.UTF8.GetString(logByte);
log = log.Replace("\0", string.Empty);
InternalIO.InternalWriteLog(log, LogType.Error);
DefaultLog.InternalWriteLog(log, LogType.Error);
}
catch (Exception ex)
{
InternalIO.InternalWriteLog(ex.Message, LogType.Error);
DefaultLog.InternalWriteLog(ex.Message, LogType.Error);
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-297
View File
@@ -35,303 +35,6 @@ namespace StgSharp.Graphics.OpenGL
public static unsafe class glConst
{
#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
#region glad
public const int _1PASS_EXT = 0x80A1;
+11 -11
View File
@@ -347,7 +347,7 @@ namespace StgSharp.Graphics.OpenGL
a = glConst.UNSIGNED_BYTE;
break;
default:
InternalIO.InternalWriteLog(
DefaultLog.InternalWriteLog(
$"{$"Parameter error in parameter {nameof(type)} method DrawElements. "}{$"Only {typeof(uint).Name},{typeof(ushort).Name},{typeof(byte).Name} types are supported."}",
LogType.Error);
return;
@@ -446,7 +446,7 @@ namespace StgSharp.Graphics.OpenGL
public string GetShaderStatus(Shader s, int index, int key)
{
IntPtr sptr = IntPtr.Zero;
if (InternalIO.glCheckShaderStatus(ref Context, s.handle[index].Value, key,
if (GraphicFramework.glCheckShaderStatus(ref Context, s.handle[index].Value, key,
ref sptr) == 0) {
return Marshal.PtrToStringAnsi(sptr);
}
@@ -546,8 +546,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 +562,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++;
}
@@ -683,7 +683,7 @@ namespace StgSharp.Graphics.OpenGL
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetVertexAttribute(uint index, int size, TypeCode t, bool normalized, uint stride, int pointer)
{
uint type = InternalIO.GLtype[t];
uint type = GraphicFramework.GLtype[(int)t];
Context.glVertexAttribPointer(index, size, type, normalized ? 1 : 0, stride, (void*)pointer);
Context.glEnableVertexAttribArray(index);
}
@@ -704,8 +704,8 @@ namespace StgSharp.Graphics.OpenGL
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
}
@@ -725,8 +725,8 @@ namespace StgSharp.Graphics.OpenGL
#pragma warning disable CS8500
fixed (T* tptr = pixelSpan)
{
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
}
@@ -81,7 +81,7 @@ namespace StgSharp.Graphics.OpenGL
/// </exception>
public unsafe void MakeAsCurrentContext()
{
InternalIO.glfwMakeContextCurrent(CanvasHandle);
GraphicFramework.glfwMakeContextCurrent(CanvasHandle);
OpenGLFunction.CurrentGL = this.GL;
}
@@ -94,7 +94,7 @@ namespace StgSharp.Graphics.OpenGL
}
SwapBuffers();
renderToThread[this] = ThreadHelper.EmptyThread;
InternalIO.glfwMakeContextCurrent(IntPtr.Zero);
GraphicFramework.glfwMakeContextCurrent(IntPtr.Zero);
OpenGLFunction.CurrentGL = null;
}
@@ -117,7 +117,7 @@ namespace StgSharp.Graphics.OpenGL
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight)
{
InternalIO.glfwSetWindowSizeLimits(
GraphicFramework.glfwSetWindowSizeLimits(
this.CanvasHandle, minWidth, minHeight, maxWidth, maxHeight);
}
@@ -160,17 +160,17 @@ namespace StgSharp.Graphics.OpenGL
protected KeyStatus CheckKey(KeyboardKey key)
{
return InternalIO.glfwGetKey(this.CanvasHandle, (int)key);
return GraphicFramework.glfwGetKey(this.CanvasHandle, (int)key);
}
protected KeyStatus CheckKey(Mouse key)
{
return InternalIO.glfwGetKey(this.CanvasHandle, (int)key);
return GraphicFramework.glfwGetKey(this.CanvasHandle, (int)key);
}
protected KeyStatus CheckKey(Joystick key)
{
return InternalIO.glfwGetKey(this.CanvasHandle, (int)key);
return GraphicFramework.glfwGetKey(this.CanvasHandle, (int)key);
}
#endregion
+4 -4
View File
@@ -46,21 +46,21 @@ namespace StgSharp.Internal.OpenGL
{
if (value.GetType().Name != "Uint32")
{
goto errorlog;
goto errorLog;
}
this.value = value;
} else
{
if (value.GetType().Name != "IntPtr")
{
goto errorlog;
goto errorLog;
}
this.value = value;
}
errorlog:
errorLog:
{
InternalIO.InternalWriteLog(
DefaultLog.InternalWriteLog(
$"{value.GetType().Name} does not match definination of GLhandlARB on OS {Environment.OSVersion.Platform} ",
LogType.Error);
}
+3 -3
View File
@@ -158,12 +158,12 @@ namespace StgSharp.Graphics
/**/
protected internal static void PollEvents()
{
InternalIO.glfwPollEvents();
GraphicFramework.glfwPollEvents();
}
private protected void SwapBuffers()
{
InternalIO.glfwSwapBuffers(CanvasHandle);
GraphicFramework.glfwSwapBuffers(CanvasHandle);
}
/**/
@@ -209,7 +209,7 @@ namespace StgSharp.Graphics
nativeCamera = new Camera();
PlatformSpecifiedInitialize();
CustomizeInit();
InternalIO.glfwMakeContextCurrent(IntPtr.Zero);
GraphicFramework.glfwMakeContextCurrent(IntPtr.Zero);
}
internal abstract void PlatformSpecifiedInitialize();
+1 -1
View File
@@ -49,7 +49,7 @@ namespace StgSharp.HighPerformance
{
ReadOnlySpan<char> nameSpan = Name.AsSpan();
fixed (char* cptr = nameSpan) {
return InternalIO.Intrinsic.city_hash_simplify(cptr, Name.Length);
return NativeIntrinsic.Intrinsic.city_hash_simplify(cptr, Name.Length);
}
}
@@ -35,19 +35,19 @@ namespace StgSharp.HighPerformance
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe int CityHashSimplify(char* span, int length)
{
return InternalIO.Intrinsic.city_hash_simplify(span, length);
return NativeIntrinsic.Intrinsic.city_hash_simplify(span, length);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe int CityHashSimplify(char* span, int begin, int length)
{
return InternalIO.Intrinsic.city_hash_simplify(span + begin, length);
return NativeIntrinsic.Intrinsic.city_hash_simplify(span + begin, length);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe int IndexOfCharPair(char* source, int pairValue, int length)
{
return InternalIO.Intrinsic.index_pair(source, pairValue, length);
return NativeIntrinsic.Intrinsic.index_pair(source, pairValue, length);
}
}
@@ -1,6 +1,6 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="InternalIO"
// file="DefaultLog"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
@@ -25,62 +25,37 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
namespace StgSharp.Internal
{
internal static unsafe partial class InternalIO
internal static unsafe partial class DefaultLog
{
private const long MaxLogFileSize = 10 * 1024 * 1024; // 10 MB
internal const string NativeLibName =
"StgSharp.Native";
internal const string SS_errorLog =
"SS_errorlog.log";
private static LogType _currentLogLevel = LogType.Info;
internal static Dictionary<TypeCode, uint> GLtype = [];
internal static readonly GCHandle ssc_logHandle =
GCHandle.Alloc(new byte[512], GCHandleType.Pinned);
internal static IntPtr _nativeLibPtr = IntPtr.Zero;
internal static SemaphoreSlim logSyncSemaphore = new(1, 1);
static InternalIO()
{
GLtype.Add(TypeCode.Single, glConst.FLOAT);
GLtype.Add(TypeCode.Int32, glConst.INT);
GLtype.Add(TypeCode.UInt32, glConst.UNSIGNED_INT);
GLtype.Add(TypeCode.Int16, glConst.SHORT);
GLtype.Add(TypeCode.UInt16, glConst.UNSIGNED_SHORT);
GLtype.Add(TypeCode.SByte, glConst.BYTE);
GLtype.Add(TypeCode.Byte, glConst.UNSIGNED_BYTE);
}
internal static void InternalAppendLog(string log)
{
if (!File.Exists(SS_errorLog))
if (!File.Exists(Native.LogPath))
{
FileStream stream = File.Create(SS_errorLog);
FileStream stream = File.Create(Native.LogPath);
stream.Close();
}
using (StreamWriter logStream = File.AppendText(SS_errorLog)) {
using (StreamWriter logStream = File.AppendText(Native.LogPath)) {
logStream.WriteLine(log);
}
}
@@ -96,32 +71,32 @@ namespace StgSharp.Internal
{
RotateLogFile();
if (!File.Exists(SS_errorLog))
if (!File.Exists(Native.LogPath))
{
FileStream stream = File.Create(SS_errorLog);
FileStream stream = File.Create(Native.LogPath);
stream.Close();
}
using (StreamWriter logStream = File.AppendText(SS_errorLog)) {
using (StreamWriter logStream = File.AppendText(Native.LogPath)) {
logStream.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}] [{logType}] {logLine}");
}
}
finally
{
logSyncSemaphore.Release();
_ = logSyncSemaphore.Release();
}
}
internal static void InternalWriteLog(string beforeTime, string logLine, LogType logType)
{
logSyncSemaphore.Wait();
if (!File.Exists(SS_errorLog))
if (!File.Exists(Native.LogPath))
{
FileStream stream = File.Create(SS_errorLog);
FileStream stream = File.Create(Native.LogPath);
stream.Close();
}
using (StreamWriter logStream = File.AppendText(SS_errorLog))
using (StreamWriter logStream = File.AppendText(Native.LogPath))
{
logStream.WriteLine(beforeTime);
logStream.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}] [{logType}] {logLine}");
@@ -136,13 +111,13 @@ namespace StgSharp.Internal
private static void RotateLogFile()
{
if (File.Exists(SS_errorLog) && new FileInfo(SS_errorLog).Length > MaxLogFileSize)
if (File.Exists(Native.LogPath) && new FileInfo(Native.LogPath).Length > MaxLogFileSize)
{
string backupFile = SS_errorLog + ".backup";
string backupFile = Native.LogPath + ".backup";
if (File.Exists(backupFile)) {
File.Delete(backupFile);
}
File.Move(SS_errorLog, backupFile);
File.Move(Native.LogPath, backupFile);
}
}
@@ -31,7 +31,7 @@ using System.Text;
namespace StgSharp.Internal
{
internal partial class InternalIO
internal static class BuiltInShader
{
#region ControllingItemRender
@@ -46,9 +46,7 @@ namespace StgSharp.Internal
#region CollisionTexture
internal static ReadOnlySpan<byte> CollisionTextureVertexShader
{
get => """
internal static ReadOnlySpan<byte> CollisionTextureVertexShader => """
#version 430 core
layout(location = 0) in vec2 localCollisionCoord;
layout(location = 1) in vec2 spaceCoord;
@@ -75,11 +73,8 @@ namespace StgSharp.Internal
gl_Position = vec4(angle, realCoord.y, dist, 1);
}
"""u8;
}
internal static ReadOnlySpan<byte> CollisionTextureFragmentShader
{
get => """
internal static ReadOnlySpan<byte> CollisionTextureFragmentShader => """
#version 430 core
out vec4 Color;
@@ -96,8 +91,7 @@ namespace StgSharp.Internal
Color = vec4(dist,0,0,1);
}
"""u8;
}
#endregion
#endregion
}
}
@@ -32,14 +32,26 @@ using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Internal
{
internal partial class InternalIO
internal static partial class GraphicFramework
{
[LibraryImport(NativeLibName, EntryPoint = "glCheckShaderStat")]
internal static uint[] GLtype = [];
static GraphicFramework()
{
GLtype[(int)TypeCode.Single] = glConst.FLOAT;
GLtype[(int)TypeCode.Int32] = glConst.INT;
GLtype[(int)TypeCode.UInt32] = glConst.UNSIGNED_INT;
GLtype[(int)TypeCode.Int16] = glConst.SHORT;
GLtype[(int)TypeCode.UInt16] = glConst.UNSIGNED_SHORT;
GLtype[(int)TypeCode.SByte] = glConst.BYTE;
GLtype[(int)TypeCode.Byte] = glConst.UNSIGNED_BYTE;
}
[LibraryImport(Native.LibName, EntryPoint = "glCheckShaderStat")]
[UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])]
#pragma warning disable CA5392
internal static partial int glCheckShaderStatus(
@@ -52,27 +64,27 @@ namespace StgSharp.Internal
#region ssgc api define
[LibraryImport(NativeLibName, EntryPoint = "initGL")]
[LibraryImport(Native.LibName, EntryPoint = "initGL")]
[UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])]
internal static partial void InternalInitGL(int majorVersion, int minorVersion);
[LibraryImport(NativeLibName, EntryPoint = "loadGlfuncDefault", StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(Native.LibName, EntryPoint = "loadGlfuncDefault", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])]
internal static partial IntPtr InternalLoadGlfuncDefault(string name);
[LibraryImport(NativeLibName, EntryPoint = "linkShaderProgram")]
[LibraryImport(Native.LibName, EntryPoint = "linkShaderProgram")]
[UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])]
internal static unsafe partial uint InternalLinkShaderProgram(OpenglContext* context, uint shaderProgram);
[LibraryImport(NativeLibName, EntryPoint = "readLog")]
[LibraryImport(Native.LibName, EntryPoint = "readLog")]
[UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])]
internal static unsafe partial IntPtr InternalReadSSCLog();
[LibraryImport(NativeLibName, EntryPoint = "loadImageData", StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(Native.LibName, EntryPoint = "loadImageData", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])]
internal static unsafe partial void InternalLoadImage(string fileName, ImageInfo* output, ImageLoader loader);
[LibraryImport(NativeLibName, EntryPoint = "unloadImageData")]
[LibraryImport(Native.LibName, EntryPoint = "unloadImageData")]
[UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])]
internal static unsafe partial void InternalUnloadImage(ImageInfo* output);
@@ -25,24 +25,21 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Internal
{
internal unsafe partial class InternalIO
internal static unsafe partial class GraphicFramework
{
private static readonly GLFWFunction _glfw = new GLFWFunction();
public static GLFWFunction glfwContext => _glfw;
[LibraryImport(NativeLibName, EntryPoint = "load_glfw_functions")]
[LibraryImport(Native.LibName, EntryPoint = "load_glfw_functions")]
internal static unsafe partial void glfwLoadLibrary(GLFWFunction* context);
internal static unsafe void LoadGlfw()
@@ -116,14 +113,14 @@ namespace StgSharp.Internal
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe void glfwGetMonitorWorkarea(
internal static unsafe void glfwGetMonitorWorkArea(
IntPtr monitor,
int* xpos,
int* ypos,
int* xPos,
int* yPos,
int* width,
int* height)
{
_glfw.glfwGetMonitorWorkarea(monitor, xpos, ypos, width, height);
_glfw.glfwGetMonitorWorkarea(monitor, xPos, yPos, width, height);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -275,12 +272,12 @@ namespace StgSharp.Internal
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe void glfwSetWindowSizeLimits(
IntPtr window,
int minwidth,
int minheight,
int maxwidth,
int maxheight)
int minWidth,
int minHeight,
int maxWidth,
int maxHeight)
{
_glfw.glfwSetWindowSizeLimits(window, minwidth, minheight, maxwidth, maxheight);
_glfw.glfwSetWindowSizeLimits(window, minWidth, minHeight, maxWidth, maxHeight);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -799,6 +796,12 @@ namespace StgSharp.Internal
return glfwGetProcAddress(Encoding.UTF8.GetBytes(procName));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe IntPtr glfwGetProcAddress(ReadOnlySpan<byte> procName)
{
return glfwGetProcAddress(procName);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe IntPtr glfwGetProcAddress(Span<byte> procName)
{
@@ -34,7 +34,7 @@ using System.Runtime.InteropServices;
namespace StgSharp.Internal
{
internal static unsafe partial class InternalIO
internal static unsafe partial class NativeIntrinsic
{
private static readonly IntrinsicContext _intrinsicContext = new();
@@ -68,7 +68,7 @@ namespace StgSharp.Internal
}
}
[LibraryImport(NativeLibName, EntryPoint = "load_intrinsic_function")]
[LibraryImport(Native.LibName, EntryPoint = "load_intrinsic_function")]
[UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])]
private static partial int LoadIntrinsicFunction(IntrinsicContext* context);
+48
View File
@@ -0,0 +1,48 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Native"
// 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.Internal
{
internal static unsafe partial class Native
{
internal const string LibName =
"StgSharp.Native";
internal const string LogPath =
"SS_error.log";
internal static IntPtr _libPtr = IntPtr.Zero;
}
}
+6 -5
View File
@@ -25,6 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL;
using System;
@@ -55,7 +56,7 @@ namespace StgSharp.Internal
#region GLFW3 struct
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWcontext
public unsafe struct glfwContext
{
private delegate*<byte*> extensionSupported;
@@ -286,8 +287,8 @@ namespace StgSharp.Internal
private IntPtr cursor; // _GLFWcursor* cursor;
// glfwVideomode videoMode; // 根据GLFWvidmode的定义转换
private IntPtr monitor; // _GLFWmonitor* monitor;
public fixed byte keys[glConst.GLFW_KEY_LAST + 1];
public fixed byte mouseButtons[glConst.GLFW_MOUSE_BUTTON_LAST + 1];
public fixed byte keys[Constant.GLFW_KEY_LAST + 1];
public fixed byte mouseButtons[Constant.GLFW_MOUSE_BUTTON_LAST + 1];
// _GLFWcontext viewPortDisplay; // 根据_GLFWcontext的定义转换
@@ -496,8 +497,8 @@ namespace StgSharp.Internal
internal unsafe struct GLFWlibrary
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = glConst.GLFW_JOYSTICK_LAST + 1)]
private GLFWjoystick[] joysticks = new GLFWjoystick[glConst.GLFW_JOYSTICK_LAST + 1];
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constant.GLFW_JOYSTICK_LAST + 1)]
private GLFWjoystick[] joysticks = new GLFWjoystick[Constant.GLFW_JOYSTICK_LAST + 1];
private GLFWallocator allocator;
@@ -1,6 +1,6 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="publicType"
// file="public"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
@@ -25,12 +25,11 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics.OpenGL;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp
{
@@ -44,4 +43,4 @@ namespace StgSharp
InfoWarning,
}
}
}
+1 -1
View File
@@ -153,7 +153,7 @@ namespace StgSharp.MVVM
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public KeyStatus GetKeyStatus(KeyboardKey key)
{
return InternalIO.glfwGetKey(context.ViewPortHandle, (int)key);
return GraphicFramework.glfwGetKey(context.ViewPortHandle, (int)key);
}
public void InternalInitialize(string name, (int, int, int) cubeSize, [NotNull]ViewModelBase viewModelBinding)
+1 -1
View File
@@ -116,7 +116,7 @@ namespace StgSharp.MVVM
{
foreach (KeyValuePair<IClickTrigger, Action> pair in keyCallbackIndex)
{
if (InternalIO.glfwGetKey(_binding.ViewHandle,
if (GraphicFramework.glfwGetKey(_binding.ViewHandle,
pair.Key.TargetKeyOrButtonID) == pair.Key.TriggeredStatus) {
pair.Value();
}
@@ -61,7 +61,7 @@ namespace StgSharp.MVVM.ViewModel
fpsCountingToken.TimeSpanRefreshed += CountFps;
fpsCountingToken.MissTimeSpanRefreshed += CountFps;
if (_nextView != _currentView) {
Interlocked.Exchange(ref _currentView, _nextView);
_ = Interlocked.Exchange(ref _currentView, _nextView);
}
Thread renderThread = new Thread((token) => {
try
@@ -70,7 +70,7 @@ namespace StgSharp.MVVM.ViewModel
}
catch (Exception ex)
{
InternalIO.InternalWriteLog(
DefaultLog.InternalWriteLog(
$"Critical error when rendering:\n" + $"{ex}", LogType.Error);
ShouldClose = true;
throw;
@@ -84,9 +84,9 @@ namespace StgSharp.MVVM.ViewModel
while (_closed)
{
if (_nextView != _currentView) {
Interlocked.Exchange(ref _currentView, _nextView);
_ = Interlocked.Exchange(ref _currentView, _nextView);
}
InternalIO.glfwPollEvents();
GraphicFramework.glfwPollEvents();
eventAwaitingToken.WaitNextSpan();
_closed = !ShouldClose;
}
@@ -115,7 +115,7 @@ namespace StgSharp.MVVM.ViewModel
private unsafe void PrivateShow()
{
if (0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortHandle))
if (0 == GraphicFramework.glfwWindowShouldClose(this.viewPortDisplay.ViewPortHandle))
{
CurrentView.Use();
RenderStream.PollEvents();
+11 -13
View File
@@ -45,8 +45,6 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using static StgSharp.Internal.InternalIO;
namespace StgSharp.MVVM.ViewModel
{
public abstract partial class ViewModelBase
@@ -72,7 +70,7 @@ namespace StgSharp.MVVM.ViewModel
_frameCount = 0;
long frameLength = (FrameSpeed > 0) ? (1000L * 1000L / FrameSpeed) : 0;
frameTimeProvider = new TimeSpanProvider(frameLength, TimeSpanProvider.DefaultProvider);
SetFrameSizeCallback(DefaultFrameRewsizeCallback);
SetFrameSizeCallback(DefaultFrameResizeCallback);
}
protected ViewModelBase(float frameLength)
@@ -85,7 +83,7 @@ namespace StgSharp.MVVM.ViewModel
long _frameLength = (FrameSpeed > 0) ? ((long)(1000 * frameLength)) : 0;
frameTimeProvider = new TimeSpanProvider(_frameLength,
TimeSpanProvider.DefaultProvider);
SetFrameSizeCallback(DefaultFrameRewsizeCallback);
SetFrameSizeCallback(DefaultFrameResizeCallback);
}
public ViewModelBase(ViewPort vBinding, int frameSpeed)
@@ -97,7 +95,7 @@ namespace StgSharp.MVVM.ViewModel
_frameCount = 0;
long frameLength = (frameSpeed > 0) ? (1000L * 1000L / frameSpeed) : 0;
frameTimeProvider = new TimeSpanProvider(frameLength, TimeSpanProvider.DefaultProvider);
SetFrameSizeCallback(DefaultFrameRewsizeCallback);
SetFrameSizeCallback(DefaultFrameResizeCallback);
}
public ViewModelBase(ViewPort vBinding, float frameLength)
@@ -110,7 +108,7 @@ namespace StgSharp.MVVM.ViewModel
long _frameLength = (frameLength > 0) ? ((long)(1000 * frameLength)) : 0;
frameTimeProvider = new TimeSpanProvider(_frameLength,
TimeSpanProvider.DefaultProvider);
SetFrameSizeCallback(DefaultFrameRewsizeCallback);
SetFrameSizeCallback(DefaultFrameResizeCallback);
}
public DataBindingEntry this[string name]
@@ -126,8 +124,8 @@ namespace StgSharp.MVVM.ViewModel
public bool ShouldClose
{
get => InternalIO.glfwWindowShouldClose(viewPortDisplay.ViewPortHandle) != 0;
set => InternalIO.glfwSetWindowShouldClose(
get => GraphicFramework.glfwWindowShouldClose(viewPortDisplay.ViewPortHandle) != 0;
set => GraphicFramework.glfwSetWindowShouldClose(
viewPortDisplay.ViewPortHandle, value ? 1 : 0);
}
@@ -195,7 +193,7 @@ namespace StgSharp.MVVM.ViewModel
public void SetSizeLimit(Vec2 minSize, Vec2 maxSize)
{
ThreadHelper.MainThreadAssert();
InternalIO.glfwSetWindowSizeLimits(
GraphicFramework.glfwSetWindowSizeLimits(
this.viewPortDisplay.ViewPortHandle, (int)minSize.X, (int)minSize.Y, (int)maxSize.X,
(int)maxSize.Y);
}
@@ -219,7 +217,7 @@ namespace StgSharp.MVVM.ViewModel
public void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight)
{
ThreadHelper.MainThreadAssert();
InternalIO.glfwSetWindowSizeLimits(
GraphicFramework.glfwSetWindowSizeLimits(
this.viewPortDisplay.ViewPortHandle, minWidth, minHeight, maxWidth, maxHeight);
}
@@ -229,11 +227,11 @@ namespace StgSharp.MVVM.ViewModel
{
_resizeCallback = callback;
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(callback);
InternalIO.glfwSetFrameBufferSizeCallback(
viewPortDisplay.ViewPortHandle, (delegate* unmanaged[Cdecl]<IntPtr,int,int,void>)handlerPtr);
_ = GraphicFramework.glfwSetFrameBufferSizeCallback(
viewPortDisplay.ViewPortHandle, (delegate* unmanaged[Cdecl]<IntPtr, int, int, void>)handlerPtr);
}
private void DefaultFrameRewsizeCallback(IntPtr windowHandle, int width, int height)
private void DefaultFrameResizeCallback(IntPtr windowHandle, int width, int height)
{
ViewPort.GetExistedViewPort(windowHandle, out ViewPort vp);
vp.RequestFlushSizeInNextFrame(width, height);
+2 -2
View File
@@ -49,7 +49,7 @@ namespace StgSharp.MVVM
Name = new StackFrame(1, false).
GetMethod()!.DeclaringType!.Name;
Monitor = IntPtr.Zero;
ViewPortHandle = InternalIO.glfwCreateWindow(
ViewPortHandle = GraphicFramework.glfwCreateWindow(
_newWidth, _newHeight, Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero);
if (ViewPortHandle == IntPtr.Zero) {
throw new InvalidOperationException("Unable to create viewport handle.");
@@ -64,7 +64,7 @@ namespace StgSharp.MVVM
FlushSize();
Name = name;
Monitor = monitor;
ViewPortHandle = InternalIO.glfwCreateWindow(
ViewPortHandle = GraphicFramework.glfwCreateWindow(
_newWidth, _newHeight, Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero);
if (ViewPortHandle == IntPtr.Zero) {
throw new InvalidOperationException("Unable to create viewport handle.");
@@ -196,7 +196,7 @@ namespace StgSharp.Mathematics.Graphic
{
fixed (ColumnSet4* source = &mat, target = &transpose)
{
InternalIO.Intrinsic.f32_transpose(source, target);
NativeIntrinsic.Intrinsic.f32_transpose(source, target);
// InternalIO.Intrinsic.transpose44(source, target);
}
@@ -26,10 +26,6 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Mathematics
{
@@ -59,7 +55,7 @@ namespace StgSharp.Mathematics
return factorialResult[n];
}
if (n < 30) {
return InternalIO.Intrinsic.factorial_simd(n);
return NativeIntrinsic.Intrinsic.factorial_simd(n);
}
double
dn = n,
+37
View File
@@ -0,0 +1,37 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="IState"
// 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.State
{
public interface IState { }
}
+46
View File
@@ -0,0 +1,46 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="IStateMachine"
// 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.State
{
public interface IStateMachine<TState, TLabel, TInput> where TState: IState
{
TState CurrentState { get; set; }
TState RootState { get; }
void GotoNextState(TInput input);
}
}
+6 -6
View File
@@ -82,7 +82,7 @@ namespace StgSharp.Stg
{
IGeometry g = item.TypicalShape;
if (!(g is PlainGeometry)) {
if (g is not PlainGeometry) {
throw new InvalidOperationException(
"The current particle buffer contains non-planar geometry,");
}
@@ -135,8 +135,8 @@ namespace StgSharp.Stg
Shader vertexShader = CreateShaderSegment(ShaderType.Vertex, 1);
Shader fragmentShader = CreateShaderSegment(ShaderType.Fragment, 1);
vertexShader.Compile(0, InternalIO.CollisionTextureVertexShader);
fragmentShader.Compile(0, InternalIO.CollisionTextureFragmentShader);
vertexShader.Compile(0, BuiltInShader.CollisionTextureVertexShader);
fragmentShader.Compile(0, BuiltInShader.CollisionTextureFragmentShader);
vertexShader.AttachTo(0, generatingShader);
fragmentShader.AttachTo(0, generatingShader);
@@ -155,9 +155,9 @@ namespace StgSharp.Stg
t = CreateTexture(1);
t.Bind2D(0);
GL.TextureImage2d<byte>(
Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, (uint)Height,
ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, Array.Empty<byte>());
GL.TextureImage2d<byte>
(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, (uint)Height
, ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, Array.Empty<byte>());
t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat);
t.Set2dFilterProperty(0, TextureFilter.Nearest, TextureFilter.Nearest);
+1 -1
View File
@@ -131,7 +131,7 @@ namespace StgSharp
if (!subscriber.CheckTime(totalMS))
{
toRemoveList.Add(subscriber);
InternalIO.InternalWriteLog(
DefaultLog.InternalWriteLog(
$"Time subscriber {subscriber} is to be removed.", LogType.Info);
}
;
+3 -3
View File
@@ -189,13 +189,13 @@ namespace StgSharp.Timing
return true;
}
foreach (TimeSpanAwaitingToken tokenAdd in _tokenToAdd) {
_awaitingTokens.Add(tokenAdd);
_ = _awaitingTokens.Add(tokenAdd);
}
_tokenToAdd.Clear();
foreach (TimeSpanAwaitingToken tokenQuit in _tokenToQuit)
{
_awaitingTokens.Remove(tokenQuit);
InternalIO.InternalWriteLog(
_ = _awaitingTokens.Remove(tokenQuit);
DefaultLog.InternalWriteLog(
$"Awaiting token {tokenQuit!.TokenID} has been removed.", LogType.Info);
}
_tokenToQuit.Clear();
@@ -1,33 +1,32 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Matrix.Basic.cs"
// file="MatrixCompute.Basic"
// 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 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.
// 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 StgSharp.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -40,20 +39,31 @@ namespace StgSharp.Mathematics.Numeric
public static class MatrixCompute
{
public static Matrix<float> Add(Matrix<float> left, Matrix<float> right)
public static unsafe Matrix<float> Add(Matrix<float> left, Matrix<float> right)
{
if (left.ColumnLength != right.ColumnLength || left.RowLength != right.RowLength) {
throw new IndexOutOfRangeException("Matrix dimensions must agree.");
}
MatrixParallel.LeadParallel();
try
Matrix<float> ans = Matrix<float>.FromDefault(left.ColumnLength, left.RowLength);
if (left.KernelColumnLength * left.KernelRowLength <= 1024)
{
throw new NotImplementedException();
}
finally
{
MatrixParallel.EndParallel();
MatrixParallelPool pool = MatrixParallel.LeadParallel();
if (!pool.TryRentIndividualHandle(out MatrixParallelWrap.Handle? handle)) { }
MatrixSegmentEnumeration<float>.Enumerator leftEnum = left.GetColumnEnumeration().GetEnumerator();
MatrixSegmentEnumeration<float>.Enumerator rightEnum = right.GetColumnEnumeration().GetEnumerator();
MatrixSegmentEnumeration<float>.Enumerator ansEnum = ans.GetColumnEnumeration().GetEnumerator();
for (int i = 0; i < left.KernelColumnLength; i++)
{
MatrixSegment<float>.Enumerator leftColumEnum = leftEnum.Current.GetEnumerator();
MatrixSegment<float>.Enumerator rightColumEnum = rightEnum.Current.GetEnumerator();
MatrixSegment<float>.Enumerator ansColumEnum = ansEnum.Current.GetEnumerator();
}
return ans;
}
Stack<MatrixParallelWrap> taskGroup = MatrixParallel.PublicTask(left.GetColumnEnumeration(), right.GetColumnEnumeration(), ans.GetColumnEnumeration(),
(delegate*<MatrixKernel<float>*, MatrixKernel<float>*, MatrixKernel<float>*, void>)NativeIntrinsic.Intrinsic.f32_add);
return ans;
}
}
@@ -42,25 +42,24 @@ namespace StgSharp.Mathematics.Numeric
nint l = p->Left, r = p->Right, a = p->Result;
long
// set beginning value to counters for primary offsets
lCount = (long)p->LeftPrimOffset * p->LeftPrimStride,
rCount = (long)p->RightPrimOffset * p->RightPrimStride,
aCount = (long)p->ResultPrimOffset * p->ResultPrimStride,
pCount = int.Min(p->PrimCount, p->PrimColumnCountInTile + p->PrimTileOffset)/*count of tile may be too much*/,
pCount = int.Min(p->PrimCount, p->PrimCountInTile + p->PrimTileOffset) /*count of tile may be too much*/,
//edge to reset counters
lLimit = pCount - p->LeftPrimOffset,
rLimit = pCount - p->RightPrimOffset,
aLimit = pCount - p->ResultPrimOffset;
delegate* unmanaged[Cdecl]<IntPtr, IntPtr, IntPtr, void> op =
(delegate* unmanaged[Cdecl]<IntPtr, IntPtr, IntPtr, void>)p->ComputeHandle;
for (long i = p->PrimTileOffset; i < pCount; i++)
for (long i = p->PrimTileOffset % pCount; i < pCount; i++)
{
// update primary counters
// if reaches edge, reset to zero
lCount = i < lLimit ? lCount + p->LeftPrimOffset : 0;
rCount = i < rLimit ? rCount + p->RightPrimOffset : 0;
aCount = i < rLimit ? aCount + p->ResultPrimOffset : 0;
lCount = i < lLimit ? lCount + p->LeftPrimStride : 0;
rCount = i < rLimit ? rCount + p->RightPrimStride : 0;
aCount = i < rLimit ? aCount + p->ResultPrimStride : 0;
// get kernel column pointers
nint left = l + (nint)(lCount * eSize);
@@ -70,16 +69,16 @@ namespace StgSharp.Mathematics.Numeric
lc = (long)p->LeftSecOffset * p->LeftSecStride,
rc = (long)p->RightSecOffset * p->RightSecStride,
ac = (long)p->ResultSecOffset * p->ResultSecStride,
sCount = int.Min(p->SecCount, p->SecColumnCountInTile + p->SecTileOffset);
sCount = int.Min(p->SecCount, p->SecCountInTile * p->SecTileOffset);
long
ll = sCount - p->LeftSecOffset,
rl = sCount - p->RightSecOffset,
al = sCount - p->ResultSecOffset;
for (int j = p->SecTileOffset; j < sCount; j++)
for (long j = p->SecTileOffset % sCount; j < sCount; j++)
{
lc = j < ll ? lc + p->LeftSecOffset : 0;
rc = j < rl ? rc + p->RightSecOffset : 0;
ac = j < al ? ac + p->ResultSecOffset : 0;
lc = j < ll ? lc + p->LeftSecStride : 0;
rc = j < rl ? rc + p->RightSecStride : 0;
ac = j < al ? ac + p->ResultSecStride : 0;
op(left + (nint)lc, right + (nint)rc, ans + (nint)ac);
}
}
@@ -88,42 +87,50 @@ namespace StgSharp.Mathematics.Numeric
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe void Compute_BinaryScalar(MatrixParallelTaskPackageNonGeneric* p)
{
int eSize = p->ElementSize;
// base pointer to matrix kernels
nint l = p->Left, r = p->Right, a = p->Result;
long
lCount = p->LeftPrimOffset * p->LeftPrimStride,
rCount = p->RightPrimOffset * p->RightPrimStride,
aCount = p->ResultPrimOffset * p->ResultPrimStride,
pCount = p->PrimCount;
long
// set beginning value to counters for primary offsets
lCount = (long)p->LeftPrimOffset * p->LeftPrimStride,
rCount = (long)p->RightPrimOffset * p->RightPrimStride,
aCount = (long)p->ResultPrimOffset * p->ResultPrimStride,
pCount = int.Min(p->PrimCount, p->PrimCountInTile + p->PrimTileOffset) /*count of tile may be too much*/,
//edge to reset counters
lLimit = pCount - p->LeftPrimOffset,
rLimit = pCount - p->RightPrimOffset,
aLimit = pCount - p->ResultPrimOffset;
delegate* unmanaged[Cdecl]<nint, nint, nint, ScalarPacket*, void> op =
(delegate* unmanaged[Cdecl]<nint, nint, nint, ScalarPacket*, void>)p->ComputeHandle;
ScalarPacket* scalar = p->Scalar;
for (long i = 0; i < pCount; i++)
delegate* unmanaged[Cdecl]<IntPtr, IntPtr, IntPtr, ScalarPacket*, void> op =
(delegate* unmanaged[Cdecl]<IntPtr, IntPtr, IntPtr, ScalarPacket*, void>)p->ComputeHandle;
for (long i = p->PrimTileOffset % pCount; i < pCount; i++)
{
lCount = i < lLimit ? lCount + p->LeftPrimOffset : 0;
rCount = i < rLimit ? rCount + p->RightPrimOffset : 0;
aCount = i < rLimit ? aCount + p->ResultPrimOffset : 0;
nint
left = l + (nint)lCount,
right = r + (nint)rCount,
ans = a + (nint)aCount;
// update primary counters
// if reaches edge, reset to zero
lCount = i < lLimit ? lCount + p->LeftPrimStride : 0;
rCount = i < rLimit ? rCount + p->RightPrimStride : 0;
aCount = i < rLimit ? aCount + p->ResultPrimStride : 0;
// get kernel column pointers
nint left = l + (nint)(lCount * eSize);
nint right = r + (nint)(rCount * eSize);
nint ans = a + (nint)(aCount * eSize);
long
lc = (long)p->LeftSecOffset * p->LeftSecStride,
rc = (long)p->RightSecOffset * p->RightSecStride,
ac = (long)p->ResultSecOffset * p->ResultSecStride,
sCount = int.Min(p->SecCount, p->SecCountInTile * p->SecTileOffset);
long
lc = p->LeftSecOffset * p->LeftSecStride,
rc = p->RightSecOffset * p->RightSecStride,
ac = p->ResultSecOffset * p->ResultSecStride,
sCount = p->SecCount,
ll = sCount - p->LeftSecOffset,
rl = sCount - p->RightSecOffset,
al = sCount - p->ResultSecOffset;
for (int j = 0; j < sCount; j++)
for (long j = p->SecTileOffset % sCount; j < sCount; j++)
{
lc = j < ll ? lc + p->LeftSecOffset : 0;
rc = j < rl ? rc + p->RightSecOffset : 0;
ac = j < al ? ac + p->ResultSecOffset : 0;
op(left + (nint)lc, right + (nint)rc, ans + (nint)ac, scalar);
lc = j < ll ? lc + p->LeftSecStride : 0;
rc = j < rl ? rc + p->RightSecStride : 0;
ac = j < al ? ac + p->ResultSecStride : 0;
op(left + (nint)lc, right + (nint)rc, ans + (nint)ac, p->Scalar);
}
}
}
@@ -131,29 +138,43 @@ namespace StgSharp.Mathematics.Numeric
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe void Compute_Unary(MatrixParallelTaskPackageNonGeneric* p)
{
nint s = p->Right, a = p->Result;
long rCount = p->RightPrimOffset * p->RightPrimStride,
aCount = p->ResultPrimOffset * p->ResultPrimStride,
pCount = p->PrimCount;
long rLimit = pCount - p->RightPrimOffset,
aLimit = pCount - p->ResultPrimOffset;
delegate* unmanaged[Cdecl]<nint, nint, void> op =
(delegate* unmanaged[Cdecl]<nint, nint, void>)p->ComputeHandle;
for (long i = 0; i < pCount; i++)
int eSize = p->ElementSize;
// base pointer to matrix kernels
nint r = p->Right, a = p->Result;
long
// set beginning value to counters for primary offsets
rCount = (long)p->RightPrimOffset * p->RightPrimStride,
aCount = (long)p->ResultPrimOffset * p->ResultPrimStride,
pCount = int.Min(p->PrimCount, p->PrimCountInTile + p->PrimTileOffset) /*count of tile may be too much*/,
//edge to reset counters
rLimit = pCount - p->RightPrimOffset,
aLimit = pCount - p->ResultPrimOffset;
delegate* unmanaged[Cdecl]<IntPtr, IntPtr, void> op =
(delegate* unmanaged[Cdecl]<IntPtr, IntPtr, void>)p->ComputeHandle;
for (long i = p->PrimTileOffset % pCount; i < pCount; i++)
{
rCount = i < rLimit ? rCount + p->RightPrimOffset : 0;
aCount = i < rLimit ? aCount + p->ResultPrimOffset : 0;
nint source = s + (nint)rCount, ans = a + (nint)aCount;
long rc = p->RightSecOffset * p->RightSecStride,
ac = p->ResultSecOffset * p->ResultSecStride,
sCount = p->SecCount;
long rl = sCount - p->RightSecOffset,
al = sCount - p->ResultSecOffset;
for (int j = 0; j < sCount; j++)
// update primary counters
// if reaches edge, reset to zero
rCount = i < rLimit ? rCount + p->RightPrimStride : 0;
aCount = i < rLimit ? aCount + p->ResultPrimStride : 0;
// get kernel column pointers
nint right = r + (nint)(rCount * eSize);
nint ans = a + (nint)(aCount * eSize);
long
rc = (long)p->RightSecOffset * p->RightSecStride,
ac = (long)p->ResultSecOffset * p->ResultSecStride,
sCount = int.Min(p->SecCount, p->SecCountInTile * p->SecTileOffset);
long
rl = sCount - p->RightSecOffset,
al = sCount - p->ResultSecOffset;
for (long j = p->SecTileOffset % sCount; j < sCount; j++)
{
rc = j < rl ? rc + p->RightSecOffset : 0;
ac = j < al ? ac + p->ResultSecOffset : 0;
op(source + (nint)rc, ans + (nint)ac);
rc = j < rl ? rc + p->RightSecStride : 0;
ac = j < al ? ac + p->ResultSecStride : 0;
op(right + (nint)rc, ans + (nint)ac);
}
}
}
@@ -161,34 +182,46 @@ namespace StgSharp.Mathematics.Numeric
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe void Compute_UnaryScalar(MatrixParallelTaskPackageNonGeneric* p)
{
nint s = p->Right, a = p->Result;
long rCount = p->RightPrimOffset * p->RightPrimStride,
aCount = p->ResultPrimOffset * p->ResultPrimStride,
pCount = p->PrimCount;
long rLimit = pCount - p->RightPrimOffset,
aLimit = pCount - p->ResultPrimOffset;
delegate* unmanaged[Cdecl]<nint, nint, ScalarPacket*, void> op =
(delegate* unmanaged[Cdecl]<nint, nint, ScalarPacket*, void>)p->ComputeHandle;
ScalarPacket* scalar = p->Scalar;
for (long i = 0; i < pCount; i++)
int eSize = p->ElementSize;
// base pointer to matrix kernels
nint r = p->Right, a = p->Result;
long
// set beginning value to counters for primary offsets
rCount = (long)p->RightPrimOffset * p->RightPrimStride,
aCount = (long)p->ResultPrimOffset * p->ResultPrimStride,
pCount = int.Min(p->PrimCount, p->PrimCountInTile + p->PrimTileOffset) /*count of tile may be too much*/,
//edge to reset counters
rLimit = pCount - p->RightPrimOffset,
aLimit = pCount - p->ResultPrimOffset;
delegate* unmanaged[Cdecl]<IntPtr, IntPtr, ScalarPacket*, void> op =
(delegate* unmanaged[Cdecl]<IntPtr, IntPtr, ScalarPacket*, void>)p->ComputeHandle;
for (long i = p->PrimTileOffset % pCount; i < pCount; i++)
{
rCount = i < rLimit ? rCount + p->RightPrimOffset : 0;
aCount = i < rLimit ? aCount + p->ResultPrimOffset : 0;
nint source = s + (nint)rCount;
nint ans = a + (nint)aCount;
long rc = p->RightSecOffset * p->RightSecStride,
ac = p->ResultSecOffset * p->ResultSecStride,
sCount = p->SecCount;
long rl = sCount - p->RightSecOffset,
al = sCount - p->ResultSecOffset;
for (int j = 0; j < sCount; j++)
// update primary counters
// if reaches edge, reset to zero
rCount = i < rLimit ? rCount + p->RightPrimStride : 0;
aCount = i < rLimit ? aCount + p->ResultPrimStride : 0;
// get kernel column pointers
nint right = r + (nint)(rCount * eSize);
nint ans = a + (nint)(aCount * eSize);
long
rc = (long)p->RightSecOffset * p->RightSecStride,
ac = (long)p->ResultSecOffset * p->ResultSecStride,
sCount = int.Min(p->SecCount, p->SecCountInTile * p->SecTileOffset);
long
rl = sCount - p->RightSecOffset,
al = sCount - p->ResultSecOffset;
for (long j = p->SecTileOffset % sCount; j < sCount; j++)
{
rc = j < rl ? rc + p->RightSecOffset : 0;
ac = j < al ? ac + p->ResultSecOffset : 0;
op(source + (nint)rc, ans + (nint)ac, scalar);
rc = j < rl ? rc + p->RightSecStride : 0;
ac = j < al ? ac + p->ResultSecStride : 0;
op(right + (nint)rc, ans + (nint)ac, p->Scalar);
}
}
}
}
}
}
@@ -40,10 +40,10 @@ namespace StgSharp.Mathematics.Numeric
public static partial class MatrixParallel
{
public static unsafe void PublicTask<T>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation)
where T: unmanaged, INumber<T>
{
MatrixParallelTaskPackage<T>* package = MatrixParallelFactory.CreateBaseTask<T>();
@@ -63,14 +63,14 @@ namespace StgSharp.Mathematics.Numeric
package->ElementSize = sizeof(T);
package->ComputeMode = 1; // Unary
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation)
where T: unmanaged, INumber<T>
{
MatrixParallelTaskPackage<T>* package = MatrixParallelFactory.CreateBaseTask<T>();
@@ -95,15 +95,15 @@ namespace StgSharp.Mathematics.Numeric
package->ElementSize = sizeof(T);
package->ComputeMode = 3; // Binary
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
// Unary with 1..8 scalars (each scalar is independent generic type)
public static unsafe void PublicTask<T, TScalar0>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
{
@@ -127,15 +127,15 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar0>(0) = s0;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -161,16 +161,16 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar0>(0) = s0;
sp->Data<TScalar1>(1) = s1;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
// Binary with 1..8 scalars (each scalar is independent generic type)
public static unsafe void PublicTask<T, TScalar0>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
{
@@ -199,16 +199,16 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar0>(0) = s0;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -236,16 +236,16 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar1>(1) = s1;
sp->Data<TScalar2>(2) = s2;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -276,17 +276,17 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar0>(0) = s0;
sp->Data<TScalar1>(1) = s1;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -316,17 +316,17 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar2>(2) = s2;
sp->Data<TScalar3>(3) = s3;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -359,18 +359,18 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar1>(1) = s1;
sp->Data<TScalar2>(2) = s2;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -402,18 +402,18 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar3>(3) = s3;
sp->Data<TScalar4>(4) = s4;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -448,19 +448,19 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar2>(2) = s2;
sp->Data<TScalar3>(3) = s3;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -494,19 +494,19 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar4>(4) = s4;
sp->Data<TScalar5>(5) = s5;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -543,20 +543,20 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar3>(3) = s3;
sp->Data<TScalar4>(4) = s4;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5, TScalar6>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5,
TScalar6 s6)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5, TScalar6>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5,
TScalar6 s6)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -592,20 +592,20 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar5>(5) = s5;
sp->Data<TScalar6>(6) = s6;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -644,21 +644,21 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar4>(4) = s4;
sp->Data<TScalar5>(5) = s5;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5, TScalar6, TScalar7>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5,
TScalar6 s6,
TScalar7 s7)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5, TScalar6, TScalar7>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5,
TScalar6 s6,
TScalar7 s7)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -696,21 +696,21 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar6>(6) = s6;
sp->Data<TScalar7>(7) = s7;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5, TScalar6>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5,
TScalar6 s6)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5, TScalar6>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5,
TScalar6 s6)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -751,22 +751,22 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar5>(5) = s5;
sp->Data<TScalar6>(6) = s6;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
public static unsafe void PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5, TScalar6, TScalar7>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5,
TScalar6 s6,
TScalar7 s7)
public static unsafe Stack<MatrixParallelWrap> PublicTask<T, TScalar0, TScalar1, TScalar2, TScalar3, TScalar4, TScalar5, TScalar6, TScalar7>(
MatrixSegmentEnumeration<T> left,
MatrixSegmentEnumeration<T> right,
MatrixSegmentEnumeration<T> ans,
delegate*<MatrixKernel<T>*, MatrixKernel<T>*, MatrixKernel<T>*, void> Operation,
TScalar0 s0,
TScalar1 s1,
TScalar2 s2,
TScalar3 s3,
TScalar4 s4,
TScalar5 s5,
TScalar6 s6,
TScalar7 s7)
where T: unmanaged, INumber<T>
where TScalar0: unmanaged, INumber<TScalar0>
where TScalar1: unmanaged, INumber<TScalar1>
@@ -809,7 +809,7 @@ namespace StgSharp.Mathematics.Numeric
sp->Data<TScalar6>(6) = s6;
sp->Data<TScalar7>(7) = s7;
package->Scalar = sp;
PublicTaskPrivate<T>(package);
return PublicTaskPrivate<T>(package);
}
private static unsafe Stack<MatrixParallelWrap> PublicTaskPrivate<T>(MatrixParallelTaskPackage<T>* package)
@@ -860,7 +860,7 @@ namespace StgSharp.Mathematics.Numeric
// update current task
current->PrimColumnCountInTile = columnInWrap;
current->SecColumnCountInTile = current->SecCount;
current->SecTileBegin = 0;
current->SecTileOffset = 0;
// remove tiles count
extraColumnCount--;
@@ -877,7 +877,7 @@ namespace StgSharp.Mathematics.Numeric
break;
}
current = MatrixParallelFactory.FromExistPackage(current);
current->PrimTileBegin += columnInWrap;
current->PrimTileOffset += columnInWrap;
}
ReleaseParallelLeadership(ref pool);
@@ -116,10 +116,10 @@ namespace StgSharp.Mathematics.Numeric
#region count offset
public readonly int PrimTileOffset; // 4
public readonly int SecTileOffset; // 4
public readonly int PrimColumnCountInTile; // 4
public readonly int SecColumnCountInTile; // 4
public readonly int PrimTileOffset; // 4
public readonly int SecTileOffset; // 4
public readonly int PrimCountInTile; // 4
public readonly int SecCountInTile; // 4
#endregion
}
@@ -205,8 +205,8 @@ namespace StgSharp.Mathematics.Numeric
#region count offset
public int PrimTileBegin; // 4
public int SecTileBegin; // 4
public int PrimTileOffset; // 4
public int SecTileOffset; // 4
public int PrimColumnCountInTile; // 4
public int SecColumnCountInTile; // 4