daily update on 20230804 by nitload youmu

This commit is contained in:
Nitload
2023-08-04 22:51:24 +08:00
parent aae7e0292c
commit b3785e35af
55 changed files with 1363 additions and 791 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -43,8 +43,8 @@ namespace StgSharp.Geometries
uint nowTick = TimeLine.tickCounter._value;
this.vertex01.Position = RefOrigin.Position + movVertex01Operation(nowTick);
this.vertex02.Position = RefOrigin.Position + movVertex02Operation(nowTick);
this.vertex03.Position = 2 * center.Position - vertex01.Position;
this.vertex04.Position = 2 * center.Position - vertex02.Position;
this.vertex03.Position = center.Position * 2 - vertex01.Position;
this.vertex04.Position = center.Position * 2 - vertex02.Position;
}
}
+19
View File
@@ -1,6 +1,7 @@
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -29,6 +30,24 @@ namespace StgSharp
CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr mulps_const_internal(IntPtr ptr, float value);
[DllImport("StgSharpGraphic.dll", EntryPoint = "mulps_sum",
CallingConvention = CallingConvention.Cdecl)]
internal static extern float mulps_sum_internal(IntPtr ptr1, IntPtr ptr2);
[DllImport("StgSharpGraphic.dll", EntryPoint = "mulps",
CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr divps_internal(IntPtr ptr1, IntPtr ptr2);
[DllImport("StgSharpGraphic.dll", EntryPoint = "divps_const",
CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr divps_const_internal(IntPtr ptr, float value);
[DllImport("StgSharpGraphic.dll", EntryPoint = "deinitM128",
@@ -1,35 +1,60 @@
using System;
using System.Runtime.InteropServices;
namespace StgSharp.Math
{
public static unsafe partial class VectorCalc
{
public static unsafe float Multiple(Vec3d vec1, Vec4d vec2)
public static unsafe float Multiple(Vec3d vec1, Vec3d vec2)
{
M128* retPtr = (M128*)internalIO.mulps_internal(vec1._m128Ptr,vec2._m128Ptr);
IntPtr retPtr = internalIO.mulps_internal(vec1._m128Ptr,vec2._m128Ptr);
M128 m128 = *(M128*)retPtr;
Marshal.FreeHGlobal(retPtr);
return
retPtr->single_0 +
retPtr->single_1 +
retPtr->single_2;
m128.single_0 +
m128.single_1 +
m128.single_2;
}
public static unsafe float Multiple(Vec4d vec1,Vec4d vec2)
public static unsafe float Multiple(Vec4d vec1,Vec3d vec2)
{
M128* retPtr = (M128*)internalIO.mulps_internal(vec1._m128Ptr,vec2._m128Ptr);
IntPtr retPtr = internalIO.mulps_internal(vec1._m128Ptr,vec2._m128Ptr);
M128 m128 = *(M128*)retPtr;
Marshal.FreeHGlobal(retPtr);
return
retPtr->single_0 +
retPtr->single_1 +
retPtr->single_2 +
retPtr->single_3;
m128.single_0 +
m128.single_1 +
m128.single_2 +
m128.single_3;
}
public static unsafe Matrix4x4 Multiple(
public static Matrix4x4 Multiple(
Matrix4x4 matrix1, Matrix4x4 matrix2
)
{
return default;
Matrix4x4 transpose = matrix2.Transpose(TransposeMode.Copy);
return new Matrix4x4(
internalIO.mulps_sum_internal(matrix1._row0Ptr, transpose._row0Ptr),
internalIO.mulps_sum_internal(matrix1._row0Ptr, transpose._row1Ptr),
internalIO.mulps_sum_internal(matrix1._row0Ptr, transpose._row2Ptr),
internalIO.mulps_sum_internal(matrix1._row0Ptr, transpose._row3Ptr),
internalIO.mulps_sum_internal(matrix1._row1Ptr, transpose._row0Ptr),
internalIO.mulps_sum_internal(matrix1._row1Ptr, transpose._row1Ptr),
internalIO.mulps_sum_internal(matrix1._row1Ptr, transpose._row2Ptr),
internalIO.mulps_sum_internal(matrix1._row1Ptr, transpose._row3Ptr),
internalIO.mulps_sum_internal(matrix1._row2Ptr, transpose._row0Ptr),
internalIO.mulps_sum_internal(matrix1._row2Ptr, transpose._row1Ptr),
internalIO.mulps_sum_internal(matrix1._row2Ptr, transpose._row2Ptr),
internalIO.mulps_sum_internal(matrix1._row2Ptr, transpose._row3Ptr),
internalIO.mulps_sum_internal(matrix1._row3Ptr, transpose._row0Ptr),
internalIO.mulps_sum_internal(matrix1._row3Ptr, transpose._row1Ptr),
internalIO.mulps_sum_internal(matrix1._row3Ptr, transpose._row2Ptr),
internalIO.mulps_sum_internal(matrix1._row3Ptr, transpose._row3Ptr)
);
}
/*
+50 -1
View File
@@ -1,10 +1,59 @@
using System;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
namespace StgSharp.Math
{
public class Matrix3x4
{
internal IntPtr _row0Ptr;
internal IntPtr _row1Ptr;
internal IntPtr _row2Ptr;
private bool _isTransposed;
private Matrix4x3 _transpose;
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
)
{
_row0Ptr = internalIO.load_internal(a00,a01,a02,a03);
_row1Ptr = internalIO.load_internal(a10,a11,a12,a13);
_row2Ptr = internalIO.load_internal(a20,a21,a22,a23);
_transpose = new Matrix4x3(this);
}
internal Matrix3x4()
{
_transpose = new Matrix4x3(this);
}
internal Matrix3x4(Matrix4x3 transpose)
{
_transpose = transpose;
}
public Matrix4x3 Transpose(TransposeMode transposeMode)
{
switch (transposeMode)
{
case TransposeMode.New:
return new Matrix4x3();
break;
case TransposeMode.Copy:
break;
default:
throw new Exception();
break;
}
}
}
}
@@ -3,6 +3,38 @@ using System.Runtime.InteropServices;
namespace StgSharp.Math
{
public class Matrix4x3
{
internal IntPtr _row0Ptr;
internal IntPtr _row1Ptr;
internal IntPtr _row2Ptr;
internal IntPtr _row3Ptr;
private bool _isTransposed;
private Matrix3x4 _transpose;
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
)
{
_row0Ptr = internalIO.load_internal(a00,a01,a02,0);
_row1Ptr = internalIO.load_internal(a10,a11,a12,0);
_row2Ptr = internalIO.load_internal(a20,a21,a22,0);
_row3Ptr = internalIO.load_internal(a30,a31,a32,0);
_transpose = new Matrix3x4(this);
}
internal Matrix4x3(Matrix3x4 transpose)
{
this._transpose = transpose;
}
}
[StructLayout(LayoutKind.Explicit)]
public struct matrix4x3 : IEquatable<matrix4x3>
+6 -1
View File
@@ -22,6 +22,7 @@ namespace StgSharp.Math
);
internal M128Map map;
internal IntPtr _row0Ptr;
@@ -34,6 +35,9 @@ namespace StgSharp.Math
private Matrix4x4 _transpose;
internal Matrix4x4()
{
_row0Ptr = internalIO.load_internal(0,0,0,0);
@@ -60,7 +64,8 @@ namespace StgSharp.Math
IntPtr row0Ptr,
IntPtr row1Ptr,
IntPtr row2Ptr,
IntPtr row3Ptr)
IntPtr row3Ptr
)
{
_row0Ptr = row0Ptr;
+12
View File
@@ -220,6 +220,18 @@ namespace StgSharp.Math
);
}
public static Vec3d operator /(Vec3d vec, float value)
{
return new Vec3d(
internalIO.divps_const_internal(vec._m128Ptr,value)
);
}
public static float operator *(Vec3d vec1, Vec3d vec2)
{
return VectorCalc.Multiple(vec1,vec2);
}
public unsafe override string ToString()
{
return (*(M128*)_m128Ptr).ToString();
+7
View File
@@ -94,6 +94,13 @@ namespace StgSharp.Math
);
}
public static Vec4d operator /(Vec4d vec, float value)
{
return new Vec4d(
internalIO.divps_const_internal(vec._m128Ptr, value)
);
}
public unsafe override string ToString()
{
return $"{*(M128*)_m128Ptr}";
+15 -1
View File
@@ -9,6 +9,8 @@ namespace StgSharp
{
private unsafe static void Main(string[] args)
{
/*
Vec3d v = new Vec3d(1,2,3);
Console.WriteLine(v._m128Ptr);
Console.WriteLine(v);
@@ -19,11 +21,23 @@ namespace StgSharp
Console.WriteLine(v2);
Console.WriteLine();
Vec3d v3 = v - v2;
Vec3d v3 = v / 114514.0f;
Console.WriteLine();
Console.WriteLine(v3);
/**/
Matrix4x4 m1 = new Matrix4x4(
1,2,3,4,
5,6,7,8,
1,2,3,4,
5,6,7,8
);
Console.WriteLine(VectorCalc.Multiple(m1,m1));
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3 -3
View File
@@ -11,7 +11,7 @@
extern SSEfuncptr sseFunc;
extern glIOpackage pack;
STGSHARPGRAPHIC_API glIOpackage loadGLApi(void)
SSGC_API glIOpackage loadGLApi(void)
{
pack.createWindow = glfwCreateWindow;
@@ -28,7 +28,7 @@ STGSHARPGRAPHIC_API glIOpackage loadGLApi(void)
return pack;
}
STGSHARPGRAPHIC_API void initGL(void)
SSGC_API void initGL(void)
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
@@ -41,7 +41,7 @@ STGSHARPGRAPHIC_API void initGL(void)
}
STGSHARPGRAPHIC_API int initGLAD(void)
SSGC_API int initGLAD(void)
{
return gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
}
+15 -11
View File
@@ -4,9 +4,9 @@
#define SSG_Api
#ifdef SSG_Api
#define STGSHARPGRAPHIC_API __declspec(dllexport)
#define SSGC_API __declspec(dllexport)
#else
#define STGSHARPGRAPHIC_API __declspec(dllimport)
#define SSGC_API __declspec(dllimport)
#endif
@@ -14,19 +14,23 @@
#include "GLenv/include/GLFW/glfw3.h"
#include "SSGinternal.h"
STGSHARPGRAPHIC_API glIOpackage loadGLApi(void);
STGSHARPGRAPHIC_API void initGL(void);
STGSHARPGRAPHIC_API int initGLAD(void);
SSGC_API glIOpackage loadGLApi(void);
SSGC_API void initGL(void);
SSGC_API int initGLAD(void);
STGSHARPGRAPHIC_API __m128* __cdecl load(float x, float y, float z, float w);
STGSHARPGRAPHIC_API __m128* __cdecl addps(__m128* ptr1, __m128* ptr2);
STGSHARPGRAPHIC_API __m128* __cdecl subps(__m128* ptr1, __m128* ptr2);
STGSHARPGRAPHIC_API __m128* __cdecl mulps_const(__m128* ptr, float value);
STGSHARPGRAPHIC_API __m128* __cdecl mulps(__m128* ptr1, __m128* ptr2);
SSGC_API __m128* __cdecl load(float x, float y, float z, float w);
SSGC_API __m128* __cdecl addps(__m128* ptr1, __m128* ptr2);
SSGC_API __m128* __cdecl subps(__m128* ptr1, __m128* ptr2);
SSGC_API __m128* __cdecl mulps_const(__m128* ptr, float value);
SSGC_API __m128* __cdecl mulps(__m128* ptr1, __m128* ptr2);
SSGC_API float __cdecl mulps_sum(__m128* ptr1, __m128* ptr2);
SSGC_API __m128* __cdecl divps_const(__m128* ptr, float value);
SSGC_API __m128* __cdecl divps(__m128* ptr1, __m128* ptr2);
STGSHARPGRAPHIC_API void __cdecl deinitM128(__m128* ptr);
SSGC_API void __cdecl deinitM128(__m128* ptr);
#endif // !SSG
+54 -6
View File
@@ -6,8 +6,9 @@
#include <stdalign.h>
#include <xmmintrin.h>
#include <pmmintrin.h>
STGSHARPGRAPHIC_API __m128* __cdecl load(float x, float y, float z, float w)
SSGC_API __m128* __cdecl load(float x, float y, float z, float w)
{
float array[4] = {x,y,z,w};
__m128* ptr = _aligned_malloc(sizeof(__m128),16);
@@ -23,7 +24,7 @@ STGSHARPGRAPHIC_API __m128* __cdecl load(float x, float y, float z, float w)
}
}
STGSHARPGRAPHIC_API __m128* __cdecl addps(__m128* ptr1, __m128* ptr2)
SSGC_API __m128* __cdecl addps(__m128* ptr1, __m128* ptr2)
{
__m128* ret = _aligned_malloc(sizeof(__m128*),16);
@@ -40,7 +41,7 @@ STGSHARPGRAPHIC_API __m128* __cdecl addps(__m128* ptr1, __m128* ptr2)
}
STGSHARPGRAPHIC_API __m128* __cdecl subps(__m128* ptr1, __m128* ptr2)
SSGC_API __m128* __cdecl subps(__m128* ptr1, __m128* ptr2)
{
__m128* ret = _aligned_malloc(sizeof(__m128*), 16);
@@ -55,7 +56,7 @@ STGSHARPGRAPHIC_API __m128* __cdecl subps(__m128* ptr1, __m128* ptr2)
}
}
STGSHARPGRAPHIC_API __m128* __cdecl mulps_const(__m128* ptr, float value)
SSGC_API __m128* __cdecl mulps_const(__m128* ptr, float value)
{
float c[4] = { value, value, value, value };
__m128* ret = _aligned_malloc(sizeof(__m128),16);
@@ -73,7 +74,7 @@ STGSHARPGRAPHIC_API __m128* __cdecl mulps_const(__m128* ptr, float value)
}
}
STGSHARPGRAPHIC_API __m128* __cdecl mulps(__m128* ptr1, __m128* ptr2)
SSGC_API __m128* __cdecl mulps(__m128* ptr1, __m128* ptr2)
{
__m128* ret = _aligned_malloc(sizeof(__m128), 16);
@@ -88,9 +89,56 @@ STGSHARPGRAPHIC_API __m128* __cdecl mulps(__m128* ptr1, __m128* ptr2)
}
}
SSGC_API float __cdecl mulps_sum(__m128* ptr1, __m128* ptr2)
{
__m128 ret = _mm_mul_ps(*ptr1,*ptr2);
ret = _mm_hadd_ps(ret,ret);
ret = _mm_hadd_ps(ret,ret);
return *(float*)&ret;
}
SSGC_API __m128* __cdecl divps_const(__m128* ptr, float value)
{
float c[4] = { value, value, value, value };
__m128* ret = _aligned_malloc(sizeof(__m128), 16);
__m128 valueVec = _mm_loadu_ps(&c);
if (NULL != ret)
{
*ret = _mm_div_ps(*ptr, valueVec);
return ret;
}
else
{
return -1;
}
}
SSGC_API __m128* __cdecl divps(__m128* ptr1, __m128* ptr2)
{
__m128* ret = _aligned_malloc(sizeof(__m128), 16);
if (NULL != ret)
{
*ret = _mm_div_ps(*ptr1, *ptr2);
return ret;
}
else
{
return -1;
}
}
STGSHARPGRAPHIC_API void __cdecl deinitM128(__m128* ptr)
SSGC_API void __cdecl deinitM128(__m128* ptr)
{
free(ptr);
}
File diff suppressed because it is too large Load Diff
Binary file not shown.
+390 -45
View File
@@ -30,11 +30,18 @@ __D0E9C0B0_corecrt_stdio_config@h DB 01H
__119849BB_corecrt_wstdio@h DB 01H
__2BEDEB13_stdio@h DB 01H
__70BD074A_stdalign@h DB 01H
__72219779_emmintrin@h DB 01H
__AD80FFF0_pmmintrin@h DB 01H
__B5461FF6_linear@c DB 01H
msvcjmc ENDS
PUBLIC load
PUBLIC addps
PUBLIC subps
PUBLIC mulps_const
PUBLIC mulps
PUBLIC mulps_sum
PUBLIC divps_const
PUBLIC divps
PUBLIC deinitM128
PUBLIC __JustMyCode_Default
EXTRN __imp_free:PROC
@@ -61,6 +68,36 @@ $pdata$subps DD imagerel $LN6
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$mulps_const DD imagerel $LN6
DD imagerel $LN6+94
DD imagerel $unwind$mulps_const
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$mulps DD imagerel $LN6
DD imagerel $LN6+84
DD imagerel $unwind$mulps
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$mulps_sum DD imagerel $LN4
DD imagerel $LN4+53
DD imagerel $unwind$mulps_sum
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$divps_const DD imagerel $LN6
DD imagerel $LN6+97
DD imagerel $unwind$divps_const
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$divps DD imagerel $LN6
DD imagerel $LN6+84
DD imagerel $unwind$divps
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$deinitM128 DD imagerel $LN4
DD imagerel $LN4+36
DD imagerel $unwind$deinitM128
@@ -72,6 +109,36 @@ $unwind$deinitM128 DD 020601H
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$divps DD 040a01H
DD 06340aH
DD 07006320aH
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$divps_const DD 040b01H
DD 03680bH
DD 030027206H
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$mulps_sum DD 040a01H
DD 06340aH
DD 07006320aH
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$mulps DD 040a01H
DD 06340aH
DD 07006320aH
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$mulps_const DD 040b01H
DD 03680bH
DD 030027206H
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$subps DD 040a01H
DD 06340aH
DD 07006320aH
@@ -105,7 +172,7 @@ _TEXT SEGMENT
ptr$ = 48
deinitM128 PROC ; COMDAT
; 59 : {
; 142 : {
$LN4:
00000 40 53 push rbx
@@ -116,8 +183,8 @@ $LN4:
00010 e8 00 00 00 00 call __CheckForDebuggerJustMyCode
00015 48 8b cb mov rcx, rbx
; 60 : free(ptr);
; 61 : }
; 143 : free(ptr);
; 144 : }
00018 48 83 c4 20 add rsp, 32 ; 00000020H
0001c 5b pop rbx
@@ -127,13 +194,291 @@ deinitM128 ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
; COMDAT divps
_TEXT SEGMENT
ptr1$ = 48
ptr2$ = 56
divps PROC ; COMDAT
; 120 : {
$LN6:
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 f9 mov rdi, rcx
0000d 48 8b da mov rbx, 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 ba 10 00 00 00 mov edx, 16
00021 8b ca mov ecx, edx
00023 ff 15 00 00 00
00 call QWORD PTR __imp__aligned_malloc
00029 48 85 c0 test rax, rax
0002c 74 14 je SHORT $LN2@divps
; 121 : __m128* ret = _aligned_malloc(sizeof(__m128), 16);
; 122 :
; 123 : if (NULL != ret)
; 124 : {
; 125 : *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
; 126 : return ret;
; 127 : }
; 128 : else
; 129 : {
; 130 : return -1;
; 131 : }
; 132 : }
00037 48 8b 5c 24 30 mov rbx, QWORD PTR [rsp+48]
0003c 48 83 c4 20 add rsp, 32 ; 00000020H
00040 5f pop rdi
00041 c3 ret 0
$LN2@divps:
00042 48 8b 5c 24 30 mov rbx, QWORD PTR [rsp+48]
00047 48 c7 c0 ff ff
ff ff mov rax, -1
0004e 48 83 c4 20 add rsp, 32 ; 00000020H
00052 5f pop rdi
00053 c3 ret 0
divps ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
; COMDAT divps_const
_TEXT SEGMENT
c$ = 32
ptr$ = 80
value$ = 88
divps_const PROC ; COMDAT
; 101 : {
$LN6:
00000 40 53 push rbx
00002 48 83 ec 40 sub rsp, 64 ; 00000040H
00006 0f 29 74 24 30 movaps XMMWORD PTR [rsp+48], xmm6
0000b 48 8b d9 mov rbx, rcx
0000e 0f 28 f1 movaps xmm6, xmm1
00011 48 8d 0d 00 00
00 00 lea rcx, OFFSET FLAT:__B5461FF6_linear@c
00018 0f c6 f6 00 shufps xmm6, xmm6, 0
0001c e8 00 00 00 00 call __CheckForDebuggerJustMyCode
00021 ba 10 00 00 00 mov edx, 16
00026 8b ca mov ecx, edx
00028 0f 11 74 24 20 movups XMMWORD PTR c$[rsp], xmm6
0002d ff 15 00 00 00
00 call QWORD PTR __imp__aligned_malloc
00033 48 85 c0 test rax, rax
00036 74 17 je SHORT $LN2@divps_cons
; 102 :
; 103 : float c[4] = { value, value, value, value };
; 104 : __m128* ret = _aligned_malloc(sizeof(__m128), 16);
; 105 :
; 106 : __m128 valueVec = _mm_loadu_ps(&c);
; 107 :
; 108 : if (NULL != ret)
; 109 : {
; 110 : *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
; 111 : return ret;
; 112 : }
; 113 : else
; 114 : {
; 115 : return -1;
; 116 : }
; 117 : }
00044 0f 28 74 24 30 movaps xmm6, XMMWORD PTR [rsp+48]
00049 48 83 c4 40 add rsp, 64 ; 00000040H
0004d 5b pop rbx
0004e c3 ret 0
$LN2@divps_cons:
0004f 0f 28 74 24 30 movaps xmm6, XMMWORD PTR [rsp+48]
00054 48 c7 c0 ff ff
ff ff mov rax, -1
0005b 48 83 c4 40 add rsp, 64 ; 00000040H
0005f 5b pop rbx
00060 c3 ret 0
divps_const ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
; COMDAT mulps_sum
_TEXT SEGMENT
ptr1$ = 48
ptr2$ = 56
mulps_sum PROC ; COMDAT
; 93 : {
$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
; 94 : __m128 ret = _mm_mul_ps(*ptr1,*ptr2);
; 95 : ret = _mm_hadd_ps(ret,ret);
; 96 : ret = _mm_hadd_ps(ret,ret);
; 97 : return *(float*)&ret;
; 98 : }
0002f 48 83 c4 20 add rsp, 32 ; 00000020H
00033 5f pop rdi
00034 c3 ret 0
mulps_sum ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
; COMDAT mulps
_TEXT SEGMENT
ptr1$ = 48
ptr2$ = 56
mulps PROC ; COMDAT
; 78 : {
$LN6:
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 f9 mov rdi, rcx
0000d 48 8b da mov rbx, 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 ba 10 00 00 00 mov edx, 16
00021 8b ca mov ecx, edx
00023 ff 15 00 00 00
00 call QWORD PTR __imp__aligned_malloc
00029 48 85 c0 test rax, rax
0002c 74 14 je SHORT $LN2@mulps
; 79 : __m128* ret = _aligned_malloc(sizeof(__m128), 16);
; 80 :
; 81 : if (NULL != ret)
; 82 : {
; 83 : *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
; 84 : return ret;
; 85 : }
; 86 : else
; 87 : {
; 88 : return -1;
; 89 : }
; 90 : }
00037 48 8b 5c 24 30 mov rbx, QWORD PTR [rsp+48]
0003c 48 83 c4 20 add rsp, 32 ; 00000020H
00040 5f pop rdi
00041 c3 ret 0
$LN2@mulps:
00042 48 8b 5c 24 30 mov rbx, QWORD PTR [rsp+48]
00047 48 c7 c0 ff ff
ff ff mov rax, -1
0004e 48 83 c4 20 add rsp, 32 ; 00000020H
00052 5f pop rdi
00053 c3 ret 0
mulps ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
; COMDAT mulps_const
_TEXT SEGMENT
c$ = 32
ptr$ = 80
value$ = 88
mulps_const PROC ; COMDAT
; 60 : {
$LN6:
00000 40 53 push rbx
00002 48 83 ec 40 sub rsp, 64 ; 00000040H
00006 0f 29 74 24 30 movaps XMMWORD PTR [rsp+48], xmm6
0000b 48 8b d9 mov rbx, rcx
0000e 0f 28 f1 movaps xmm6, xmm1
00011 48 8d 0d 00 00
00 00 lea rcx, OFFSET FLAT:__B5461FF6_linear@c
00018 0f c6 f6 00 shufps xmm6, xmm6, 0
0001c e8 00 00 00 00 call __CheckForDebuggerJustMyCode
00021 ba 10 00 00 00 mov edx, 16
00026 8b ca mov ecx, edx
00028 0f 11 74 24 20 movups XMMWORD PTR c$[rsp], xmm6
0002d ff 15 00 00 00
00 call QWORD PTR __imp__aligned_malloc
00033 48 85 c0 test rax, rax
00036 74 14 je SHORT $LN2@mulps_cons
; 61 : float c[4] = { value, value, value, value };
; 62 : __m128* ret = _aligned_malloc(sizeof(__m128),16);
; 63 :
; 64 : __m128 valueVec = _mm_loadu_ps(&c);
; 65 :
; 66 : if (NULL != ret)
; 67 : {
; 68 : *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
; 69 : return ret;
; 70 : }
; 71 : else
; 72 : {
; 73 : return -1;
; 74 : }
; 75 : }
00041 0f 28 74 24 30 movaps xmm6, XMMWORD PTR [rsp+48]
00046 48 83 c4 40 add rsp, 64 ; 00000040H
0004a 5b pop rbx
0004b c3 ret 0
$LN2@mulps_cons:
0004c 0f 28 74 24 30 movaps xmm6, XMMWORD PTR [rsp+48]
00051 48 c7 c0 ff ff
ff ff mov rax, -1
00058 48 83 c4 40 add rsp, 64 ; 00000040H
0005c 5b pop rbx
0005d c3 ret 0
mulps_const ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File D:\NitloadIndustry\Ñо¿ÏîÄ¿\1-Flagship\TH2020\ProjectFile\Ô´´úÂë\StgShqrpGraphic\linear.c
; COMDAT subps
_TEXT SEGMENT
ptr1$ = 48
ptr2$ = 56
subps PROC ; COMDAT
; 44 : {
; 45 : {
$LN6:
00000 48 89 5c 24 08 mov QWORD PTR [rsp+8], rbx
@@ -151,23 +496,23 @@ $LN6:
0002a 48 85 c0 test rax, rax
0002d 74 14 je SHORT $LN2@subps
; 45 : __m128* ret = _aligned_malloc(sizeof(__m128*), 16);
; 46 :
; 47 : if (NULL != ret)
; 48 : {
; 49 : *ret = _mm_sub_ps(*ptr1, *ptr2);
; 46 : __m128* ret = _aligned_malloc(sizeof(__m128*), 16);
; 47 :
; 48 : if (NULL != ret)
; 49 : {
; 50 : *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
; 50 : return ret;
; 51 : }
; 52 : else
; 53 : {
; 54 : return -1;
; 55 : }
; 56 : }
; 51 : return ret;
; 52 : }
; 53 : else
; 54 : {
; 55 : return -1;
; 56 : }
; 57 : }
00038 48 8b 5c 24 30 mov rbx, QWORD PTR [rsp+48]
0003d 48 83 c4 20 add rsp, 32 ; 00000020H
@@ -190,7 +535,7 @@ ptr1$ = 48
ptr2$ = 56
addps PROC ; COMDAT
; 27 : {
; 28 : {
$LN6:
00000 48 89 5c 24 08 mov QWORD PTR [rsp+8], rbx
@@ -208,25 +553,25 @@ $LN6:
0002a 48 85 c0 test rax, rax
0002d 74 14 je SHORT $LN2@addps
; 28 :
; 29 : __m128* ret = _aligned_malloc(sizeof(__m128*),16);
; 30 :
; 31 : if (NULL != ret)
; 32 : {
; 33 : *ret = _mm_add_ps(*ptr1, *ptr2);
; 29 :
; 30 : __m128* ret = _aligned_malloc(sizeof(__m128*),16);
; 31 :
; 32 : if (NULL != ret)
; 33 : {
; 34 : *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
; 34 : return ret;
; 35 : }
; 36 : else
; 37 : {
; 38 : return -1;
; 39 : }
; 40 :
; 41 : }
; 35 : return ret;
; 36 : }
; 37 : else
; 38 : {
; 39 : return -1;
; 40 : }
; 41 :
; 42 : }
00038 48 8b 5c 24 30 mov rbx, QWORD PTR [rsp+48]
0003d 48 83 c4 20 add rsp, 32 ; 00000020H
@@ -252,7 +597,7 @@ z$ = 144
w$ = 152
load PROC ; COMDAT
; 11 : {
; 12 : {
$LN6:
00000 48 83 ec 78 sub rsp, 120 ; 00000078H
@@ -284,32 +629,32 @@ $LN6:
0005b 48 85 c0 test rax, rax
0005e 74 0a je SHORT $LN2@load
; 12 : float array[4] = {x,y,z,w};
; 13 : __m128* ptr = _aligned_malloc(sizeof(__m128),16);
; 14 :
; 15 : if (NULL != ptr)
; 16 : {
; 17 : *ptr = _mm_loadu_ps(&array);
; 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);
00060 0f 10 44 24 20 movups xmm0, XMMWORD PTR array$[rsp]
00065 0f 11 00 movups XMMWORD PTR [rax], xmm0
; 18 : return ptr;
; 19 : return ptr;
00068 eb 07 jmp SHORT $LN3@load
$LN2@load:
; 19 : }
; 20 : else
; 21 : {
; 22 : return -1;
; 20 : }
; 21 : else
; 22 : {
; 23 : return -1;
0006a 48 c7 c0 ff ff
ff ff mov rax, -1
$LN3@load:
; 23 : }
; 24 : }
; 24 : }
; 25 : }
00071 0f 28 74 24 60 movaps xmm6, XMMWORD PTR [rsp+96]
00076 0f 28 7c 24 50 movaps xmm7, XMMWORD PTR [rsp+80]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+10 -7
View File
@@ -4,21 +4,24 @@
#include <stdio.h>
#include <stdint.h>
#include <xmmintrin.h>
#include <pmmintrin.h>
__m128 __cdecl addps(__m128* ptr1, __m128* ptr2);
int main()
{
float c[4] = { 1,2,3,4 };
float c[4] = { 1,10,100,1000 };
float c1[4] = { 1,2,3,4 };
__m128 m = _mm_loadu_ps(&c);
__m128 m1 = _mm_loadu_ps(&c1);
__m128 m3 = addps(&m,&m1);
__m128 m1 = _mm_hadd_ps(m,m);
m1 = _mm_hadd_ps(m1,m1);
m1 = m;
m1 = _mm_shuffle_ps(m,m,0b01101100);
printf("%f\t%f\t%f\t%f\t\n",
m3.m128_f32[0], m3.m128_f32[1], m3.m128_f32[2], m3.m128_f32[3]);
m1.m128_f32[0], m1.m128_f32[1], m1.m128_f32[2], m1.m128_f32[3]
);
}
__m128 addps(__m128* ptr1, __m128* ptr2)
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.