mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Refactor SIMD langext.
This commit is contained in:
@@ -47,9 +47,9 @@ namespace bx
|
||||
#define ELEMw 3
|
||||
#define IMPLEMENT_SWIZZLE(_x, _y, _z, _w) \
|
||||
template<> \
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_swiz_##_x##_y##_z##_w(float4_t _a) \
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_swiz_##_x##_y##_z##_w(float4_langext_t _a) \
|
||||
{ \
|
||||
float4_t result; \
|
||||
float4_langext_t result; \
|
||||
result.vf = __builtin_shufflevector(_a.vf, _a.vf, ELEM##_x, ELEM##_y, ELEM##_z, ELEM##_w); \
|
||||
return result; \
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace bx
|
||||
|
||||
#define IMPLEMENT_TEST(_xyzw, _mask) \
|
||||
template<> \
|
||||
BX_FLOAT4_FORCE_INLINE bool float4_test_any_##_xyzw(float4_t _test) \
|
||||
BX_FLOAT4_FORCE_INLINE bool float4_test_any_##_xyzw(float4_langext_t _test) \
|
||||
{ \
|
||||
uint32_t tmp = ( (_test.uxyzw[3]>>31)<<3) \
|
||||
| ( (_test.uxyzw[2]>>31)<<2) \
|
||||
@@ -75,7 +75,7 @@ namespace bx
|
||||
} \
|
||||
\
|
||||
template<> \
|
||||
BX_FLOAT4_FORCE_INLINE bool float4_test_all_##_xyzw(float4_t _test) \
|
||||
BX_FLOAT4_FORCE_INLINE bool float4_test_all_##_xyzw(float4_langext_t _test) \
|
||||
{ \
|
||||
uint32_t tmp = ( (_test.uxyzw[3]>>31)<<3) \
|
||||
| ( (_test.uxyzw[2]>>31)<<2) \
|
||||
@@ -104,114 +104,114 @@ IMPLEMENT_TEST(xyzw , 0xf);
|
||||
#undef IMPLEMENT_TEST
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_xyAB(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_shuf_xyAB(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 0, 1, 4, 5);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_ABxy(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_shuf_ABxy(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 4, 5, 0, 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_CDzw(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_shuf_CDzw(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 5, 7, 2, 3);
|
||||
float4_langext_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 6, 7, 2, 3);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_zwCD(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_shuf_zwCD(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 2, 3, 5, 7);
|
||||
float4_langext_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 2, 3, 6, 7);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_xAyB(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_shuf_xAyB(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 0, 4, 1, 5);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_yBxA(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_shuf_yBxA(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 1, 5, 0, 4);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_zCwD(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_shuf_zCwD(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 2, 6, 3, 7);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_CzDw(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_shuf_CzDw(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 6, 2, 7, 3);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_xAzC(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_shuf_xAzC(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 0, 4, 2, 6);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_yBwD(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_shuf_yBwD(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = __builtin_shufflevector(_a.vf, _b.vf, 1, 5, 3, 7);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float float4_x(float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE float float4_x(float4_langext_t _a)
|
||||
{
|
||||
return _a.fxyzw[0];
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float float4_y(float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE float float4_y(float4_langext_t _a)
|
||||
{
|
||||
return _a.fxyzw[1];
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float float4_z(float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE float float4_z(float4_langext_t _a)
|
||||
{
|
||||
return _a.fxyzw[2];
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float float4_w(float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE float float4_w(float4_langext_t _a)
|
||||
{
|
||||
return _a.fxyzw[3];
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_ld(const void* _ptr)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_ld(const void* _ptr)
|
||||
{
|
||||
const uint32_t* input = reinterpret_cast<const uint32_t*>(_ptr);
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.uxyzw[0] = input[0];
|
||||
result.uxyzw[1] = input[1];
|
||||
result.uxyzw[2] = input[2];
|
||||
@@ -220,7 +220,7 @@ IMPLEMENT_TEST(xyzw , 0xf);
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE void float4_st(void* _ptr, float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE void float4_st(void* _ptr, float4_langext_t _a)
|
||||
{
|
||||
uint32_t* result = reinterpret_cast<uint32_t*>(_ptr);
|
||||
result[0] = _a.uxyzw[0];
|
||||
@@ -230,14 +230,14 @@ IMPLEMENT_TEST(xyzw , 0xf);
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE void float4_stx(void* _ptr, float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE void float4_stx(void* _ptr, float4_langext_t _a)
|
||||
{
|
||||
uint32_t* result = reinterpret_cast<uint32_t*>(_ptr);
|
||||
result[0] = _a.uxyzw[0];
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE void float4_stream(void* _ptr, float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE void float4_stream(void* _ptr, float4_langext_t _a)
|
||||
{
|
||||
uint32_t* result = reinterpret_cast<uint32_t*>(_ptr);
|
||||
result[0] = _a.uxyzw[0];
|
||||
@@ -247,109 +247,109 @@ IMPLEMENT_TEST(xyzw , 0xf);
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_ld(float _x, float _y, float _z, float _w)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_ld(float _x, float _y, float _z, float _w)
|
||||
{
|
||||
float4_t result;
|
||||
result.vf = { _x, _y, _z, _w };
|
||||
float4_langext_t result;
|
||||
result.vf = (float __attribute__((vector_size(16)))){ _x, _y, _z, _w };
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_ild(uint32_t _x, uint32_t _y, uint32_t _z, uint32_t _w)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_ild(uint32_t _x, uint32_t _y, uint32_t _z, uint32_t _w)
|
||||
{
|
||||
float4_t result;
|
||||
result.vu = { _x, _y, _z, _w };
|
||||
float4_langext_t result;
|
||||
result.vu = (uint32_t __attribute__((vector_size(16)))){ _x, _y, _z, _w };
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_splat(const void* _ptr)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_splat(const void* _ptr)
|
||||
{
|
||||
const uint32_t val = *reinterpret_cast<const uint32_t*>(_ptr);
|
||||
float4_t result;
|
||||
result.vu = { val, val, val, val };
|
||||
float4_langext_t result;
|
||||
result.vu = (uint32_t __attribute__((vector_size(16)))){ val, val, val, val };
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_splat(float _a)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_splat(float _a)
|
||||
{
|
||||
return float4_ld(_a, _a, _a, _a);
|
||||
return float4_ld<float4_langext_t>(_a, _a, _a, _a);
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_isplat(uint32_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_isplat(uint32_t _a)
|
||||
{
|
||||
return float4_ild(_a, _a, _a, _a);
|
||||
return float4_ild<float4_langext_t>(_a, _a, _a, _a);
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_zero()
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_zero()
|
||||
{
|
||||
return float4_ild(0, 0, 0, 0);
|
||||
return float4_ild<float4_langext_t>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_itof(float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_itof(float4_langext_t _a)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = __builtin_convertvector(_a.vi, float __attribute__((vector_size(16))) );
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_ftoi(float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_ftoi(float4_langext_t _a)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vi = __builtin_convertvector(_a.vf, int32_t __attribute__((vector_size(16))) );
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_round(float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_round(float4_langext_t _a)
|
||||
{
|
||||
const float4_t tmp = float4_ftoi(_a);
|
||||
const float4_t result = float4_itof(tmp);
|
||||
const float4_langext_t tmp = float4_ftoi(_a);
|
||||
const float4_langext_t result = float4_itof(tmp);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_add(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_add(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = _a.vf + _b.vf;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_sub(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_sub(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = _a.vf - _b.vf;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_mul(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_mul(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = _a.vf * _b.vf;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_div(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_div(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf = _a.vf / _b.vf;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_sqrt(float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_sqrt(float4_langext_t _a)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf[0] = sqrtf(_a.vf[0]);
|
||||
result.vf[1] = sqrtf(_a.vf[1]);
|
||||
result.vf[2] = sqrtf(_a.vf[2]);
|
||||
@@ -358,9 +358,9 @@ IMPLEMENT_TEST(xyzw , 0xf);
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_rsqrt_est(float4_t _a)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_rsqrt_est(float4_langext_t _a)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vf[0] = 1.0f / sqrtf(_a.vf[0]);
|
||||
result.vf[1] = 1.0f / sqrtf(_a.vf[1]);
|
||||
result.vf[2] = 1.0f / sqrtf(_a.vf[2]);
|
||||
@@ -369,144 +369,146 @@ IMPLEMENT_TEST(xyzw , 0xf);
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_cmpeq(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_cmpeq(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vi = _a.vf == _b.vf;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_cmplt(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_cmplt(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vi = _a.vf < _b.vf;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_cmple(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_cmple(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vi = _a.vf <= _b.vf;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_cmpgt(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_cmpgt(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vi = _a.vf > _b.vf;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_cmpge(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_cmpge(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vi = _a.vf >= _b.vf;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_and(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_and(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vu = _a.vu & _b.vu;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_andc(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_andc(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vu = _a.vu & ~_b.vu;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_or(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_or(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vu = _a.vu | _b.vu;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_xor(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_xor(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vu = _a.vu ^ _b.vu;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_sll(float4_t _a, int _count)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_sll(float4_langext_t _a, int _count)
|
||||
{
|
||||
float4_t result;
|
||||
const float4_t count = float4_isplat(_count);
|
||||
float4_langext_t result;
|
||||
const float4_langext_t count = float4_isplat<float4_langext_t>(_count);
|
||||
result.vu = _a.vu << count.vi;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_srl(float4_t _a, int _count)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_srl(float4_langext_t _a, int _count)
|
||||
{
|
||||
float4_t result;
|
||||
const float4_t count = float4_isplat(_count);
|
||||
float4_langext_t result;
|
||||
const float4_langext_t count = float4_isplat<float4_langext_t>(_count);
|
||||
result.vu = _a.vu >> count.vi;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_sra(float4_t _a, int _count)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_sra(float4_langext_t _a, int _count)
|
||||
{
|
||||
float4_t result;
|
||||
const float4_t count = float4_isplat(_count);
|
||||
float4_langext_t result;
|
||||
const float4_langext_t count = float4_isplat<float4_langext_t>(_count);
|
||||
result.vi = _a.vi >> count.vi;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_icmpeq(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_icmpeq(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vi = _a.vi == _b.vi;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_icmplt(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_icmplt(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vi = _a.vi < _b.vi;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_icmpgt(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_icmpgt(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vi = _a.vi > _b.vi;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_iadd(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_iadd(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vi = _a.vi + _b.vi;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_FLOAT4_FORCE_INLINE float4_t float4_isub(float4_t _a, float4_t _b)
|
||||
BX_FLOAT4_FORCE_INLINE float4_langext_t float4_isub(float4_langext_t _a, float4_langext_t _b)
|
||||
{
|
||||
float4_t result;
|
||||
float4_langext_t result;
|
||||
result.vi = _a.vi - _b.vi;
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef float4_langext_t float4_t;
|
||||
|
||||
} // namespace bx
|
||||
|
||||
#endif // BX_FLOAT4_LANGEXT_H_HEADER_GUARD
|
||||
|
||||
@@ -11,12 +11,19 @@
|
||||
#define BX_FLOAT4_FORCE_INLINE BX_FORCE_INLINE
|
||||
#define BX_FLOAT4_INLINE inline
|
||||
|
||||
#define BX_FLOAT4_SSE 0
|
||||
#define BX_FLOAT4_AVX 0
|
||||
#define BX_FLOAT4_NEON 0
|
||||
#define BX_FLOAT4_LANGEXT 0
|
||||
|
||||
#if defined(__SSE2__) || (BX_COMPILER_MSVC && (BX_ARCH_64BIT || _M_IX86_FP >= 2) )
|
||||
# include <emmintrin.h> // __m128i
|
||||
# if defined(__SSE4_1__)
|
||||
# include <smmintrin.h>
|
||||
# endif // defined(__SSE4_1__)
|
||||
# include <xmmintrin.h> // __m128
|
||||
# undef BX_FLOAT4_SSE
|
||||
# define BX_FLOAT4_SSE 1
|
||||
|
||||
namespace bx
|
||||
{
|
||||
@@ -26,6 +33,8 @@ namespace bx
|
||||
|
||||
#elif defined(__ARM_NEON__) && !BX_COMPILER_CLANG
|
||||
# include <arm_neon.h>
|
||||
# undef BX_FLOAT4_NEON
|
||||
# define BX_FLOAT4_NEON 1
|
||||
|
||||
namespace bx
|
||||
{
|
||||
@@ -38,10 +47,12 @@ namespace bx
|
||||
&& !BX_PLATFORM_IOS \
|
||||
&& BX_CLANG_HAS_EXTENSION(attribute_ext_vector_type)
|
||||
# include <math.h>
|
||||
# undef BX_FLOAT4_LANGEXT
|
||||
# define BX_FLOAT4_LANGEXT 1
|
||||
|
||||
namespace bx
|
||||
{
|
||||
typedef union float4_langext_t
|
||||
union float4_langext_t
|
||||
{
|
||||
float __attribute__((vector_size(16))) vf;
|
||||
int32_t __attribute__((vector_size(16))) vi;
|
||||
@@ -50,19 +61,19 @@ namespace bx
|
||||
int32_t ixyzw[4];
|
||||
uint32_t uxyzw[4];
|
||||
|
||||
} float4_langext_t;
|
||||
};
|
||||
} // namespace bx
|
||||
#endif //
|
||||
|
||||
namespace bx
|
||||
{
|
||||
typedef union float4_ref_t
|
||||
union float4_ref_t
|
||||
{
|
||||
float fxyzw[4];
|
||||
int32_t ixyzw[4];
|
||||
uint32_t uxyzw[4];
|
||||
|
||||
} float4_ref_t;
|
||||
};
|
||||
} // namespace bx
|
||||
|
||||
namespace bx
|
||||
@@ -351,16 +362,23 @@ IMPLEMENT_TEST(xyzw);
|
||||
|
||||
} // namespace bx
|
||||
|
||||
#if defined(__SSE2__) || (BX_COMPILER_MSVC && (BX_ARCH_64BIT || _M_IX86_FP >= 2) )
|
||||
#if BX_FLOAT4_SSE
|
||||
# include "float4_sse.h"
|
||||
#elif defined(__ARM_NEON__) && !BX_COMPILER_CLANG
|
||||
#endif // BX_FLOAT4_SSE
|
||||
|
||||
#if BX_FLOAT4_NEON
|
||||
# include "float4_neon.h"
|
||||
#elif BX_COMPILER_CLANG \
|
||||
&& !BX_PLATFORM_EMSCRIPTEN \
|
||||
&& !BX_PLATFORM_IOS \
|
||||
&& BX_CLANG_HAS_EXTENSION(attribute_ext_vector_type)
|
||||
#endif // BX_FLOAT4_NEON
|
||||
|
||||
#if BX_FLOAT4_LANGEXT
|
||||
# include "float4_langext.h"
|
||||
#else
|
||||
#endif // BX_FLOAT4_LANGEXT
|
||||
|
||||
#if !( BX_FLOAT4_SSE \
|
||||
|| BX_FLOAT4_AVX \
|
||||
|| BX_FLOAT4_NEON \
|
||||
|| BX_FLOAT4_LANGEXT \
|
||||
)
|
||||
# ifndef BX_FLOAT4_WARN_REFERENCE_IMPL
|
||||
# define BX_FLOAT4_WARN_REFERENCE_IMPL 0
|
||||
# endif // BX_FLOAT4_WARN_REFERENCE_IMPL
|
||||
|
||||
Reference in New Issue
Block a user