daily update on 20230829 by nitload youmu
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -28,10 +28,10 @@ namespace StgSharp
|
||||
|
||||
}
|
||||
|
||||
internal static void InitM128map(Pool target)
|
||||
internal static void InitVector4map(Pool target)
|
||||
{
|
||||
M128Map map = new M128Map();
|
||||
TimeLine.GetCurrentPool()._m128mapContainer.Add(map);
|
||||
Vector4Map map = new Vector4Map();
|
||||
TimeLine.GetCurrentPool()._Vector4mapContainer.Add(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,31 +18,31 @@ namespace StgSharp
|
||||
/**/
|
||||
}
|
||||
|
||||
internal static M128Map GetAvailabem128map()
|
||||
internal static Vector4Map GetAvailabeVector4map()
|
||||
{
|
||||
Pool p = TimeLine.GetCurrentPool();
|
||||
M128Map lastMap = p._m128mapContainer.Tail;
|
||||
Vector4Map lastMap = p._Vector4mapContainer.Tail;
|
||||
|
||||
if (lastMap.isFull)
|
||||
{
|
||||
lastMap = new M128Map();
|
||||
p._m128mapContainer.Add(lastMap);
|
||||
lastMap = new Vector4Map();
|
||||
p._Vector4mapContainer.Add(lastMap);
|
||||
}
|
||||
|
||||
return lastMap;
|
||||
}
|
||||
|
||||
internal static long GetAvailableM128ptr()
|
||||
internal static long GetAvailableVector4ptr()
|
||||
{
|
||||
Pool p = TimeLine.GetCurrentPool();
|
||||
M128Map lastMap = p._m128mapContainer.Tail;
|
||||
Vector4Map lastMap = p._Vector4mapContainer.Tail;
|
||||
|
||||
if (lastMap.isFull)
|
||||
{
|
||||
lastMap = new M128Map();
|
||||
p._m128mapContainer.Add(lastMap);
|
||||
lastMap = new Vector4Map();
|
||||
p._Vector4mapContainer.Add(lastMap);
|
||||
}
|
||||
long ptr = lastMap.RegistManagedM128Ptr();
|
||||
long ptr = lastMap.RegistManagedVector4Ptr();
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@ namespace StgSharp
|
||||
{
|
||||
internal static partial class internalIO
|
||||
{
|
||||
[DllImport("StgSharpGraphic.dll",EntryPoint = "loadGLApi",
|
||||
[DllImport("StgSharpGraphic",EntryPoint = "loadGLApi",
|
||||
CallingConvention = CallingConvention.Cdecl,CharSet =CharSet.Ansi)]
|
||||
internal static extern GraphicIOPack InternalInitGraphicApi();
|
||||
|
||||
[DllImport("StgSharpGraphic.dll",EntryPoint = "initGL",
|
||||
[DllImport("StgSharpGraphic",EntryPoint = "initGL",
|
||||
CallingConvention = CallingConvention.Cdecl,CharSet = CharSet.Ansi)]
|
||||
internal static extern unsafe void InternalInitGL();
|
||||
|
||||
[DllImport("StgSharpGraphic.dll",EntryPoint = "initGLAD",
|
||||
[DllImport("StgSharpGraphic",EntryPoint = "initGLAD",
|
||||
CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
internal static extern unsafe int InternalInitGLAD();
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
@@ -9,7 +10,7 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
public int width;
|
||||
public int height;
|
||||
public M128 color;
|
||||
public Vector4 color;
|
||||
public byte[] name;
|
||||
}
|
||||
|
||||
@@ -44,7 +45,7 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
|
||||
/*
|
||||
public M128 Color
|
||||
public Vector4 Color
|
||||
{
|
||||
get => info.color;
|
||||
set => info.color = value;
|
||||
|
||||
@@ -103,5 +103,11 @@ namespace StgSharp
|
||||
counter.QuickSub();
|
||||
return counter;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Value.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace StgSharp
|
||||
{
|
||||
public class Pool
|
||||
{
|
||||
internal LinkedList<M128Map> _m128mapContainer;
|
||||
internal LinkedList<Vector4Map> _Vector4mapContainer;
|
||||
internal LinkedList<IPlainGeometry> _geometryContainer;
|
||||
internal LinkedList<IEntity> _bulletContainer;
|
||||
internal LinkedList<IEntity> _awardContainer;
|
||||
@@ -29,7 +29,7 @@ namespace StgSharp
|
||||
|
||||
private void initContainers()
|
||||
{
|
||||
_m128mapContainer = new LinkedList<M128Map>();
|
||||
_Vector4mapContainer = new LinkedList<Vector4Map>();
|
||||
_bulletContainer = new LinkedList<IEntity>();
|
||||
_awardContainer = new LinkedList<IEntity>();
|
||||
_enemyContainer = new LinkedList<IEntity>();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -14,21 +15,21 @@ namespace StgSharp
|
||||
|
||||
#region load
|
||||
|
||||
[DllImport(dllName: "StgSharpGraphic.dll", EntryPoint = "load",
|
||||
[DllImport(dllName: "StgSharpGraphic", EntryPoint = "load",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern ref M128 load_internal(float x,float y, float z, float w);
|
||||
internal static extern ref Vector4 load_internal(float x,float y, float z, float w);
|
||||
|
||||
[DllImport(dllName: "StgSharpGraphic.dll", EntryPoint = "load",
|
||||
[DllImport(dllName: "StgSharpGraphic", EntryPoint = "load",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static unsafe extern M128* loadptr_internal(float x, float y, float z, float w);
|
||||
internal static unsafe extern Vector4* loadptr_internal(float x, float y, float z, float w);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll",EntryPoint = "load_matmap",
|
||||
[DllImport("StgSharpGraphic",EntryPoint = "load_matmap",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern IntPtr load_mat(IntPtr c0, IntPtr c1, IntPtr c2, IntPtr c3);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "load_cpy",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "load_cpy",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern IntPtr load_cpy_internal(IntPtr ptr);
|
||||
|
||||
@@ -37,11 +38,11 @@ namespace StgSharp
|
||||
|
||||
#region add sub
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "addps",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "addps",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern IntPtr addps_internal(IntPtr ptr1, IntPtr ptr2);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "subps",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "subps",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern IntPtr subps_internal(IntPtr ptr1, IntPtr ptr2);
|
||||
|
||||
@@ -49,63 +50,67 @@ namespace StgSharp
|
||||
|
||||
#region mulps
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "mulps",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "mulps",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern IntPtr mulps_internal(IntPtr ptr1, IntPtr ptr2);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "mulps_const",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "mulps_const",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern IntPtr mulps_const_internal(IntPtr ptr, float value);
|
||||
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "mulps_sum",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "mulps_sum",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern float mulps_sum_internal(IntPtr ptr1, IntPtr ptr2);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "mulps_sum",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "mulps_sum",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe float mulps_sum_internal(M128* ptr1, M128* ptr2);
|
||||
internal static extern unsafe float mulps_sum_internal(Vector4* ptr1, Vector4* ptr2);
|
||||
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "mulps_sum",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe float mulps_sum_internal(Vec4d* ptr1, Vec4d* ptr2);
|
||||
|
||||
#endregion
|
||||
|
||||
#region div
|
||||
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "mulps",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "mulps",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern IntPtr divps_internal(IntPtr ptr1, IntPtr ptr2);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "divps_const",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "divps_const",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern IntPtr divps_const_internal(IntPtr ptr, float value);
|
||||
|
||||
#endregion
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "sqrtss_const",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "sqrtss_const",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern float sqrtss_const_internal(float a);
|
||||
|
||||
|
||||
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "set_m128ptr_default",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "set_Vector4ptr_default",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern IntPtr set_m128ptr_default_internal();
|
||||
internal static extern IntPtr set_Vector4ptr_default_internal();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region deinit m128
|
||||
#region deinit Vector4
|
||||
|
||||
[DllImport(
|
||||
"msvcrt.dll",
|
||||
EntryPoint = "_aligned_free",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe void deinit_internal(M128* ptr);
|
||||
internal static extern unsafe void deinit_internal(Vector4* ptr);
|
||||
|
||||
[DllImport(
|
||||
"msvcrt.dll",
|
||||
@@ -130,23 +135,23 @@ namespace StgSharp
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe void deinit_internal(Mat4* ptr);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "deinitM128",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "deinitVector4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void deinitM128_internal(ref M128 vec);
|
||||
internal static extern void deinitVector4_internal(ref Vector4 vec);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "deinitM128",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "deinitVector4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void deinitM128_internal(M128* vec);
|
||||
internal static extern unsafe void deinitVector4_internal(Vector4* vec);
|
||||
|
||||
#endregion
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "deinit_matmapPtr_sse",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "deinit_matmapPtr_sse",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void deinitMatmapPtr_sse_internal(ref M128matMap mapPtr);
|
||||
internal static extern void deinitMatmapPtr_sse_internal(ref Vector4Map mapPtr);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "deinit_matmap_sse",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "deinit_matmap_sse",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void deinitMatmap_sse_internal(ref M128matMap mapPtr);
|
||||
internal static extern void deinitMatmap_sse_internal(ref Vector4Map mapPtr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +1,63 @@
|
||||
using StgSharp;
|
||||
using StgSharp.Control;
|
||||
using StgSharp.Logic;
|
||||
using System.Data;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public unsafe class M128Map
|
||||
public unsafe class Vector4Map
|
||||
{
|
||||
public readonly long mapID;
|
||||
internal long mapPtr;
|
||||
internal readonly StgSharp.LinkedListNode<long> _unusedM128Header;
|
||||
internal readonly StgSharp.LinkedListNode<long> _unusedVector4Header;
|
||||
private const int mapSize = 30 * 30;
|
||||
|
||||
internal StgSharp.LinkedList<long> m128Map =
|
||||
internal StgSharp.LinkedList<long> vector4Map =
|
||||
new StgSharp.LinkedList<long>();
|
||||
|
||||
public bool isFull
|
||||
{
|
||||
get
|
||||
{
|
||||
return _unusedM128Header == m128Map._hook;
|
||||
return _unusedVector4Header == vector4Map._hook;
|
||||
}
|
||||
}
|
||||
|
||||
public M128Map()
|
||||
public Vector4Map()
|
||||
{
|
||||
mapPtr = (long)(Marshal.AllocHGlobal(sizeof(M128)*mapSize)+15);
|
||||
mapPtr = (long)(Marshal.AllocHGlobal(sizeof(Vector4)*mapSize)+15);
|
||||
|
||||
long firstM128ptr = (mapPtr / 16 + 1) * 16;
|
||||
long firstVector4ptr = (mapPtr / 16 + 1) * 16;
|
||||
|
||||
m128Map.Add(0);
|
||||
_unusedM128Header = m128Map._hook._next;
|
||||
vector4Map.Add(0);
|
||||
_unusedVector4Header = vector4Map._hook._next;
|
||||
|
||||
for (int i = 0; i < 4*30*30*4; i+=16)
|
||||
{
|
||||
m128Map.Add(firstM128ptr+i);
|
||||
vector4Map.Add(firstVector4ptr+i);
|
||||
}
|
||||
|
||||
mapID = Calc.RandomSeed();
|
||||
}
|
||||
|
||||
internal long RegistManagedM128Ptr()
|
||||
internal long RegistManagedVector4Ptr()
|
||||
{
|
||||
LinkedListNode<long> m128 = _unusedM128Header._next;
|
||||
LinkedListNode<long> m128Previous = _unusedM128Header._previous;
|
||||
LinkedListNode<long> Vector4 = _unusedVector4Header._next;
|
||||
LinkedListNode<long> Vector4Previous = _unusedVector4Header._previous;
|
||||
|
||||
m128._next._previous = _unusedM128Header.Next;
|
||||
m128Previous._next = m128;
|
||||
m128._previous = m128Previous;
|
||||
_unusedM128Header._next = m128._next;
|
||||
m128._next = _unusedM128Header;
|
||||
_unusedM128Header._previous = m128;
|
||||
Vector4._next._previous = _unusedVector4Header.Next;
|
||||
Vector4Previous._next = Vector4;
|
||||
Vector4._previous = Vector4Previous;
|
||||
_unusedVector4Header._next = Vector4._next;
|
||||
Vector4._next = _unusedVector4Header;
|
||||
_unusedVector4Header._previous = Vector4;
|
||||
|
||||
return m128._value;
|
||||
return Vector4._value;
|
||||
|
||||
}
|
||||
|
||||
internal void RecycleManagedM128Ptr()
|
||||
internal void RecycleManagedVector4Ptr()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace StgSharp.Math
|
||||
|
||||
public static unsafe partial class SSE
|
||||
{
|
||||
public static int M128Size = 16;
|
||||
public static int Vector4Size = 16;
|
||||
|
||||
internal static IntPtr defaultM128Ptr =
|
||||
internalIO.set_m128ptr_default_internal();
|
||||
internal static IntPtr defaultVector4Ptr =
|
||||
internalIO.set_Vector4ptr_default_internal();
|
||||
|
||||
|
||||
internal static IntPtr defaultM256Ptr;
|
||||
|
||||
@@ -5,63 +5,4 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct M128matMap
|
||||
{
|
||||
internal IntPtr colum0Ptr;
|
||||
internal IntPtr colum1Ptr;
|
||||
internal IntPtr colum2Ptr;
|
||||
internal IntPtr colum3Ptr;
|
||||
|
||||
internal M128matMap(
|
||||
IntPtr c0ptr,
|
||||
IntPtr c1ptr,
|
||||
IntPtr c2ptr,
|
||||
IntPtr c3ptr
|
||||
)
|
||||
{
|
||||
colum0Ptr = c0ptr;
|
||||
colum1Ptr = c1ptr;
|
||||
colum2Ptr = c2ptr;
|
||||
colum3Ptr = c3ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
|
||||
internal struct M128
|
||||
{
|
||||
[FieldOffset(0)] internal float single_0;
|
||||
[FieldOffset(4)] internal float single_1;
|
||||
[FieldOffset(8)] internal float single_2;
|
||||
[FieldOffset(12)] internal float single_3;
|
||||
|
||||
[FieldOffset(0)] internal int int32_0;
|
||||
[FieldOffset(4)] internal int int32_1;
|
||||
[FieldOffset(8)] internal int int32_2;
|
||||
[FieldOffset(12)] internal int int32_3;
|
||||
|
||||
[FieldOffset(0)] internal long int64_0;
|
||||
[FieldOffset(8)] internal long int64_1;
|
||||
|
||||
[FieldOffset(0)] internal IntPtr ptr_0;
|
||||
[FieldOffset(8)] internal IntPtr ptr_1;
|
||||
|
||||
[FieldOffset(0)] internal long double_0;
|
||||
[FieldOffset(8)] internal long double_1;
|
||||
|
||||
internal M128(float x,float y,float z,float w)
|
||||
{
|
||||
single_0 = x;
|
||||
single_1 = y;
|
||||
single_2 = z;
|
||||
single_3 = w;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{single_0}\t{single_1}\t{single_2}\t{single_3}";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,26 +9,26 @@ namespace StgSharp.Math
|
||||
|
||||
public static unsafe float Multiple(Vec3d vec1, Vec3d vec2)
|
||||
{
|
||||
IntPtr retPtr = internalIO.mulps_internal(vec1._m128Ptr,vec2._m128Ptr);
|
||||
IntPtr retPtr = internalIO.mulps_internal(vec1._Vector4Ptr,vec2._Vector4Ptr);
|
||||
|
||||
M128 m128 = *(M128*)retPtr;
|
||||
Vector4 Vector4 = *(Vector4*)retPtr;
|
||||
Marshal.FreeHGlobal(retPtr);
|
||||
return
|
||||
m128.single_0 +
|
||||
m128.single_1 +
|
||||
m128.single_2;
|
||||
Vector4.single_0 +
|
||||
Vector4.single_1 +
|
||||
Vector4.single_2;
|
||||
}
|
||||
|
||||
public static unsafe float Multiple(Vec4d vec1,Vec3d vec2)
|
||||
{
|
||||
IntPtr retPtr = internalIO.mulps_internal(vec1._m128Ptr,vec2._m128Ptr);
|
||||
M128 m128 = *(M128*)retPtr;
|
||||
IntPtr retPtr = internalIO.mulps_internal(vec1._Vector4Ptr,vec2._Vector4Ptr);
|
||||
Vector4 Vector4 = *(Vector4*)retPtr;
|
||||
Marshal.FreeHGlobal(retPtr);
|
||||
return
|
||||
m128.single_0 +
|
||||
m128.single_1 +
|
||||
m128.single_2 +
|
||||
m128.single_3;
|
||||
Vector4.single_0 +
|
||||
Vector4.single_1 +
|
||||
Vector4.single_2 +
|
||||
Vector4.single_3;
|
||||
}
|
||||
|
||||
public static Matrix2x2 Multiple(Matrix2x2 matrix1, Matrix2x2 matrix2)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
@@ -36,6 +36,11 @@ namespace StgSharp
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe void Transpose2to4_internal(Mat2* source, Mat4* target);
|
||||
|
||||
[DllImport("StgsharpGraphic", EntryPoint = "transmpose2to3",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe void Transpose2to3_internal(Mat2* source, Mat3* target);
|
||||
|
||||
#endregion
|
||||
|
||||
#region deinit mat2
|
||||
@@ -56,8 +61,8 @@ namespace StgSharp.Math
|
||||
internal struct Mat2
|
||||
{
|
||||
|
||||
[FieldOffset(0)] internal M128 colum0;
|
||||
[FieldOffset(4 * sizeof(float))] internal M128 colum1;
|
||||
[FieldOffset(0)] internal Vector4 colum0;
|
||||
[FieldOffset(4 * sizeof(float))] internal Vector4 colum1;
|
||||
|
||||
[FieldOffset(0 * sizeof(float))] internal float m00;
|
||||
[FieldOffset(1 * sizeof(float))] internal float m10;
|
||||
@@ -69,5 +74,31 @@ namespace StgSharp.Math
|
||||
[FieldOffset(6 * sizeof(float))] internal float m21;
|
||||
[FieldOffset(7 * sizeof(float))] internal float m31;
|
||||
|
||||
internal Mat2(
|
||||
Vector4 c0,
|
||||
Vector4 c1
|
||||
)
|
||||
{
|
||||
colum0 = c0;
|
||||
colum1 = c1;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static Mat2 Add(Mat2 left, Mat2 right)
|
||||
{
|
||||
return new Mat2(
|
||||
left.colum0 + right.colum0,
|
||||
left.colum1 + right.colum1
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static Mat2 Sub(Mat2 left, Mat2 right)
|
||||
{
|
||||
return new Mat2(
|
||||
left.colum0 - right.colum0,
|
||||
left.colum1 - right.colum1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,45 @@
|
||||
using StgSharp.Math;
|
||||
using StgSharp.StgSharp.Math;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
internal static unsafe partial class internalIO
|
||||
{
|
||||
|
||||
|
||||
#region transpose
|
||||
|
||||
[DllImport("StgsharpGraphic", EntryPoint = "transpose3to4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose3to4_internal(Mat3* source, Mat4* target);
|
||||
|
||||
[DllImport("StgsharpGra[hic", EntryPoint = "transpose3to4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose3to3_internal(Mat3* source, Mat3* target);
|
||||
|
||||
[DllImport("StgsharpGra[hic", EntryPoint = "transpose3to2",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose3to2_internal(Mat3* source, Mat2* target);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 12*sizeof(float),Pack = 16)]
|
||||
internal struct mat3
|
||||
[StructLayout(LayoutKind.Explicit, Size = 12 * sizeof(float), Pack = 16)]
|
||||
internal struct Mat3
|
||||
{
|
||||
|
||||
[FieldOffset(0)] internal M128 colum0;
|
||||
[FieldOffset(4 * sizeof(float))] internal M128 colum1;
|
||||
[FieldOffset(8 * sizeof(float))] internal M128 colum2;
|
||||
[FieldOffset(0)] internal Vector4 colum0;
|
||||
[FieldOffset(4 * sizeof(float))] internal Vector4 colum1;
|
||||
[FieldOffset(8 * sizeof(float))] internal Vector4 colum2;
|
||||
|
||||
[FieldOffset(0 * sizeof(float))] internal float m00;
|
||||
[FieldOffset(1 * sizeof(float))] internal float m10;
|
||||
@@ -30,4 +57,3 @@ namespace StgSharp.Math
|
||||
[FieldOffset(11 * sizeof(float))] internal float m32;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using StgSharp;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -13,51 +14,56 @@ namespace StgSharp
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
#else
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "addmat4",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "addmat4",
|
||||
#endif
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe StgSharp.Math.Mat4* add_mat4(
|
||||
ref StgSharp.Math.Mat4 mat1, ref StgSharp.Math.Mat4 Mat2);
|
||||
internal static extern unsafe Mat4* add_mat4(
|
||||
ref Mat4 mat1, ref Mat4 Mat2);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "addmat4",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "addmat4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe StgSharp.Math.Mat4* add_mat4(
|
||||
StgSharp.Math.Mat4* mat1, StgSharp.Math.Mat4* Mat2);
|
||||
internal static extern unsafe Mat4* add_mat4(
|
||||
Mat4* mat1, Mat4* Mat2);
|
||||
|
||||
#endregion
|
||||
|
||||
#region sub_mat4
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "sub_mat4",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "sub_mat4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static unsafe extern StgSharp.Math.Mat4* sub_mat4(
|
||||
ref StgSharp.Math.Mat4 mat1, ref StgSharp.Math.Mat4 Mat2);
|
||||
internal static unsafe extern Mat4* sub_mat4(
|
||||
ref Mat4 mat1, ref Mat4 Mat2);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "StgSharp.Math.Mat4",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "Mat4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static unsafe extern StgSharp.Math.Mat4* sub_mat4(
|
||||
StgSharp.Math.Mat4* mat1, StgSharp.Math.Mat4* Mat2);
|
||||
internal static unsafe extern Mat4* sub_mat4(
|
||||
Mat4* mat1, Mat4* Mat2);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region mul
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "mul_const",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "mul_const",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static unsafe extern StgSharp.Math.Mat4* mul_const(
|
||||
StgSharp.Math.Mat4* mat, float value);
|
||||
internal static unsafe extern Mat4* mul_const(
|
||||
Mat4* mat, float value);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "mul_const",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "mul_const",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static unsafe extern StgSharp.Math.Mat4* mul_const(
|
||||
ref StgSharp.Math.Mat4 mat, float value);
|
||||
internal static unsafe extern Mat4* mul_const(
|
||||
ref Mat4 mat, float value);
|
||||
|
||||
[DllImport("StgsharpGraphic", EntryPoint = "mul_4_2",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe Mat2* mul_4_2(Mat4* left, Mat2* right);
|
||||
|
||||
[DllImport("StgsharpGraphic", EntryPoint = "mul_4_4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
@@ -68,13 +74,17 @@ namespace StgSharp
|
||||
|
||||
#region transpose
|
||||
|
||||
[DllImport("StgsharpGraphic.dll", EntryPoint = "transpose4to4",
|
||||
[DllImport("StgsharpGraphic", EntryPoint = "transpose4to4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose4to4_internal(Mat4* source, Mat4* target);
|
||||
|
||||
[DllImport("StgsharpGraphic.dll", EntryPoint = "transpose4to4",
|
||||
[DllImport("StgsharpGraphic", EntryPoint = "transpose4to3",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose4to4_internal(ref Mat4* source, ref Mat4* target);
|
||||
internal static extern unsafe void Transpose4to3_internal(Mat4* source, Mat3* target);
|
||||
|
||||
[DllImport("StgsharpGraphic", EntryPoint = "transpose4to2",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose4to2_internal(Mat4* source, Mat2* target);
|
||||
|
||||
|
||||
#endregion
|
||||
@@ -84,21 +94,21 @@ namespace StgSharp
|
||||
[DllImport("StgsharpGraphic", EntryPoint = "det_mat4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static unsafe extern float det_mat4(Matrix4x4* matPtr);
|
||||
internal static unsafe extern float det_mat4(Mat4* matPtr, Mat4* transpose);
|
||||
|
||||
#endregion
|
||||
|
||||
#region deinit_mat4
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "deinit_mat4",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "deinit_mat4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern void deinit_mat4(ref StgSharp.Math.Mat4 mat);
|
||||
internal static extern void deinit_mat4(ref Mat4 mat);
|
||||
|
||||
[DllImport("StgSharpGraphic.dll", EntryPoint = "deinit_mat4",
|
||||
[DllImport("StgSharpGraphic", EntryPoint = "deinit_mat4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern void deinit_mat4(StgSharp.Math.Mat4* mat);
|
||||
internal static extern void deinit_mat4(Mat4* mat);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -113,30 +123,66 @@ namespace StgSharp.Math
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16 * sizeof(float))]
|
||||
public struct Mat4
|
||||
{
|
||||
[FieldOffset(0)] internal M128 colum0;
|
||||
[FieldOffset(16)] internal M128 colum1;
|
||||
[FieldOffset(32)] internal M128 colum2;
|
||||
[FieldOffset(48)] internal M128 colum3;
|
||||
[FieldOffset(0)] internal Vector4 colum0;
|
||||
[FieldOffset(16)] internal Vector4 colum1;
|
||||
[FieldOffset(32)] internal Vector4 colum2;
|
||||
[FieldOffset(48)] internal Vector4 colum3;
|
||||
|
||||
[FieldOffset(0)] public float a00;
|
||||
[FieldOffset(4)] public float a10;
|
||||
[FieldOffset(8)] public float a20;
|
||||
[FieldOffset(12)] public float a30;
|
||||
[FieldOffset(0)] public float m00;
|
||||
[FieldOffset(4)] public float m10;
|
||||
[FieldOffset(8)] public float m20;
|
||||
[FieldOffset(12)] public float m30;
|
||||
|
||||
[FieldOffset(16)] public float a01;
|
||||
[FieldOffset(20)] public float a11;
|
||||
[FieldOffset(24)] public float a21;
|
||||
[FieldOffset(28)] public float a31;
|
||||
[FieldOffset(16)] public float m01;
|
||||
[FieldOffset(20)] public float m11;
|
||||
[FieldOffset(24)] public float m21;
|
||||
[FieldOffset(28)] public float m31;
|
||||
|
||||
[FieldOffset(32)] public float a02;
|
||||
[FieldOffset(36)] public float a12;
|
||||
[FieldOffset(40)] public float a22;
|
||||
[FieldOffset(44)] public float a32;
|
||||
[FieldOffset(32)] public float m02;
|
||||
[FieldOffset(36)] public float m12;
|
||||
[FieldOffset(40)] public float m22;
|
||||
[FieldOffset(44)] public float m32;
|
||||
|
||||
[FieldOffset(48)] public float a03;
|
||||
[FieldOffset(52)] public float a13;
|
||||
[FieldOffset(56)] public float a23;
|
||||
[FieldOffset(60)] public float a33;
|
||||
[FieldOffset(48)] public float m03;
|
||||
[FieldOffset(52)] public float m13;
|
||||
[FieldOffset(56)] public float m23;
|
||||
[FieldOffset(60)] public float m33;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal Mat4(
|
||||
Vector4 colum0,
|
||||
Vector4 colum1,
|
||||
Vector4 colum2,
|
||||
Vector4 colum3
|
||||
)
|
||||
{
|
||||
this.colum0 = colum0;
|
||||
this.colum1 = colum1;
|
||||
this.colum2 = colum2;
|
||||
this.colum3 = colum3;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static Mat4 add(Mat4 left, Mat4 right)
|
||||
{
|
||||
return new Mat4(
|
||||
left.colum0 + right.colum0,
|
||||
left.colum1 + right.colum1,
|
||||
left.colum2 + right.colum2,
|
||||
left.colum3 + right.colum3
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static Mat4 sub(Mat4 left, Mat4 right)
|
||||
{
|
||||
return new Mat4(
|
||||
left.colum0 - right.colum0,
|
||||
left.colum1 - right.colum1,
|
||||
left.colum2 - right.colum2,
|
||||
left.colum3 - right.colum3
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,122 +1,151 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
/*
|
||||
public class Matrix2x2
|
||||
[StructLayout(LayoutKind.Explicit, Size = 2 * 2 * 4 * sizeof(float) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix2x2
|
||||
{
|
||||
public static Matrix2x2 Unit
|
||||
= new Matrix2x2(
|
||||
1,0,
|
||||
0,1
|
||||
);
|
||||
|
||||
internal M128Map _map;
|
||||
|
||||
internal IntPtr _colum0Ptr;
|
||||
internal IntPtr _colum1Ptr;
|
||||
|
||||
private bool _isTranpsed;
|
||||
private Matrix2x2 _transpose;
|
||||
[FieldOffset(0)]
|
||||
internal Mat2 mat;
|
||||
[FieldOffset(2 * 4 * sizeof(float))]
|
||||
internal Mat2 transpose;
|
||||
[FieldOffset(2 * 2 * 4 * sizeof(float))]
|
||||
internal bool isTransposed;
|
||||
|
||||
public Matrix2x2(
|
||||
float a00, float a01,
|
||||
float a10, float a11
|
||||
)
|
||||
)
|
||||
{
|
||||
_colum0Ptr = internalIO.load_internal(a00, a10, 0, 0);
|
||||
_colum0Ptr = internalIO.load_internal(a01, a11, 0, 0);
|
||||
|
||||
_transpose = new Matrix2x2(this);
|
||||
mat.colum0 = new Vector4(a00,a10,0,0);
|
||||
mat.colum1 = new Vector4(a01,a11,0,0);
|
||||
}
|
||||
|
||||
internal Matrix2x2(
|
||||
IntPtr colum0Ptr,
|
||||
IntPtr colum1Ptr
|
||||
Vector4 c0,
|
||||
Vector4 c1
|
||||
)
|
||||
{
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
}
|
||||
|
||||
internal Matrix2x2(
|
||||
Mat2 mat
|
||||
)
|
||||
{
|
||||
_colum0Ptr = colum0Ptr;
|
||||
_colum1Ptr = colum1Ptr;
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
internal Matrix2x2(Matrix2x2 transpose)
|
||||
public Matrix2x2 Transpose
|
||||
{
|
||||
_transpose = transpose;
|
||||
}
|
||||
|
||||
public unsafe Matrix2x2 Transpose(TransposeMode transposeMode)
|
||||
{
|
||||
if (_isTranpsed)
|
||||
get
|
||||
{
|
||||
(*(M128*)_transpose._colum0Ptr).single_0 = (*(M128*)_colum0Ptr).single_0;
|
||||
(*(M128*)_transpose._colum1Ptr).single_0 = (*(M128*)_colum0Ptr).single_1;
|
||||
|
||||
(*(M128*)_transpose._colum0Ptr).single_1 = (*(M128*)_colum1Ptr).single_0;
|
||||
(*(M128*)_transpose._colum1Ptr).single_1 = (*(M128*)_colum1Ptr).single_1;
|
||||
}
|
||||
|
||||
switch (transposeMode)
|
||||
{
|
||||
case TransposeMode.New:
|
||||
return new Matrix2x2(
|
||||
internalIO.load_cpy_internal(_transpose._colum0Ptr),
|
||||
internalIO.load_cpy_internal(_transpose._colum1Ptr)
|
||||
);
|
||||
break;
|
||||
case TransposeMode.Copy:
|
||||
return _transpose;
|
||||
break;
|
||||
default:
|
||||
throw new Exception();
|
||||
break;
|
||||
InternalTranspose();
|
||||
return new Matrix2x2(this.transpose);
|
||||
}
|
||||
}
|
||||
|
||||
public static Matrix2x2 operator +(Matrix2x2 matrix1, Matrix2x2 matrix2)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal void InternalTranspose()
|
||||
{
|
||||
return new Matrix2x2(
|
||||
internalIO.addps_internal(matrix1._colum0Ptr, matrix2._colum0Ptr),
|
||||
internalIO.addps_internal(matrix1._colum1Ptr, matrix2._colum1Ptr)
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix2x2 operator -(Matrix2x2 matrix1, Matrix2x2 matrix2)
|
||||
{
|
||||
return new Matrix2x2(
|
||||
internalIO.subps_internal(matrix1._colum0Ptr, matrix2._colum0Ptr),
|
||||
internalIO.subps_internal(matrix1._colum1Ptr, matrix2._colum1Ptr)
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix2x2 operator *(Matrix2x2 matrix1, float value)
|
||||
{
|
||||
return new Matrix2x2(
|
||||
internalIO.mulps_const_internal(matrix1._colum0Ptr, value),
|
||||
internalIO.mulps_const_internal(matrix1._colum1Ptr, value)
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix2x2 operator /(Matrix2x2 matrix1, float value)
|
||||
{
|
||||
return new Matrix2x2(
|
||||
internalIO.divps_const_internal(matrix1._colum0Ptr, value),
|
||||
internalIO.divps_const_internal(matrix1._colum1Ptr, value)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
~Matrix2x2()
|
||||
{
|
||||
if (_map == null)
|
||||
if (!isTransposed)
|
||||
{
|
||||
internalIO.deinitM128_internal(_colum0Ptr);
|
||||
internalIO.deinitM128_internal(_colum1Ptr);
|
||||
transpose = mat;
|
||||
float cache = transpose.m10;
|
||||
transpose.m10 = transpose.m01;
|
||||
transpose.m01 = cache;
|
||||
|
||||
isTransposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix2x2 operator +(Matrix2x2 left, Matrix2x2 right)
|
||||
{
|
||||
Mat2* refmat = internalIO.add_mat2(&left.mat, &right.mat);
|
||||
Matrix2x2 ret = new Matrix2x2(*refmat);
|
||||
internalIO.deinit_mat2(refmat);
|
||||
return ret;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator -(Matrix2x2 left, Matrix2x2 right)
|
||||
{
|
||||
return new Matrix2x2(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator *(Matrix2x2 mat, float value)
|
||||
{
|
||||
return new Matrix2x2(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator /(Matrix2x2 mat, float value)
|
||||
{
|
||||
return new Matrix2x2(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator *(Matrix2x2 left, Matrix2x2 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x2(
|
||||
Vector4.Dot( left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot( left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
Vector4.Dot( left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot( left.transpose.colum1, right.mat.colum1)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator *(Matrix2x2 left, Matrix2x3 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x3(
|
||||
Vector4.Dot( left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot( left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot( left.transpose.colum0, right.mat.colum2),
|
||||
|
||||
Vector4.Dot( left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot( left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot( left.transpose.colum1, right.mat.colum2)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator *(Matrix2x2 left, Matrix2x4 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x4(
|
||||
Vector4.Dot( left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot( left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot( left.transpose.colum0, right.mat.colum2),
|
||||
Vector4.Dot( left.transpose.colum0, right.mat.colum3),
|
||||
|
||||
Vector4.Dot( left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot( left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot( left.transpose.colum1, right.mat.colum2),
|
||||
Vector4.Dot( left.transpose.colum1, right.mat.colum3)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
}
|
||||
|
||||
@@ -1,133 +1,182 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
|
||||
/*
|
||||
public class Matrix2x3
|
||||
[StructLayout(LayoutKind.Explicit, Size = (3 + 2) * 4 * sizeof(float) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix2x3
|
||||
{
|
||||
internal M128Map _map;
|
||||
|
||||
internal IntPtr _colum0Ptr;
|
||||
internal IntPtr _colum1Ptr;
|
||||
internal IntPtr _colum2Ptr;
|
||||
|
||||
private bool _isTransposed;
|
||||
private Matrix3x2 _transpose;
|
||||
[FieldOffset(0)] internal Mat3 mat;
|
||||
[FieldOffset(3 * 4 * sizeof(float))] internal Mat2 transpose;
|
||||
[FieldOffset(5 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
|
||||
public Matrix2x3(
|
||||
float a00, float a01, float a02,
|
||||
float a10, float a11, float a12
|
||||
float a00,float a01,float a02,
|
||||
float a10,float a11,float a12
|
||||
)
|
||||
{
|
||||
_colum0Ptr = internalIO.load_internal(a00,a10,0,0);
|
||||
_colum0Ptr = internalIO.load_internal(a01,a11,0,0);
|
||||
_colum0Ptr = internalIO.load_internal(a02,a12,0,0);
|
||||
|
||||
_transpose = new Matrix3x2(this);
|
||||
mat.colum0 = new Vector4(a00, a10, 0, 0);
|
||||
mat.colum1 = new Vector4(a01, a11, 0, 0);
|
||||
mat.colum2 = new Vector4(a02, a12, 0, 0);
|
||||
}
|
||||
|
||||
internal Matrix2x3(
|
||||
IntPtr colum0Ptr,
|
||||
IntPtr colum1Ptr,
|
||||
IntPtr colum2Ptr
|
||||
Vector4 c0,
|
||||
Vector4 c1,
|
||||
Vector4 c2
|
||||
)
|
||||
{
|
||||
_colum0Ptr = colum0Ptr;
|
||||
_colum1Ptr = colum1Ptr;
|
||||
_colum2Ptr = colum2Ptr;
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
mat.colum2 = c2;
|
||||
}
|
||||
|
||||
_transpose = new Matrix3x2(this);
|
||||
public unsafe float this[int rowNum, int columNum]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (rowNum > 1 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 2 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
return *(float*)pbit;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (rowNum > 1 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 2 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
*(float*)pbit = value;
|
||||
}
|
||||
isTransposed = false;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if (!isTransposed)
|
||||
{
|
||||
fixed(Mat3* source = &this.mat)
|
||||
fixed(Mat2* target = &this.transpose)
|
||||
{
|
||||
internalIO.Transpose3to2_internal(source, target);
|
||||
}
|
||||
isTransposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public Matrix2x3(Matrix3x2 transpose)
|
||||
{
|
||||
_transpose = transpose;
|
||||
}
|
||||
|
||||
public unsafe Matrix3x2 Transpose(TransposeMode transposeMode)
|
||||
{
|
||||
if (_isTransposed)
|
||||
{
|
||||
(*(M128*)_transpose._colum0Ptr).single_0 = (*(M128*)_colum0Ptr).single_0;
|
||||
(*(M128*)_transpose._colum1Ptr).single_0 = (*(M128*)_colum0Ptr).single_1;
|
||||
|
||||
(*(M128*)_transpose._colum0Ptr).single_1 = (*(M128*)_colum1Ptr).single_0;
|
||||
(*(M128*)_transpose._colum1Ptr).single_1 = (*(M128*)_colum1Ptr).single_1;
|
||||
|
||||
(*(M128*)_transpose._colum0Ptr).single_2 = (*(M128*)_colum2Ptr).single_0;
|
||||
(*(M128*)_transpose._colum1Ptr).single_2 = (*(M128*)_colum2Ptr).single_1;
|
||||
|
||||
_isTransposed = true;
|
||||
}
|
||||
switch (transposeMode)
|
||||
{
|
||||
case TransposeMode.New:
|
||||
return new Matrix3x2(
|
||||
_transpose._colum0Ptr,
|
||||
_transpose._colum1Ptr
|
||||
);
|
||||
break;
|
||||
case TransposeMode.Copy:
|
||||
return _transpose;
|
||||
break;
|
||||
default:
|
||||
throw new Exception();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static Matrix2x3 operator +(Matrix2x3 matrix1, Matrix2x3 matrix2)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator +(Matrix2x3 left, Matrix2x3 right)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
internalIO.addps_internal(matrix1._colum0Ptr,matrix2._colum0Ptr),
|
||||
internalIO.addps_internal(matrix1._colum1Ptr,matrix2._colum1Ptr),
|
||||
internalIO.addps_internal(matrix1._colum2Ptr,matrix2._colum2Ptr)
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix2x3 operator -(Matrix2x3 matrix1, Matrix2x3 matrix2)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator -(Matrix2x3 left, Matrix2x3 right)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
internalIO.subps_internal(matrix1._colum0Ptr, matrix2._colum0Ptr),
|
||||
internalIO.subps_internal(matrix1._colum1Ptr, matrix2._colum1Ptr),
|
||||
internalIO.subps_internal(matrix1._colum2Ptr, matrix2._colum2Ptr)
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum2 - right.mat.colum2
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix2x3 operator *(Matrix2x3 matrix, float value)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator *(Matrix2x3 mat, float value)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
internalIO.mulps_const_internal(matrix._colum0Ptr, value),
|
||||
internalIO.mulps_const_internal(matrix._colum1Ptr, value),
|
||||
internalIO.mulps_const_internal(matrix._colum2Ptr, value)
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix2x3 operator /(Matrix2x3 matrix, float value)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator /(Matrix2x3 mat, float value)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
internalIO.divps_const_internal(matrix._colum0Ptr, value),
|
||||
internalIO.divps_const_internal(matrix._colum1Ptr, value),
|
||||
internalIO.divps_const_internal(matrix._colum2Ptr, value)
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value
|
||||
);
|
||||
}
|
||||
|
||||
~Matrix2x3()
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator *(Matrix2x3 left, Matrix3x2 right)
|
||||
{
|
||||
if (_map == null)
|
||||
{
|
||||
internalIO.deinitM128_internal(_colum0Ptr);
|
||||
internalIO.deinitM128_internal(_colum1Ptr);
|
||||
internalIO.deinitM128_internal(_colum2Ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x2(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
}
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator *(Matrix2x3 left, Matrix3x3 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x3(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator *(Matrix2x3 left, Matrix3x4 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x4(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum3)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**/
|
||||
}
|
||||
|
||||
@@ -1,12 +1,197 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = (4 + 2) * 4 * sizeof(float) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix2x4
|
||||
{
|
||||
[FieldOffset(0)] internal Mat4 mat;
|
||||
[FieldOffset(4 * 4 * sizeof(float))] internal Mat2 transpose;
|
||||
[FieldOffset(6 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
|
||||
public Matrix2x4(
|
||||
float a00, float a01,float a02,float a03,
|
||||
float a10, float a11,float a12,float a13
|
||||
)
|
||||
{
|
||||
mat.colum0 = new Vector4(a00, a10, 0, 0);
|
||||
mat.colum1 = new Vector4(a01, a11, 0, 0);
|
||||
mat.colum2 = new Vector4(a02, a12, 0, 0);
|
||||
mat.colum3 = new Vector4(a03, a13, 0, 0);
|
||||
}
|
||||
|
||||
internal Matrix2x4(
|
||||
Vector4 c0,
|
||||
Vector4 c1,
|
||||
Vector4 c2,
|
||||
Vector4 c3
|
||||
)
|
||||
{
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
mat.colum2 = c2;
|
||||
mat.colum3 = c3;
|
||||
}
|
||||
|
||||
public unsafe float this[int rowNum, int columNum]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (rowNum > 1 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 3 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
return *(float*)pbit;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (rowNum > 1 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 3 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
*(float*)pbit = value;
|
||||
}
|
||||
isTransposed = false;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if (!isTransposed)
|
||||
{
|
||||
fixed (Mat4* source = &this.mat)
|
||||
fixed (Mat2* target = &this.transpose)
|
||||
{
|
||||
internalIO.Transpose4to2_internal(source, target);
|
||||
}
|
||||
isTransposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator +(Matrix2x4 left, Matrix2x4 right)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2,
|
||||
left.mat.colum3 + right.mat.colum3
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator -(Matrix2x4 left, Matrix2x4 right)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum2 - right.mat.colum2,
|
||||
left.mat.colum3 - right.mat.colum3
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator *(Matrix2x4 mat, float value)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value,
|
||||
mat.mat.colum3 * value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator /(Matrix2x4 mat, float value)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value,
|
||||
mat.mat.colum3 / value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator *(Matrix2x4 left, Matrix4x2 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x2(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator *(Matrix2x4 left, Matrix4x3 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x3(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator *(Matrix2x4 left, Matrix4x4 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x4(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum3)
|
||||
);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
InternalTranspose();
|
||||
return $"[{mat.m00},{mat.m01},{mat.m02},{mat.m03}]," +
|
||||
$"[{mat.m10},{mat.m11},{mat.m12},{mat.m13}]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,187 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 5 * 4 * sizeof(float) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix3x2
|
||||
{
|
||||
[FieldOffset(0)] internal Mat2 mat;
|
||||
[FieldOffset(2 * 4 * sizeof(float))] internal Mat3 transpose;
|
||||
[FieldOffset(5 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
|
||||
|
||||
public Matrix3x2(
|
||||
float a00, float a01,
|
||||
float a10, float a11,
|
||||
float a20, float a21
|
||||
)
|
||||
{
|
||||
mat.colum0 = new Vector4(a00, a10, a20, 0);
|
||||
mat.colum0 = new Vector4(a01, a11, a21, 0);
|
||||
}
|
||||
|
||||
internal Matrix3x2(
|
||||
Vector4 c0,
|
||||
Vector4 c1
|
||||
)
|
||||
{
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
}
|
||||
|
||||
public unsafe float this[int rowNum, int columNum]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (rowNum > 2 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 1 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
return *(float*)pbit;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (rowNum > 2 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 1 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
*(float*)pbit = value;
|
||||
}
|
||||
isTransposed = false;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if (!isTransposed)
|
||||
{
|
||||
fixed (Mat2* source = &this.mat)
|
||||
fixed (Mat3* target = &this.transpose)
|
||||
{
|
||||
internalIO.Transpose2to3_internal(source, target);
|
||||
}
|
||||
isTransposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator +(Matrix3x2 left, Matrix3x2 right)
|
||||
{
|
||||
return new Matrix3x2(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator -(Matrix3x2 left, Matrix3x2 right)
|
||||
{
|
||||
return new Matrix3x2(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator *(Matrix3x2 mat, float value)
|
||||
{
|
||||
return new Matrix3x2(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator /(Matrix3x2 mat, float value)
|
||||
{
|
||||
return new Matrix3x2(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator *(Matrix3x2 left, Matrix2x2 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x2(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator *(Matrix3x2 left, Matrix2x3 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x3(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum2)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator *(Matrix3x2 left, Matrix2x4 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x4(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum3)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,198 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public class Matrix3x3
|
||||
[StructLayout(LayoutKind.Explicit, Size = 6 * 4 * sizeof(float) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix3x3
|
||||
{
|
||||
[FieldOffset(0)] internal Mat3 mat;
|
||||
[FieldOffset(3 * 4 * sizeof(float))] internal Mat3 transpose;
|
||||
[FieldOffset(6 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
|
||||
|
||||
public Matrix3x3(
|
||||
float a00,float a01,float a02,
|
||||
float a10,float a11,float a12,
|
||||
float a20,float a21,float a22
|
||||
)
|
||||
{
|
||||
mat.colum0 = new Vector4(a00,a10,a20,0);
|
||||
mat.colum1 = new Vector4(a01,a11,a21,0);
|
||||
mat.colum2 = new Vector4(a02,a12,a22,0);
|
||||
}
|
||||
|
||||
internal Matrix3x3(
|
||||
Vector4 c0,
|
||||
Vector4 c1,
|
||||
Vector4 c2
|
||||
)
|
||||
{
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
mat.colum2 = c2;
|
||||
}
|
||||
|
||||
public unsafe float this[int rowNum, int columNum]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (rowNum > 2 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 2 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
return *(float*)pbit;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (rowNum > 2 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 2 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
*(float*)pbit = value;
|
||||
}
|
||||
isTransposed = false;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if (!isTransposed)
|
||||
{
|
||||
fixed (Mat3* source = &this.mat, target = &this.transpose)
|
||||
{
|
||||
internalIO.Transpose3to3_internal(source, target);
|
||||
}
|
||||
isTransposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator +(Matrix3x3 left, Matrix3x3 right)
|
||||
{
|
||||
return new Matrix3x3(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator -(Matrix3x3 left, Matrix3x3 right)
|
||||
{
|
||||
return new Matrix3x3(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator *(Matrix3x3 mat, float value)
|
||||
{
|
||||
return new Matrix3x3(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator /(Matrix3x3 mat, float value)
|
||||
{
|
||||
return new Matrix3x3(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator *(Matrix3x3 left, Matrix3x2 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x2(
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum1)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator *(Matrix3x3 left, Matrix3x3 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x3(
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum2)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator *(Matrix3x3 left, Matrix3x4 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x4(
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum3)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,206 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public class Matrix3x4
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 7*4*sizeof(float)+ sizeof(bool),Pack = 16)]
|
||||
public struct Matrix3x4
|
||||
{
|
||||
[FieldOffset(0)] internal Mat4 mat;
|
||||
[FieldOffset(4*4*sizeof(float))] internal Mat3 transpose;
|
||||
[FieldOffset(7 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
|
||||
public Matrix3x4(
|
||||
float a00, float a01, float a02, float a03,
|
||||
float a10, float a11, float a12, float a13,
|
||||
float a20, float a21, float a22, float a23
|
||||
)
|
||||
{
|
||||
mat.colum0 = new Vector4(a00, a10, a20, 0);
|
||||
mat.colum0 = new Vector4(a01, a11, a21, 0);
|
||||
mat.colum0 = new Vector4(a02, a12, a22, 0);
|
||||
mat.colum0 = new Vector4(a03, a13, a23, 0);
|
||||
}
|
||||
|
||||
internal Matrix3x4(
|
||||
Vector4 c0,
|
||||
Vector4 c1,
|
||||
Vector4 c2,
|
||||
Vector4 c3
|
||||
)
|
||||
{
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
mat.colum2 = c2;
|
||||
mat.colum3 = c3;
|
||||
}
|
||||
|
||||
internal Matrix3x4(Mat4 mat)
|
||||
{
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
public unsafe float this[int rowNum, int columNum]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (rowNum > 2 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 3 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
return *(float*)pbit;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (rowNum > 2 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 3 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
*(float*)pbit = value;
|
||||
}
|
||||
isTransposed = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if (!isTransposed)
|
||||
{
|
||||
fixed(Mat4* source = &this.mat)
|
||||
fixed(Mat3* target = &this.transpose)
|
||||
{
|
||||
internalIO.Transpose4to3_internal(source, target);
|
||||
}
|
||||
isTransposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator +(Matrix3x4 left, Matrix3x4 right)
|
||||
{
|
||||
return new Matrix3x4(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2,
|
||||
left.mat.colum3 + right.mat.colum3
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator -(Matrix3x4 left, Matrix3x4 right)
|
||||
{
|
||||
return new Matrix3x4(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum2 - right.mat.colum2,
|
||||
left.mat.colum3 - right.mat.colum3
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator *(Matrix3x4 mat, float value)
|
||||
{
|
||||
return new Matrix3x4(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value,
|
||||
mat.mat.colum3 * value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator /(Matrix3x4 mat, float value)
|
||||
{
|
||||
return new Matrix3x4(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value,
|
||||
mat.mat.colum3 / value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator *(Matrix3x4 left, Matrix4x2 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x2(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator *(Matrix3x4 left, Matrix4x3 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x3(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum2)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator *(Matrix3x4 left, Matrix4x4 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x4(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum3)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using static StgSharp.Graphics.GLFWwndconfig;
|
||||
|
||||
namespace StgSharp.Math
|
||||
@@ -13,66 +14,200 @@ namespace StgSharp.Math
|
||||
{
|
||||
[FieldOffset(0)] internal Mat2 mat;
|
||||
[FieldOffset(8 * sizeof(float))] internal Mat4 transpose;
|
||||
[FieldOffset((16 + 8) * sizeof(float))] internal bool isTranspose;
|
||||
[FieldOffset((16 + 8) * sizeof(float))] internal bool isTransposed;
|
||||
|
||||
|
||||
unsafe public Matrix4x2(
|
||||
public Matrix4x2(
|
||||
float a00,float a01,
|
||||
float a10,float a11,
|
||||
float a20,float a21,
|
||||
float a30,float a31
|
||||
)
|
||||
{
|
||||
M128* c0ref = internalIO.loadptr_internal(a00, a10, a20, a30);
|
||||
M128* c1ref = internalIO.loadptr_internal(a01, a11, a21, a31);
|
||||
|
||||
mat.colum0 = *c0ref;
|
||||
mat.colum1 = *c1ref;
|
||||
|
||||
/**/
|
||||
internalIO.deinitM128_internal(c0ref);
|
||||
internalIO.deinitM128_internal(c1ref);
|
||||
mat.colum0 = new Vector4(a00, a10, a20, a30);
|
||||
mat.colum1 = new Vector4(a01, a11, a21, a31);
|
||||
}
|
||||
|
||||
unsafe internal Matrix4x2(Mat2 mat)
|
||||
|
||||
internal Matrix4x2(
|
||||
Vector4 c0,
|
||||
Vector4 c1
|
||||
)
|
||||
{
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
}
|
||||
|
||||
internal Matrix4x2(Mat2 mat)
|
||||
{
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public unsafe float this[int rowNum, int columNum]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (rowNum > 3 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 1 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
return *(float*)pbit;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (rowNum > 3 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 1 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
*(float*)pbit = value;
|
||||
}
|
||||
isTransposed = false;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x2 operator +(Matrix4x2 left, Matrix4x2 right)
|
||||
{
|
||||
Mat2* p = internalIO.add_mat2(&left.mat, &right.mat);
|
||||
Matrix4x2 ret = new Matrix4x2(*p);
|
||||
internalIO.deinit_mat2(p);
|
||||
return ret;
|
||||
return new Matrix4x2(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum0 + right.mat.colum0
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x2 operator *(Matrix4x2 mat, float value)
|
||||
{
|
||||
return new Matrix4x2(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x2 operator /(Matrix4x2 mat, float value)
|
||||
{
|
||||
return new Matrix4x2(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x2 operator -(Matrix4x2 left, Matrix4x2 right)
|
||||
{
|
||||
Mat2* p = internalIO.sub_mat2(&left.mat, &right.mat);
|
||||
Matrix4x2 ret = new Matrix4x2(*p);
|
||||
internalIO.deinit_mat2(p);
|
||||
return ret;
|
||||
return new Matrix4x2(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum0 - right.mat.colum0
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x2 operator *(Matrix4x2 left, Matrix2x2 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x2(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum1)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator *(Matrix4x2 left, Matrix2x3 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x3(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum2)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x4 operator *(Matrix4x2 left, Matrix2x4 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x4(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum2)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if (!isTranspose)
|
||||
if (!isTransposed)
|
||||
{
|
||||
fixed (Mat2* source = &this.mat)
|
||||
fixed (Mat4* target = &this.transpose)
|
||||
{
|
||||
internalIO.Transpose2to4_internal(source, target);
|
||||
}
|
||||
|
||||
isTranspose = true;
|
||||
isTransposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,216 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public class Matrix4x3
|
||||
[StructLayout(LayoutKind.Explicit, Size = 7*4*sizeof(float)+ sizeof(bool),Pack =16 )]
|
||||
public struct Matrix4x3
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
internal Mat3 mat;
|
||||
[FieldOffset(3 * 4 * sizeof(float))]
|
||||
internal Mat4 transpose;
|
||||
[FieldOffset(7 * 4 * sizeof(float))]
|
||||
internal bool isTransposed;
|
||||
|
||||
public Matrix4x3(
|
||||
float a00, float a01, float a02,
|
||||
float a10, float a11, float a12,
|
||||
float a20, float a21, float a22,
|
||||
float a30, float a31, float a32
|
||||
)
|
||||
{
|
||||
mat.colum0 = new Vector4(a00, a10, a20, a30);
|
||||
mat.colum1 = new Vector4(a01, a11, a21, a31);
|
||||
mat.colum2 = new Vector4(a02, a12, a22, a32);
|
||||
}
|
||||
|
||||
internal Matrix4x3(
|
||||
Vector4 c0,
|
||||
Vector4 c1,
|
||||
Vector4 c2
|
||||
)
|
||||
{
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
mat.colum2 = c2;
|
||||
}
|
||||
|
||||
public unsafe float this[int rowNum, int columNum]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (rowNum > 3 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 2 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
return *(float*)pbit;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
if (rowNum > 3 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 2 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
*(float*)pbit = value;
|
||||
}
|
||||
isTransposed = false;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if (!isTransposed)
|
||||
{
|
||||
fixed (Mat3* source = &this.mat)
|
||||
fixed (Mat4* target = &this.transpose)
|
||||
{
|
||||
internalIO.Transpose3to4_internal(source, target);
|
||||
|
||||
}
|
||||
isTransposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator +(Matrix4x3 left, Matrix4x3 right)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator -(Matrix4x3 left, Matrix4x3 right)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum2 - right.mat.colum2
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator *(Matrix4x3 mat, float value)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator /(Matrix4x3 mat, float value)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x2 operator *(Matrix4x3 left, Matrix3x2 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x2(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum1)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator *(Matrix4x3 left, Matrix3x3 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x3(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum2)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x4 operator *(Matrix4x3 left, Matrix3x4 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x4(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum3)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -28,22 +28,10 @@ namespace StgSharp.Math
|
||||
float a30, float a31, float a32, float a33
|
||||
)
|
||||
{
|
||||
M128* c0ref = internalIO.loadptr_internal(a00, a10, a20, a30);
|
||||
M128* c1ref = internalIO.loadptr_internal(a01, a11, a21, a31);
|
||||
M128* c2ref = internalIO.loadptr_internal(a02, a12, a22, a32);
|
||||
M128* c3ref = internalIO.loadptr_internal(a03, a13, a23, a33);
|
||||
|
||||
mat.colum0 = *c0ref;
|
||||
mat.colum1 = *c1ref;
|
||||
mat.colum2 = *c2ref;
|
||||
mat.colum3 = *c3ref;
|
||||
|
||||
/**/
|
||||
internalIO.deinitM128_internal(c0ref);
|
||||
internalIO.deinitM128_internal(c1ref);
|
||||
internalIO.deinitM128_internal(c2ref);
|
||||
internalIO.deinitM128_internal(c3ref);
|
||||
/**/
|
||||
mat.colum0 = new Vector4(a00, a10, a20, a30);
|
||||
mat.colum0 = new Vector4(a01, a11, a21, a31);
|
||||
mat.colum0 = new Vector4(a02, a12, a22, a32);
|
||||
mat.colum0 = new Vector4(a03, a13, a23, a33);
|
||||
|
||||
}
|
||||
|
||||
@@ -60,22 +48,44 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.a00 )
|
||||
fixed (float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(M128) * (ulong)rowNum
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
return *(float*)pbit;
|
||||
}
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
if (rowNum > 3 || rowNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
if (columNum > 3 || columNum < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
ulong pbit = (ulong)p
|
||||
+ (ulong)sizeof(Vector4) * (ulong)rowNum
|
||||
+ (ulong)sizeof(float) * (ulong)columNum;
|
||||
*(float*)pbit = value;
|
||||
}
|
||||
isTransposed = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
internal Matrix4x4(
|
||||
ref M128 vec0,
|
||||
ref M128 vec1,
|
||||
ref M128 vec2,
|
||||
ref M128 vec3
|
||||
Vector4 vec0,
|
||||
Vector4 vec1,
|
||||
Vector4 vec2,
|
||||
Vector4 vec3
|
||||
)
|
||||
{
|
||||
mat.colum0 = vec0;
|
||||
@@ -90,67 +100,111 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x4 operator +(Matrix4x4 mat1, Matrix4x4 Mat2)
|
||||
public static unsafe Matrix4x4 operator +(Matrix4x4 left, Matrix4x4 right)
|
||||
{
|
||||
Mat4* refret = internalIO.add_mat4(ref mat1.mat, ref Mat2.mat);
|
||||
Matrix4x4 ret = new Matrix4x4(*refret);
|
||||
internalIO.deinit_mat4(refret);
|
||||
return ret;
|
||||
return new Matrix4x4(
|
||||
Mat4.add( right.mat,left.mat)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x4 operator -(Matrix4x4 mat1, Matrix4x4 Mat2)
|
||||
public static unsafe Matrix4x4 operator -(Matrix4x4 left, Matrix4x4 right)
|
||||
{
|
||||
Mat4* refret = internalIO.sub_mat4(ref mat1.mat, ref Mat2.mat);
|
||||
Matrix4x4 ret = new Matrix4x4(*refret);
|
||||
internalIO.deinit_mat4(refret);
|
||||
return ret;
|
||||
return new Matrix4x4(
|
||||
Mat4.sub(right.mat, left.mat)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x4 operator *(Matrix4x4 mat, float value)
|
||||
{
|
||||
Mat4* refret = internalIO.mul_const(ref mat.mat, value);
|
||||
Matrix4x4 ret = new Matrix4x4(*refret);
|
||||
internalIO.deinit_mat4(refret);
|
||||
return ret;
|
||||
return new Matrix4x4(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value,
|
||||
mat.mat.colum3 * value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x2 operator *(Matrix4x4 left, Matrix4x2 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
Mat4 tr = left.transpose;
|
||||
return new Matrix4x2(
|
||||
internalIO.mulps_sum_internal(&tr.colum0, &right.mat.colum0),
|
||||
internalIO.mulps_sum_internal(&tr.colum0, &right.mat.colum1),
|
||||
internalIO.mulps_sum_internal(&tr.colum1, &right.mat.colum0),
|
||||
internalIO.mulps_sum_internal(&tr.colum1, &right.mat.colum1),
|
||||
internalIO.mulps_sum_internal(&tr.colum2, &right.mat.colum0),
|
||||
internalIO.mulps_sum_internal(&tr.colum2, &right.mat.colum1),
|
||||
internalIO.mulps_sum_internal(&tr.colum3, &right.mat.colum0),
|
||||
internalIO.mulps_sum_internal(&tr.colum3, &right.mat.colum1)
|
||||
);
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum1)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x4 operator *(Matrix4x4 left, Matrix4x4 right)
|
||||
public static Matrix4x3 operator *(Matrix4x4 left, Matrix4x3 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
Mat4* p = internalIO.mul_4_4(&left.transpose, &right.mat);
|
||||
Matrix4x4 ret = new Matrix4x4(*p);
|
||||
internalIO.deinit_mat4(p);
|
||||
return ret;
|
||||
return new Matrix4x3(
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0,right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1,right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2,right.mat.colum2),
|
||||
|
||||
Vector4.Dot(left.transpose.colum3,right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum3,right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum3,right.mat.colum2)
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x4 operator *(Matrix4x4 left, Matrix4x4 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x4(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum1, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum2, right.mat.colum3),
|
||||
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum2),
|
||||
Vector4.Dot(left.transpose.colum3, right.mat.colum3)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe float Det()
|
||||
{
|
||||
InternalTranspose();
|
||||
fixed (Matrix4x4* _this = &this)
|
||||
fixed (Mat4* _this = &mat, _trans = &transpose)
|
||||
{
|
||||
return internalIO.det_mat4(_this);
|
||||
return internalIO.det_mat4(_this,_trans);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace StgSharp.Math
|
||||
public float Y;
|
||||
|
||||
[FieldOffset(0)]
|
||||
internal M128 vec;
|
||||
internal Vector4 vec;
|
||||
|
||||
public Vec2d(float x, float y)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using StgSharp.Control;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace StgSharp.Math
|
||||
public struct Vec3d
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
internal M128 vec;
|
||||
internal Vector4 vec;
|
||||
|
||||
[FieldOffset(0)] public float X;
|
||||
[FieldOffset(4)] public float Y;
|
||||
@@ -72,5 +72,12 @@ namespace StgSharp.Math
|
||||
vec1.Z * vec2.Z;
|
||||
}
|
||||
|
||||
public string ToString(string sample)
|
||||
{
|
||||
return $"{this.X}\t{this.Y}\t{this.Z}\t";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using StgSharp.Control;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Math
|
||||
@@ -9,7 +9,7 @@ namespace StgSharp.Math
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
|
||||
public struct Vec4d
|
||||
{
|
||||
[FieldOffset(0)] internal M128 vec;
|
||||
[FieldOffset(0)] internal Vector4 vec;
|
||||
|
||||
[FieldOffset(0)]public float X;
|
||||
[FieldOffset(4)]public float Y;
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="..\StgSharpGraphic.dll">
|
||||
<None Update="..\StgSharpGraphic">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
Binary file not shown.
@@ -162,12 +162,6 @@
|
||||
Vec2Ds in StgSharp are defaultly usaed as colum vector.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Vec4d.#ctor(System.IntPtr)">
|
||||
<summary>
|
||||
internal constructor to recive a pointer of the M128 value
|
||||
</summary>
|
||||
<param name="value"></param>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Calc.ASin(System.Single)">
|
||||
<summary>
|
||||
Reurns the value of ArcSin(x)
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
a481b6da709e541cf6f2d458de164b157415491e
|
||||
f6acdcb7485571fc33859ff7052c64de7abcc14b
|
||||
|
||||
Binary file not shown.
@@ -162,12 +162,6 @@
|
||||
Vec2Ds in StgSharp are defaultly usaed as colum vector.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Vec4d.#ctor(System.IntPtr)">
|
||||
<summary>
|
||||
internal constructor to recive a pointer of the M128 value
|
||||
</summary>
|
||||
<param name="value"></param>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Calc.ASin(System.Single)">
|
||||
<summary>
|
||||
Reurns the value of ArcSin(x)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -26,6 +26,7 @@
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"C:\\Program Files\\dotnet\\library-packs": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
|
||||
@@ -159,6 +159,7 @@
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"C:\\Program Files\\dotnet\\library-packs": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "LkDSeyeGIzwEX93A0bihMviHOggcsL8tMl89DOcWOldIkA/gZCDUU1UH3ksMLOCGXi+sVGG+kz4l8+2AIbLJ1Q==",
|
||||
"dgSpecHash": "nyq9v8WRAFwIjz8I9Gv9vf0PpGAcnjjNKfzoUjZTNrikCVkWYQ0og9Fjs/Iji8EwIym3cvVShDpL3VAfbdckRQ==",
|
||||
"success": true,
|
||||
"projectFilePath": "D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\源代码\\StgSharp\\StgSharp.csproj",
|
||||
"expectedPackageFiles": [
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -23,14 +23,16 @@ namespace StgSharp
|
||||
|
||||
Console.WriteLine(matrix.Det());
|
||||
|
||||
/*
|
||||
/**/
|
||||
System.Numerics.Matrix4x4 m = new System.Numerics.Matrix4x4(
|
||||
0,1,2,3,
|
||||
0,0,1,2,
|
||||
0,0,0,0,
|
||||
1,2,5,6
|
||||
1, 1, -1, 2,
|
||||
-1, -1, -4, 1,
|
||||
2, 4, -6, 1,
|
||||
1, 2, 4, 2
|
||||
);
|
||||
|
||||
Console.WriteLine(m.GetDeterminant());
|
||||
/**/
|
||||
int cycle = 1000;
|
||||
int time = 10000;
|
||||
|
||||
@@ -42,7 +44,12 @@ namespace StgSharp
|
||||
sw.Start();
|
||||
for (int i = 0; i < time; i++)
|
||||
{
|
||||
Matrix4x4 mat = matrix * matrix;
|
||||
Matrix4x4 matrix4X4 = new Matrix4x4(
|
||||
1, 1, -1, 2,
|
||||
-1, -1, -4, 1,
|
||||
2, 4, -6, 1,
|
||||
1, 2, 4, 2
|
||||
);
|
||||
}
|
||||
sw.Stop();
|
||||
|
||||
@@ -53,7 +60,12 @@ namespace StgSharp
|
||||
sw2.Start();
|
||||
for (int i = 0; i < time; i++)
|
||||
{
|
||||
System.Numerics.Matrix4x4 mat = m * m;
|
||||
System.Numerics.Matrix4x4 test = new System.Numerics.Matrix4x4(
|
||||
1, 1, -1, 2,
|
||||
-1, -1, -4, 1,
|
||||
2, 4, -6, 1,
|
||||
1, 2, 4, 2
|
||||
);
|
||||
}
|
||||
sw2.Stop();
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -26,6 +26,7 @@
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"C:\\Program Files\\dotnet\\library-packs": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"C:\\Program Files\\dotnet\\library-packs": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "bJeaJ29NiRKRDDL14x43+x7ppAyg6cFYHEJ+iaHmGnptYwgfeAM5gtujyal3rrYEkfMuojEy1I3XTltcs9FMxA==",
|
||||
"dgSpecHash": "EIWMDFy9zzJrykYjrfUBwHbP9SwB8ZoyVm5HhjnpN+8CBIi2Zd+p6o35FnDHiYyxjYWf47TWyG6ymafb5pKNVw==",
|
||||
"success": true,
|
||||
"projectFilePath": "D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\源代码\\StgSharpDebug\\StgSharpDebug.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -99,7 +99,7 @@ typedef struct matrix3map
|
||||
{
|
||||
__m128 colum[3];
|
||||
float m[4][3];
|
||||
};
|
||||
}matrix3map;
|
||||
|
||||
typedef union matrix4map {
|
||||
__m128 colum[4];
|
||||
@@ -118,10 +118,9 @@ typedef struct matrix4 {
|
||||
|
||||
#pragma region mat2
|
||||
|
||||
SSGC_API __inline matrix2map* __cdecl add_mat2(matrix2map* mat1, matrix2map* mat2);
|
||||
SSGC_API __inline matrix2map* __cdecl sub_mat2(matrix2map* mat1, matrix2map* mat2);
|
||||
|
||||
SSGC_API __inline void __cdecl transmpose2to4(matrix2map* source, matrix4map* target);
|
||||
SSGC_API _inline void __cdecl transpose2to3(matrix2map* source, matrix3map* target);
|
||||
SSGC_API _inline void __cdecl transpose2to4(matrix2map* source, matrix4map* target);
|
||||
|
||||
SSGC_API _inline void __cdecl deinit_mat2(matrix2map* mat);
|
||||
|
||||
@@ -130,6 +129,11 @@ SSGC_API _inline void __cdecl deinit_mat2(matrix2map* mat);
|
||||
|
||||
#pragma region mat3
|
||||
|
||||
|
||||
SSGC_API __inline void _cdecl transpose3to2(matrix3map* source, matrix2map* target);
|
||||
SSGC_API __inline void _cdecl transpose3to3(matrix3map* source, matrix3map* target);
|
||||
SSGC_API __inline void _cdecl transpose3to4(matrix3map* source, matrix4map* target);
|
||||
|
||||
SSGC_API __inline float det_mat3_internal(__m128 const c1, __m128 const c2, __m128 const c3);
|
||||
|
||||
#pragma endregion
|
||||
@@ -140,15 +144,11 @@ SSGC_API __inline float det_mat3_internal(__m128 const c1, __m128 const c2, __m1
|
||||
#pragma region mat4
|
||||
//type and function for 4 colum matrix
|
||||
|
||||
SSGC_API __inline matrix4map* __cdecl add_mat4(matrix4map* mat1, matrix4map* mat2);
|
||||
SSGC_API __inline matrix4map* __cdecl sub_mat4(matrix4map* mat1, matrix4map* mat2);
|
||||
SSGC_API __inline matrix4map* __cdecl mul_const(matrix4map* mat, float value);
|
||||
SSGC_API __inline matrix4* __cdecl mul_4_4(matrix4map* left, matrix4map* right);
|
||||
|
||||
SSGC_API __inline void __cdecl transpose4to2(matrix4map* source, matrix4map* target);
|
||||
SSGC_API __inline void __cdecl transpose4to4(matrix4map* matrix, matrix4map* target);
|
||||
|
||||
SSGC_API __inline float __cdecl det_mat4(matrix4* matPtr);
|
||||
SSGC_API __inline float __cdecl det_mat4(matrix4map* matPtr, matrix4map* transpose);
|
||||
|
||||
SSGC_API __inline void __cdecl deinit_mat4(matrix4map* matPtr);
|
||||
|
||||
|
||||
@@ -1,34 +1,19 @@
|
||||
#include "StgSharpGraphic.h"
|
||||
|
||||
|
||||
SSGC_API _inline matrix2map* __cdecl add_mat2(matrix2map* mat1, matrix2map* mat2)
|
||||
|
||||
|
||||
SSGC_API _inline void __cdecl transpose2to3(matrix2map* source, matrix3map* target)
|
||||
{
|
||||
matrix2map* ret = _aligned_malloc(sizeof(matrix2map), 16);
|
||||
__m128 t0 = _mm_shuffle_ps(ALIGN(source->colum[0]), ALIGN(source->colum[1]), _MM_SHUFFLE(1, 0, 1, 0));
|
||||
__m128 t1 = _mm_shuffle_ps(ALIGN(source->colum[0]), ALIGN(source->colum[1]), _MM_SHUFFLE(3, 2, 3, 2));
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
ret->colum[0] = _mm_add_ps(mat1->colum[0], mat2->colum[0]);
|
||||
ret->colum[1] = _mm_add_ps(mat1->colum[1], mat2->colum[1]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
target->colum[0] = _mm_shuffle_ps(t0, *defaultVecPtr, _MM_SHUFFLE(2, 0, 2, 0));
|
||||
target->colum[1] = _mm_shuffle_ps(t0, *defaultVecPtr, _MM_SHUFFLE(3, 1, 3, 1));
|
||||
target->colum[2] = _mm_shuffle_ps(t1, *defaultVecPtr, _MM_SHUFFLE(2, 0, 2, 0));
|
||||
}
|
||||
|
||||
SSGC_API _inline matrix2map* __cdecl sub_mat2(matrix2map* mat1, matrix2map* mat2)
|
||||
{
|
||||
matrix2map* ret = _aligned_malloc(sizeof(matrix2map), 16);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
ret->colum[0] = _mm_sub_ps(mat1->colum[0], mat2->colum[0]);
|
||||
ret->colum[1] = _mm_sub_ps(mat1->colum[1], mat2->colum[1]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
SSGC_API _inline void __cdecl transmpose2to4(matrix2map* source, matrix4map* target)
|
||||
SSGC_API _inline void __cdecl transpose2to4(matrix2map* source, matrix4map* target)
|
||||
{
|
||||
__m128 t0 = _mm_shuffle_ps(ALIGN(source->colum[0]), ALIGN(source->colum[1]), _MM_SHUFFLE(1, 0, 1, 0));
|
||||
__m128 t1 = _mm_shuffle_ps(ALIGN(source->colum[0]), ALIGN(source->colum[1]), _MM_SHUFFLE(3, 2, 3, 2));
|
||||
|
||||
+39
-11
@@ -1,14 +1,47 @@
|
||||
#include "StgSharpGraphic.h"
|
||||
#include <stdio.h>
|
||||
|
||||
SSGC_API __inline void _cdecl transpose3to2(matrix3map* source, matrix2map* target)
|
||||
{
|
||||
__m128 t0 = _mm_shuffle_ps(ALIGN(source->colum[0]), ALIGN(source->colum[1]), _MM_SHUFFLE(1, 0, 1, 0));
|
||||
__m128 t2 = _mm_shuffle_ps(ALIGN(source->colum[2]), *defaultVecPtr, _MM_SHUFFLE(1, 0, 1, 0));
|
||||
|
||||
target->colum[0] = _mm_shuffle_ps(t0, t2, _MM_SHUFFLE(2, 0, 2, 0));
|
||||
target->colum[1] = _mm_shuffle_ps(t0, t2, _MM_SHUFFLE(3, 1, 3, 1));
|
||||
}
|
||||
|
||||
SSGC_API __inline void _cdecl transpose3to3(matrix3map* source, matrix3map* target)
|
||||
{
|
||||
__m128 t0 = _mm_shuffle_ps(ALIGN(source->colum[0]), ALIGN(source->colum[1]), _MM_SHUFFLE(1, 0, 1, 0));
|
||||
__m128 t1 = _mm_shuffle_ps(ALIGN(source->colum[0]), ALIGN(source->colum[1]), _MM_SHUFFLE(3, 2, 3, 2));
|
||||
__m128 t2 = _mm_shuffle_ps(ALIGN(source->colum[2]), *defaultVecPtr, _MM_SHUFFLE(1, 0, 1, 0));
|
||||
__m128 t3 = _mm_shuffle_ps(ALIGN(source->colum[2]), *defaultVecPtr, _MM_SHUFFLE(3, 2, 3, 2));
|
||||
|
||||
target->colum[0] = _mm_shuffle_ps(t0, t2, _MM_SHUFFLE(2, 0, 2, 0));
|
||||
target->colum[1] = _mm_shuffle_ps(t0, t2, _MM_SHUFFLE(3, 1, 3, 1));
|
||||
target->colum[2] = _mm_shuffle_ps(t1, t3, _MM_SHUFFLE(2, 0, 2, 0));
|
||||
}
|
||||
|
||||
|
||||
SSGC_API __inline void _cdecl transpose3to4(matrix3map* source, matrix4map* target)
|
||||
{
|
||||
__m128 t0 = _mm_shuffle_ps(ALIGN(source->colum[0]), ALIGN(source->colum[1]), _MM_SHUFFLE(1, 0, 1, 0));
|
||||
__m128 t1 = _mm_shuffle_ps(ALIGN(source->colum[0]), ALIGN(source->colum[1]), _MM_SHUFFLE(3, 2, 3, 2));
|
||||
__m128 t2 = _mm_shuffle_ps(ALIGN(source->colum[2]), *defaultVecPtr, _MM_SHUFFLE(1, 0, 1, 0));
|
||||
__m128 t3 = _mm_shuffle_ps(ALIGN(source->colum[2]), *defaultVecPtr, _MM_SHUFFLE(3, 2, 3, 2));
|
||||
|
||||
target->colum[0] = _mm_shuffle_ps(t0, t2, _MM_SHUFFLE(2, 0, 2, 0));
|
||||
target->colum[1] = _mm_shuffle_ps(t0, t2, _MM_SHUFFLE(3, 1, 3, 1));
|
||||
target->colum[2] = _mm_shuffle_ps(t1, t3, _MM_SHUFFLE(2, 0, 2, 0));
|
||||
target->colum[3] = _mm_shuffle_ps(t1, t3, _MM_SHUFFLE(3, 1, 3, 1));
|
||||
}
|
||||
|
||||
float det_mat3_internal(__m128 const c0, __m128 const c1, __m128 const c2)
|
||||
{
|
||||
|
||||
//let adding row aligned
|
||||
__m128 addc1 = _mm_shuffle_ps(c1, c1, _MM_SHUFFLE(3, 0, 2, 1));
|
||||
__m128 addc2 = _mm_shuffle_ps(c2, c1, _MM_SHUFFLE(3, 1, 0, 2));
|
||||
|
||||
printf("%f\t%f\t%f\n", addc1.m128_f32[0], addc1.m128_f32[1], addc1.m128_f32[2]);
|
||||
printf("%f\t%f\t%f\n\n", addc2.m128_f32[0], addc2.m128_f32[1], addc2.m128_f32[2]);
|
||||
__m128 addc2 = _mm_shuffle_ps(c2, c2, _MM_SHUFFLE(3, 1, 0, 2));
|
||||
|
||||
//let sub row aligned
|
||||
__m128 subc1 = _mm_shuffle_ps(c1, c1, _MM_SHUFFLE(3, 1, 0, 2));
|
||||
@@ -18,13 +51,9 @@ float det_mat3_internal(__m128 const c0, __m128 const c1, __m128 const c2)
|
||||
__m128 cache = _mm_mul_ps(c0,addc1);
|
||||
cache = _mm_mul_ps(cache,addc2);
|
||||
|
||||
printf("%f\t%f\t%f\n\n", cache.m128_f32[0], cache.m128_f32[1], cache.m128_f32[2]);
|
||||
|
||||
//multiple all sub row
|
||||
__m128 sub = _mm_mul_ps(c0, subc1);
|
||||
sub = _mm_mul_ps(sub, subc1);
|
||||
|
||||
printf("%f\t%f\t%f\n\n", sub.m128_f32[0], sub.m128_f32[1], sub.m128_f32[2]);
|
||||
sub = _mm_mul_ps(sub, subc2);
|
||||
|
||||
//main-corner sub sub-corner
|
||||
cache = _mm_sub_ps(cache,sub);
|
||||
@@ -32,7 +61,6 @@ float det_mat3_internal(__m128 const c0, __m128 const c1, __m128 const c2)
|
||||
__m128 ret = _mm_hadd_ps(cache,cache); //element 1 add element 2
|
||||
ret = _mm_add_ps(ret, cache); //(e1 add e2) add element 3
|
||||
|
||||
int a = *(int*)0; //for debug, all an excepotion
|
||||
|
||||
return ret.m128_f32[3] + a;
|
||||
return ret.m128_f32[2];
|
||||
}
|
||||
|
||||
+26
-75
@@ -3,73 +3,7 @@
|
||||
#include <pmmintrin.h>
|
||||
|
||||
|
||||
SSGC_API matrix4map* add_mat4(matrix4map* mat1, matrix4map* mat2)
|
||||
{
|
||||
matrix4map* ret = _aligned_malloc(sizeof(matrix4), 16);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
ret->colum[0] = _mm_add_ps(mat1->colum[0], mat2->colum[0]);
|
||||
ret->colum[1] = _mm_add_ps(mat1->colum[1], mat2->colum[1]);
|
||||
ret->colum[2] = _mm_add_ps(mat1->colum[2], mat2->colum[2]);
|
||||
ret->colum[3] = _mm_add_ps(mat1->colum[3], mat2->colum[3]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SSGC_API matrix4map* sub_mat4(matrix4map* mat1, matrix4map* mat2)
|
||||
{
|
||||
matrix4map* ret = _aligned_malloc(sizeof(matrix4), 16);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
ret->colum[0] = _mm_sub_ps(mat1->colum[0], mat2->colum[0]);
|
||||
ret->colum[1] = _mm_sub_ps(mat1->colum[1], mat2->colum[1]);
|
||||
ret->colum[2] = _mm_sub_ps(mat1->colum[2], mat2->colum[2]);
|
||||
ret->colum[3] = _mm_sub_ps(mat1->colum[3], mat2->colum[3]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SSGC_API __inline matrix4map* __cdecl mul_const(matrix4map* mat, float value)
|
||||
{
|
||||
matrix4map* ret = _aligned_malloc(sizeof(matrix4),16);
|
||||
|
||||
if (NULL != ret)
|
||||
{
|
||||
float cstarray[4] = { value, value, value, value };
|
||||
|
||||
__m128 cst128 = _mm_loadu_ps(&cstarray);
|
||||
|
||||
ret->colum[0] = _mm_mul_ps(mat->colum[0], cst128);
|
||||
ret->colum[1] = _mm_mul_ps(mat->colum[1], cst128);
|
||||
ret->colum[2] = _mm_mul_ps(mat->colum[2], cst128);
|
||||
ret->colum[3] = _mm_mul_ps(mat->colum[3], cst128);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
//left is the transposed matrix of real left
|
||||
SSGC_API __inline matrix4* __cdecl mul_4_4(matrix4map* left, matrix4map* right)
|
||||
{
|
||||
matrix4map* retPtr = _aligned_malloc(sizeof(matrix4map), 16);
|
||||
if (NULL != retPtr)
|
||||
{
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
for (size_t t = 0; t < 4; t++)
|
||||
{
|
||||
retPtr->m[i][t] = mulps_sum_internal(
|
||||
ALIGN( left->colum[i]),ALIGN(right->colum[t]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return retPtr;
|
||||
}
|
||||
|
||||
SSGC_API __inline void __cdecl transpose4to2(matrix4map* source, matrix4map* target)
|
||||
{
|
||||
@@ -94,18 +28,35 @@ SSGC_API __inline void __cdecl transpose4to4(matrix4map* source, matrix4map* tar
|
||||
|
||||
}
|
||||
|
||||
SSGC_API __inline float __cdecl det_mat4(matrix4* matPtr)
|
||||
SSGC_API __inline void __cdecl transpose4to3(matrix4map* source, matrix3map* target)
|
||||
{
|
||||
__m128 t0 = _mm_shuffle_ps(ALIGN(source->colum[0]), ALIGN(source->colum[1]), _MM_SHUFFLE(1, 0, 1, 0));
|
||||
__m128 t1 = _mm_shuffle_ps(ALIGN(source->colum[0]), ALIGN(source->colum[1]), _MM_SHUFFLE(3, 2, 3, 2));
|
||||
__m128 t2 = _mm_shuffle_ps(ALIGN(source->colum[2]), ALIGN(source->colum[3]), _MM_SHUFFLE(1, 0, 1, 0));
|
||||
__m128 t3 = _mm_shuffle_ps(ALIGN(source->colum[2]), ALIGN(source->colum[3]), _MM_SHUFFLE(3, 2, 3, 2));
|
||||
|
||||
target->colum[0] = _mm_shuffle_ps(t0, t2, _MM_SHUFFLE(2, 0, 2, 0));
|
||||
target->colum[1] = _mm_shuffle_ps(t0, t2, _MM_SHUFFLE(3, 1, 3, 1));
|
||||
target->colum[2] = _mm_shuffle_ps(t1, t3, _MM_SHUFFLE(2, 0, 2, 0));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
SSGC_API __inline float __cdecl det_mat4(matrix4map* matPtr, matrix4map* transpose)
|
||||
{
|
||||
__m128 mc0 = ALIGN(matPtr->colum[0]);
|
||||
__m128 mc1 = ALIGN(matPtr->colum[1]);
|
||||
__m128 mc2 = ALIGN(matPtr->colum[2]);
|
||||
__m128 mc3 = ALIGN(matPtr->colum[3]);
|
||||
|
||||
__m128 cogeneration = _mm_set_ps(
|
||||
det_mat3_internal(matPtr->matrix.colum[1], matPtr->matrix.colum[2], matPtr->matrix.colum[3]),
|
||||
det_mat3_internal(matPtr->matrix.colum[0], matPtr->matrix.colum[2], matPtr->matrix.colum[3]),
|
||||
det_mat3_internal(matPtr->matrix.colum[0], matPtr->matrix.colum[1], matPtr->matrix.colum[3]),
|
||||
det_mat3_internal(matPtr->matrix.colum[0], matPtr->matrix.colum[1], matPtr->matrix.colum[2])
|
||||
det_mat3_internal(mc0, mc1, mc2),
|
||||
det_mat3_internal(mc0, mc1, mc3),
|
||||
det_mat3_internal(mc0, mc2, mc3),
|
||||
det_mat3_internal(mc1, mc2, mc3)
|
||||
);
|
||||
|
||||
printf("%f\n\n", det_mat3_internal(matPtr->matrix.colum[1], matPtr->matrix.colum[2], matPtr->matrix.colum[3]));
|
||||
|
||||
__m128 retvec = _mm_mul_ps((matPtr->transpose).colum[3],cogeneration);
|
||||
__m128 retvec = _mm_mul_ps(ALIGN(transpose->colum[3]),cogeneration);
|
||||
retvec = _mm_hsub_ps(retvec,retvec);
|
||||
retvec = _mm_hadd_ps(retvec,retvec);
|
||||
return -retvec.m128_f32[0];
|
||||
|
||||
@@ -1,27 +1,32 @@
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\vc143.pdb
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\vc143.idb
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.obj
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\dllmain.obj
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\glad.obj
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.cod
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\linear.obj
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\linear.cod
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\dllmain.obj
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\dllmain.cod
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\glad.obj
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\glad.cod
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgshqrpgraphic.ilk
|
||||
d:\nitloadindustry\研究项目\1-flagship\huftdt cooperation\2023固火方案4\cfs\cadc_flight_simulator\x64\debug\stgshqrpgraphic.dll
|
||||
d:\nitloadindustry\研究项目\1-flagship\huftdt cooperation\2023固火方案4\cfs\cadc_flight_simulator\x64\debug\stgshqrpgraphic.pdb
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpgraphic.dll
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\mat4.obj
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\mat4.cod
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\mat3.obj
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\mat3.cod
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\mat2.obj
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\mat2.cod
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.ilk
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpgraphic.pdb
|
||||
d:\nitloadindustry\研究项目\1-flagship\huftdt cooperation\2023固火方案4\cfs\cadc_flight_simulator\x64\debug\stgshqrpgraphic.lib
|
||||
d:\nitloadindustry\研究项目\1-flagship\huftdt cooperation\2023固火方案4\cfs\cadc_flight_simulator\x64\debug\stgshqrpgraphic.exp
|
||||
d:\nitloadindustry\研究项目\1-flagship\huftdt cooperation\2023固火方案4\cfs\cadc_flight_simulator\stgsharpgraphic.dll
|
||||
d:\nitloadindustry\研究项目\1-flagship\huftdt cooperation\2023固火方案4\cfs\cadc_flight_simulator\stgsharpgraphic.pdb
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpgraphic.lib
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpgraphic.exp
|
||||
d:\nitloadindustry\研究项目\1-flagship\huftdt cooperation\2023固火方案4\cfs\cadc_flight_simulator\stgsharpgraphic.lib
|
||||
d:\nitloadindustry\研究项目\1-flagship\huftdt cooperation\2023固火方案4\cfs\cadc_flight_simulator\stgsharpgraphic.exp
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.tlog\cl.command.1.tlog
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.tlog\cl.items.tlog
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.tlog\cl.read.1.tlog
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.tlog\cl.write.1.tlog
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.tlog\link.command.1.tlog
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.tlog\link.read.1.tlog
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.tlog\link.write.1.tlog
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.tlog\link.write.2u.tlog
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgshqrpgraphic\x64\debug\stgsharpgraphic.tlog\stgsharpgraphic.write.1u.tlog
|
||||
|
||||
@@ -6,7 +6,6 @@ INCLUDELIB MSVCRT
|
||||
INCLUDELIB OLDNAMES
|
||||
|
||||
_DATA SEGMENT
|
||||
COMM sseFunc:BYTE:018H
|
||||
COMM pack:BYTE:038H
|
||||
_DATA ENDS
|
||||
msvcjmc SEGMENT
|
||||
@@ -111,12 +110,19 @@ __BC6D10F5_ime_cmodes@h DB 01H
|
||||
__1D49718C_imm@h DB 01H
|
||||
__95734585_windows@h DB 01H
|
||||
__F7492337_framework@h DB 01H
|
||||
__C508448F_StgSharpGraphic@h DB 01H
|
||||
__9BEA891A_mmintrin@h DB 01H
|
||||
__494656A0_corecrt_malloc@h DB 01H
|
||||
__E5D9469F_malloc@h DB 01H
|
||||
__7FB111F1_xmmintrin@h DB 01H
|
||||
__203A43BB_SSGinternal@h DB 01H
|
||||
__1AD3983D_emmintrin@h DB 01H
|
||||
__C572F0B4_pmmintrin@h DB 01H
|
||||
__75AB8336_tmmintrin@h DB 01H
|
||||
__5C9096B5_smmintrin@h DB 01H
|
||||
__39F21F79_nmmintrin@h DB 01H
|
||||
__EC49E537_wmmintrin@h DB 01H
|
||||
__27DDA830_zmmintrin@h DB 01H
|
||||
__10C90AFA_immintrin@h DB 01H
|
||||
__C508448F_StgSharpGraphic@h DB 01H
|
||||
__52DA9D07_StgSharpGraphic@c DB 01H
|
||||
msvcjmc ENDS
|
||||
PUBLIC loadGLApi
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpGraphic.dll</FullPath>
|
||||
<FullPath>D:\NitloadIndustry\研究项目\1-Flagship\HUFTDT Cooperation\2023固火方案4\CFS\CADC_flight_simulator\StgSharpGraphic.dll</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,7 @@
|
||||
D:\Programmer\GLenv\glad.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\x64\Debug\glad.obj
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\dllmain.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\x64\Debug\dllmain.obj
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\linear.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\x64\Debug\linear.obj
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\mat2.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\x64\Debug\mat2.obj
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\mat3.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\x64\Debug\mat3.obj
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\mat4.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\x64\Debug\mat4.obj
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\StgSharpGraphic.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgShqrpGraphic\x64\Debug\StgSharpGraphic.obj
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.36.32532:TargetPlatformVersion=10.0.22000.0:
|
||||
Debug|x64|D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\|
|
||||
Debug|x64|D:\NitloadIndustry\研究项目\1-Flagship\HUFTDT Cooperation\2023固火方案4\CFS\CADC_flight_simulator\|
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -5,8 +5,11 @@ include listing.inc
|
||||
INCLUDELIB MSVCRT
|
||||
INCLUDELIB OLDNAMES
|
||||
|
||||
PUBLIC defaultVecPtr
|
||||
_BSS SEGMENT
|
||||
defaultVecPtr DQ 01H DUP (?)
|
||||
_BSS ENDS
|
||||
_DATA SEGMENT
|
||||
COMM sseFunc:BYTE:018H
|
||||
COMM pack:BYTE:038H
|
||||
_DATA ENDS
|
||||
msvcjmc SEGMENT
|
||||
@@ -111,27 +114,35 @@ __018B5678_khrplatform@h DB 01H
|
||||
__79FC18F0_glad@h DB 01H
|
||||
__0C5B3DCC_stddef@h DB 01H
|
||||
__986CAB3E_glfw3@h DB 01H
|
||||
__C508448F_StgSharpGraphic@h DB 01H
|
||||
__9BEA891A_mmintrin@h DB 01H
|
||||
__494656A0_corecrt_malloc@h DB 01H
|
||||
__E5D9469F_malloc@h DB 01H
|
||||
__7FB111F1_xmmintrin@h DB 01H
|
||||
__203A43BB_SSGinternal@h DB 01H
|
||||
__1AD3983D_emmintrin@h DB 01H
|
||||
__C572F0B4_pmmintrin@h DB 01H
|
||||
__75AB8336_tmmintrin@h DB 01H
|
||||
__5C9096B5_smmintrin@h DB 01H
|
||||
__39F21F79_nmmintrin@h DB 01H
|
||||
__EC49E537_wmmintrin@h DB 01H
|
||||
__27DDA830_zmmintrin@h DB 01H
|
||||
__10C90AFA_immintrin@h DB 01H
|
||||
__C508448F_StgSharpGraphic@h DB 01H
|
||||
__BA7172FA_dllmain@c DB 01H
|
||||
msvcjmc ENDS
|
||||
PUBLIC DllMain
|
||||
PUBLIC __JustMyCode_Default
|
||||
EXTRN __imp__aligned_malloc:PROC
|
||||
EXTRN __CheckForDebuggerJustMyCode:PROC
|
||||
; COMDAT pdata
|
||||
pdata SEGMENT
|
||||
$pdata$DllMain DD imagerel $LN10
|
||||
DD imagerel $LN10+26
|
||||
$pdata$DllMain DD imagerel $LN24
|
||||
DD imagerel $LN24+68
|
||||
DD imagerel $unwind$DllMain
|
||||
pdata ENDS
|
||||
; COMDAT xdata
|
||||
xdata SEGMENT
|
||||
$unwind$DllMain DD 010401H
|
||||
DD 04204H
|
||||
$unwind$DllMain DD 020601H
|
||||
DD 030023206H
|
||||
xdata ENDS
|
||||
; Function compile flags: /Odt
|
||||
; COMDAT __JustMyCode_Default
|
||||
@@ -151,29 +162,60 @@ DllMain PROC ; COMDAT
|
||||
|
||||
; 17 : {
|
||||
|
||||
$LN10:
|
||||
00000 48 83 ec 28 sub rsp, 40 ; 00000028H
|
||||
00004 48 8d 0d 00 00
|
||||
$LN24:
|
||||
00000 40 53 push rbx
|
||||
00002 48 83 ec 20 sub rsp, 32 ; 00000020H
|
||||
00006 48 8d 0d 00 00
|
||||
00 00 lea rcx, OFFSET FLAT:__BA7172FA_dllmain@c
|
||||
0000b e8 00 00 00 00 call __CheckForDebuggerJustMyCode
|
||||
00010 b8 01 00 00 00 mov eax, 1
|
||||
0000d 8b da mov ebx, edx
|
||||
0000f e8 00 00 00 00 call __CheckForDebuggerJustMyCode
|
||||
00014 83 fb 01 cmp ebx, 1
|
||||
00017 75 20 jne SHORT $LN20@DllMain
|
||||
00019 0f 1f 80 00 00
|
||||
00 00 npad 7
|
||||
$LL6@DllMain:
|
||||
|
||||
; 18 : switch (ul_reason_for_call)
|
||||
; 19 : {
|
||||
; 20 : case DLL_PROCESS_ATTACH:
|
||||
; 21 :
|
||||
; 22 : case DLL_THREAD_ATTACH:
|
||||
; 23 :
|
||||
; 24 :
|
||||
; 25 : case DLL_THREAD_DETACH:
|
||||
; 26 : case DLL_PROCESS_DETACH:
|
||||
; 27 : break;
|
||||
; 28 : }
|
||||
; 29 : return TRUE;
|
||||
; 30 : }
|
||||
; 21 : do
|
||||
; 22 : {
|
||||
; 23 : defaultVecPtr = _aligned_malloc(sizeof(__m128),16);
|
||||
|
||||
00015 48 83 c4 28 add rsp, 40 ; 00000028H
|
||||
00019 c3 ret 0
|
||||
00020 ba 10 00 00 00 mov edx, 16
|
||||
00025 8b ca mov ecx, edx
|
||||
00027 ff 15 00 00 00
|
||||
00 call QWORD PTR __imp__aligned_malloc
|
||||
0002d 48 89 05 00 00
|
||||
00 00 mov QWORD PTR defaultVecPtr, rax
|
||||
|
||||
; 24 : } while (defaultVecPtr == NULL);
|
||||
|
||||
00034 48 85 c0 test rax, rax
|
||||
00037 74 e7 je SHORT $LL6@DllMain
|
||||
$LN20@DllMain:
|
||||
|
||||
; 25 :
|
||||
; 26 :
|
||||
; 27 : case DLL_THREAD_ATTACH:
|
||||
; 28 :
|
||||
; 29 :
|
||||
; 30 : case DLL_THREAD_DETACH:
|
||||
; 31 :
|
||||
; 32 :
|
||||
; 33 : case DLL_PROCESS_DETACH:
|
||||
; 34 :
|
||||
; 35 :
|
||||
; 36 :
|
||||
; 37 : break;
|
||||
; 38 : }
|
||||
; 39 : return TRUE;
|
||||
; 40 : }
|
||||
|
||||
00039 b8 01 00 00 00 mov eax, 1
|
||||
0003e 48 83 c4 20 add rsp, 32 ; 00000020H
|
||||
00042 5b pop rbx
|
||||
00043 c3 ret 0
|
||||
DllMain ENDP
|
||||
_TEXT ENDS
|
||||
END
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -6,7 +6,6 @@ INCLUDELIB MSVCRT
|
||||
INCLUDELIB OLDNAMES
|
||||
|
||||
_DATA SEGMENT
|
||||
COMM sseFunc:BYTE:018H
|
||||
COMM pack:BYTE:038H
|
||||
_DATA ENDS
|
||||
msvcjmc SEGMENT
|
||||
@@ -20,20 +19,27 @@ __79FC18F0_glad@h DB 01H
|
||||
__04C75F1C_corecrt@h DB 01H
|
||||
__0C5B3DCC_stddef@h DB 01H
|
||||
__986CAB3E_glfw3@h DB 01H
|
||||
__C508448F_StgSharpGraphic@h DB 01H
|
||||
__9BEA891A_mmintrin@h DB 01H
|
||||
__494656A0_corecrt_malloc@h DB 01H
|
||||
__E5D9469F_malloc@h DB 01H
|
||||
__7FB111F1_xmmintrin@h DB 01H
|
||||
__203A43BB_SSGinternal@h DB 01H
|
||||
__1AD3983D_emmintrin@h DB 01H
|
||||
__C572F0B4_pmmintrin@h DB 01H
|
||||
__75AB8336_tmmintrin@h DB 01H
|
||||
__5C9096B5_smmintrin@h DB 01H
|
||||
__39F21F79_nmmintrin@h DB 01H
|
||||
__EC49E537_wmmintrin@h DB 01H
|
||||
__27DDA830_zmmintrin@h DB 01H
|
||||
__10C90AFA_immintrin@h DB 01H
|
||||
__C508448F_StgSharpGraphic@h DB 01H
|
||||
__C44F8F6B_corecrt_stdio_config@h DB 01H
|
||||
__A7F89B2B_corecrt_wstdio@h DB 01H
|
||||
__B5C48800_stdio@h DB 01H
|
||||
__62BFBAF5_stdalign@h DB 01H
|
||||
__1AD3983D_emmintrin@h DB 01H
|
||||
__C572F0B4_pmmintrin@h DB 01H
|
||||
__B5461FF6_linear@c DB 01H
|
||||
msvcjmc ENDS
|
||||
PUBLIC mulps_sum_internal
|
||||
PUBLIC mulps_total_internal
|
||||
PUBLIC load
|
||||
PUBLIC load_cpy
|
||||
PUBLIC addps
|
||||
@@ -44,14 +50,26 @@ PUBLIC mulps_sum
|
||||
PUBLIC divps_const
|
||||
PUBLIC divps
|
||||
PUBLIC sqrtss_const
|
||||
PUBLIC set_m128ptr_default
|
||||
PUBLIC deinitM128
|
||||
PUBLIC load_matmap
|
||||
PUBLIC __JustMyCode_Default
|
||||
EXTRN __imp_free:PROC
|
||||
EXTRN __imp__aligned_free:PROC
|
||||
EXTRN __imp__aligned_malloc:PROC
|
||||
EXTRN __CheckForDebuggerJustMyCode:PROC
|
||||
EXTRN __GSHandlerCheck:PROC
|
||||
EXTRN __security_check_cookie:PROC
|
||||
EXTRN defaultVecPtr:QWORD
|
||||
EXTRN __security_cookie:QWORD
|
||||
EXTRN _fltused:DWORD
|
||||
; COMDAT pdata
|
||||
pdata SEGMENT
|
||||
$pdata$mulps_sum_internal DD imagerel $LN4
|
||||
DD imagerel $LN4+53
|
||||
DD imagerel $unwind$mulps_sum_internal
|
||||
pdata ENDS
|
||||
; COMDAT pdata
|
||||
pdata SEGMENT
|
||||
$pdata$load DD imagerel $LN7
|
||||
DD imagerel $LN7+140
|
||||
DD imagerel $unwind$load
|
||||
@@ -112,10 +130,32 @@ $pdata$sqrtss_const DD imagerel $LN4
|
||||
pdata ENDS
|
||||
; COMDAT pdata
|
||||
pdata SEGMENT
|
||||
$pdata$set_m128ptr_default DD imagerel $LN4
|
||||
DD imagerel $LN4+28
|
||||
DD imagerel $unwind$set_m128ptr_default
|
||||
pdata ENDS
|
||||
; COMDAT pdata
|
||||
pdata SEGMENT
|
||||
$pdata$deinitM128 DD imagerel $LN4
|
||||
DD imagerel $LN4+36
|
||||
DD imagerel $unwind$deinitM128
|
||||
pdata ENDS
|
||||
; COMDAT pdata
|
||||
pdata SEGMENT
|
||||
$pdata$load_matmap DD imagerel $LN7
|
||||
DD imagerel $LN7+146
|
||||
DD imagerel $unwind$load_matmap
|
||||
pdata ENDS
|
||||
; COMDAT xdata
|
||||
xdata SEGMENT
|
||||
$unwind$load_matmap DD 082419H
|
||||
DD 0e7415H
|
||||
DD 0d6415H
|
||||
DD 0c3415H
|
||||
DD 0e0119215H
|
||||
DD imagerel __GSHandlerCheck
|
||||
DD 040H
|
||||
xdata ENDS
|
||||
; COMDAT xdata
|
||||
xdata SEGMENT
|
||||
$unwind$deinitM128 DD 020601H
|
||||
@@ -123,6 +163,11 @@ $unwind$deinitM128 DD 020601H
|
||||
xdata ENDS
|
||||
; COMDAT xdata
|
||||
xdata SEGMENT
|
||||
$unwind$set_m128ptr_default DD 010401H
|
||||
DD 04204H
|
||||
xdata ENDS
|
||||
; COMDAT xdata
|
||||
xdata SEGMENT
|
||||
$unwind$sqrtss_const DD 030901H
|
||||
DD 026809H
|
||||
DD 06204H
|
||||
@@ -183,6 +228,12 @@ $unwind$load DD 092701H
|
||||
DD 066809H
|
||||
DD 0e204H
|
||||
xdata ENDS
|
||||
; COMDAT xdata
|
||||
xdata SEGMENT
|
||||
$unwind$mulps_sum_internal DD 040a01H
|
||||
DD 06340aH
|
||||
DD 07006320aH
|
||||
xdata ENDS
|
||||
; Function compile flags: /Odt
|
||||
; COMDAT __JustMyCode_Default
|
||||
_TEXT SEGMENT
|
||||
@@ -192,12 +243,85 @@ __JustMyCode_Default ENDP
|
||||
_TEXT ENDS
|
||||
; Function compile flags: /Ogtpy
|
||||
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
|
||||
; COMDAT load_matmap
|
||||
_TEXT SEGMENT
|
||||
ptr$ = 32
|
||||
__$ArrayPad$ = 64
|
||||
c0$ = 96
|
||||
c1$ = 104
|
||||
c2$ = 112
|
||||
c3$ = 120
|
||||
load_matmap PROC ; COMDAT
|
||||
|
||||
; 182 : {
|
||||
|
||||
$LN7:
|
||||
00000 48 89 5c 24 08 mov QWORD PTR [rsp+8], rbx
|
||||
00005 48 89 74 24 10 mov QWORD PTR [rsp+16], rsi
|
||||
0000a 48 89 7c 24 18 mov QWORD PTR [rsp+24], rdi
|
||||
0000f 41 56 push r14
|
||||
00011 48 83 ec 50 sub rsp, 80 ; 00000050H
|
||||
00015 48 8b 05 00 00
|
||||
00 00 mov rax, QWORD PTR __security_cookie
|
||||
0001c 48 33 c4 xor rax, rsp
|
||||
0001f 48 89 44 24 40 mov QWORD PTR __$ArrayPad$[rsp], rax
|
||||
00024 48 8b d9 mov rbx, rcx
|
||||
00027 4d 8b f1 mov r14, r9
|
||||
0002a 48 8d 0d 00 00
|
||||
00 00 lea rcx, OFFSET FLAT:__B5461FF6_linear@c
|
||||
00031 49 8b f0 mov rsi, r8
|
||||
00034 48 8b fa mov rdi, rdx
|
||||
00037 e8 00 00 00 00 call __CheckForDebuggerJustMyCode
|
||||
0003c ba 20 00 00 00 mov edx, 32 ; 00000020H
|
||||
00041 8b ca mov ecx, edx
|
||||
00043 ff 15 00 00 00
|
||||
00 call QWORD PTR __imp__aligned_malloc
|
||||
00049 48 89 5c 24 20 mov QWORD PTR ptr$[rsp], rbx
|
||||
0004e 48 89 7c 24 28 mov QWORD PTR ptr$[rsp+8], rdi
|
||||
00053 48 89 74 24 30 mov QWORD PTR ptr$[rsp+16], rsi
|
||||
00058 4c 89 74 24 38 mov QWORD PTR ptr$[rsp+24], r14
|
||||
0005d 48 85 c0 test rax, rax
|
||||
00060 74 0d je SHORT $LN4@load_matma
|
||||
|
||||
; 183 : __m256i* retPtr = _aligned_malloc(sizeof(__m256i), sizeof(__m256i));
|
||||
; 184 :
|
||||
; 185 : uint64_t ptr[4] = {c0,c1,c2,c3 };
|
||||
; 186 :
|
||||
; 187 : if (NULL != retPtr)
|
||||
; 188 : {
|
||||
; 189 : *retPtr = _mm256_loadu_epi64(&ptr);
|
||||
|
||||
00062 c5 fe 6f 44 24
|
||||
20 vmovdqu ymm0, YMMWORD PTR ptr$[rsp]
|
||||
00068 c5 fe 7f 00 vmovdqu YMMWORD PTR [rax], ymm0
|
||||
0006c c5 f8 77 vzeroupper
|
||||
$LN4@load_matma:
|
||||
|
||||
; 190 : }
|
||||
; 191 :
|
||||
; 192 : return retPtr;
|
||||
; 193 :
|
||||
; 194 : }
|
||||
|
||||
0006f 48 8b 4c 24 40 mov rcx, QWORD PTR __$ArrayPad$[rsp]
|
||||
00074 48 33 cc xor rcx, rsp
|
||||
00077 e8 00 00 00 00 call __security_check_cookie
|
||||
0007c 48 8b 5c 24 60 mov rbx, QWORD PTR [rsp+96]
|
||||
00081 48 8b 74 24 68 mov rsi, QWORD PTR [rsp+104]
|
||||
00086 48 8b 7c 24 70 mov rdi, QWORD PTR [rsp+112]
|
||||
0008b 48 83 c4 50 add rsp, 80 ; 00000050H
|
||||
0008f 41 5e pop r14
|
||||
00091 c3 ret 0
|
||||
load_matmap ENDP
|
||||
_TEXT ENDS
|
||||
; Function compile flags: /Ogtpy
|
||||
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
|
||||
; COMDAT deinitM128
|
||||
_TEXT SEGMENT
|
||||
ptr$ = 48
|
||||
deinitM128 PROC ; COMDAT
|
||||
|
||||
; 162 : {
|
||||
; 212 : {
|
||||
|
||||
$LN4:
|
||||
00000 40 53 push rbx
|
||||
@@ -208,23 +332,46 @@ $LN4:
|
||||
00010 e8 00 00 00 00 call __CheckForDebuggerJustMyCode
|
||||
00015 48 8b cb mov rcx, rbx
|
||||
|
||||
; 163 : free(ptr);
|
||||
; 164 : }
|
||||
; 213 : _aligned_free(ptr);
|
||||
; 214 : }
|
||||
|
||||
00018 48 83 c4 20 add rsp, 32 ; 00000020H
|
||||
0001c 5b pop rbx
|
||||
0001d 48 ff 25 00 00
|
||||
00 00 rex_jmp QWORD PTR __imp_free
|
||||
00 00 rex_jmp QWORD PTR __imp__aligned_free
|
||||
deinitM128 ENDP
|
||||
_TEXT ENDS
|
||||
; Function compile flags: /Ogtpy
|
||||
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
|
||||
; COMDAT set_m128ptr_default
|
||||
_TEXT SEGMENT
|
||||
set_m128ptr_default PROC ; COMDAT
|
||||
|
||||
; 199 : {
|
||||
|
||||
$LN4:
|
||||
00000 48 83 ec 28 sub rsp, 40 ; 00000028H
|
||||
00004 48 8d 0d 00 00
|
||||
00 00 lea rcx, OFFSET FLAT:__B5461FF6_linear@c
|
||||
0000b e8 00 00 00 00 call __CheckForDebuggerJustMyCode
|
||||
00010 48 8b 05 00 00
|
||||
00 00 mov rax, QWORD PTR defaultVecPtr
|
||||
|
||||
; 200 : return defaultVecPtr;
|
||||
; 201 : }
|
||||
|
||||
00017 48 83 c4 28 add rsp, 40 ; 00000028H
|
||||
0001b c3 ret 0
|
||||
set_m128ptr_default ENDP
|
||||
_TEXT ENDS
|
||||
; Function compile flags: /Ogtpy
|
||||
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
|
||||
; COMDAT sqrtss_const
|
||||
_TEXT SEGMENT
|
||||
a$ = 64
|
||||
sqrtss_const PROC ; COMDAT
|
||||
|
||||
; 147 : {
|
||||
; 169 : {
|
||||
|
||||
$LN4:
|
||||
00000 48 83 ec 38 sub rsp, 56 ; 00000038H
|
||||
@@ -238,11 +385,10 @@ $LN4:
|
||||
00021 0f 28 74 24 20 movaps xmm6, XMMWORD PTR [rsp+32]
|
||||
00026 f3 0f 51 c0 sqrtss xmm0, xmm0
|
||||
|
||||
; 148 : __m128 ret = _mm_sqrt_ss(*(__m128*) & a);
|
||||
; 149 :
|
||||
; 150 : return ret.m128_f32[0];
|
||||
; 151 :
|
||||
; 152 : }
|
||||
; 170 : __m128 ret = _mm_sqrt_ss(*(__m128*) & a);
|
||||
; 171 :
|
||||
; 172 : return ret.m128_f32[0];
|
||||
; 173 : }
|
||||
|
||||
0002a 48 83 c4 38 add rsp, 56 ; 00000038H
|
||||
0002e c3 ret 0
|
||||
@@ -256,7 +402,7 @@ ptr1$ = 48
|
||||
ptr2$ = 56
|
||||
divps PROC ; COMDAT
|
||||
|
||||
; 132 : {
|
||||
; 154 : {
|
||||
|
||||
$LN7:
|
||||
00000 48 89 5c 24 08 mov QWORD PTR [rsp+8], rbx
|
||||
@@ -274,23 +420,23 @@ $LN7:
|
||||
00029 48 85 c0 test rax, rax
|
||||
0002c 74 14 je SHORT $LN2@divps
|
||||
|
||||
; 133 : __m128* ret = _aligned_malloc(sizeof(__m128), 16);
|
||||
; 134 :
|
||||
; 135 : if (NULL != ret)
|
||||
; 136 : {
|
||||
; 137 : *ret = _mm_div_ps(*ptr1, *ptr2);
|
||||
; 155 : __m128* ret = _aligned_malloc(sizeof(__m128), 16);
|
||||
; 156 :
|
||||
; 157 : if (NULL != ret)
|
||||
; 158 : {
|
||||
; 159 : *ret = _mm_div_ps(*ptr1, *ptr2);
|
||||
|
||||
0002e 0f 10 07 movups xmm0, XMMWORD PTR [rdi]
|
||||
00031 0f 5e 03 divps xmm0, XMMWORD PTR [rbx]
|
||||
00034 0f 11 00 movups XMMWORD PTR [rax], xmm0
|
||||
|
||||
; 138 : return ret;
|
||||
; 139 : }
|
||||
; 140 : else
|
||||
; 141 : {
|
||||
; 142 : return -1;
|
||||
; 143 : }
|
||||
; 144 : }
|
||||
; 160 : return ret;
|
||||
; 161 : }
|
||||
; 162 : else
|
||||
; 163 : {
|
||||
; 164 : return -1;
|
||||
; 165 : }
|
||||
; 166 : }
|
||||
|
||||
00037 48 8b 5c 24 30 mov rbx, QWORD PTR [rsp+48]
|
||||
0003c 48 83 c4 20 add rsp, 32 ; 00000020H
|
||||
@@ -314,7 +460,7 @@ ptr$ = 80
|
||||
value$ = 88
|
||||
divps_const PROC ; COMDAT
|
||||
|
||||
; 113 : {
|
||||
; 135 : {
|
||||
|
||||
$LN7:
|
||||
00000 40 53 push rbx
|
||||
@@ -334,28 +480,28 @@ $LN7:
|
||||
00033 48 85 c0 test rax, rax
|
||||
00036 74 17 je SHORT $LN2@divps_cons
|
||||
|
||||
; 114 :
|
||||
; 115 : float c[4] = { value, value, value, value };
|
||||
; 116 : __m128* ret = _aligned_malloc(sizeof(__m128), 16);
|
||||
; 117 :
|
||||
; 118 : __m128 valueVec = _mm_loadu_ps(&c);
|
||||
; 119 :
|
||||
; 120 : if (NULL != ret)
|
||||
; 121 : {
|
||||
; 122 : *ret = _mm_div_ps(*ptr, valueVec);
|
||||
; 136 :
|
||||
; 137 : float c[4] = { value, value, value, value };
|
||||
; 138 : __m128* ret = _aligned_malloc(sizeof(__m128), 16);
|
||||
; 139 :
|
||||
; 140 : __m128 valueVec = _mm_loadu_ps(&c);
|
||||
; 141 :
|
||||
; 142 : if (NULL != ret)
|
||||
; 143 : {
|
||||
; 144 : *ret = _mm_div_ps(*ptr, valueVec);
|
||||
|
||||
00038 0f 10 0b movups xmm1, XMMWORD PTR [rbx]
|
||||
0003b 0f 10 c6 movups xmm0, xmm6
|
||||
0003e 0f 5e ce divps xmm1, xmm6
|
||||
00041 0f 11 08 movups XMMWORD PTR [rax], xmm1
|
||||
|
||||
; 123 : return ret;
|
||||
; 124 : }
|
||||
; 125 : else
|
||||
; 126 : {
|
||||
; 127 : return -1;
|
||||
; 128 : }
|
||||
; 129 : }
|
||||
; 145 : return ret;
|
||||
; 146 : }
|
||||
; 147 : else
|
||||
; 148 : {
|
||||
; 149 : return -1;
|
||||
; 150 : }
|
||||
; 151 : }
|
||||
|
||||
00044 0f 28 74 24 30 movaps xmm6, XMMWORD PTR [rsp+48]
|
||||
00049 48 83 c4 40 add rsp, 64 ; 00000040H
|
||||
@@ -378,7 +524,7 @@ ptr1$ = 48
|
||||
ptr2$ = 56
|
||||
mulps_sum PROC ; COMDAT
|
||||
|
||||
; 105 : {
|
||||
; 114 : {
|
||||
|
||||
$LN4:
|
||||
00000 48 89 5c 24 08 mov QWORD PTR [rsp+8], rbx
|
||||
@@ -395,11 +541,11 @@ $LN4:
|
||||
00027 f2 0f 7c c0 haddps xmm0, xmm0
|
||||
0002b f2 0f 7c c0 haddps xmm0, xmm0
|
||||
|
||||
; 106 : __m128 ret = _mm_mul_ps(*ptr1,*ptr2);
|
||||
; 107 : ret = _mm_hadd_ps(ret,ret);
|
||||
; 108 : ret = _mm_hadd_ps(ret,ret);
|
||||
; 109 : return *(float*)&ret;
|
||||
; 110 : }
|
||||
; 115 : __m128 ret = _mm_mul_ps(*ptr1,*ptr2);
|
||||
; 116 : ret = _mm_hadd_ps(ret,ret);
|
||||
; 117 : ret = _mm_hadd_ps(ret,ret);
|
||||
; 118 : return *(float*)&ret;
|
||||
; 119 : }
|
||||
|
||||
0002f 48 83 c4 20 add rsp, 32 ; 00000020H
|
||||
00033 5f pop rdi
|
||||
@@ -414,7 +560,7 @@ ptr1$ = 48
|
||||
ptr2$ = 56
|
||||
mulps PROC ; COMDAT
|
||||
|
||||
; 90 : {
|
||||
; 99 : {
|
||||
|
||||
$LN7:
|
||||
00000 48 89 5c 24 08 mov QWORD PTR [rsp+8], rbx
|
||||
@@ -432,23 +578,23 @@ $LN7:
|
||||
00029 48 85 c0 test rax, rax
|
||||
0002c 74 14 je SHORT $LN2@mulps
|
||||
|
||||
; 91 : __m128* ret = _aligned_malloc(sizeof(__m128), 16);
|
||||
; 92 :
|
||||
; 93 : if (NULL != ret)
|
||||
; 94 : {
|
||||
; 95 : *ret = _mm_mul_ps(*ptr1, *ptr2);
|
||||
; 100 : __m128* ret = _aligned_malloc(sizeof(__m128), 16);
|
||||
; 101 :
|
||||
; 102 : if (NULL != ret)
|
||||
; 103 : {
|
||||
; 104 : *ret = _mm_mul_ps(*ptr1, *ptr2);
|
||||
|
||||
0002e 0f 10 07 movups xmm0, XMMWORD PTR [rdi]
|
||||
00031 0f 59 03 mulps xmm0, XMMWORD PTR [rbx]
|
||||
00034 0f 11 00 movups XMMWORD PTR [rax], xmm0
|
||||
|
||||
; 96 : return ret;
|
||||
; 97 : }
|
||||
; 98 : else
|
||||
; 99 : {
|
||||
; 100 : return -1;
|
||||
; 101 : }
|
||||
; 102 : }
|
||||
; 105 : return ret;
|
||||
; 106 : }
|
||||
; 107 : else
|
||||
; 108 : {
|
||||
; 109 : return -1;
|
||||
; 110 : }
|
||||
; 111 : }
|
||||
|
||||
00037 48 8b 5c 24 30 mov rbx, QWORD PTR [rsp+48]
|
||||
0003c 48 83 c4 20 add rsp, 32 ; 00000020H
|
||||
@@ -472,7 +618,7 @@ ptr$ = 80
|
||||
value$ = 88
|
||||
mulps_const PROC ; COMDAT
|
||||
|
||||
; 72 : {
|
||||
; 81 : {
|
||||
|
||||
$LN7:
|
||||
00000 40 53 push rbx
|
||||
@@ -492,26 +638,26 @@ $LN7:
|
||||
00033 48 85 c0 test rax, rax
|
||||
00036 74 14 je SHORT $LN2@mulps_cons
|
||||
|
||||
; 73 : float c[4] = { value, value, value, value };
|
||||
; 74 : __m128* ret = _aligned_malloc(sizeof(__m128),16);
|
||||
; 75 :
|
||||
; 76 : __m128 valueVec = _mm_loadu_ps(&c);
|
||||
; 77 :
|
||||
; 78 : if (NULL != ret)
|
||||
; 79 : {
|
||||
; 80 : *ret = _mm_mul_ps(*ptr,valueVec);
|
||||
; 82 : float c[4] = { value, value, value, value };
|
||||
; 83 : __m128* ret = _aligned_malloc(sizeof(__m128),16);
|
||||
; 84 :
|
||||
; 85 : __m128 valueVec = _mm_loadu_ps(&c);
|
||||
; 86 :
|
||||
; 87 : if (NULL != ret)
|
||||
; 88 : {
|
||||
; 89 : *ret = _mm_mul_ps(*ptr,valueVec);
|
||||
|
||||
00038 0f 10 c6 movups xmm0, xmm6
|
||||
0003b 0f 59 03 mulps xmm0, XMMWORD PTR [rbx]
|
||||
0003e 0f 11 00 movups XMMWORD PTR [rax], xmm0
|
||||
|
||||
; 81 : return ret;
|
||||
; 82 : }
|
||||
; 83 : else
|
||||
; 84 : {
|
||||
; 85 : return -1;
|
||||
; 86 : }
|
||||
; 87 : }
|
||||
; 90 : return ret;
|
||||
; 91 : }
|
||||
; 92 : else
|
||||
; 93 : {
|
||||
; 94 : return -1;
|
||||
; 95 : }
|
||||
; 96 : }
|
||||
|
||||
00041 0f 28 74 24 30 movaps xmm6, XMMWORD PTR [rsp+48]
|
||||
00046 48 83 c4 40 add rsp, 64 ; 00000040H
|
||||
@@ -534,7 +680,7 @@ ptr1$ = 48
|
||||
ptr2$ = 56
|
||||
subps PROC ; COMDAT
|
||||
|
||||
; 57 : {
|
||||
; 66 : {
|
||||
|
||||
$LN7:
|
||||
00000 48 89 5c 24 08 mov QWORD PTR [rsp+8], rbx
|
||||
@@ -552,23 +698,23 @@ $LN7:
|
||||
0002a 48 85 c0 test rax, rax
|
||||
0002d 74 14 je SHORT $LN2@subps
|
||||
|
||||
; 58 : __m128* ret = _aligned_malloc(sizeof(__m128*), 16);
|
||||
; 59 :
|
||||
; 60 : if (NULL != ret)
|
||||
; 61 : {
|
||||
; 62 : *ret = _mm_sub_ps(*ptr1, *ptr2);
|
||||
; 67 : __m128* ret = _aligned_malloc(sizeof(__m128*), 16);
|
||||
; 68 :
|
||||
; 69 : if (NULL != ret)
|
||||
; 70 : {
|
||||
; 71 : *ret = _mm_sub_ps(*ptr1, *ptr2);
|
||||
|
||||
0002f 0f 10 07 movups xmm0, XMMWORD PTR [rdi]
|
||||
00032 0f 5c 03 subps xmm0, XMMWORD PTR [rbx]
|
||||
00035 0f 11 00 movups XMMWORD PTR [rax], xmm0
|
||||
|
||||
; 63 : return ret;
|
||||
; 64 : }
|
||||
; 65 : else
|
||||
; 66 : {
|
||||
; 67 : return -1;
|
||||
; 68 : }
|
||||
; 69 : }
|
||||
; 72 : return ret;
|
||||
; 73 : }
|
||||
; 74 : else
|
||||
; 75 : {
|
||||
; 76 : return -1;
|
||||
; 77 : }
|
||||
; 78 : }
|
||||
|
||||
00038 48 8b 5c 24 30 mov rbx, QWORD PTR [rsp+48]
|
||||
0003d 48 83 c4 20 add rsp, 32 ; 00000020H
|
||||
@@ -591,7 +737,7 @@ ptr1$ = 48
|
||||
ptr2$ = 56
|
||||
addps PROC ; COMDAT
|
||||
|
||||
; 40 : {
|
||||
; 49 : {
|
||||
|
||||
$LN7:
|
||||
00000 48 89 5c 24 08 mov QWORD PTR [rsp+8], rbx
|
||||
@@ -609,25 +755,25 @@ $LN7:
|
||||
0002a 48 85 c0 test rax, rax
|
||||
0002d 74 14 je SHORT $LN2@addps
|
||||
|
||||
; 41 :
|
||||
; 42 : __m128* ret = _aligned_malloc(sizeof(__m128*),16);
|
||||
; 43 :
|
||||
; 44 : if (NULL != ret)
|
||||
; 45 : {
|
||||
; 46 : *ret = _mm_add_ps(*ptr1, *ptr2);
|
||||
; 50 :
|
||||
; 51 : __m128* ret = _aligned_malloc(sizeof(__m128*),16);
|
||||
; 52 :
|
||||
; 53 : if (NULL != ret)
|
||||
; 54 : {
|
||||
; 55 : *ret = _mm_add_ps(*ptr1, *ptr2);
|
||||
|
||||
0002f 0f 10 07 movups xmm0, XMMWORD PTR [rdi]
|
||||
00032 0f 58 03 addps xmm0, XMMWORD PTR [rbx]
|
||||
00035 0f 11 00 movups XMMWORD PTR [rax], xmm0
|
||||
|
||||
; 47 : return ret;
|
||||
; 48 : }
|
||||
; 49 : else
|
||||
; 50 : {
|
||||
; 51 : return -1;
|
||||
; 52 : }
|
||||
; 53 :
|
||||
; 54 : }
|
||||
; 56 : return ret;
|
||||
; 57 : }
|
||||
; 58 : else
|
||||
; 59 : {
|
||||
; 60 : return (__m128*) - 1;
|
||||
; 61 : }
|
||||
; 62 :
|
||||
; 63 : }
|
||||
|
||||
00038 48 8b 5c 24 30 mov rbx, QWORD PTR [rsp+48]
|
||||
0003d 48 83 c4 20 add rsp, 32 ; 00000020H
|
||||
@@ -649,7 +795,7 @@ _TEXT SEGMENT
|
||||
ptr$ = 48
|
||||
load_cpy PROC ; COMDAT
|
||||
|
||||
; 28 : {
|
||||
; 37 : {
|
||||
|
||||
$LN7:
|
||||
00000 40 53 push rbx
|
||||
@@ -665,20 +811,20 @@ $LN7:
|
||||
00023 48 85 c0 test rax, rax
|
||||
00026 74 06 je SHORT $LN4@load_cpy
|
||||
|
||||
; 29 : __m128* ret = _aligned_malloc(sizeof(__m128*),16);
|
||||
; 30 :
|
||||
; 31 : if (NULL != ret)
|
||||
; 32 : {
|
||||
; 33 : *ret = *ptr;
|
||||
; 38 : __m128* ret = _aligned_malloc(sizeof(__m128*),16);
|
||||
; 39 :
|
||||
; 40 : if (NULL != ret)
|
||||
; 41 : {
|
||||
; 42 : *ret = *ptr;
|
||||
|
||||
00028 0f 10 03 movups xmm0, XMMWORD PTR [rbx]
|
||||
0002b 0f 11 00 movups XMMWORD PTR [rax], xmm0
|
||||
$LN4@load_cpy:
|
||||
|
||||
; 34 : }
|
||||
; 35 :
|
||||
; 36 : return ret;
|
||||
; 37 : }
|
||||
; 43 : }
|
||||
; 44 :
|
||||
; 45 : return ret;
|
||||
; 46 : }
|
||||
|
||||
0002e 48 83 c4 20 add rsp, 32 ; 00000020H
|
||||
00032 5b pop rbx
|
||||
@@ -696,7 +842,7 @@ z$ = 144
|
||||
w$ = 152
|
||||
load PROC ; COMDAT
|
||||
|
||||
; 12 : {
|
||||
; 21 : {
|
||||
|
||||
$LN7:
|
||||
00000 48 83 ec 78 sub rsp, 120 ; 00000078H
|
||||
@@ -728,32 +874,32 @@ $LN7:
|
||||
0005b 48 85 c0 test rax, rax
|
||||
0005e 74 0a je SHORT $LN2@load
|
||||
|
||||
; 13 : float array[4] = {x,y,z,w};
|
||||
; 14 : __m128* ptr = _aligned_malloc(sizeof(__m128),16);
|
||||
; 15 :
|
||||
; 16 : if (NULL != ptr)
|
||||
; 17 : {
|
||||
; 18 : *ptr = _mm_loadu_ps(&array);
|
||||
; 22 : float array[4] = {x,y,z,w};
|
||||
; 23 : __m128* ptr = _aligned_malloc(sizeof(__m128),16);
|
||||
; 24 :
|
||||
; 25 : if (NULL != ptr)
|
||||
; 26 : {
|
||||
; 27 : *ptr = _mm_loadu_ps(&array);
|
||||
|
||||
00060 0f 10 44 24 20 movups xmm0, XMMWORD PTR array$[rsp]
|
||||
00065 0f 11 00 movups XMMWORD PTR [rax], xmm0
|
||||
|
||||
; 19 : return ptr;
|
||||
; 28 : return ptr;
|
||||
|
||||
00068 eb 07 jmp SHORT $LN3@load
|
||||
$LN2@load:
|
||||
|
||||
; 20 : }
|
||||
; 21 : else
|
||||
; 22 : {
|
||||
; 23 : return -1;
|
||||
; 29 : }
|
||||
; 30 : else
|
||||
; 31 : {
|
||||
; 32 : return -1;
|
||||
|
||||
0006a 48 c7 c0 ff ff
|
||||
ff ff mov rax, -1
|
||||
$LN3@load:
|
||||
|
||||
; 24 : }
|
||||
; 25 : }
|
||||
; 33 : }
|
||||
; 34 : }
|
||||
|
||||
00071 0f 28 74 24 60 movaps xmm6, XMMWORD PTR [rsp+96]
|
||||
00076 0f 28 7c 24 50 movaps xmm7, XMMWORD PTR [rsp+80]
|
||||
@@ -765,4 +911,51 @@ $LN3@load:
|
||||
0008b c3 ret 0
|
||||
load ENDP
|
||||
_TEXT ENDS
|
||||
; Function compile flags: /Ogtpy
|
||||
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
|
||||
; COMDAT mulps_total_internal
|
||||
_TEXT SEGMENT
|
||||
vec$ = 8
|
||||
mulps_total_internal PROC ; COMDAT
|
||||
00000 48 8d 0d 00 00
|
||||
00 00 lea rcx, OFFSET FLAT:__B5461FF6_linear@c
|
||||
00007 e9 00 00 00 00 jmp __CheckForDebuggerJustMyCode
|
||||
mulps_total_internal ENDP
|
||||
_TEXT ENDS
|
||||
; Function compile flags: /Ogtpy
|
||||
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
|
||||
; COMDAT mulps_sum_internal
|
||||
_TEXT SEGMENT
|
||||
left$ = 48
|
||||
right$ = 56
|
||||
mulps_sum_internal PROC ; COMDAT
|
||||
|
||||
; 122 : {
|
||||
|
||||
$LN4:
|
||||
00000 48 89 5c 24 08 mov QWORD PTR [rsp+8], rbx
|
||||
00005 57 push rdi
|
||||
00006 48 83 ec 20 sub rsp, 32 ; 00000020H
|
||||
0000a 48 8b d9 mov rbx, rcx
|
||||
0000d 48 8b fa mov rdi, rdx
|
||||
00010 48 8d 0d 00 00
|
||||
00 00 lea rcx, OFFSET FLAT:__B5461FF6_linear@c
|
||||
00017 e8 00 00 00 00 call __CheckForDebuggerJustMyCode
|
||||
0001c 0f 10 03 movups xmm0, XMMWORD PTR [rbx]
|
||||
0001f 0f 59 07 mulps xmm0, XMMWORD PTR [rdi]
|
||||
00022 48 8b 5c 24 30 mov rbx, QWORD PTR [rsp+48]
|
||||
00027 f2 0f 7c c0 haddps xmm0, xmm0
|
||||
0002b f2 0f 7c c0 haddps xmm0, xmm0
|
||||
|
||||
; 123 : __m128 ret = _mm_mul_ps(left, right);
|
||||
; 124 : ret = _mm_hadd_ps(ret, ret);
|
||||
; 125 : ret = _mm_hadd_ps(ret, ret);
|
||||
; 126 : return *(float*)&ret;
|
||||
; 127 : }
|
||||
|
||||
0002f 48 83 c4 20 add rsp, 32 ; 00000020H
|
||||
00033 5f pop rdi
|
||||
00034 c3 ret 0
|
||||
mulps_sum_internal ENDP
|
||||
_TEXT ENDS
|
||||
END
|
||||
|
||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user