Daily update on 20230803 by nitload youmu, problem of parameter displacement solved, rewriting other linear math

This commit is contained in:
Nitload
2023-08-03 22:46:16 +08:00
parent 194d65edf6
commit aae7e0292c
105 changed files with 13858 additions and 11394 deletions
+70 -53
View File
@@ -1,3 +1,5 @@
#pragma once
#include "StgSharpGraphic.h"
#include "SSGinternal.h"
#include <stdio.h>
@@ -5,77 +7,92 @@
#include <xmmintrin.h>
STGSHARPGRAPHIC_API __m128* InitM128(float x, float y, float z, float w)
STGSHARPGRAPHIC_API __m128* __cdecl load(float x, float y, float z, float w)
{
__m128* Ptr = _aligned_malloc(16, sizeof(__m128));
if (NULL==Ptr)
float array[4] = {x,y,z,w};
__m128* ptr = _aligned_malloc(sizeof(__m128),16);
if (NULL != ptr)
{
return (__m128*) - 1;
*ptr = _mm_loadu_ps(&array);
return ptr;
}
else
{
Ptr->m128_f32[0] = x;
Ptr->m128_f32[1] = y;
Ptr->m128_f32[2] = z;
Ptr->m128_f32[3] = w;
return Ptr;
return -1;
}
}
STGSHARPGRAPHIC_API void DeinitM128(__m128* m128Ptr)
STGSHARPGRAPHIC_API __m128* __cdecl addps(__m128* ptr1, __m128* ptr2)
{
free(m128Ptr);
}
__m128* ret = _aligned_malloc(sizeof(__m128*),16);
STGSHARPGRAPHIC_API void __stdcall VecAddVec(__m128* ptr1,__m128* ptr2, __m128* ret)
{
printf("%llu\n",(uint64_t)ptr1);
printf("%llu\n",(uint64_t)ptr2);
printf("%llu\n",(uint64_t)ret);
printf("%f\t%f\t%f\t%f\t\n",
ptr1->m128_f32[0], ptr1->m128_f32[1], ptr1->m128_f32[2], ptr1->m128_f32[3]
);
printf("%f\t%f\t%f\t%f\t\n",
ptr2->m128_f32[0], ptr2->m128_f32[1], ptr2->m128_f32[2], ptr2->m128_f32[3]
);
*ret = _mm_add_ps(*ptr1, *ptr2);
printf("%f\t%f\t%f\t%f\t\n",
ret->m128_f32[0], ret->m128_f32[1], ret->m128_f32[2], ret->m128_f32[3]
);
if (NULL != ret)
{
*ret = _mm_add_ps(*ptr1, *ptr2);
return ret;
}
else
{
return -1;
}
}
STGSHARPGRAPHIC_API void VecSubVec(__m128* ptr1, __m128* ptr2, __m128* ret)
STGSHARPGRAPHIC_API __m128* __cdecl subps(__m128* ptr1, __m128* ptr2)
{
printf("%llu\n", (uint64_t)ptr1);
printf("%llu\n", (uint64_t)ptr2);
printf("%llu\n", (uint64_t)ret);
printf("%f\t%f\t%f\t%f\t\n",
ptr1->m128_f32[0], ptr1->m128_f32[1], ptr1->m128_f32[2], ptr1->m128_f32[3]
);
printf("%f\t%f\t%f\t%f\t\n",
ptr2->m128_f32[0], ptr2->m128_f32[1], ptr2->m128_f32[2], ptr2->m128_f32[3]
);
*ret = _mm_sub_ps(*ptr1, *ptr2);
printf("%f\t%f\t%f\t%f\t\n",
ret->m128_f32[0], ret->m128_f32[1], ret->m128_f32[2], ret->m128_f32[3]
);
__m128* ret = _aligned_malloc(sizeof(__m128*), 16);
if (NULL != ret)
{
*ret = _mm_sub_ps(*ptr1, *ptr2);
return ret;
}
else
{
return -1;
}
}
STGSHARPGRAPHIC_API void VecMulVec(__m128* ptr1, __m128* ptr2, __m128* ret)
STGSHARPGRAPHIC_API __m128* __cdecl mulps_const(__m128* ptr, float value)
{
*ret = _mm_mul_ps(*ptr1, *ptr2);
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_mul_ps(*ptr,valueVec);
return ret;
}
else
{
return -1;
}
}
STGSHARPGRAPHIC_API __m128* __cdecl mulps(__m128* ptr1, __m128* ptr2)
{
__m128* ret = _aligned_malloc(sizeof(__m128), 16);
if (NULL != ret)
{
*ret = _mm_mul_ps(*ptr1, *ptr2);
return ret;
}
else
{
return -1;
}
}
STGSHARPGRAPHIC_API void __cdecl deinitM128(__m128* ptr)
{
free(ptr);
}