float4_ref.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. /*
  2. * Copyright 2010-2015 Branimir Karadzic. All rights reserved.
  3. * License: http://www.opensource.org/licenses/BSD-2-Clause
  4. */
  5. #ifndef BX_FLOAT4_REF_H_HEADER_GUARD
  6. #define BX_FLOAT4_REF_H_HEADER_GUARD
  7. #include <math.h> // sqrtf
  8. namespace bx
  9. {
  10. typedef union float4_t
  11. {
  12. float fxyzw[4];
  13. int32_t ixyzw[4];
  14. uint32_t uxyzw[4];
  15. } float4_t;
  16. #define ELEMx 0
  17. #define ELEMy 1
  18. #define ELEMz 2
  19. #define ELEMw 3
  20. #define IMPLEMENT_SWIZZLE(_x, _y, _z, _w) \
  21. BX_FLOAT4_FORCE_INLINE float4_t float4_swiz_##_x##_y##_z##_w(float4_t _a) \
  22. { \
  23. float4_t result; \
  24. result.ixyzw[0] = _a.ixyzw[ELEM##_x]; \
  25. result.ixyzw[1] = _a.ixyzw[ELEM##_y]; \
  26. result.ixyzw[2] = _a.ixyzw[ELEM##_z]; \
  27. result.ixyzw[3] = _a.ixyzw[ELEM##_w]; \
  28. return result; \
  29. }
  30. #include "float4_swizzle.inl"
  31. #undef IMPLEMENT_SWIZZLE
  32. #undef ELEMw
  33. #undef ELEMz
  34. #undef ELEMy
  35. #undef ELEMx
  36. #define IMPLEMENT_TEST(_xyzw, _mask) \
  37. BX_FLOAT4_FORCE_INLINE bool float4_test_any_##_xyzw(float4_t _test) \
  38. { \
  39. uint32_t tmp = ( (_test.uxyzw[3]>>31)<<3) \
  40. | ( (_test.uxyzw[2]>>31)<<2) \
  41. | ( (_test.uxyzw[1]>>31)<<1) \
  42. | ( _test.uxyzw[0]>>31) \
  43. ; \
  44. return 0 != (tmp&(_mask) ); \
  45. } \
  46. \
  47. BX_FLOAT4_FORCE_INLINE bool float4_test_all_##_xyzw(float4_t _test) \
  48. { \
  49. uint32_t tmp = ( (_test.uxyzw[3]>>31)<<3) \
  50. | ( (_test.uxyzw[2]>>31)<<2) \
  51. | ( (_test.uxyzw[1]>>31)<<1) \
  52. | ( _test.uxyzw[0]>>31) \
  53. ; \
  54. return (_mask) == (tmp&(_mask) ); \
  55. }
  56. IMPLEMENT_TEST(x , 0x1);
  57. IMPLEMENT_TEST(y , 0x2);
  58. IMPLEMENT_TEST(xy , 0x3);
  59. IMPLEMENT_TEST(z , 0x4);
  60. IMPLEMENT_TEST(xz , 0x5);
  61. IMPLEMENT_TEST(yz , 0x6);
  62. IMPLEMENT_TEST(xyz , 0x7);
  63. IMPLEMENT_TEST(w , 0x8);
  64. IMPLEMENT_TEST(xw , 0x9);
  65. IMPLEMENT_TEST(yw , 0xa);
  66. IMPLEMENT_TEST(xyw , 0xb);
  67. IMPLEMENT_TEST(zw , 0xc);
  68. IMPLEMENT_TEST(xzw , 0xd);
  69. IMPLEMENT_TEST(yzw , 0xe);
  70. IMPLEMENT_TEST(xyzw , 0xf);
  71. #undef IMPLEMENT_TEST
  72. BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_xyAB(float4_t _a, float4_t _b)
  73. {
  74. float4_t result;
  75. result.uxyzw[0] = _a.uxyzw[0];
  76. result.uxyzw[1] = _a.uxyzw[1];
  77. result.uxyzw[2] = _b.uxyzw[0];
  78. result.uxyzw[3] = _b.uxyzw[1];
  79. return result;
  80. }
  81. BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_ABxy(float4_t _a, float4_t _b)
  82. {
  83. float4_t result;
  84. result.uxyzw[0] = _b.uxyzw[0];
  85. result.uxyzw[1] = _b.uxyzw[1];
  86. result.uxyzw[2] = _a.uxyzw[0];
  87. result.uxyzw[3] = _a.uxyzw[1];
  88. return result;
  89. }
  90. BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_CDzw(float4_t _a, float4_t _b)
  91. {
  92. float4_t result;
  93. result.uxyzw[0] = _b.uxyzw[2];
  94. result.uxyzw[1] = _b.uxyzw[3];
  95. result.uxyzw[2] = _a.uxyzw[2];
  96. result.uxyzw[3] = _a.uxyzw[3];
  97. return result;
  98. }
  99. BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_zwCD(float4_t _a, float4_t _b)
  100. {
  101. float4_t result;
  102. result.uxyzw[0] = _a.uxyzw[2];
  103. result.uxyzw[1] = _a.uxyzw[3];
  104. result.uxyzw[2] = _b.uxyzw[2];
  105. result.uxyzw[3] = _b.uxyzw[3];
  106. return result;
  107. }
  108. BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_xAyB(float4_t _a, float4_t _b)
  109. {
  110. float4_t result;
  111. result.uxyzw[0] = _a.uxyzw[0];
  112. result.uxyzw[1] = _b.uxyzw[0];
  113. result.uxyzw[2] = _a.uxyzw[1];
  114. result.uxyzw[3] = _b.uxyzw[1];
  115. return result;
  116. }
  117. BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_yBxA(float4_t _a, float4_t _b)
  118. {
  119. float4_t result;
  120. result.uxyzw[0] = _a.uxyzw[1];
  121. result.uxyzw[1] = _b.uxyzw[1];
  122. result.uxyzw[2] = _a.uxyzw[0];
  123. result.uxyzw[3] = _b.uxyzw[0];
  124. return result;
  125. }
  126. BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_zCwD(float4_t _a, float4_t _b)
  127. {
  128. float4_t result;
  129. result.uxyzw[0] = _a.uxyzw[2];
  130. result.uxyzw[1] = _b.uxyzw[2];
  131. result.uxyzw[2] = _a.uxyzw[3];
  132. result.uxyzw[3] = _b.uxyzw[3];
  133. return result;
  134. }
  135. BX_FLOAT4_FORCE_INLINE float4_t float4_shuf_CzDw(float4_t _a, float4_t _b)
  136. {
  137. float4_t result;
  138. result.uxyzw[0] = _b.uxyzw[2];
  139. result.uxyzw[1] = _a.uxyzw[2];
  140. result.uxyzw[2] = _b.uxyzw[3];
  141. result.uxyzw[3] = _a.uxyzw[3];
  142. return result;
  143. }
  144. BX_FLOAT4_FORCE_INLINE float float4_x(float4_t _a)
  145. {
  146. return _a.fxyzw[0];
  147. }
  148. BX_FLOAT4_FORCE_INLINE float float4_y(float4_t _a)
  149. {
  150. return _a.fxyzw[1];
  151. }
  152. BX_FLOAT4_FORCE_INLINE float float4_z(float4_t _a)
  153. {
  154. return _a.fxyzw[2];
  155. }
  156. BX_FLOAT4_FORCE_INLINE float float4_w(float4_t _a)
  157. {
  158. return _a.fxyzw[3];
  159. }
  160. BX_FLOAT4_FORCE_INLINE float4_t float4_ld(const void* _ptr)
  161. {
  162. const uint32_t* input = reinterpret_cast<const uint32_t*>(_ptr);
  163. float4_t result;
  164. result.uxyzw[0] = input[0];
  165. result.uxyzw[1] = input[1];
  166. result.uxyzw[2] = input[2];
  167. result.uxyzw[3] = input[3];
  168. return result;
  169. }
  170. BX_FLOAT4_FORCE_INLINE void float4_st(void* _ptr, float4_t _a)
  171. {
  172. uint32_t* result = reinterpret_cast<uint32_t*>(_ptr);
  173. result[0] = _a.uxyzw[0];
  174. result[1] = _a.uxyzw[1];
  175. result[2] = _a.uxyzw[2];
  176. result[3] = _a.uxyzw[3];
  177. }
  178. BX_FLOAT4_FORCE_INLINE void float4_stx(void* _ptr, float4_t _a)
  179. {
  180. uint32_t* result = reinterpret_cast<uint32_t*>(_ptr);
  181. result[0] = _a.uxyzw[0];
  182. }
  183. BX_FLOAT4_FORCE_INLINE void float4_stream(void* _ptr, float4_t _a)
  184. {
  185. uint32_t* result = reinterpret_cast<uint32_t*>(_ptr);
  186. result[0] = _a.uxyzw[0];
  187. result[1] = _a.uxyzw[1];
  188. result[2] = _a.uxyzw[2];
  189. result[3] = _a.uxyzw[3];
  190. }
  191. BX_FLOAT4_FORCE_INLINE float4_t float4_ld(float _x, float _y, float _z, float _w)
  192. {
  193. float4_t result;
  194. result.fxyzw[0] = _x;
  195. result.fxyzw[1] = _y;
  196. result.fxyzw[2] = _z;
  197. result.fxyzw[3] = _w;
  198. return result;
  199. }
  200. BX_FLOAT4_FORCE_INLINE float4_t float4_ild(uint32_t _x, uint32_t _y, uint32_t _z, uint32_t _w)
  201. {
  202. float4_t result;
  203. result.uxyzw[0] = _x;
  204. result.uxyzw[1] = _y;
  205. result.uxyzw[2] = _z;
  206. result.uxyzw[3] = _w;
  207. return result;
  208. }
  209. BX_FLOAT4_FORCE_INLINE float4_t float4_splat(const void* _ptr)
  210. {
  211. const uint32_t val = *reinterpret_cast<const uint32_t*>(_ptr);
  212. float4_t result;
  213. result.uxyzw[0] = val;
  214. result.uxyzw[1] = val;
  215. result.uxyzw[2] = val;
  216. result.uxyzw[3] = val;
  217. return result;
  218. }
  219. BX_FLOAT4_FORCE_INLINE float4_t float4_splat(float _a)
  220. {
  221. return float4_ld(_a, _a, _a, _a);
  222. }
  223. BX_FLOAT4_FORCE_INLINE float4_t float4_isplat(uint32_t _a)
  224. {
  225. return float4_ild(_a, _a, _a, _a);
  226. }
  227. BX_FLOAT4_FORCE_INLINE float4_t float4_zero()
  228. {
  229. return float4_ild(0, 0, 0, 0);
  230. }
  231. BX_FLOAT4_FORCE_INLINE float4_t float4_itof(float4_t _a)
  232. {
  233. float4_t result;
  234. result.fxyzw[0] = (float)_a.ixyzw[0];
  235. result.fxyzw[1] = (float)_a.ixyzw[1];
  236. result.fxyzw[2] = (float)_a.ixyzw[2];
  237. result.fxyzw[3] = (float)_a.ixyzw[3];
  238. return result;
  239. }
  240. BX_FLOAT4_FORCE_INLINE float4_t float4_ftoi(float4_t _a)
  241. {
  242. float4_t result;
  243. result.ixyzw[0] = (int)_a.fxyzw[0];
  244. result.ixyzw[1] = (int)_a.fxyzw[1];
  245. result.ixyzw[2] = (int)_a.fxyzw[2];
  246. result.ixyzw[3] = (int)_a.fxyzw[3];
  247. return result;
  248. }
  249. BX_FLOAT4_FORCE_INLINE float4_t float4_round(float4_t _a)
  250. {
  251. const float4_t tmp = float4_ftoi(_a);
  252. const float4_t result = float4_itof(tmp);
  253. return result;
  254. }
  255. BX_FLOAT4_FORCE_INLINE float4_t float4_add(float4_t _a, float4_t _b)
  256. {
  257. float4_t result;
  258. result.fxyzw[0] = _a.fxyzw[0] + _b.fxyzw[0];
  259. result.fxyzw[1] = _a.fxyzw[1] + _b.fxyzw[1];
  260. result.fxyzw[2] = _a.fxyzw[2] + _b.fxyzw[2];
  261. result.fxyzw[3] = _a.fxyzw[3] + _b.fxyzw[3];
  262. return result;
  263. }
  264. BX_FLOAT4_FORCE_INLINE float4_t float4_sub(float4_t _a, float4_t _b)
  265. {
  266. float4_t result;
  267. result.fxyzw[0] = _a.fxyzw[0] - _b.fxyzw[0];
  268. result.fxyzw[1] = _a.fxyzw[1] - _b.fxyzw[1];
  269. result.fxyzw[2] = _a.fxyzw[2] - _b.fxyzw[2];
  270. result.fxyzw[3] = _a.fxyzw[3] - _b.fxyzw[3];
  271. return result;
  272. }
  273. BX_FLOAT4_FORCE_INLINE float4_t float4_mul(float4_t _a, float4_t _b)
  274. {
  275. float4_t result;
  276. result.fxyzw[0] = _a.fxyzw[0] * _b.fxyzw[0];
  277. result.fxyzw[1] = _a.fxyzw[1] * _b.fxyzw[1];
  278. result.fxyzw[2] = _a.fxyzw[2] * _b.fxyzw[2];
  279. result.fxyzw[3] = _a.fxyzw[3] * _b.fxyzw[3];
  280. return result;
  281. }
  282. BX_FLOAT4_FORCE_INLINE float4_t float4_div(float4_t _a, float4_t _b)
  283. {
  284. float4_t result;
  285. result.fxyzw[0] = _a.fxyzw[0] / _b.fxyzw[0];
  286. result.fxyzw[1] = _a.fxyzw[1] / _b.fxyzw[1];
  287. result.fxyzw[2] = _a.fxyzw[2] / _b.fxyzw[2];
  288. result.fxyzw[3] = _a.fxyzw[3] / _b.fxyzw[3];
  289. return result;
  290. }
  291. BX_FLOAT4_FORCE_INLINE float4_t float4_rcp_est(float4_t _a)
  292. {
  293. float4_t result;
  294. result.fxyzw[0] = 1.0f / _a.fxyzw[0];
  295. result.fxyzw[1] = 1.0f / _a.fxyzw[1];
  296. result.fxyzw[2] = 1.0f / _a.fxyzw[2];
  297. result.fxyzw[3] = 1.0f / _a.fxyzw[3];
  298. return result;
  299. }
  300. BX_FLOAT4_FORCE_INLINE float4_t float4_sqrt(float4_t _a)
  301. {
  302. float4_t result;
  303. result.fxyzw[0] = sqrtf(_a.fxyzw[0]);
  304. result.fxyzw[1] = sqrtf(_a.fxyzw[1]);
  305. result.fxyzw[2] = sqrtf(_a.fxyzw[2]);
  306. result.fxyzw[3] = sqrtf(_a.fxyzw[3]);
  307. return result;
  308. }
  309. BX_FLOAT4_FORCE_INLINE float4_t float4_rsqrt_est(float4_t _a)
  310. {
  311. float4_t result;
  312. result.fxyzw[0] = 1.0f / sqrtf(_a.fxyzw[0]);
  313. result.fxyzw[1] = 1.0f / sqrtf(_a.fxyzw[1]);
  314. result.fxyzw[2] = 1.0f / sqrtf(_a.fxyzw[2]);
  315. result.fxyzw[3] = 1.0f / sqrtf(_a.fxyzw[3]);
  316. return result;
  317. }
  318. BX_FLOAT4_FORCE_INLINE float4_t float4_cmpeq(float4_t _a, float4_t _b)
  319. {
  320. float4_t result;
  321. result.ixyzw[0] = _a.fxyzw[0] == _b.fxyzw[0] ? 0xffffffff : 0x0;
  322. result.ixyzw[1] = _a.fxyzw[1] == _b.fxyzw[1] ? 0xffffffff : 0x0;
  323. result.ixyzw[2] = _a.fxyzw[2] == _b.fxyzw[2] ? 0xffffffff : 0x0;
  324. result.ixyzw[3] = _a.fxyzw[3] == _b.fxyzw[3] ? 0xffffffff : 0x0;
  325. return result;
  326. }
  327. BX_FLOAT4_FORCE_INLINE float4_t float4_cmplt(float4_t _a, float4_t _b)
  328. {
  329. float4_t result;
  330. result.ixyzw[0] = _a.fxyzw[0] < _b.fxyzw[0] ? 0xffffffff : 0x0;
  331. result.ixyzw[1] = _a.fxyzw[1] < _b.fxyzw[1] ? 0xffffffff : 0x0;
  332. result.ixyzw[2] = _a.fxyzw[2] < _b.fxyzw[2] ? 0xffffffff : 0x0;
  333. result.ixyzw[3] = _a.fxyzw[3] < _b.fxyzw[3] ? 0xffffffff : 0x0;
  334. return result;
  335. }
  336. BX_FLOAT4_FORCE_INLINE float4_t float4_cmple(float4_t _a, float4_t _b)
  337. {
  338. float4_t result;
  339. result.ixyzw[0] = _a.fxyzw[0] <= _b.fxyzw[0] ? 0xffffffff : 0x0;
  340. result.ixyzw[1] = _a.fxyzw[1] <= _b.fxyzw[1] ? 0xffffffff : 0x0;
  341. result.ixyzw[2] = _a.fxyzw[2] <= _b.fxyzw[2] ? 0xffffffff : 0x0;
  342. result.ixyzw[3] = _a.fxyzw[3] <= _b.fxyzw[3] ? 0xffffffff : 0x0;
  343. return result;
  344. }
  345. BX_FLOAT4_FORCE_INLINE float4_t float4_cmpgt(float4_t _a, float4_t _b)
  346. {
  347. float4_t result;
  348. result.ixyzw[0] = _a.fxyzw[0] > _b.fxyzw[0] ? 0xffffffff : 0x0;
  349. result.ixyzw[1] = _a.fxyzw[1] > _b.fxyzw[1] ? 0xffffffff : 0x0;
  350. result.ixyzw[2] = _a.fxyzw[2] > _b.fxyzw[2] ? 0xffffffff : 0x0;
  351. result.ixyzw[3] = _a.fxyzw[3] > _b.fxyzw[3] ? 0xffffffff : 0x0;
  352. return result;
  353. }
  354. BX_FLOAT4_FORCE_INLINE float4_t float4_cmpge(float4_t _a, float4_t _b)
  355. {
  356. float4_t result;
  357. result.ixyzw[0] = _a.fxyzw[0] >= _b.fxyzw[0] ? 0xffffffff : 0x0;
  358. result.ixyzw[1] = _a.fxyzw[1] >= _b.fxyzw[1] ? 0xffffffff : 0x0;
  359. result.ixyzw[2] = _a.fxyzw[2] >= _b.fxyzw[2] ? 0xffffffff : 0x0;
  360. result.ixyzw[3] = _a.fxyzw[3] >= _b.fxyzw[3] ? 0xffffffff : 0x0;
  361. return result;
  362. }
  363. BX_FLOAT4_FORCE_INLINE float4_t float4_min(float4_t _a, float4_t _b)
  364. {
  365. float4_t result;
  366. result.fxyzw[0] = _a.fxyzw[0] < _b.fxyzw[0] ? _a.fxyzw[0] : _b.fxyzw[0];
  367. result.fxyzw[1] = _a.fxyzw[1] < _b.fxyzw[1] ? _a.fxyzw[1] : _b.fxyzw[1];
  368. result.fxyzw[2] = _a.fxyzw[2] < _b.fxyzw[2] ? _a.fxyzw[2] : _b.fxyzw[2];
  369. result.fxyzw[3] = _a.fxyzw[3] < _b.fxyzw[3] ? _a.fxyzw[3] : _b.fxyzw[3];
  370. return result;
  371. }
  372. BX_FLOAT4_FORCE_INLINE float4_t float4_max(float4_t _a, float4_t _b)
  373. {
  374. float4_t result;
  375. result.fxyzw[0] = _a.fxyzw[0] > _b.fxyzw[0] ? _a.fxyzw[0] : _b.fxyzw[0];
  376. result.fxyzw[1] = _a.fxyzw[1] > _b.fxyzw[1] ? _a.fxyzw[1] : _b.fxyzw[1];
  377. result.fxyzw[2] = _a.fxyzw[2] > _b.fxyzw[2] ? _a.fxyzw[2] : _b.fxyzw[2];
  378. result.fxyzw[3] = _a.fxyzw[3] > _b.fxyzw[3] ? _a.fxyzw[3] : _b.fxyzw[3];
  379. return result;
  380. }
  381. BX_FLOAT4_FORCE_INLINE float4_t float4_and(float4_t _a, float4_t _b)
  382. {
  383. float4_t result;
  384. result.uxyzw[0] = _a.uxyzw[0] & _b.uxyzw[0];
  385. result.uxyzw[1] = _a.uxyzw[1] & _b.uxyzw[1];
  386. result.uxyzw[2] = _a.uxyzw[2] & _b.uxyzw[2];
  387. result.uxyzw[3] = _a.uxyzw[3] & _b.uxyzw[3];
  388. return result;
  389. }
  390. BX_FLOAT4_FORCE_INLINE float4_t float4_andc(float4_t _a, float4_t _b)
  391. {
  392. float4_t result;
  393. result.uxyzw[0] = _a.uxyzw[0] & ~_b.uxyzw[0];
  394. result.uxyzw[1] = _a.uxyzw[1] & ~_b.uxyzw[1];
  395. result.uxyzw[2] = _a.uxyzw[2] & ~_b.uxyzw[2];
  396. result.uxyzw[3] = _a.uxyzw[3] & ~_b.uxyzw[3];
  397. return result;
  398. }
  399. BX_FLOAT4_FORCE_INLINE float4_t float4_or(float4_t _a, float4_t _b)
  400. {
  401. float4_t result;
  402. result.uxyzw[0] = _a.uxyzw[0] | _b.uxyzw[0];
  403. result.uxyzw[1] = _a.uxyzw[1] | _b.uxyzw[1];
  404. result.uxyzw[2] = _a.uxyzw[2] | _b.uxyzw[2];
  405. result.uxyzw[3] = _a.uxyzw[3] | _b.uxyzw[3];
  406. return result;
  407. }
  408. BX_FLOAT4_FORCE_INLINE float4_t float4_xor(float4_t _a, float4_t _b)
  409. {
  410. float4_t result;
  411. result.uxyzw[0] = _a.uxyzw[0] ^ _b.uxyzw[0];
  412. result.uxyzw[1] = _a.uxyzw[1] ^ _b.uxyzw[1];
  413. result.uxyzw[2] = _a.uxyzw[2] ^ _b.uxyzw[2];
  414. result.uxyzw[3] = _a.uxyzw[3] ^ _b.uxyzw[3];
  415. return result;
  416. }
  417. BX_FLOAT4_FORCE_INLINE float4_t float4_sll(float4_t _a, int _count)
  418. {
  419. float4_t result;
  420. result.uxyzw[0] = _a.uxyzw[0] << _count;
  421. result.uxyzw[1] = _a.uxyzw[1] << _count;
  422. result.uxyzw[2] = _a.uxyzw[2] << _count;
  423. result.uxyzw[3] = _a.uxyzw[3] << _count;
  424. return result;
  425. }
  426. BX_FLOAT4_FORCE_INLINE float4_t float4_srl(float4_t _a, int _count)
  427. {
  428. float4_t result;
  429. result.uxyzw[0] = _a.uxyzw[0] >> _count;
  430. result.uxyzw[1] = _a.uxyzw[1] >> _count;
  431. result.uxyzw[2] = _a.uxyzw[2] >> _count;
  432. result.uxyzw[3] = _a.uxyzw[3] >> _count;
  433. return result;
  434. }
  435. BX_FLOAT4_FORCE_INLINE float4_t float4_sra(float4_t _a, int _count)
  436. {
  437. float4_t result;
  438. result.ixyzw[0] = _a.ixyzw[0] >> _count;
  439. result.ixyzw[1] = _a.ixyzw[1] >> _count;
  440. result.ixyzw[2] = _a.ixyzw[2] >> _count;
  441. result.ixyzw[3] = _a.ixyzw[3] >> _count;
  442. return result;
  443. }
  444. BX_FLOAT4_FORCE_INLINE float4_t float4_icmpeq(float4_t _a, float4_t _b)
  445. {
  446. float4_t result;
  447. result.ixyzw[0] = _a.ixyzw[0] == _b.ixyzw[0] ? 0xffffffff : 0x0;
  448. result.ixyzw[1] = _a.ixyzw[1] == _b.ixyzw[1] ? 0xffffffff : 0x0;
  449. result.ixyzw[2] = _a.ixyzw[2] == _b.ixyzw[2] ? 0xffffffff : 0x0;
  450. result.ixyzw[3] = _a.ixyzw[3] == _b.ixyzw[3] ? 0xffffffff : 0x0;
  451. return result;
  452. }
  453. BX_FLOAT4_FORCE_INLINE float4_t float4_icmplt(float4_t _a, float4_t _b)
  454. {
  455. float4_t result;
  456. result.ixyzw[0] = _a.ixyzw[0] < _b.ixyzw[0] ? 0xffffffff : 0x0;
  457. result.ixyzw[1] = _a.ixyzw[1] < _b.ixyzw[1] ? 0xffffffff : 0x0;
  458. result.ixyzw[2] = _a.ixyzw[2] < _b.ixyzw[2] ? 0xffffffff : 0x0;
  459. result.ixyzw[3] = _a.ixyzw[3] < _b.ixyzw[3] ? 0xffffffff : 0x0;
  460. return result;
  461. }
  462. BX_FLOAT4_FORCE_INLINE float4_t float4_icmpgt(float4_t _a, float4_t _b)
  463. {
  464. float4_t result;
  465. result.ixyzw[0] = _a.ixyzw[0] > _b.ixyzw[0] ? 0xffffffff : 0x0;
  466. result.ixyzw[1] = _a.ixyzw[1] > _b.ixyzw[1] ? 0xffffffff : 0x0;
  467. result.ixyzw[2] = _a.ixyzw[2] > _b.ixyzw[2] ? 0xffffffff : 0x0;
  468. result.ixyzw[3] = _a.ixyzw[3] > _b.ixyzw[3] ? 0xffffffff : 0x0;
  469. return result;
  470. }
  471. BX_FLOAT4_FORCE_INLINE float4_t float4_imin(float4_t _a, float4_t _b)
  472. {
  473. float4_t result;
  474. result.ixyzw[0] = _a.ixyzw[0] < _b.ixyzw[0] ? _a.ixyzw[0] : _b.ixyzw[0];
  475. result.ixyzw[1] = _a.ixyzw[1] < _b.ixyzw[1] ? _a.ixyzw[1] : _b.ixyzw[1];
  476. result.ixyzw[2] = _a.ixyzw[2] < _b.ixyzw[2] ? _a.ixyzw[2] : _b.ixyzw[2];
  477. result.ixyzw[3] = _a.ixyzw[3] < _b.ixyzw[3] ? _a.ixyzw[3] : _b.ixyzw[3];
  478. return result;
  479. }
  480. BX_FLOAT4_FORCE_INLINE float4_t float4_imax(float4_t _a, float4_t _b)
  481. {
  482. float4_t result;
  483. result.ixyzw[0] = _a.ixyzw[0] > _b.ixyzw[0] ? _a.ixyzw[0] : _b.ixyzw[0];
  484. result.ixyzw[1] = _a.ixyzw[1] > _b.ixyzw[1] ? _a.ixyzw[1] : _b.ixyzw[1];
  485. result.ixyzw[2] = _a.ixyzw[2] > _b.ixyzw[2] ? _a.ixyzw[2] : _b.ixyzw[2];
  486. result.ixyzw[3] = _a.ixyzw[3] > _b.ixyzw[3] ? _a.ixyzw[3] : _b.ixyzw[3];
  487. return result;
  488. }
  489. BX_FLOAT4_FORCE_INLINE float4_t float4_iadd(float4_t _a, float4_t _b)
  490. {
  491. float4_t result;
  492. result.ixyzw[0] = _a.ixyzw[0] + _b.ixyzw[0];
  493. result.ixyzw[1] = _a.ixyzw[1] + _b.ixyzw[1];
  494. result.ixyzw[2] = _a.ixyzw[2] + _b.ixyzw[2];
  495. result.ixyzw[3] = _a.ixyzw[3] + _b.ixyzw[3];
  496. return result;
  497. }
  498. BX_FLOAT4_FORCE_INLINE float4_t float4_isub(float4_t _a, float4_t _b)
  499. {
  500. float4_t result;
  501. result.ixyzw[0] = _a.ixyzw[0] - _b.ixyzw[0];
  502. result.ixyzw[1] = _a.ixyzw[1] - _b.ixyzw[1];
  503. result.ixyzw[2] = _a.ixyzw[2] - _b.ixyzw[2];
  504. result.ixyzw[3] = _a.ixyzw[3] - _b.ixyzw[3];
  505. return result;
  506. }
  507. } // namespace bx
  508. #define float4_shuf_xAzC float4_shuf_xAzC_ni
  509. #define float4_shuf_yBwD float4_shuf_yBwD_ni
  510. #define float4_rcp float4_rcp_ni
  511. #define float4_orx float4_orx_ni
  512. #define float4_orc float4_orc_ni
  513. #define float4_neg float4_neg_ni
  514. #define float4_madd float4_madd_ni
  515. #define float4_nmsub float4_nmsub_ni
  516. #define float4_div_nr float4_div_nr_ni
  517. #define float4_selb float4_selb_ni
  518. #define float4_sels float4_sels_ni
  519. #define float4_not float4_not_ni
  520. #define float4_abs float4_abs_ni
  521. #define float4_clamp float4_clamp_ni
  522. #define float4_lerp float4_lerp_ni
  523. #define float4_rsqrt float4_rsqrt_ni
  524. #define float4_rsqrt_nr float4_rsqrt_nr_ni
  525. #define float4_rsqrt_carmack float4_rsqrt_carmack_ni
  526. #define float4_sqrt_nr float4_sqrt_nr_ni
  527. #define float4_log2 float4_log2_ni
  528. #define float4_exp2 float4_exp2_ni
  529. #define float4_pow float4_pow_ni
  530. #define float4_cross3 float4_cross3_ni
  531. #define float4_normalize3 float4_normalize3_ni
  532. #define float4_dot3 float4_dot3_ni
  533. #define float4_dot float4_dot_ni
  534. #define float4_ceil float4_ceil_ni
  535. #define float4_floor float4_floor_ni
  536. #include "float4_ni.h"
  537. #endif // BX_FLOAT4_REF_H_HEADER_GUARD