namespace arrange; final wrap scheduale solution

This commit is contained in:
Youmu Liu
2025-10-13 20:59:14 +08:00
parent 31f649015c
commit a95e9b1ff7
44 changed files with 683 additions and 926 deletions
+38 -35
View File
@@ -1,33 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Global.cs" // file="Global.cs"
// Project: StepVisualizer // Project: StepVisualizer
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // 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, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// This file is used by Code Analysis to maintain SuppressMessage // This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project. // attributes that are applied to this project.
// Project-level suppressions either have no target or are given // Project-level suppressions either have no target or are given
@@ -38,64 +38,67 @@ global using StgSharp.Internal.Intrinsic;
global using StgSharp.Internal.OpenGL; global using StgSharp.Internal.OpenGL;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("StgSharp.Mathematics")]
[assembly: SuppressMessage( [assembly: SuppressMessage(
"Design", "Design",
"CA1008:枚举应具有零值", "CA1008:枚举应具有零值",
Justification = "<挂起>", Justification = "<挂起>",
Scope = "type", Scope = "type",
Target = "~T:StgSharp.Graphics.OpenGL.ShaderStatus" )] Target = "~T:StgSharp.Graphics.OpenGL.ShaderStatus")]
[assembly: SuppressMessage( [assembly: SuppressMessage(
"Naming", "Naming",
"CA1715:标识符应具有正确的前缀", "CA1715:标识符应具有正确的前缀",
Justification = "<挂起>", Justification = "<挂起>",
Scope = "member", Scope = "member",
Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``2(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1}" )] Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``2(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1}")]
[assembly: SuppressMessage( [assembly: SuppressMessage(
"Naming", "Naming",
"CA1715:标识符应具有正确的前缀", "CA1715:标识符应具有正确的前缀",
Justification = "<挂起>", Justification = "<挂起>",
Scope = "member", Scope = "member",
Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``3(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1,``2}" )] Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``3(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1,``2}")]
[assembly: SuppressMessage( [assembly: SuppressMessage(
"Naming", "Naming",
"CA1715:标识符应具有正确的前缀", "CA1715:标识符应具有正确的前缀",
Justification = "<挂起>", Justification = "<挂起>",
Scope = "member", Scope = "member",
Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``4(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1,``2,``3}" )] Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``4(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1,``2,``3}")]
[assembly: SuppressMessage( [assembly: SuppressMessage(
"Naming", "Naming",
"CA1715:标识符应具有正确的前缀", "CA1715:标识符应具有正确的前缀",
Justification = "<挂起>", Justification = "<挂起>",
Scope = "type", Scope = "type",
Target = "~T:StgSharp.Graphics.OpenGL.Uniform`4" )] Target = "~T:StgSharp.Graphics.OpenGL.Uniform`4")]
[assembly: SuppressMessage( [assembly: SuppressMessage(
"Design", "Design",
"CA1043:将整型或字符串参数用于索引器", "CA1043:将整型或字符串参数用于索引器",
Justification = "<挂起>", Justification = "<挂起>",
Scope = "member", Scope = "member",
Target = "~P:StgSharp.MVVM.ViewBase.IViewResponder`1.Item(StgSharp.Controlling.UsrActivity.ITrigger)" )] Target = "~P:StgSharp.MVVM.ViewBase.IViewResponder`1.Item(StgSharp.Controlling.UsrActivity.ITrigger)")]
[assembly: SuppressMessage( [assembly: SuppressMessage(
"Design", "Design",
"CA1043:将整型或字符串参数用于索引器", "CA1043:将整型或字符串参数用于索引器",
Justification = "<挂起>", Justification = "<挂起>",
Scope = "member", Scope = "member",
Target = "~P:StgSharp.MVVM.ViewBase.ViewResponder`1.Item(StgSharp.Controlling.UsrActivity.ITrigger)" )] Target = "~P:StgSharp.MVVM.ViewBase.ViewResponder`1.Item(StgSharp.Controlling.UsrActivity.ITrigger)")]
[assembly: SuppressMessage( [assembly: SuppressMessage(
"Performance", "Performance",
"CA1864:首选 \"IDictionary.TryAdd(TKey, TValue)\" 方法", "CA1864:首选 \"IDictionary.TryAdd(TKey, TValue)\" 方法",
Justification = "<挂起>", Justification = "<挂起>",
Scope = "member", Scope = "member",
Target = "~P:StgSharp.MVVM.ViewBase.ViewRender`1.Item(System.String)" )] Target = "~P:StgSharp.MVVM.ViewBase.ViewRender`1.Item(System.String)")]
[assembly: SuppressMessage( [assembly: SuppressMessage(
"Design", "Design",
"CA1033:接口方法应可由子类型调用", "CA1033:接口方法应可由子类型调用",
Justification = "<挂起>", Justification = "<挂起>",
Scope = "member", Scope = "member",
Target = "~P:StgSharp.Collections.IBidirectionalDictionary`2.System#Collections#Generic#IDictionary<TFirst,TSecond>#Keys" )] Target = "~P:StgSharp.Collections.IBidirectionalDictionary`2.System#Collections#Generic#IDictionary<TFirst,TSecond>#Keys")]
[assembly: SuppressMessage( [assembly: SuppressMessage(
"Design", "Design",
"CA1033:接口方法应可由子类型调用", "CA1033:接口方法应可由子类型调用",
Justification = "<挂起>", Justification = "<挂起>",
Scope = "member", Scope = "member",
Target = "~P:StgSharp.Collections.IBidirectionalDictionary`2.System#Collections#Generic#IDictionary<TFirst,TSecond>#Values" )] Target = "~P:StgSharp.Collections.IBidirectionalDictionary`2.System#Collections#Generic#IDictionary<TFirst,TSecond>#Values")]
@@ -28,17 +28,9 @@
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Graphics; using StgSharp.Mathematics.Graphic;
using StgSharp.Mathematics;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Graphics.OpenGL namespace StgSharp.Graphics.OpenGL
{ {
@@ -1,33 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="IRegisterType.cs" // file="IRegisterType.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // 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, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -40,9 +40,9 @@ namespace StgSharp.HighPerformance
public interface IRegisterType public interface IRegisterType
{ {
public ref T AsRef<T>() where T: unmanaged, INumber<T>; ref T AsRef<T>() where T: unmanaged, INumber<T>;
public ref T Member<T>(int index) where T: unmanaged, INumber<T>; ref T Member<T>(int index) where T: unmanaged, INumber<T>;
} }
} }
+2 -1
View File
@@ -43,7 +43,7 @@ namespace StgSharp.HighPerformance
public string Name public string Name
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get; get;
init; init;
} }
@@ -61,6 +61,7 @@ namespace StgSharp.HighPerformance
public static class DataLabelBuilder public static class DataLabelBuilder
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static DataLabel AsLabel(this string name) public static DataLabel AsLabel(this string name)
{ {
return new DataLabel(name); return new DataLabel(name);
@@ -28,16 +28,9 @@
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.HighPerformance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.HighPerformance namespace StgSharp.HighPerformance
{ {
@@ -52,7 +52,7 @@ namespace StgSharp.HighPerformance.Memory
public int Count public int Count
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get => (int)_count; get => (int)_count;
} }
@@ -151,7 +151,7 @@ namespace StgSharp.HighPerformance.Memory
{ {
Header* header = (Header*)_buffer; Header* header = (Header*)_buffer;
nuint newCap = header->Capacity * 2; nuint newCap = header->Capacity * 2;
nuint newSize = (nuint)sizeof(Header) + newCap * (nuint)sizeof(T); nuint newSize = (nuint)sizeof(Header) + (newCap * (nuint)sizeof(T));
_buffer = (byte*)NativeMemory.Realloc(_buffer, newSize); _buffer = (byte*)NativeMemory.Realloc(_buffer, newSize);
header = (Header*)_buffer; header = (Header*)_buffer;
header->Capacity = newCap; header->Capacity = newCap;
@@ -1,60 +1,56 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="UnsafeCompute.cs" // file="UnsafeCompute.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // 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, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text;
namespace StgSharp.HighPerformance namespace StgSharp.HighPerformance
{ {
public static class UnsafeCompute public static class UnsafeCompute
{ {
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe int CityHashSimplify( char* span, int length ) public static unsafe int CityHashSimplify(char* span, int length)
{ {
return InternalIO.Intrinsic.city_hash_simplify( span, length ); return InternalIO.Intrinsic.city_hash_simplify(span, length);
} }
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe int CityHashSimplify( char* span, int begin, int length ) public static unsafe int CityHashSimplify(char* span, int begin, int length)
{ {
return InternalIO.Intrinsic.city_hash_simplify( span + begin, length ); return InternalIO.Intrinsic.city_hash_simplify(span + begin, length);
} }
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe int IndexOfCharPair( char* source, int pairValue, int length ) public static unsafe int IndexOfCharPair(char* source, int pairValue, int length)
{ {
return InternalIO.Intrinsic.index_pair( source, pairValue, length ); return InternalIO.Intrinsic.index_pair(source, pairValue, length);
} }
} }
@@ -1,33 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ColumnSet4.cs" // file="ColumnSet4.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // 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, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp; using StgSharp;
using StgSharp.Internal.Intrinsic; using StgSharp.Internal.Intrinsic;
@@ -38,66 +38,66 @@ using System.Runtime.InteropServices;
namespace StgSharp.Internal.Intrinsic namespace StgSharp.Internal.Intrinsic
{ {
[StructLayout( LayoutKind.Explicit, Size = 16 * sizeof( float ) )] [StructLayout(LayoutKind.Explicit, Size = 16 * sizeof(float))]
internal struct ColumnSet4 : IEquatable<ColumnSet4> internal struct ColumnSet4 : IEquatable<ColumnSet4>
{ {
[FieldOffset( 0 )] internal Vector4 colum0; [FieldOffset(0)] internal Vector4 colum0;
[FieldOffset( 16 )] internal Vector4 colum1; [FieldOffset(16)] internal Vector4 colum1;
[FieldOffset( 32 )] internal Vector4 colum2; [FieldOffset(32)] internal Vector4 colum2;
[FieldOffset( 48 )] internal Vector4 colum3; [FieldOffset(48)] internal Vector4 colum3;
[FieldOffset( 0 )] public float m00; [FieldOffset(0)] public float m00;
[FieldOffset( 16 )] public float m01; [FieldOffset(16)] public float m01;
[FieldOffset( 32 )] public float m02; [FieldOffset(32)] public float m02;
[FieldOffset( 48 )] public float m03; [FieldOffset(48)] public float m03;
[FieldOffset( 4 )] public float m10; [FieldOffset(4)] public float m10;
[FieldOffset( 20 )] public float m11; [FieldOffset(20)] public float m11;
[FieldOffset( 36 )] public float m12; [FieldOffset(36)] public float m12;
[FieldOffset( 52 )] public float m13; [FieldOffset(52)] public float m13;
[FieldOffset( 8 )] public float m20; [FieldOffset(8)] public float m20;
[FieldOffset( 24 )] public float m21; [FieldOffset(24)] public float m21;
[FieldOffset( 40 )] public float m22; [FieldOffset(40)] public float m22;
[FieldOffset( 56 )] public float m23; [FieldOffset(56)] public float m23;
[FieldOffset( 12 )] public float m30; [FieldOffset(12)] public float m30;
[FieldOffset( 28 )] public float m31; [FieldOffset(28)] public float m31;
[FieldOffset( 44 )] public float m32; [FieldOffset(44)] public float m32;
[FieldOffset( 60 )] public float m33; [FieldOffset(60)] public float m33;
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal ColumnSet4( Vector4 colum0, Vector4 colum1, Vector4 colum2, Vector4 colum3 ) internal ColumnSet4(Vector4 colum0, Vector4 colum1, Vector4 colum2, Vector4 colum3)
{ {
Unsafe.SkipInit( out this ); Unsafe.SkipInit(out this);
this.colum0 = colum0; this.colum0 = colum0;
this.colum1 = colum1; this.colum1 = colum1;
this.colum2 = colum2; this.colum2 = colum2;
this.colum3 = colum3; this.colum3 = colum3;
} }
public override bool Equals( object? obj ) public override bool Equals(object? obj)
{ {
return ( obj is ColumnSet4 mat ) && Equals( mat ); return (obj is ColumnSet4 mat) && Equals(mat);
} }
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals( ColumnSet4 other ) public bool Equals(ColumnSet4 other)
{ {
return colum0.Equals( other.colum0 ) && return colum0.Equals(other.colum0) &&
colum1.Equals( other.colum1 ) && colum1.Equals(other.colum1) &&
colum2.Equals( other.colum2 ) && colum2.Equals(other.colum2) &&
colum3.Equals( other.colum3 ); colum3.Equals(other.colum3);
} }
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=( ColumnSet4 left, ColumnSet4 right ) public static bool operator !=(ColumnSet4 left, ColumnSet4 right)
{ {
return !( left == right ); return !(left == right);
} }
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==( ColumnSet4 left, ColumnSet4 right ) public static bool operator ==(ColumnSet4 left, ColumnSet4 right)
{ {
return left.Equals( right ); return left.Equals(right);
} }
} }
+12 -20
View File
@@ -28,20 +28,12 @@
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL; using StgSharp.Graphics.OpenGL;
using StgSharp.Graphics.ShaderEdit; using StgSharp.Graphics.ShaderEdit;
using StgSharp.HighPerformance;
using StgSharp.Mathematics;
using System; using System;
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Graphics namespace StgSharp.Mathematics.Graphic
{ {
public sealed class Camera : IglConvertable public sealed class Camera : IglConvertable
{ {
@@ -150,7 +142,7 @@ namespace StgSharp.Graphics
public unsafe void SetAllUniforms() public unsafe void SetAllUniforms()
{ {
// Console.WriteLine(Projection * ViewBase); // Console.WriteLine(Projection * ViewBase);
OpenGL.OpenGLFunction.CurrentGL.SetUniformValue(convertedUniform, Projection * View); OpenGLFunction.CurrentGL.SetUniformValue(convertedUniform, Projection * View);
} }
public void SetViewDirection(Vec3 position, Vec3 target, Vec3 up) public void SetViewDirection(Vec3 position, Vec3 target, Vec3 up)
@@ -172,7 +164,7 @@ namespace StgSharp.Graphics
_isLookAtAvailable = false; _isLookAtAvailable = false;
Linear.Orthogonalize(ref direction, ref up); direction.Orthogonalize(ref up);
Vec3 right = Linear.Orthogonalize(Linear.Cross(up, direction)); Vec3 right = Linear.Orthogonalize(Linear.Cross(up, direction));
@@ -186,24 +178,24 @@ namespace StgSharp.Graphics
InternalYaw(); InternalYaw();
} }
public void SetViewRange(Radius fovRadius, Vec2 size, Vec2 offset, (float front, float back) dephRange) public void SetViewRange(Radius fovRadius, Vec2 size, Vec2 offset, (float front, float back) depthRange)
{ {
float float
distance = _target.GetLength(), distance = _target.GetLength(),
near = distance - dephRange.front, near = distance - depthRange.front,
far = distance + dephRange.back, far = distance + depthRange.back,
offsetX = offset.X, offsetX = offset.X,
offsetY = offset.Y, offsetY = offset.Y,
width = Scaler.Abs(GeometryScaler.Tan(fovRadius / 2) * near * 2), width = Scaler.Abs(GeometryScaler.Tan(fovRadius / 2) * near * 2),
height = (width * size.Y) / size.X; height = width * size.Y / size.X;
_projection.colum0.X = (2 * near) / width; _projection.colum0.X = 2 * near / width;
_projection.colum1.Y = (2 * near) / height; _projection.colum1.Y = 2 * near / height;
_projection.colum2.X = (2 * offsetX) / width; _projection.colum2.X = 2 * offsetX / width;
_projection.colum2.Y = (2 * offsetY) / height; _projection.colum2.Y = 2 * offsetY / height;
_projection.colum2.Z = (far + near) / (near - far); _projection.colum2.Z = (far + near) / (near - far);
_projection.colum2.W = -1; _projection.colum2.W = -1;
_projection.colum3.Z = (2 * near * far) / (near - far); _projection.colum3.Z = 2 * near * far / (near - far);
} }
public void Test(params Vec4[] vec) public void Test(params Vec4[] vec)
@@ -29,7 +29,7 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Internal.Intrinsic; using StgSharp.Internal.Intrinsic;
using StgSharp.Mathematics.Numeric;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
@@ -37,9 +37,9 @@ using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Graphic
{ {
[StructLayout(LayoutKind.Explicit, Size = (2 * 16 * sizeof(float)) + sizeof(bool), Pack = 16)] [StructLayout(LayoutKind.Explicit, Size = 2 * 16 * sizeof(float) + sizeof(bool), Pack = 16)]
public unsafe struct Matrix44 : IEquatable<Matrix44>, IMatrix<Matrix44> public unsafe struct Matrix44 : IEquatable<Matrix44>, IMatrix<Matrix44>
{ {
@@ -115,9 +115,9 @@ namespace StgSharp.Mathematics
} }
#endif #endif
InternalTranspose(); InternalTranspose();
fixed (float* p = &this.transpose.m00) fixed (float* p = &transpose.m00)
{ {
ulong pBit = ((ulong)p) + (((ulong)sizeof(Vector4)) * ((ulong)rowNum)) + (((ulong)sizeof(float)) * ((ulong)columNum)); ulong pBit = (ulong)p + (ulong)sizeof(Vector4) * (ulong)rowNum + sizeof(float) * (ulong)columNum;
return *(float*)pBit; return *(float*)pBit;
} }
} }
@@ -133,9 +133,9 @@ namespace StgSharp.Mathematics
} }
#endif #endif
InternalTranspose(); InternalTranspose();
fixed (float* p = &this.transpose.m00) fixed (float* p = &transpose.m00)
{ {
ulong pbit = ((ulong)p) + (((ulong)sizeof(Vector4)) * ((ulong)rowNum)) + (((ulong)sizeof(float)) * ((ulong)columNum)); ulong pbit = (ulong)p + (ulong)sizeof(Vector4) * (ulong)rowNum + sizeof(float) * (ulong)columNum;
*(float*)pbit = value; *(float*)pbit = value;
} }
isTransposed = false; isTransposed = false;
@@ -147,7 +147,7 @@ namespace StgSharp.Mathematics
get get
{ {
InternalTranspose(); InternalTranspose();
return new Matrix44(this.transpose); return new Matrix44(transpose);
} }
} }
@@ -169,7 +169,7 @@ namespace StgSharp.Mathematics
public override bool Equals(object? obj) public override bool Equals(object? obj)
{ {
return (obj is Matrix44 x) && Equals(x); return obj is Matrix44 x && Equals(x);
} }
public bool Equals(Matrix44 other) public bool Equals(Matrix44 other)
@@ -197,6 +197,8 @@ namespace StgSharp.Mathematics
{ {
fixed (ColumnSet4* source = &mat, target = &transpose) fixed (ColumnSet4* source = &mat, target = &transpose)
{ {
InternalIO.Intrinsic.f32_transpose(source, target);
// InternalIO.Intrinsic.transpose44(source, target); // InternalIO.Intrinsic.transpose44(source, target);
} }
isTransposed = true; isTransposed = true;
@@ -29,20 +29,20 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.HighPerformance; using StgSharp.HighPerformance;
using StgSharp.Mathematics.Numeric;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Graphic
{ {
/// <summary> /// <summary>
/// A two dimension vector defined by two elements. Vec2 in World are default used as colum /// A two dimension vector defined by two elements. Vec2 in World are default used as colum
/// vector. /// vector.
/// </summary> /// </summary>
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)] [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
public struct Vec2 : IFixedVector<Vec2> public struct Vec2 : IUnmanagedVector<Vec2>
{ {
[FieldOffset(0)] internal unsafe fixed float num[2]; [FieldOffset(0)] internal unsafe fixed float num[2];
@@ -108,7 +108,7 @@ namespace StgSharp.Mathematics
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public float Cross(Vec2 right) public float Cross(Vec2 right)
{ {
return (X * right.Y) - (Y * right.X); return X * right.Y - Y * right.X;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -29,6 +29,7 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.HighPerformance; using StgSharp.HighPerformance;
using StgSharp.Mathematics.Numeric;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@@ -36,11 +37,11 @@ using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Graphic
{ {
[CollectionBuilder(typeof(Vec3), nameof(Vec3.FromSpan))] [CollectionBuilder(typeof(Vec3), nameof(FromSpan))]
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)] [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
public struct Vec3 : IEquatable<Vec3>, IFixedVector<Vec3>, IEnumerable<float> public struct Vec3 : IEquatable<Vec3>, IUnmanagedVector<Vec3>, IEnumerable<float>
{ {
[FieldOffset(0)] internal unsafe fixed float num[3]; [FieldOffset(0)] internal unsafe fixed float num[3];
@@ -93,7 +94,7 @@ namespace StgSharp.Mathematics
public unsafe Vec2 XY public unsafe Vec2 XY
{ {
get => new Vec2(this.reg); get => new Vec2(reg);
set set
{ {
fixed (Vector3* vptr = &v) { fixed (Vector3* vptr = &v) {
@@ -132,7 +133,7 @@ namespace StgSharp.Mathematics
public bool Equals(Vec3 other) public bool Equals(Vec3 other)
{ {
return this.reg == other.reg; return reg == other.reg;
} }
public override bool Equals(object obj) public override bool Equals(object obj)
@@ -171,8 +172,8 @@ namespace StgSharp.Mathematics
public float GetMaxValue() public float GetMaxValue()
{ {
float ret = X; float ret = X;
ret = (ret > Y) ? ret : Y; ret = ret > Y ? ret : Y;
ret = (ret > Z) ? ret : Z; ret = ret > Z ? ret : Z;
return ret; return ret;
} }
@@ -30,18 +30,17 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.HighPerformance; using StgSharp.HighPerformance;
using StgSharp.Internal.Intrinsic; using StgSharp.Internal.Intrinsic;
using StgSharp.Mathematics; using StgSharp.Mathematics.Numeric;
using System; using System;
using System.Data.Common; using System.Data.Common;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Graphic
{ {
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)] [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
public struct Vec4 : IEquatable<Vec4>, IFixedVector<Vec4> public struct Vec4 : IEquatable<Vec4>, IUnmanagedVector<Vec4>
{ {
[FieldOffset(0)] internal unsafe fixed float num[4]; [FieldOffset(0)] internal unsafe fixed float num[4];
@@ -131,7 +130,7 @@ namespace StgSharp.Mathematics
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return (obj is Vec4 v) ? (v == this) : false; return obj is Vec4 v ? v == this : false;
} }
public override int GetHashCode() public override int GetHashCode()
@@ -0,0 +1,52 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Vector.Cross.cs"
// Project: World
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics.Graphic;
namespace StgSharp.Mathematics.Graphic
{
public static unsafe partial class Linear
{
public static float Cross(Vec2 vec1, Vec2 vec2)
{
return (vec1.X * vec2.Y) - (vec1.Y * vec2.X);
}
public static Vec3 Cross(Vec3 vec1, Vec3 vec2)
{
return new Vec3(
(vec1.Y * vec2.Z) - (vec1.Z * vec2.Y),
(vec1.X * vec2.Z) - (vec1.Z * vec2.X),
(vec1.X * vec2.Y) - (vec1.Y * vec2.X));
}
}
}
@@ -1,6 +1,6 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Vec4HP.cs" // file="Vector.GetAngle.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
@@ -28,43 +28,23 @@
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.HighPerformance; using StgSharp.Mathematics.Graphic;
using System; namespace StgSharp.Mathematics.Graphic
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Mathematics.HighPrecision
{ {
[StructLayout(LayoutKind.Explicit, Pack =16)] public static unsafe partial class Linear
public struct Vec4HP : IFixedVector<Vec4HP>
{ {
[FieldOffset(0)] private M256 buffer; public static float GetAngle(Vec2 vec1, Vec2 vec2)
[FieldOffset(0)] private Vector256<float> clrBuffer;
[FieldOffset(3 * sizeof(double))] public double W;
[FieldOffset(0 * sizeof(double))] public double X;
[FieldOffset(1 * sizeof(double))] public double Y;
[FieldOffset(2 * sizeof(double))] public double Z;
public Vec4HP(double x, double y, double z, double w)
{ {
this.X = x; return Scaler.ACos(
this.Y = y; 1 / (vec1.GetLength() * vec2.GetLength()));
this.Z = z;
this.W = w;
Unsafe.SkipInit(out buffer);
Unsafe.SkipInit(out clrBuffer);
} }
public static Vec4HP Zero => new Vec4HP(0, 0, 0, 0); public static float GetAngle(Vec3 vec1, Vec3 vec2)
{
public static Vec4HP One => new Vec4HP(1, 1, 1, 1); return Scaler.ACos((vec1 * vec2) / (vec1.GetLength() * vec2.GetLength()));
}
} }
} }
@@ -0,0 +1,49 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Vector.GetLength.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics.Graphic;
namespace StgSharp.Mathematics.Graphic
{
public static unsafe partial class Linear
{
public static float GetLength(this Vec3 vec)
{
return Scaler.Sqrt(vec.Dot(vec));
}
public static float GetLength(this Vec2 vec)
{
return Scaler.Sqrt(vec.Dot(vec));
}
}
}
@@ -1,6 +1,6 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Vec3HP.cs" // file="Vector.Normalize.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
@@ -28,58 +28,57 @@
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.HighPerformance; using StgSharp.Mathematics.Graphic;
using System.Numerics;
using System; namespace StgSharp.Mathematics.Graphic
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Mathematics.HighPrecision
{ {
[StructLayout(LayoutKind.Explicit, Pack = 16)] public static partial class Linear
public struct Vec3HP : IFixedVector<Vec3HP>
{ {
[FieldOffset(0)] internal M256 buffer; public static Vec4 Normalize(Vec4 vec)
[FieldOffset(0)] internal Vector256<float> clrBuffer;
[FieldOffset(0 * sizeof(double))] public double X;
[FieldOffset(1 * sizeof(double))] public double Y;
[FieldOffset(2 * sizeof(double))] public double Z;
public Vec3HP() : this(0, 0, 0) { }
public Vec3HP(Vector256<float> clrBuffer)
{ {
this.X = 0; return new Vec4
this.Y = 0; {
this.Z = 0; vec = Vector4.Normalize(vec.vec)
Unsafe.SkipInit(out buffer); };
Unsafe.SkipInit(out this.clrBuffer);
this.clrBuffer = clrBuffer;
} }
public Vec3HP(double x, double y, double z) public static Vec3 Normalize(Vec3 vec)
{ {
this.X = x; return new Vec3
this.Y = y; {
this.Z = z; v = Vector3.Normalize(vec.v)
Unsafe.SkipInit(out buffer); };
Unsafe.SkipInit(out clrBuffer);
} }
public static Vec3HP Zero => new Vec3HP(1, 1, 1); public static unsafe void Normalize(ref Vec4 source, ref Vec4 target)
public static Vec3HP One => throw new NotImplementedException();
public override string ToString()
{ {
return $"Double precision 3D Vector<{X},{Y},{Z}>"; Vector4 s = source.vec;
Vector4 t = target.vec;
s = Vector4.Normalize(s);
Vector4 projection = Vector4.Multiply(s, t);
t -= projection;
source.vec = s;
target.vec = t;
}
public static unsafe void Normalize(ref Vec3 source, ref Vec3 target)
{
Vector3 s = source.v;
Vector3 t = target.v;
s = Vector3.Normalize(s);
Vector3 projection = Vector3.Dot(t, s) / Vector3.Dot(s, s) * s;
t -= projection;
t = Vector3.Normalize(t);
source.v = s;
target.v = t;
} }
} }
@@ -0,0 +1,95 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Vector.Orthogonalize.cs"
// Project: World
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics.Graphic;
using System.Numerics;
namespace StgSharp.Mathematics.Graphic
{
public static partial class Linear
{
public static Vec4 Orthogonalize(this Vec4 vec)
{
return new Vec4
{
vec = Vector4.Normalize(vec.vec)
};
}
public static Vec3 Orthogonalize(Vec3 vec)
{
return new Vec3
{
v = Vector3.Normalize(vec.v)
};
}
public static unsafe void Orthogonalize(this Vec4 source, ref Vec4 target)
{
Vector4 s = source.vec;
Vector4 t = target.vec;
s = Vector4.Normalize(s);
Vector4 projection = Vector4.Multiply(s, t);
t -= projection;
source.vec = s;
target.vec = t;
}
/// <summary>
/// Orthogonalize two <see cref="Vec3" />s, let their length be 1 and perpendicular to
/// each other.
/// </summary>
/// <param _label="source">
///
/// </param>
/// <param _label="target">
///
/// </param>
public static unsafe void Orthogonalize(this Vec3 source, ref Vec3 target)
{
Vector3 s = source.v;
Vector3 t = target.v;
s = Vector3.Normalize(s);
Vector3 projection = Vector3.Dot(t, s) / Vector3.Dot(s, s) * s;
t -= projection;
t = Vector3.Normalize(t);
source.v = s;
target.v = t;
}
}
}
@@ -28,7 +28,7 @@
// //
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
public enum CoordinatePlain public enum CoordinatePlain
{ {
+26 -26
View File
@@ -1,40 +1,40 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="IMatrix.cs" // file="IMatrix.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // 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, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Graphics; using StgSharp.Graphics;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
public interface IMatrix<TSelf> where TSelf: IMatrix<TSelf> { } public interface IMatrix<TSelf> where TSelf: IMatrix<TSelf> { }
} }
@@ -36,9 +36,9 @@ using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
public interface IFixedVector<TSelf> where TSelf: unmanaged, IFixedVector<TSelf> public interface IUnmanagedVector<TSelf> where TSelf: unmanaged, IUnmanagedVector<TSelf>
{ {
public static abstract TSelf Zero { get; } public static abstract TSelf Zero { get; }
@@ -1,86 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Matrix.Basic.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Mathematics
{
public static class Matrix
{
public static 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> result = GCMatrix<float>.FromDefault(left.ColumnLength, left.RowLength);
unsafe
{
MatrixParallelTaskPackage<float>* handle = MatrixParallelFactory.CreateBaseTask<float>();
handle->Left = left.Buffer;
handle->Right = right.Buffer;
handle->Result = result.Buffer;
handle->ComputeHandle = (IntPtr)InternalIO.Intrinsic.f32_add;
handle->LeftPrimOffset = 0;
handle->RightPrimOffset = 0;
handle->LeftPrimStride = left.KernelColumnLength;
handle->LeftSecOffset = 1;
handle->LeftPrimOffset = 0;
handle->RightPrimOffset = 0;
handle->RightPrimStride = right.KernelColumnLength;
handle->RightSecOffset = 1;
handle->RightPrimOffset = 0;
handle->ResultPrimOffset = 0;
handle->ResultPrimStride = result.KernelColumnLength;
handle->ResultSecOffset = 1;
handle->ResultPrimOffset = 0;
handle->PrimCount = left.KernelRowLength;
handle->SecCount = left.KernelColumnLength;
}
MatrixParallel.LaunchParallel(SleepMode.DeepSleep);
return result;
}
finally
{
MatrixParallel.EndParallel();
}
}
}
}
@@ -39,7 +39,7 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
internal unsafe partial class GCMatrix<T> : Matrix<T> where T: unmanaged, INumber<T> internal unsafe partial class GCMatrix<T> : Matrix<T> where T: unmanaged, INumber<T>
{ {
@@ -40,7 +40,7 @@ using System.Threading.Tasks;
using hlsfAllocator = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator; using hlsfAllocator = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator;
using hlsfHandle = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocationHandle; using hlsfHandle = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocationHandle;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
internal unsafe partial class HlsfMatrix<T> : Matrix<T> where T: unmanaged, INumber<T> internal unsafe partial class HlsfMatrix<T> : Matrix<T> where T: unmanaged, INumber<T>
{ {
+2 -2
View File
@@ -38,7 +38,7 @@ using hlsfAllocator = global::StgSharp.HighPerformance.Memory.HybridLayerSegrega
// using hlsfHandle = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocationHandle; // using hlsfHandle = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocationHandle;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
public abstract unsafe partial class Matrix<T> where T: unmanaged, INumber<T> public abstract unsafe partial class Matrix<T> where T: unmanaged, INumber<T>
{ {
@@ -147,13 +147,13 @@ namespace StgSharp.Mathematics
{ {
private readonly MatrixKernel<T>* _source = source; private readonly MatrixKernel<T>* _source = source;
internal readonly int SecondaryStride = secondaryStride;
internal readonly int PrimOffset = primOffset; internal readonly int PrimOffset = primOffset;
internal readonly int PrimSize = primSize; internal readonly int PrimSize = primSize;
internal readonly int PrimStride = primStride; internal readonly int PrimStride = primStride;
internal readonly int SecondaryOffset = secondaryOffset; internal readonly int SecondaryOffset = secondaryOffset;
internal readonly int SecondarySize = secondarySize; internal readonly int SecondarySize = secondarySize;
internal readonly int SecondaryStride = secondaryStride;
internal readonly MatrixKernel<T>* Source internal readonly MatrixKernel<T>* Source
{ {
@@ -34,7 +34,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
public enum MatrixAllocation public enum MatrixAllocation
{ {
@@ -29,14 +29,10 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public readonly struct MatrixIndex public readonly struct MatrixIndex
@@ -1,50 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Vector.Cross.cs"
// Project: World
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
namespace StgSharp.Mathematics
{
public static unsafe partial class Linear
{
public static float Cross( Vec2 vec1, Vec2 vec2 )
{
return ( vec1.X * vec2.Y ) - ( vec1.Y * vec2.X );
}
public static Vec3 Cross( Vec3 vec1, Vec3 vec2 )
{
return new Vec3(
( vec1.Y * vec2.Z ) - ( vec1.Z * vec2.Y ),
( vec1.X * vec2.Z ) - ( vec1.Z * vec2.X ),
( vec1.X * vec2.Y ) - ( vec1.Y * vec2.X ) );
}
}
}
@@ -1,50 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Vector.GetAngle.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
namespace StgSharp.Mathematics
{
public static unsafe partial class Linear
{
public static float GetAngle( Vec2 vec1, Vec2 vec2 )
{
return Scaler.ACos(
1
//vec1.multiple(vec2)
/ ( vec1.GetLength() * vec2.GetLength() ) );
}
public static float GetAngle( Vec3 vec1, Vec3 vec2 )
{
return Scaler.ACos( ( vec1 * vec2 ) / ( vec1.GetLength() * vec2.GetLength() ) );
}
}
}
@@ -1,47 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Vector.GetLength.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
namespace StgSharp.Mathematics
{
public static unsafe partial class Linear
{
public static float GetLength( this Vec3 vec )
{
return Scaler.Sqrt( vec.Dot( vec ) );
}
public static float GetLength( this Vec2 vec )
{
return Scaler.Sqrt( vec.Dot( vec ) );
}
}
}
@@ -1,94 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Vector.Normalize.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Internal;
using StgSharp.Mathematics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Mathematics
{
public static partial class Linear
{
public static Vec4 Normalize( Vec4 vec )
{
return new Vec4
{
vec = Vector4.Normalize( vec.vec )
};
}
public static Vec3 Normalize( Vec3 vec )
{
return new Vec3
{
v = Vector3.Normalize( vec.v )
};
}
public static unsafe void Normalize( ref Vec4 source, ref Vec4 target )
{
Vector4 s = source.vec;
Vector4 t = target.vec;
s = Vector4.Normalize( s );
float dotProduct = Vector4.Dot( s, t );
Vector4 projection = Vector4.Multiply( s, t );
t -= projection;
source.vec = s;
target.vec = t;
}
public static unsafe void Normalize( ref Vec3 source, ref Vec3 target )
{
Vector3 s = source.v;
Vector3 t = target.v;
s = Vector3.Normalize( s );
Vector3 projection = ( Vector3.Dot( t, s ) / Vector3.Dot( s, s ) ) * s;
t -= projection;
t = Vector3.Normalize( t );
source.v = s;
target.v = t;
}
}
}
@@ -1,104 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Vector.Orthogonalize.cs"
// Project: World
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Internal.Intrinsic;
using StgSharp.Mathematics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Mathematics
{
public static partial class Linear
{
public static Vec4 Orthogonalize( Vec4 vec )
{
return new Vec4
{
vec = Vector4.Normalize( vec.vec )
};
}
public static Vec3 Orthogonalize( Vec3 vec )
{
return new Vec3
{
v = Vector3.Normalize( vec.v )
};
}
public static unsafe void Orthogonalize( ref Vec4 source, ref Vec4 target )
{
Vector4 s = source.vec;
Vector4 t = target.vec;
s = Vector4.Normalize( s );
float dotProduct = Vector4.Dot( s, t );
Vector4 projection = Vector4.Multiply( s, t );
t -= projection;
source.vec = s;
target.vec = t;
}
/// <summary>
/// Orthogonalize two <see cref="Vec3" />s, let their length be 1 and perpendicular to
/// each other.
/// </summary>
/// <param _label="source">
///
/// </param>
/// <param _label="target">
///
/// </param>
public static unsafe void Orthogonalize( ref Vec3 source, ref Vec3 target )
{
Vector3 s = source.v;
Vector3 t = target.v;
s = Vector3.Normalize( s );
Vector3 projection = ( Vector3.Dot( t, s ) / Vector3.Dot( s, s ) ) * s;
t -= projection;
t = Vector3.Normalize( t );
source.v = s;
target.v = t;
}
}
}
+27 -27
View File
@@ -1,33 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ASin.cs" // file="ASin.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // 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, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using System; using System;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics
@@ -52,9 +52,9 @@ namespace StgSharp.Mathematics
/// <exception cref="ArgumentException"> /// <exception cref="ArgumentException">
/// ///
/// </exception> /// </exception>
public static float ASin( float x ) public static float ASin(float x)
{ {
return MathF.Asin( x ); return MathF.Asin(x);
/* /*
int sign = 1; int sign = 1;
float y; float y;
+28 -28
View File
@@ -1,33 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Cos.cs" // file="Cos.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // 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, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@@ -36,8 +36,8 @@ namespace StgSharp.Mathematics
public static partial class Scaler public static partial class Scaler
{ {
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Cos( float x ) public static float Cos(float x)
{ {
/* /*
float refer = x / 360.0f; float refer = x / 360.0f;
@@ -53,7 +53,7 @@ namespace StgSharp.Mathematics
return ((-sinData[a]) * ((0.1570796327f * refer) - (6.459640975e-4f * refer * refer2))) return ((-sinData[a]) * ((0.1570796327f * refer) - (6.459640975e-4f * refer * refer2)))
+ (cosData[a] * ((1 - (0.0123370055f * refer2)) + (2.536695709e-5f * refer2 * refer2))); + (cosData[a] * ((1 - (0.0123370055f * refer2)) + (2.536695709e-5f * refer2 * refer2)));
*/ */
return MathF.Cos( x ); return MathF.Cos(x);
} }
} }
+33 -32
View File
@@ -1,43 +1,44 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="PlainGeometryCollisionSensor.cs" // file="PlainGeometryCollisionSensor.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // 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, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Geometries; using StgSharp.Geometries;
using System; using System;
using System.Runtime.CompilerServices;
namespace StgSharp namespace StgSharp
{ {
public class CollisionEventArgs : EventArgs public class CollisionEventArgs : EventArgs
{ {
public CollisionEventArgs( IGeometry target, IGeometry boarder ) public CollisionEventArgs(IGeometry target, IGeometry boarder)
{ {
Target = target; Target = target;
Boarder = boarder; Boarder = boarder;
@@ -49,8 +50,7 @@ namespace StgSharp
} }
public class PlainGeometryCollisionSensor<TBoarder, TTarget> where TBoarder: IGeometry public class PlainGeometryCollisionSensor<TBoarder, TTarget> where TBoarder: IGeometry where TTarget: IGeometry
where TTarget: IGeometry
{ {
internal EventHandler<CollisionEventArgs> _rule; internal EventHandler<CollisionEventArgs> _rule;
@@ -59,15 +59,16 @@ namespace StgSharp
public event EventHandler<CollisionEventArgs> Rule public event EventHandler<CollisionEventArgs> Rule
{ {
add { _rule += value; } [MethodImpl(MethodImplOptions.AggressiveInlining)]
add => _rule += value;
remove remove
{ {
if( value == null ) { if (value == null) {
return; return;
} }
#pragma warning disable CS8601 #pragma warning disable CS8601
_rule -= value; _rule -= value;
#pragma warning restore CS8601 #pragma warning restore CS8601
} }
} }
@@ -1,6 +1,6 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Vec2HP.cs" // file="Matrix.Basic.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
@@ -28,40 +28,33 @@
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.HighPerformance;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Security.AccessControl;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace StgSharp.Mathematics.HighPrecision namespace StgSharp.Mathematics.Numeric
{ {
[StructLayout(LayoutKind.Explicit, Pack = 16)] public static class MatrixCompute
public struct Vec2HP : IFixedVector<Vec2HP>
{ {
[FieldOffset(0)] private M256 buffer; public static Matrix<float> Add(Matrix<float> left, Matrix<float> right)
[FieldOffset(0)] private Vector256<float> clrBuffer;
[FieldOffset(0 * sizeof(double))] public double X;
[FieldOffset(1 * sizeof(double))] public double Y;
public Vec2HP(double x, double y)
{ {
this.X = x; if (left.ColumnLength != right.ColumnLength || left.RowLength != right.RowLength) {
this.Y = y; throw new IndexOutOfRangeException("Matrix dimensions must agree.");
Unsafe.SkipInit(out buffer); }
Unsafe.SkipInit(out clrBuffer); MatrixParallel.LeadParallel();
try
{
throw new NotImplementedException();
}
finally
{
MatrixParallel.EndParallel();
}
} }
public static Vec2HP Zero => new Vec2HP(0, 0);
public static Vec2HP One => new Vec2HP(1, 1);
} }
} }
@@ -31,7 +31,7 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
public static partial class MatrixParallel public static partial class MatrixParallel
{ {
@@ -37,7 +37,7 @@ using System.Numerics;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
public static partial class MatrixParallel public static partial class MatrixParallel
{ {
@@ -819,8 +819,14 @@ namespace StgSharp.Mathematics
{ {
int primCount = package->PrimCount; int primCount = package->PrimCount;
int secCount = package->SecCount; int secCount = package->SecCount;
int threadPerGroup = (1024 / primCount) + 1; int tileWidth = (1024 / secCount) + 1;
secCount /= threadPerGroup; int tileCount = (primCount / tileWidth) + 1;
int tilePerThreadLess = tileCount / Wraps.Length;
int tileToSlice = tileCount % Wraps.Length;
// TODO 这个方法依然是独占,需要一个新的缓存类型用来辅助复用空线程束
for (int i = 0; i < Wraps.Length; i++) { }
} }
} }
@@ -35,7 +35,7 @@ using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
public unsafe struct ScalarPacket public unsafe struct ScalarPacket
{ {
@@ -41,7 +41,7 @@ using System.Threading.Tasks;
using hlsfAllocator = StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator; using hlsfAllocator = StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
internal static unsafe class MatrixParallelFactory internal static unsafe class MatrixParallelFactory
{ {
@@ -34,7 +34,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading; using System.Threading;
namespace StgSharp.Mathematics namespace StgSharp.Mathematics.Numeric
{ {
/* /*
* Thread wrapping to accelerate matrix operations by dividing threads into groups (wraps). * Thread wrapping to accelerate matrix operations by dividing threads into groups (wraps).
@@ -56,18 +56,6 @@ namespace StgSharp.Mathematics
public static partial class MatrixParallel public static partial class MatrixParallel
{ {
// TODO
/*
* 目前认为应当按照如下方式进行调整:
* 1. 使用Queue进行线程束池化
* 2. 一次只能有一个线程进行发布活动(一次只能由一个线程持有)
* 3. 发布任务似乎应当分类进行,分类条件为q = n_task / n_thread
* 3.1 q=0时,不是全部任务束可以参与计算
* 3.2 q>0时,全部任务束可以参与计算
* 4. 后续分为a个q线程,b个q+1线程,然后分到线程束中,同时不保证束内任务同步
* 5. 仅可能保证线程间任务数量差异不超过512
*/
private static Thread[] _threads; private static Thread[] _threads;
private static readonly (int a, int b)[] LookupTable = [ private static readonly (int a, int b)[] LookupTable = [
(1, 1), // 7 (1, 1), // 7
@@ -140,47 +128,46 @@ namespace StgSharp.Mathematics
{ {
if (count == 3) if (count == 3)
{ {
SmallWraps = [ new MatrixParallelWrap(0, count, true) ]; Wraps = [ new MatrixParallelWrap(0, count, true) ];
LargeWraps = [];
(LargeWrapCount, SmallWrapCount) = (0, 1); (LargeWrapCount, SmallWrapCount) = (0, 1);
LeaderHandle = new MatrixParallelWrap.Handle(0, SmallWraps[0]); LeaderHandle = new MatrixParallelWrap.Handle(0, Wraps[0]);
} else } else
{ {
count = 4; count = 4;
LargeWraps = [ new MatrixParallelWrap(0, count, true) ]; Wraps = [ new MatrixParallelWrap(0, count, true) ];
SmallWraps = [];
(LargeWrapCount, SmallWrapCount) = (1, 0); (LargeWrapCount, SmallWrapCount) = (1, 0);
LeaderHandle = new MatrixParallelWrap.Handle(0, LargeWraps[0]); LeaderHandle = new MatrixParallelWrap.Handle(0, Wraps[0]);
} }
} else if (count == 6) } else if (count == 6)
{ {
SmallWraps = [ new MatrixParallelWrap(0, 3, true), new MatrixParallelWrap(3, 3, false) ]; Wraps = [
LargeWraps = []; new MatrixParallelWrap(0, 3, true),
new MatrixParallelWrap(3, 3, false)
];
(LargeWrapCount, SmallWrapCount) = (0, 2); (LargeWrapCount, SmallWrapCount) = (0, 2);
LeaderHandle = new MatrixParallelWrap.Handle(0, SmallWraps[0]); LeaderHandle = new MatrixParallelWrap.Handle(0, Wraps[0]);
} else } else
{ {
(int _3wrap, int _4wrap) = FastDecompose(count); (int _3wrap, int _4wrap) = FastDecompose(count);
LargeWraps = new MatrixParallelWrap[_4wrap]; Wraps = new MatrixParallelWrap[_4wrap + _3wrap];
SmallWraps = new MatrixParallelWrap[_3wrap]; int id = 0,idx = 0;
int id = 0; for (; idx < _3wrap; idx++, id += 3) {
for (int idx = 0; idx < _3wrap; idx++, id += 3) { Wraps[idx] = new MatrixParallelWrap(idx, 3, id == 0);
SmallWraps[idx] = new MatrixParallelWrap(idx, 3, id == 0);
} }
for (int idx = 0; idx < _3wrap + _4wrap; idx++, id += 4) { for (; idx < _3wrap + _4wrap; idx++, id += 4) {
LargeWraps[idx] = new MatrixParallelWrap(id, 4, id == 0); Wraps[idx] = new MatrixParallelWrap(id, 4, id == 0);
} }
LeaderHandle = new MatrixParallelWrap.Handle(0, _3wrap == 0 ? LargeWraps[0] : SmallWraps[0]); LeaderHandle = new MatrixParallelWrap.Handle(0, Wraps[0]);
} }
LeaderTask = LeaderHandle.Wrap.GetWorkerTaskQueue(0); LeaderTask = LeaderHandle.Wrap.GetWorkerTaskQueue(0);
IsInitialized = true; IsInitialized = true;
} }
public static void LaunchParallel(SleepMode afterWork) public static void LaunchParallel(IEnumerable<MatrixParallelWrap> wraps, SleepMode afterWork)
{ {
RemainThreadCount = _threads.Length; RemainThreadCount = _threads.Length;
_AfterWork = (ThreadPriority)afterWork; _AfterWork = (ThreadPriority)afterWork;
SetAllWrap(); SetAllWrap(wraps);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -202,13 +189,10 @@ namespace StgSharp.Mathematics
RemainThreadCount = _threads.Length; RemainThreadCount = _threads.Length;
} }
public static void SetAllWrap() public static void SetAllWrap(IEnumerable<MatrixParallelWrap> wraps)
{ {
ResetThreadCount(); ResetThreadCount();
foreach (MatrixParallelWrap item in LargeWraps) { foreach (MatrixParallelWrap item in wraps) {
item.SchedulerReset.Set();
}
foreach (MatrixParallelWrap item in SmallWraps) {
item.SchedulerReset.Set(); item.SchedulerReset.Set();
} }
} }
@@ -360,8 +344,7 @@ namespace StgSharp.Mathematics
#region wrap field #region wrap field
private static MatrixParallelWrap[] LargeWraps; private static MatrixParallelWrap[] Wraps;
private static MatrixParallelWrap[] SmallWraps;
private static int LargeWrapCount; private static int LargeWrapCount;
private static int SmallWrapCount; private static int SmallWrapCount;
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>Preview</LangVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\StgSharp.Common\StgSharp.Common.csproj" />
</ItemGroup>
</Project>
+40
View File
@@ -28,61 +28,101 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StgSharp.Script", "StgSharp
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StgSharp.Model", "StgSharp.Model\StgSharp.Model.csproj", "{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StgSharp.Model", "StgSharp.Model\StgSharp.Model.csproj", "{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StgSharp.Mathematics", "StgSharp.Mathematics\StgSharp.Mathematics.csproj", "{9946599F-4D34-440F-840D-F9443D5AEFAA}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64 Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|ARM64 = Release|ARM64 Release|ARM64 = Release|ARM64
Release|x64 = Release|x64 Release|x64 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Debug|Any CPU.ActiveCfg = Debug|x64
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Debug|Any CPU.Build.0 = Debug|x64
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Debug|ARM64.ActiveCfg = Debug|ARM64 {3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Debug|ARM64.ActiveCfg = Debug|ARM64
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Debug|ARM64.Build.0 = Debug|ARM64 {3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Debug|ARM64.Build.0 = Debug|ARM64
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Debug|x64.ActiveCfg = Debug|x64 {3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Debug|x64.ActiveCfg = Debug|x64
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Debug|x64.Build.0 = Debug|x64 {3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Debug|x64.Build.0 = Debug|x64
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Release|Any CPU.ActiveCfg = Release|x64
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Release|Any CPU.Build.0 = Release|x64
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Release|ARM64.ActiveCfg = Release|ARM64 {3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Release|ARM64.ActiveCfg = Release|ARM64
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Release|ARM64.Build.0 = Release|ARM64 {3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Release|ARM64.Build.0 = Release|ARM64
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Release|x64.ActiveCfg = Release|x64 {3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Release|x64.ActiveCfg = Release|x64
{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Release|x64.Build.0 = Release|x64 {3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}.Release|x64.Build.0 = Release|x64
{610B992B-BB34-49C3-9993-676C595FC12E}.Debug|Any CPU.ActiveCfg = Debug|x64
{610B992B-BB34-49C3-9993-676C595FC12E}.Debug|Any CPU.Build.0 = Debug|x64
{610B992B-BB34-49C3-9993-676C595FC12E}.Debug|ARM64.ActiveCfg = Debug|ARM64 {610B992B-BB34-49C3-9993-676C595FC12E}.Debug|ARM64.ActiveCfg = Debug|ARM64
{610B992B-BB34-49C3-9993-676C595FC12E}.Debug|ARM64.Build.0 = Debug|ARM64 {610B992B-BB34-49C3-9993-676C595FC12E}.Debug|ARM64.Build.0 = Debug|ARM64
{610B992B-BB34-49C3-9993-676C595FC12E}.Debug|x64.ActiveCfg = Debug|x64 {610B992B-BB34-49C3-9993-676C595FC12E}.Debug|x64.ActiveCfg = Debug|x64
{610B992B-BB34-49C3-9993-676C595FC12E}.Debug|x64.Build.0 = Debug|x64 {610B992B-BB34-49C3-9993-676C595FC12E}.Debug|x64.Build.0 = Debug|x64
{610B992B-BB34-49C3-9993-676C595FC12E}.Release|Any CPU.ActiveCfg = Release|x64
{610B992B-BB34-49C3-9993-676C595FC12E}.Release|Any CPU.Build.0 = Release|x64
{610B992B-BB34-49C3-9993-676C595FC12E}.Release|ARM64.ActiveCfg = Release|ARM64 {610B992B-BB34-49C3-9993-676C595FC12E}.Release|ARM64.ActiveCfg = Release|ARM64
{610B992B-BB34-49C3-9993-676C595FC12E}.Release|ARM64.Build.0 = Release|ARM64 {610B992B-BB34-49C3-9993-676C595FC12E}.Release|ARM64.Build.0 = Release|ARM64
{610B992B-BB34-49C3-9993-676C595FC12E}.Release|x64.ActiveCfg = Release|x64 {610B992B-BB34-49C3-9993-676C595FC12E}.Release|x64.ActiveCfg = Release|x64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Debug|Any CPU.ActiveCfg = Debug|x64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Debug|Any CPU.Build.0 = Debug|x64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Debug|ARM64.ActiveCfg = Debug|ARM64 {20CBFF26-6746-402E-992C-7B643E9423EB}.Debug|ARM64.ActiveCfg = Debug|ARM64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Debug|ARM64.Build.0 = Debug|ARM64 {20CBFF26-6746-402E-992C-7B643E9423EB}.Debug|ARM64.Build.0 = Debug|ARM64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Debug|x64.ActiveCfg = Release|x64 {20CBFF26-6746-402E-992C-7B643E9423EB}.Debug|x64.ActiveCfg = Release|x64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Debug|x64.Build.0 = Release|x64 {20CBFF26-6746-402E-992C-7B643E9423EB}.Debug|x64.Build.0 = Release|x64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Release|Any CPU.ActiveCfg = Release|x64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Release|Any CPU.Build.0 = Release|x64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Release|ARM64.ActiveCfg = Release|ARM64 {20CBFF26-6746-402E-992C-7B643E9423EB}.Release|ARM64.ActiveCfg = Release|ARM64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Release|ARM64.Build.0 = Release|ARM64 {20CBFF26-6746-402E-992C-7B643E9423EB}.Release|ARM64.Build.0 = Release|ARM64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Release|x64.ActiveCfg = Release|x64 {20CBFF26-6746-402E-992C-7B643E9423EB}.Release|x64.ActiveCfg = Release|x64
{20CBFF26-6746-402E-992C-7B643E9423EB}.Release|x64.Build.0 = Release|x64 {20CBFF26-6746-402E-992C-7B643E9423EB}.Release|x64.Build.0 = Release|x64
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Debug|ARM64.ActiveCfg = Debug|ARM64 {10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Debug|ARM64.ActiveCfg = Debug|ARM64
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Debug|ARM64.Build.0 = Debug|ARM64 {10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Debug|ARM64.Build.0 = Debug|ARM64
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Debug|x64.ActiveCfg = Debug|x64 {10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Debug|x64.ActiveCfg = Debug|x64
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Debug|x64.Build.0 = Debug|x64 {10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Debug|x64.Build.0 = Debug|x64
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Release|Any CPU.Build.0 = Release|Any CPU
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Release|ARM64.ActiveCfg = Release|ARM64 {10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Release|ARM64.ActiveCfg = Release|ARM64
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Release|ARM64.Build.0 = Release|ARM64 {10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Release|ARM64.Build.0 = Release|ARM64
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Release|x64.ActiveCfg = Release|x64 {10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Release|x64.ActiveCfg = Release|x64
{10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Release|x64.Build.0 = Release|x64 {10B5819F-2A62-41B6-980A-EB9E76A0E95C}.Release|x64.Build.0 = Release|x64
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Debug|ARM64.ActiveCfg = Debug|ARM64 {5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Debug|ARM64.ActiveCfg = Debug|ARM64
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Debug|ARM64.Build.0 = Debug|ARM64 {5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Debug|ARM64.Build.0 = Debug|ARM64
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Debug|x64.ActiveCfg = Debug|x64 {5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Debug|x64.ActiveCfg = Debug|x64
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Debug|x64.Build.0 = Debug|x64 {5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Debug|x64.Build.0 = Debug|x64
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Release|Any CPU.Build.0 = Release|Any CPU
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Release|ARM64.ActiveCfg = Release|ARM64 {5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Release|ARM64.ActiveCfg = Release|ARM64
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Release|ARM64.Build.0 = Release|ARM64 {5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Release|ARM64.Build.0 = Release|ARM64
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Release|x64.ActiveCfg = Release|x64 {5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Release|x64.ActiveCfg = Release|x64
{5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Release|x64.Build.0 = Release|x64 {5B51F5EA-138C-46B5-B36F-1D389968B6CF}.Release|x64.Build.0 = Release|x64
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Debug|ARM64.ActiveCfg = Debug|ARM64 {D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Debug|ARM64.ActiveCfg = Debug|ARM64
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Debug|ARM64.Build.0 = Debug|ARM64 {D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Debug|ARM64.Build.0 = Debug|ARM64
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Debug|x64.ActiveCfg = Debug|x64 {D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Debug|x64.ActiveCfg = Debug|x64
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Debug|x64.Build.0 = Debug|x64 {D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Debug|x64.Build.0 = Debug|x64
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Release|Any CPU.Build.0 = Release|Any CPU
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Release|ARM64.ActiveCfg = Release|ARM64 {D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Release|ARM64.ActiveCfg = Release|ARM64
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Release|ARM64.Build.0 = Release|ARM64 {D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Release|ARM64.Build.0 = Release|ARM64
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Release|x64.ActiveCfg = Release|x64 {D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Release|x64.ActiveCfg = Release|x64
{D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Release|x64.Build.0 = Release|x64 {D9538DE0-EE4C-4183-86D6-7DFC08A7BDFB}.Release|x64.Build.0 = Release|x64
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Debug|ARM64.Build.0 = Debug|Any CPU
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Debug|x64.ActiveCfg = Debug|Any CPU
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Debug|x64.Build.0 = Debug|Any CPU
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|Any CPU.Build.0 = Release|Any CPU
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|ARM64.ActiveCfg = Release|Any CPU
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|ARM64.Build.0 = Release|Any CPU
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|x64.ActiveCfg = Release|Any CPU
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE