[simd] Add integral loadvec3 versions that set w to 1

Always setting w to 0 made it impossible to use the resulting 4d vectors
in division-based operations as they would result in divide-by-zero and
thus an unavoidable exception (CPUs don't like integer div-by-zero).
I'll probably add similar for float and double, but they're not as
critical as they'll just give inf or nan. This also increases my doubts
about the value of keeping 3d vector operations.
This commit is contained in:
Bill Currie 2022-01-04 18:23:32 +09:00
parent 2f09ece65b
commit 63db48bf42
2 changed files with 26 additions and 0 deletions

View File

@ -97,6 +97,7 @@ GNU89INLINE inline vec4d_t qconjd (vec4d_t q) __attribute__((const));
GNU89INLINE inline vec4d_t loadvec3d (const double v3[]) __attribute__((pure));
GNU89INLINE inline void storevec3d (double v3[3], vec4d_t v4);
GNU89INLINE inline vec4l_t loadvec3l (const long *v3) __attribute__((pure));
GNU89INLINE inline vec4l_t loadvec3l1 (const long *v3) __attribute__((pure));
GNU89INLINE inline void storevec3l (long *v3, vec4l_t v4);
#ifndef IMPLEMENT_VEC4D_Funcs
@ -307,6 +308,18 @@ loadvec3l (const long *v3)
return v4;
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4l_t
loadvec3l1 (const long *v3)
{
vec4l_t v4 = { v3[0], v3[1], v3[2], 1 };
return v4;
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else

View File

@ -38,6 +38,7 @@ GNU89INLINE inline int any4i (vec4i_t v) __attribute__((const));
GNU89INLINE inline int all4i (vec4i_t v) __attribute__((const));
GNU89INLINE inline int none4i (vec4i_t v) __attribute__((const));
GNU89INLINE inline vec4i_t loadvec3i (const int *v3) __attribute__((pure));
GNU89INLINE inline vec4i_t loadvec3i1 (const int *v3) __attribute__((pure));
GNU89INLINE inline void storevec3i (int *v3, vec4i_t v4);
#ifndef IMPLEMENT_VEC4F_Funcs
@ -107,6 +108,18 @@ loadvec3i (const int *v3)
return v4;
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4i_t
loadvec3i1 (const int *v3)
{
vec4i_t v4 = { v3[0], v3[1], v3[2], 1 };
return v4;
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else