Files
stgsharp/源代码/StgShqrpGraphic/linear.c
T

84 lines
1.8 KiB
C

#include "StgSharpGraphic.h"
#include "SSGinternal.h"
#include <stdio.h>
#include <stdalign.h>
#include <xmmintrin.h>
STGSHARPGRAPHIC_API __m128* InitM128(float x, float y, float z, float w)
{
__m128* Ptr = _aligned_malloc(16, sizeof(__m128));
if (NULL==Ptr)
{
return (__m128*) - 1;
}
else
{
Ptr->m128_f32[0] = x;
Ptr->m128_f32[1] = y;
Ptr->m128_f32[2] = z;
Ptr->m128_f32[3] = w;
return Ptr;
}
}
STGSHARPGRAPHIC_API void DeinitM128(__m128* m128Ptr)
{
free(m128Ptr);
}
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]
);
}
STGSHARPGRAPHIC_API void VecSubVec(__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_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]
);
}
STGSHARPGRAPHIC_API void VecMulVec(__m128* ptr1, __m128* ptr2, __m128* ret)
{
*ret = _mm_mul_ps(*ptr1, *ptr2);
}