Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

090-Vectors-Maths.cs 55KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739
  1. using Burst.Compiler.IL.Tests.Helpers;
  2. using NUnit.Framework;
  3. using Unity.Mathematics;
  4. namespace Burst.Compiler.IL.Tests
  5. {
  6. [TestFixture]
  7. internal partial class VectorsMaths
  8. {
  9. [TestCompiler]
  10. public static ulong HalfToFloatAndDouble()
  11. {
  12. return math.asuint(new half {value = 0x0000})
  13. + math.asulong(new half {value = 0x1000});
  14. }
  15. // ---------------------------------------------------------
  16. // asfloat
  17. // ---------------------------------------------------------
  18. [TestCompiler(DataRange.Standard)]
  19. public static float AsFloatInt4(ref int4 a)
  20. {
  21. return Vectors.ConvertToFloat(math.asfloat(a));
  22. }
  23. [TestCompiler(DataRange.Standard)]
  24. public static float AsFloatInt3(ref int3 a)
  25. {
  26. return Vectors.ConvertToFloat(math.asfloat(a));
  27. }
  28. [TestCompiler(DataRange.Standard)]
  29. public static float AsFloatInt2(ref int2 a)
  30. {
  31. return Vectors.ConvertToFloat(math.asfloat(a));
  32. }
  33. [TestCompiler(DataRange.Standard)]
  34. public static float AsFloatUInt4(ref uint4 a)
  35. {
  36. return Vectors.ConvertToFloat(math.asfloat(a));
  37. }
  38. // ---------------------------------------------------------
  39. // asint
  40. // ---------------------------------------------------------
  41. [TestCompiler(DataRange.Standard)]
  42. public static int AsIntFloat4(ref float4 a)
  43. {
  44. return Vectors.ConvertToInt(math.asint(a));
  45. }
  46. [TestCompiler(DataRange.Standard)]
  47. public static int AsIntFloat3(ref float3 a)
  48. {
  49. return Vectors.ConvertToInt(math.asint(a));
  50. }
  51. [TestCompiler(DataRange.Standard)]
  52. public static int AsIntFloat2(ref float2 a)
  53. {
  54. return Vectors.ConvertToInt(math.asint(a));
  55. }
  56. // ---------------------------------------------------------
  57. // asuint
  58. // ---------------------------------------------------------
  59. [TestCompiler(DataRange.Standard)]
  60. public static int AsUIntFloat4(ref float4 a)
  61. {
  62. return Vectors.ConvertToInt(math.asuint(a));
  63. }
  64. [TestCompiler(DataRange.Standard)]
  65. public static int AsUIntFloat3(ref float3 a)
  66. {
  67. return Vectors.ConvertToInt(math.asuint(a));
  68. }
  69. [TestCompiler(DataRange.Standard)]
  70. public static int AsUIntFloat2(ref float2 a)
  71. {
  72. return Vectors.ConvertToInt(math.asuint(a));
  73. }
  74. // ---------------------------------------------------------
  75. // compress
  76. // ---------------------------------------------------------
  77. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  78. public static unsafe int CompressInt4(ref int4 value, ref bool4 mask)
  79. {
  80. var temp = default(TestCompressInt4);
  81. var ptr = &temp.Value0;
  82. var count = math.compress(ptr, 0, value, mask);
  83. int result = 0;
  84. for (int i = 0; i < count; i++)
  85. {
  86. result = result * 397 + ptr[i];
  87. }
  88. return result;
  89. }
  90. // ---------------------------------------------------------
  91. // compress
  92. // ---------------------------------------------------------
  93. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  94. public static unsafe uint CompressUInt4(ref uint4 value, ref bool4 mask)
  95. {
  96. var temp = default(TestCompressUInt4);
  97. var ptr = &temp.Value0;
  98. var count = math.compress(ptr, 0, value, mask);
  99. uint result = 0;
  100. for (int i = 0; i < count; i++)
  101. {
  102. result = result * 397 + ptr[i];
  103. }
  104. return result;
  105. }
  106. // ---------------------------------------------------------
  107. // compress
  108. // ---------------------------------------------------------
  109. // IL2CPP codegen on Android fixed in 2023.1
  110. // ... but now it's broken on Switch
  111. // ... and also broken on macOS
  112. #if BURST_TESTS_ONLY || (UNITY_2023_1_OR_NEWER && !UNITY_SWITCH && !UNITY_STANDALONE_OSX)
  113. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  114. public static unsafe float CompressFloat4(ref float4 value, ref bool4 mask)
  115. {
  116. var temp = default(TestCompressFloat4);
  117. var ptr = &temp.Value0;
  118. var count = math.compress(ptr, 0, value, mask);
  119. float result = 0;
  120. for (int i = 0; i < count; i++)
  121. {
  122. result = result * 397 + ptr[i];
  123. }
  124. return result;
  125. }
  126. #endif
  127. // ---------------------------------------------------------
  128. // count_bits
  129. // ---------------------------------------------------------
  130. [TestCompiler(DataRange.Standard)]
  131. public static int CountBitsInt(int value)
  132. {
  133. return math.countbits(value);
  134. }
  135. [TestCompiler(DataRange.Standard)]
  136. public static int CountBitsInt2(ref int2 value)
  137. {
  138. return Vectors.ConvertToInt(math.countbits(value));
  139. }
  140. [TestCompiler(DataRange.Standard)]
  141. public static int CountBitsInt3(ref int3 value)
  142. {
  143. return Vectors.ConvertToInt(math.countbits(value));
  144. }
  145. [TestCompiler(DataRange.Standard)]
  146. public static int CountBitsInt4(ref int4 value)
  147. {
  148. return Vectors.ConvertToInt(math.countbits(value));
  149. }
  150. [TestCompiler(DataRange.Standard)]
  151. public static int CountBitsUInt(uint value)
  152. {
  153. return math.countbits(value);
  154. }
  155. [TestCompiler(DataRange.Standard)]
  156. public static int CountBitsUInt2(ref uint2 value)
  157. {
  158. return Vectors.ConvertToInt(math.countbits(value));
  159. }
  160. [TestCompiler(DataRange.Standard)]
  161. public static int CountBitsUInt3(ref uint3 value)
  162. {
  163. return Vectors.ConvertToInt(math.countbits(value));
  164. }
  165. [TestCompiler(DataRange.Standard)]
  166. public static int CountBitsUInt4(ref uint4 value)
  167. {
  168. return Vectors.ConvertToInt(math.countbits(value));
  169. }
  170. [TestCompiler(DataRange.Standard)]
  171. public static int CountBitsLong(long value)
  172. {
  173. return math.countbits(value);
  174. }
  175. [TestCompiler(DataRange.Standard)]
  176. public static int CountBitsULong(ulong value)
  177. {
  178. return math.countbits(value);
  179. }
  180. // ---------------------------------------------------------
  181. // lzcnt
  182. // ---------------------------------------------------------
  183. [TestCompiler(DataRange.Standard)]
  184. public static int LzCntInt(int value)
  185. {
  186. return math.lzcnt(value);
  187. }
  188. [TestCompiler(DataRange.Standard)]
  189. public static int LzCntInt2(ref int2 value)
  190. {
  191. return Vectors.ConvertToInt(math.lzcnt(value));
  192. }
  193. [TestCompiler(DataRange.Standard)]
  194. public static int LzCntInt3(ref int3 value)
  195. {
  196. return Vectors.ConvertToInt(math.lzcnt(value));
  197. }
  198. [TestCompiler(DataRange.Standard)]
  199. public static int LzCntInt4(ref int4 value)
  200. {
  201. return Vectors.ConvertToInt(math.lzcnt(value));
  202. }
  203. [TestCompiler(DataRange.Standard)]
  204. public static int LzCntUInt(uint value)
  205. {
  206. return math.lzcnt(value);
  207. }
  208. [TestCompiler(DataRange.Standard)]
  209. public static int LzCntUInt2(ref uint2 value)
  210. {
  211. return Vectors.ConvertToInt(math.lzcnt(value));
  212. }
  213. [TestCompiler(DataRange.Standard)]
  214. public static int LzCntUInt3(ref uint3 value)
  215. {
  216. return Vectors.ConvertToInt(math.lzcnt(value));
  217. }
  218. [TestCompiler(DataRange.Standard)]
  219. public static int LzCntUInt4(ref uint4 value)
  220. {
  221. return Vectors.ConvertToInt(math.lzcnt(value));
  222. }
  223. [TestCompiler(DataRange.Standard)]
  224. public static int LzCntLong(long value)
  225. {
  226. return math.lzcnt(value);
  227. }
  228. [TestCompiler(DataRange.Standard)]
  229. public static int LzCntULong(ulong value)
  230. {
  231. return math.lzcnt(value);
  232. }
  233. // ---------------------------------------------------------
  234. // tzcnt
  235. // ---------------------------------------------------------
  236. [TestCompiler(DataRange.Standard)]
  237. public static int TzCntInt(int value)
  238. {
  239. return math.tzcnt(value);
  240. }
  241. [TestCompiler(DataRange.Standard)]
  242. public static int TzCntInt2(ref int2 value)
  243. {
  244. return Vectors.ConvertToInt(math.tzcnt(value));
  245. }
  246. [TestCompiler(DataRange.Standard)]
  247. public static int TzCntInt3(ref int3 value)
  248. {
  249. return Vectors.ConvertToInt(math.tzcnt(value));
  250. }
  251. [TestCompiler(DataRange.Standard)]
  252. public static int TzCntInt4(ref int4 value)
  253. {
  254. return Vectors.ConvertToInt(math.tzcnt(value));
  255. }
  256. [TestCompiler(DataRange.Standard)]
  257. public static int TzCntUInt(uint value)
  258. {
  259. return math.tzcnt(value);
  260. }
  261. [TestCompiler(DataRange.Standard)]
  262. public static int TzCntUInt2(ref uint2 value)
  263. {
  264. return Vectors.ConvertToInt(math.tzcnt(value));
  265. }
  266. [TestCompiler(DataRange.Standard)]
  267. public static int TzCntUInt3(ref uint3 value)
  268. {
  269. return Vectors.ConvertToInt(math.tzcnt(value));
  270. }
  271. [TestCompiler(DataRange.Standard)]
  272. public static int TzCntUInt4(ref uint4 value)
  273. {
  274. return Vectors.ConvertToInt(math.tzcnt(value));
  275. }
  276. [TestCompiler(DataRange.Standard)]
  277. public static int TzCntLong(long value)
  278. {
  279. return math.tzcnt(value);
  280. }
  281. [TestCompiler(DataRange.Standard)]
  282. public static int TzCntULong(ulong value)
  283. {
  284. return math.tzcnt(value);
  285. }
  286. // ---------------------------------------------------------
  287. // min
  288. // ---------------------------------------------------------
  289. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  290. public static float Min4(ref float4 a, ref float4 b)
  291. {
  292. return Vectors.ConvertToFloat(math.min(a, b));
  293. }
  294. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  295. public static float Min3(ref float3 a, ref float3 b)
  296. {
  297. return Vectors.ConvertToFloat(math.min(a, b));
  298. }
  299. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  300. public static float Min2(ref float2 a, ref float2 b)
  301. {
  302. return Vectors.ConvertToFloat(math.min(a, b));
  303. }
  304. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  305. public static float Min(float a, float b)
  306. {
  307. return math.min(a, b);
  308. }
  309. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  310. public static int MinInt4(ref int4 a, ref int4 b)
  311. {
  312. return Vectors.ConvertToInt(math.min(a, b));
  313. }
  314. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  315. public static int MinInt3(ref int3 a, ref int3 b)
  316. {
  317. return Vectors.ConvertToInt(math.min(a, b));
  318. }
  319. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  320. public static int MinInt2(ref int2 a, ref int2 b)
  321. {
  322. return Vectors.ConvertToInt(math.min(a, b));
  323. }
  324. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  325. public static int MinInt(int a, int b)
  326. {
  327. return math.min(a, b);
  328. }
  329. // ---------------------------------------------------------
  330. // max
  331. // ---------------------------------------------------------
  332. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  333. public static float Max4(ref float4 a, ref float4 b)
  334. {
  335. return Vectors.ConvertToFloat(math.max(a, b));
  336. }
  337. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  338. public static float Max3(ref float3 a, ref float3 b)
  339. {
  340. return Vectors.ConvertToFloat(math.max(a, b));
  341. }
  342. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  343. public static float Max2(ref float2 a, ref float2 b)
  344. {
  345. return Vectors.ConvertToFloat(math.max(a, b));
  346. }
  347. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  348. public static float Max(float a, float b)
  349. {
  350. return math.max(a, b);
  351. }
  352. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  353. public static int MaxInt4(ref int4 a, ref int4 b)
  354. {
  355. return Vectors.ConvertToInt(math.max(a, b));
  356. }
  357. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  358. public static int MaxInt3(ref int3 a, ref int3 b)
  359. {
  360. return Vectors.ConvertToInt(math.max(a, b));
  361. }
  362. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  363. public static int MaxInt2(ref int2 a, ref int2 b)
  364. {
  365. return Vectors.ConvertToInt(math.max(a, b));
  366. }
  367. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  368. public static float MaxInt(int a, int b)
  369. {
  370. return math.max(a, b);
  371. }
  372. // ---------------------------------------------------------
  373. // lerp
  374. // ---------------------------------------------------------
  375. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive|DataRange.Zero)]
  376. public static float Lerp4(ref float4 a, ref float4 b, float w)
  377. {
  378. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  379. }
  380. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  381. public static float Lerp3(ref float3 a, ref float3 b, float w)
  382. {
  383. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  384. }
  385. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  386. public static float Lerp2(ref float2 a, ref float2 b, float w)
  387. {
  388. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  389. }
  390. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  391. public static float Lerp(float a, float b, float w)
  392. {
  393. return math.lerp(a, b, w);
  394. }
  395. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  396. public static float Lerp4_4(ref float4 a, ref float4 b, ref float4 w)
  397. {
  398. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  399. }
  400. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  401. public static float Lerp3_3(ref float3 a, ref float3 b, ref float3 w)
  402. {
  403. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  404. }
  405. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  406. public static float Lerp2_2(ref float2 a, ref float2 b, ref float2 w)
  407. {
  408. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  409. }
  410. // ---------------------------------------------------------
  411. // mad
  412. // ---------------------------------------------------------
  413. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  414. public static float Mad4(ref float4 a, ref float4 b, ref float4 c)
  415. {
  416. return Vectors.ConvertToFloat(math.mad(a, b, c));
  417. }
  418. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  419. public static float Mad3(ref float3 a, ref float3 b, ref float3 c)
  420. {
  421. return Vectors.ConvertToFloat(math.mad(a, b, c));
  422. }
  423. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  424. public static float Mad2(ref float2 a, ref float2 b, ref float2 c)
  425. {
  426. return Vectors.ConvertToFloat(math.mad(a, b, c));
  427. }
  428. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  429. public static float Mad(float a, float b, float c)
  430. {
  431. return math.mad(a, b, c);
  432. }
  433. // ---------------------------------------------------------
  434. // clamp
  435. // ---------------------------------------------------------
  436. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  437. public static float Clamp4(ref float4 x, ref float4 a, ref float4 b)
  438. {
  439. return Vectors.ConvertToFloat(math.clamp(x, a, b));
  440. }
  441. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  442. public static float Clamp3(ref float3 x, ref float3 a, ref float3 b)
  443. {
  444. return Vectors.ConvertToFloat(math.clamp(x, a, b));
  445. }
  446. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  447. public static float Clamp2(ref float2 x, ref float2 a, ref float2 b)
  448. {
  449. return Vectors.ConvertToFloat(math.clamp(x, a, b));
  450. }
  451. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  452. public static float Clamp(float x, float a, float b)
  453. {
  454. return math.clamp(x, a, b);
  455. }
  456. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  457. public static int ClampInt4(ref int4 x, ref int4 a, ref int4 b)
  458. {
  459. return Vectors.ConvertToInt(math.clamp(x, a, b));
  460. }
  461. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  462. public static int ClampInt3(ref int3 x, ref int3 a, ref int3 b)
  463. {
  464. return Vectors.ConvertToInt(math.clamp(x, a, b));
  465. }
  466. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  467. public static int ClampInt2(ref int2 x, ref int2 a, ref int2 b)
  468. {
  469. return Vectors.ConvertToInt(math.clamp(x, a, b));
  470. }
  471. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  472. public static int ClampInt(int x, int a, int b)
  473. {
  474. return math.clamp(x, a, b);
  475. }
  476. // ---------------------------------------------------------
  477. // saturate
  478. // ---------------------------------------------------------
  479. [TestCompiler(DataRange.Standard)]
  480. public static float Saturate4(ref float4 x)
  481. {
  482. return Vectors.ConvertToFloat(math.saturate(x));
  483. }
  484. [TestCompiler(DataRange.Standard)]
  485. public static float Saturate3(ref float3 x)
  486. {
  487. return Vectors.ConvertToFloat(math.saturate(x));
  488. }
  489. [TestCompiler(DataRange.Standard)]
  490. public static float Saturate2(ref float2 x)
  491. {
  492. return Vectors.ConvertToFloat(math.saturate(x));
  493. }
  494. [TestCompiler(DataRange.Standard)]
  495. public static float Saturate(float x)
  496. {
  497. return math.saturate(x);
  498. }
  499. // ---------------------------------------------------------
  500. // abs
  501. // ---------------------------------------------------------
  502. [TestCompiler(DataRange.Standard)]
  503. public static float Abs4(ref float4 x)
  504. {
  505. return Vectors.ConvertToFloat(math.abs(x));
  506. }
  507. [TestCompiler(DataRange.Standard)]
  508. public static float Abs3(ref float3 x)
  509. {
  510. return Vectors.ConvertToFloat(math.abs(x));
  511. }
  512. [TestCompiler(DataRange.Standard)]
  513. public static float Abs2(ref float2 x)
  514. {
  515. return Vectors.ConvertToFloat(math.abs(x));
  516. }
  517. [TestCompiler(DataRange.Standard)]
  518. public static float Abs(float x)
  519. {
  520. return math.abs(x);
  521. }
  522. [TestCompiler(DataRange.Standard)]
  523. public static double AbsDouble4(ref double4 x)
  524. {
  525. return Vectors.ConvertToDouble(math.abs(x));
  526. }
  527. [TestCompiler(DataRange.Standard)]
  528. public static double AbsDouble3(ref double3 x)
  529. {
  530. return Vectors.ConvertToDouble(math.abs(x));
  531. }
  532. [TestCompiler(DataRange.Standard)]
  533. public static double AbsDouble2(ref double2 x)
  534. {
  535. return Vectors.ConvertToDouble(math.abs(x));
  536. }
  537. [TestCompiler(DataRange.Standard)]
  538. public static double AbsDouble(double x)
  539. {
  540. return math.abs(x);
  541. }
  542. [TestCompiler(DataRange.Standard)]
  543. public static int AbsInt4(ref int4 x)
  544. {
  545. return Vectors.ConvertToInt(math.abs(x));
  546. }
  547. [TestCompiler(DataRange.Standard)]
  548. public static int AbsInt3(ref int3 x)
  549. {
  550. return Vectors.ConvertToInt(math.abs(x));
  551. }
  552. [TestCompiler(DataRange.Standard)]
  553. public static int AbsInt2(ref int2 x)
  554. {
  555. return Vectors.ConvertToInt(math.abs(x));
  556. }
  557. [TestCompiler(DataRange.Standard)]
  558. public static int AbsInt(int x)
  559. {
  560. return math.abs(x);
  561. }
  562. // ---------------------------------------------------------
  563. // dot
  564. // ---------------------------------------------------------
  565. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  566. public static float Dot4(ref float4 a, ref float4 b)
  567. {
  568. return math.dot(a, b);
  569. }
  570. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  571. public static float Dot3(ref float3 a, ref float3 b)
  572. {
  573. return math.dot(a, b);
  574. }
  575. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  576. public static float Dot2(ref float2 a, ref float2 b)
  577. {
  578. return math.dot(a, b);
  579. }
  580. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  581. public static float Dot(float a, float b)
  582. {
  583. return math.dot(a, b);
  584. }
  585. // ---------------------------------------------------------
  586. // cmin
  587. // ---------------------------------------------------------
  588. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  589. public static float CMin4(ref float4 input)
  590. {
  591. return math.cmin(input);
  592. }
  593. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  594. public static float CMin3(ref float3 input)
  595. {
  596. return math.cmin(input);
  597. }
  598. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  599. public static float CMin2(ref float2 input)
  600. {
  601. return math.cmin(input);
  602. }
  603. [TestCompiler(DataRange.Standard)]
  604. public static float CMinInt4(ref int4 input)
  605. {
  606. return math.cmin(input);
  607. }
  608. [TestCompiler(DataRange.Standard)]
  609. public static float CMinInt3(ref int3 input)
  610. {
  611. return math.cmin(input);
  612. }
  613. [TestCompiler(DataRange.Standard)]
  614. public static float CMinInt2(ref int2 input)
  615. {
  616. return math.cmin(input);
  617. }
  618. // ---------------------------------------------------------
  619. // cmax
  620. // ---------------------------------------------------------
  621. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  622. public static float CMax4(ref float4 input)
  623. {
  624. return math.cmax(input);
  625. }
  626. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  627. public static float CMax3(ref float3 input)
  628. {
  629. return math.cmax(input);
  630. }
  631. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  632. public static float CMax2(ref float2 input)
  633. {
  634. return math.cmax(input);
  635. }
  636. [TestCompiler(DataRange.Standard)]
  637. public static float CMaxInt4(ref int4 input)
  638. {
  639. return math.cmax(input);
  640. }
  641. [TestCompiler(DataRange.Standard)]
  642. public static float CMaxInt3(ref int3 input)
  643. {
  644. return math.cmax(input);
  645. }
  646. [TestCompiler(DataRange.Standard)]
  647. public static float CMaxInt2(ref int2 input)
  648. {
  649. return math.cmax(input);
  650. }
  651. // ---------------------------------------------------------
  652. // csum
  653. // ---------------------------------------------------------
  654. [TestCompiler(DataRange.Standard)]
  655. public static double CSum4d(ref double4 input)
  656. {
  657. return math.csum(input);
  658. }
  659. [TestCompiler(DataRange.Standard)]
  660. public static float CSum4(ref float4 input)
  661. {
  662. return math.csum(input);
  663. }
  664. [TestCompiler(DataRange.Standard)]
  665. public static float CSum3(ref float3 input)
  666. {
  667. return math.csum(input);
  668. }
  669. [TestCompiler(DataRange.Standard)]
  670. public static float CSum2(ref float2 input)
  671. {
  672. return math.csum(input);
  673. }
  674. [TestCompiler(DataRange.Standard)]
  675. public static float CSumInt4(ref int4 input)
  676. {
  677. return math.csum(input);
  678. }
  679. [TestCompiler(DataRange.Standard)]
  680. public static float CSumInt3(ref int3 input)
  681. {
  682. return math.csum(input);
  683. }
  684. [TestCompiler(DataRange.Standard)]
  685. public static float CSumInt2(ref int2 input)
  686. {
  687. return math.csum(input);
  688. }
  689. // ---------------------------------------------------------
  690. // acos
  691. // ---------------------------------------------------------
  692. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  693. public static float ACos4(ref float4 input)
  694. {
  695. return Vectors.ConvertToFloat(math.acos(input));
  696. }
  697. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  698. public static float ACos3(ref float3 input)
  699. {
  700. return Vectors.ConvertToFloat(math.acos(input));
  701. }
  702. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  703. public static float ACos2(ref float2 input)
  704. {
  705. return Vectors.ConvertToFloat(math.acos(input));
  706. }
  707. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  708. public static float ACos(float input)
  709. {
  710. return math.acos(input);
  711. }
  712. // ---------------------------------------------------------
  713. // asin
  714. // ---------------------------------------------------------
  715. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  716. public static float ASin4(ref float4 input)
  717. {
  718. return Vectors.ConvertToFloat(math.asin(input));
  719. }
  720. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  721. public static float ASin3(ref float3 input)
  722. {
  723. return Vectors.ConvertToFloat(math.asin(input));
  724. }
  725. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  726. public static float ASin2(ref float2 input)
  727. {
  728. return Vectors.ConvertToFloat(math.asin(input));
  729. }
  730. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  731. public static float ASin(float input)
  732. {
  733. return math.asin(input);
  734. }
  735. // ---------------------------------------------------------
  736. // atan
  737. // ---------------------------------------------------------
  738. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  739. public static float ATan_4(ref float4 input)
  740. {
  741. return Vectors.ConvertToFloat(math.atan(input));
  742. }
  743. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  744. public static float ATan_3(ref float3 input)
  745. {
  746. return Vectors.ConvertToFloat(math.atan(input));
  747. }
  748. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  749. public static float ATan_2(ref float2 input)
  750. {
  751. return Vectors.ConvertToFloat(math.atan(input));
  752. }
  753. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  754. public static float ATan(float input)
  755. {
  756. return math.atan(input);
  757. }
  758. // ---------------------------------------------------------
  759. // atan2
  760. // ---------------------------------------------------------
  761. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive, DataRange.MinusOneInclusiveToOneInclusive)]
  762. public static float ATan2_4(ref float4 a, ref float4 b)
  763. {
  764. return Vectors.ConvertToFloat(math.atan2(a, b));
  765. }
  766. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive, DataRange.MinusOneInclusiveToOneInclusive)]
  767. public static float ATan2_3(ref float3 a, ref float3 b)
  768. {
  769. return Vectors.ConvertToFloat(math.atan2(a, b));
  770. }
  771. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive, DataRange.MinusOneInclusiveToOneInclusive)]
  772. public static float ATan2_2(ref float2 a, ref float2 b)
  773. {
  774. return Vectors.ConvertToFloat(math.atan2(a, b));
  775. }
  776. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive, DataRange.MinusOneInclusiveToOneInclusive)]
  777. public static float ATan2(float a, float b)
  778. {
  779. return math.atan2(a, b);
  780. }
  781. // ---------------------------------------------------------
  782. // cos
  783. // ---------------------------------------------------------
  784. [TestCompiler(DataRange.Standard)]
  785. public static double Cos4d(ref double4 input)
  786. {
  787. return Vectors.ConvertToDouble(math.cos(input));
  788. }
  789. [TestCompiler(DataRange.Standard)]
  790. public static float Cos4(ref float4 input)
  791. {
  792. return Vectors.ConvertToFloat(math.cos(input));
  793. }
  794. [TestCompiler(DataRange.Standard)]
  795. public static float Cos3(ref float3 input)
  796. {
  797. return Vectors.ConvertToFloat(math.cos(input));
  798. }
  799. [TestCompiler(DataRange.Standard)]
  800. public static float Cos2(ref float2 input)
  801. {
  802. return Vectors.ConvertToFloat(math.cos(input));
  803. }
  804. [TestCompiler(DataRange.Standard)]
  805. public static float Cos(float input)
  806. {
  807. return math.cos(input);
  808. }
  809. // ---------------------------------------------------------
  810. // cosh
  811. // ---------------------------------------------------------
  812. [TestCompiler(DataRange.Standard)]
  813. public static double Cosh4d(ref double4 input)
  814. {
  815. return Vectors.ConvertToDouble(math.cosh(input));
  816. }
  817. [TestCompiler(DataRange.Standard)]
  818. public static float Cosh4(ref float4 input)
  819. {
  820. return Vectors.ConvertToFloat(math.cosh(input));
  821. }
  822. [TestCompiler(DataRange.Standard)]
  823. public static float Cosh3(ref float3 input)
  824. {
  825. return Vectors.ConvertToFloat(math.cosh(input));
  826. }
  827. [TestCompiler(DataRange.Standard)]
  828. public static float Cosh2(ref float2 input)
  829. {
  830. return Vectors.ConvertToFloat(math.cosh(input));
  831. }
  832. [TestCompiler(DataRange.Standard)]
  833. public static float Cosh(float input)
  834. {
  835. return math.cosh(input);
  836. }
  837. // ---------------------------------------------------------
  838. // sin
  839. // ---------------------------------------------------------
  840. [TestCompiler(DataRange.Standard)]
  841. public static double Sin4d(ref double4 input)
  842. {
  843. return Vectors.ConvertToDouble(math.sin(input));
  844. }
  845. [TestCompiler(DataRange.Standard)]
  846. public static float Sin4(ref float4 input)
  847. {
  848. return Vectors.ConvertToFloat(math.sin(input));
  849. }
  850. [TestCompiler(DataRange.Standard)]
  851. public static float Sin3(ref float3 input)
  852. {
  853. return Vectors.ConvertToFloat(math.sin(input));
  854. }
  855. [TestCompiler(DataRange.Standard)]
  856. public static float Sin2(ref float2 input)
  857. {
  858. return Vectors.ConvertToFloat(math.sin(input));
  859. }
  860. [TestCompiler(DataRange.Standard)]
  861. public static float Sin(float input)
  862. {
  863. return math.sin(input);
  864. }
  865. // ---------------------------------------------------------
  866. // sinh
  867. // ---------------------------------------------------------
  868. [TestCompiler(DataRange.Standard)]
  869. public static float Sinh4(ref float4 input)
  870. {
  871. return Vectors.ConvertToFloat(math.sinh(input));
  872. }
  873. [TestCompiler(DataRange.Standard)]
  874. public static float Sinh3(ref float3 input)
  875. {
  876. return Vectors.ConvertToFloat(math.sinh(input));
  877. }
  878. [TestCompiler(DataRange.Standard)]
  879. public static float Sinh2(ref float2 input)
  880. {
  881. return Vectors.ConvertToFloat(math.sinh(input));
  882. }
  883. [TestCompiler(DataRange.Standard)]
  884. public static float Sinh(float input)
  885. {
  886. return math.sinh(input);
  887. }
  888. // ---------------------------------------------------------
  889. // sincos
  890. // ---------------------------------------------------------
  891. [TestCompiler(DataRange.Standard)]
  892. public static float SinCos4(ref float4 input)
  893. {
  894. float4 sina, cosa;
  895. math.sincos(input, out sina, out cosa);
  896. return Vectors.ConvertToFloat(sina) + Vectors.ConvertToFloat(cosa) * 7.1f;
  897. }
  898. [TestCompiler(DataRange.Standard)]
  899. public static float SinCos3(ref float3 input)
  900. {
  901. float3 sina, cosa;
  902. math.sincos(input, out sina, out cosa);
  903. return Vectors.ConvertToFloat(sina) + Vectors.ConvertToFloat(cosa) * 7.1f;
  904. }
  905. [TestCompiler(DataRange.Standard)]
  906. public static float SinCos2(ref float2 input)
  907. {
  908. float2 sina, cosa;
  909. math.sincos(input, out sina, out cosa);
  910. return Vectors.ConvertToFloat(sina) + Vectors.ConvertToFloat(cosa) * 7.1f;
  911. }
  912. [TestCompiler(DataRange.Standard)]
  913. public static float SinCos(float input)
  914. {
  915. float sina, cosa;
  916. math.sincos(input, out sina, out cosa);
  917. return sina + cosa * 7.1f;
  918. }
  919. // ---------------------------------------------------------
  920. // tanh
  921. // ---------------------------------------------------------
  922. [TestCompiler(DataRange.Standard)]
  923. public static float Tanh4(ref float4 input)
  924. {
  925. return Vectors.ConvertToFloat(math.tanh(input));
  926. }
  927. [TestCompiler(DataRange.Standard)]
  928. public static float Tanh3(ref float3 input)
  929. {
  930. return Vectors.ConvertToFloat(math.tanh(input));
  931. }
  932. [TestCompiler(DataRange.Standard)]
  933. public static float Tanh2(ref float2 input)
  934. {
  935. return Vectors.ConvertToFloat(math.tanh(input));
  936. }
  937. [TestCompiler(DataRange.Standard)]
  938. public static float Tanh(float input)
  939. {
  940. return math.tanh(input);
  941. }
  942. // ---------------------------------------------------------
  943. // sqrt
  944. // ---------------------------------------------------------
  945. [TestCompiler(DataRange.Standard)]
  946. public static float Sqrt4(ref float4 input)
  947. {
  948. return Vectors.ConvertToFloat(math.sqrt(input));
  949. }
  950. [TestCompiler(DataRange.Standard)]
  951. public static float Sqrt3(ref float3 input)
  952. {
  953. return Vectors.ConvertToFloat(math.sqrt(input));
  954. }
  955. [TestCompiler(DataRange.Standard)]
  956. public static float Sqrt2(ref float2 input)
  957. {
  958. return Vectors.ConvertToFloat(math.sqrt(input));
  959. }
  960. [TestCompiler(DataRange.Standard)]
  961. public static float Sqrt(float input)
  962. {
  963. return math.sqrt(input);
  964. }
  965. // ---------------------------------------------------------
  966. // rsqrt
  967. // ---------------------------------------------------------
  968. [TestCompiler(DataRange.Standard)]
  969. public static float RSqrt4(ref float4 input)
  970. {
  971. return Vectors.ConvertToFloat(math.rsqrt(input));
  972. }
  973. [TestCompiler(DataRange.Standard)]
  974. public static float RSqrt3(ref float3 input)
  975. {
  976. return Vectors.ConvertToFloat(math.rsqrt(input));
  977. }
  978. [TestCompiler(DataRange.Standard)]
  979. public static float RSqrt2(ref float2 input)
  980. {
  981. return Vectors.ConvertToFloat(math.rsqrt(input));
  982. }
  983. [TestCompiler(DataRange.Standard)]
  984. public static float RSqrt(float input)
  985. {
  986. return math.rsqrt(input);
  987. }
  988. // ---------------------------------------------------------
  989. // floor
  990. // ---------------------------------------------------------
  991. [TestCompiler(DataRange.Standard)]
  992. public static float Floor4(ref float4 input)
  993. {
  994. return Vectors.ConvertToFloat(math.floor(input));
  995. }
  996. [TestCompiler(DataRange.Standard)]
  997. public static float Floor3(ref float3 input)
  998. {
  999. return Vectors.ConvertToFloat(math.floor(input));
  1000. }
  1001. [TestCompiler(DataRange.Standard)]
  1002. public static float Floor2(ref float2 input)
  1003. {
  1004. return Vectors.ConvertToFloat(math.floor(input));
  1005. }
  1006. [TestCompiler(DataRange.Standard)]
  1007. public static float Floor(float input)
  1008. {
  1009. return math.floor(input);
  1010. }
  1011. // ---------------------------------------------------------
  1012. // ceil
  1013. // ---------------------------------------------------------
  1014. [TestCompiler(DataRange.Standard)]
  1015. public static float Ceil4(ref float4 input)
  1016. {
  1017. return Vectors.ConvertToFloat(math.ceil(input));
  1018. }
  1019. [TestCompiler(DataRange.Standard)]
  1020. public static float Ceil3(ref float3 input)
  1021. {
  1022. return Vectors.ConvertToFloat(math.ceil(input));
  1023. }
  1024. [TestCompiler(DataRange.Standard)]
  1025. public static float Ceil2(ref float2 input)
  1026. {
  1027. return Vectors.ConvertToFloat(math.ceil(input));
  1028. }
  1029. [TestCompiler(DataRange.Standard)]
  1030. public static float Ceil(float input)
  1031. {
  1032. return math.ceil(input);
  1033. }
  1034. // ---------------------------------------------------------
  1035. // round
  1036. // ---------------------------------------------------------
  1037. [TestCompiler(DataRange.Standard)]
  1038. public static float Round4(ref float4 input)
  1039. {
  1040. return Vectors.ConvertToFloat(math.round(input));
  1041. }
  1042. [TestCompiler(DataRange.Standard)]
  1043. public static float Round3(ref float3 input)
  1044. {
  1045. return Vectors.ConvertToFloat(math.round(input));
  1046. }
  1047. [TestCompiler(DataRange.Standard)]
  1048. public static float Round2(ref float2 input)
  1049. {
  1050. return Vectors.ConvertToFloat(math.round(input));
  1051. }
  1052. [TestCompiler(DataRange.Standard)]
  1053. public static float Round(float input)
  1054. {
  1055. return math.round(input);
  1056. }
  1057. // ---------------------------------------------------------
  1058. // frac
  1059. // ---------------------------------------------------------
  1060. [TestCompiler(DataRange.Standard)]
  1061. public static float Frac4(ref float4 input)
  1062. {
  1063. return Vectors.ConvertToFloat(math.frac(input));
  1064. }
  1065. [TestCompiler(DataRange.Standard)]
  1066. public static float Frac3(ref float3 input)
  1067. {
  1068. return Vectors.ConvertToFloat(math.frac(input));
  1069. }
  1070. [TestCompiler(DataRange.Standard)]
  1071. public static float Frac2(ref float2 input)
  1072. {
  1073. return Vectors.ConvertToFloat(math.frac(input));
  1074. }
  1075. [TestCompiler(DataRange.Standard)]
  1076. public static float Frac(float input)
  1077. {
  1078. return math.frac(input);
  1079. }
  1080. // ---------------------------------------------------------
  1081. // rcp
  1082. // ---------------------------------------------------------
  1083. [TestCompiler(DataRange.Standard)]
  1084. public static float Rcp4(ref float4 input)
  1085. {
  1086. return Vectors.ConvertToFloat(math.rcp(input));
  1087. }
  1088. [TestCompiler(DataRange.Standard)]
  1089. public static float Rcp3(ref float3 input)
  1090. {
  1091. return Vectors.ConvertToFloat(math.rcp(input));
  1092. }
  1093. [TestCompiler(DataRange.Standard)]
  1094. public static float Rcp2(ref float2 input)
  1095. {
  1096. return Vectors.ConvertToFloat(math.rcp(input));
  1097. }
  1098. [TestCompiler(DataRange.Standard)]
  1099. public static float Rcp(float input)
  1100. {
  1101. return math.rcp(input);
  1102. }
  1103. // ---------------------------------------------------------
  1104. // sign
  1105. // ---------------------------------------------------------
  1106. [TestCompiler(DataRange.Standard)]
  1107. public static float Sign4(ref float4 input)
  1108. {
  1109. return Vectors.ConvertToFloat(math.sign(input));
  1110. }
  1111. [TestCompiler(DataRange.Standard)]
  1112. public static float Sign3(ref float3 input)
  1113. {
  1114. return Vectors.ConvertToFloat(math.sign(input));
  1115. }
  1116. [TestCompiler(DataRange.Standard)]
  1117. public static float Sign2(ref float2 input)
  1118. {
  1119. return Vectors.ConvertToFloat(math.sign(input));
  1120. }
  1121. [TestCompiler(DataRange.Standard)]
  1122. public static float Sign(float input)
  1123. {
  1124. return math.sign(input);
  1125. }
  1126. // ---------------------------------------------------------
  1127. // pow
  1128. // ---------------------------------------------------------
  1129. [TestCompiler(DataRange.Standard & ~(DataRange.NaN | DataRange.Zero), DataRange.Standard)]
  1130. [TestCompiler(DataRange.Standard & ~(DataRange.NaN), DataRange.Standard & ~(DataRange.Zero))]
  1131. public static float Pow4(ref float4 a, ref float4 b)
  1132. {
  1133. return Vectors.ConvertToFloat(math.pow(a, b));
  1134. }
  1135. [TestCompiler(DataRange.Standard & ~(DataRange.NaN | DataRange.Zero), DataRange.Standard)]
  1136. [TestCompiler(DataRange.Standard & ~(DataRange.NaN), DataRange.Standard & ~(DataRange.Zero))]
  1137. public static float Pow3(ref float3 a, ref float3 b)
  1138. {
  1139. return Vectors.ConvertToFloat(math.pow(a, b));
  1140. }
  1141. [TestCompiler(DataRange.Standard & ~(DataRange.NaN | DataRange.Zero), DataRange.Standard)]
  1142. [TestCompiler(DataRange.Standard & ~(DataRange.NaN), DataRange.Standard & ~(DataRange.Zero))]
  1143. public static float Pow2(ref float2 a, ref float2 b)
  1144. {
  1145. return Vectors.ConvertToFloat(math.pow(a, b));
  1146. }
  1147. [TestCompiler(DataRange.Standard & ~(DataRange.NaN | DataRange.Zero), DataRange.Standard)]
  1148. [TestCompiler(DataRange.Standard & ~(DataRange.NaN), DataRange.Standard & ~(DataRange.Zero))]
  1149. public static float Pow(float a, float b)
  1150. {
  1151. return math.pow(a, b);
  1152. }
  1153. // ---------------------------------------------------------
  1154. // exp
  1155. // ---------------------------------------------------------
  1156. [TestCompiler(DataRange.Standard)]
  1157. public static float Exp4(ref float4 input)
  1158. {
  1159. return Vectors.ConvertToFloat(math.exp(input));
  1160. }
  1161. [TestCompiler(DataRange.Standard)]
  1162. public static float Exp3(ref float3 input)
  1163. {
  1164. return Vectors.ConvertToFloat(math.exp(input));
  1165. }
  1166. [TestCompiler(DataRange.Standard)]
  1167. public static float Exp2(ref float2 input)
  1168. {
  1169. return Vectors.ConvertToFloat(math.exp(input));
  1170. }
  1171. [TestCompiler(DataRange.Standard)]
  1172. public static float Exp(float input)
  1173. {
  1174. return math.exp(input);
  1175. }
  1176. // ---------------------------------------------------------
  1177. // mod
  1178. // ---------------------------------------------------------
  1179. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1180. public static float Mod4(ref float4 a, ref float4 b)
  1181. {
  1182. return Vectors.ConvertToFloat(math.fmod(a, b));
  1183. }
  1184. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1185. public static float Mod3(ref float3 a, ref float3 b)
  1186. {
  1187. return Vectors.ConvertToFloat(math.fmod(a, b));
  1188. }
  1189. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1190. public static float Mod2(ref float2 a, ref float2 b)
  1191. {
  1192. return Vectors.ConvertToFloat(math.fmod(a, b));
  1193. }
  1194. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1195. public static float Mod(float a, float b)
  1196. {
  1197. return math.fmod(a, b);
  1198. }
  1199. // ---------------------------------------------------------
  1200. // normalize
  1201. // ---------------------------------------------------------
  1202. [TestCompiler(DataRange.Standard)]
  1203. public static float Normalize4(ref float4 input)
  1204. {
  1205. return Vectors.ConvertToFloat(math.normalize(input));
  1206. }
  1207. [TestCompiler(DataRange.Standard)]
  1208. public static float Normalize3(ref float3 input)
  1209. {
  1210. return Vectors.ConvertToFloat(math.normalize(input));
  1211. }
  1212. [TestCompiler(DataRange.Standard)]
  1213. public static float Normalize2(ref float2 input)
  1214. {
  1215. return Vectors.ConvertToFloat(math.normalize(input));
  1216. }
  1217. // ---------------------------------------------------------
  1218. // length
  1219. // ---------------------------------------------------------
  1220. [TestCompiler(DataRange.Standard)]
  1221. public static float Length4(ref float4 input)
  1222. {
  1223. return math.length(input);
  1224. }
  1225. [TestCompiler(DataRange.Standard)]
  1226. public static float Length3(ref float3 input)
  1227. {
  1228. return math.length(input);
  1229. }
  1230. [TestCompiler(DataRange.Standard)]
  1231. public static float Length2(ref float2 input)
  1232. {
  1233. return math.length(input);
  1234. }
  1235. [TestCompiler(DataRange.Standard)]
  1236. public static float Length(float input)
  1237. {
  1238. return math.length(input);
  1239. }
  1240. // ---------------------------------------------------------
  1241. // distance
  1242. // ---------------------------------------------------------
  1243. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1244. public static float Distance4(ref float4 a, ref float4 b)
  1245. {
  1246. return math.distance(a, b);
  1247. }
  1248. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1249. public static float Distance3(ref float3 a, ref float3 b)
  1250. {
  1251. return math.distance(a, b);
  1252. }
  1253. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1254. public static float Distance2(ref float2 a, ref float2 b)
  1255. {
  1256. return math.distance(a, b);
  1257. }
  1258. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1259. public static float Distance(float a, float b)
  1260. {
  1261. return math.distance(a, b);
  1262. }
  1263. // ---------------------------------------------------------
  1264. // cross
  1265. // ---------------------------------------------------------
  1266. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1267. public static float Cross3(ref float3 a, ref float3 b)
  1268. {
  1269. return Vectors.ConvertToFloat(math.cross(a, b));
  1270. }
  1271. // ---------------------------------------------------------
  1272. // smoothstep
  1273. // ---------------------------------------------------------
  1274. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  1275. public static float Smoothstep4(ref float4 a, ref float4 b, float w)
  1276. {
  1277. return Vectors.ConvertToFloat(math.smoothstep(a, b, w));
  1278. }
  1279. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  1280. public static float Smoothstep3(ref float3 a, ref float3 b, float w)
  1281. {
  1282. return Vectors.ConvertToFloat(math.smoothstep(a, b, w));
  1283. }
  1284. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  1285. public static float Smoothstep2(ref float2 a, ref float2 b, float w)
  1286. {
  1287. return Vectors.ConvertToFloat(math.smoothstep(a, b, w));
  1288. }
  1289. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  1290. public static float Smoothstep(float a, float b, float w)
  1291. {
  1292. return math.smoothstep(a, b, w);
  1293. }
  1294. // ---------------------------------------------------------
  1295. // any
  1296. // ---------------------------------------------------------
  1297. [TestCompiler(DataRange.Standard)]
  1298. public static bool Any4(ref float4 input)
  1299. {
  1300. return math.any(input);
  1301. }
  1302. [TestCompiler(DataRange.Standard)]
  1303. public static bool Any32(ref float3 input)
  1304. {
  1305. return math.any(input);
  1306. }
  1307. [TestCompiler(DataRange.Standard)]
  1308. public static bool Any(ref float2 input)
  1309. {
  1310. return math.any(input);
  1311. }
  1312. [TestCompiler(DataRange.Standard)]
  1313. public static bool AnyInt4(ref int4 input)
  1314. {
  1315. return math.any(input);
  1316. }
  1317. [TestCompiler(DataRange.Standard)]
  1318. public static bool AnyInt3(ref int3 input)
  1319. {
  1320. return math.any(input);
  1321. }
  1322. [TestCompiler(DataRange.Standard)]
  1323. public static bool AnyInt2(ref int2 input)
  1324. {
  1325. return math.any(input);
  1326. }
  1327. [TestCompiler(DataRange.Standard)]
  1328. public static bool AnyBool4(ref bool4 input)
  1329. {
  1330. return math.any(input);
  1331. }
  1332. [TestCompiler(DataRange.Standard)]
  1333. public static bool AnyBool3(ref bool3 input)
  1334. {
  1335. return math.any(input);
  1336. }
  1337. [TestCompiler(DataRange.Standard)]
  1338. public static bool AnyBool2(ref bool2 input)
  1339. {
  1340. return math.any(input);
  1341. }
  1342. // ---------------------------------------------------------
  1343. // all
  1344. // ---------------------------------------------------------
  1345. [TestCompiler(DataRange.Standard)]
  1346. public static bool All4(ref float4 input)
  1347. {
  1348. return math.all(input);
  1349. }
  1350. [TestCompiler(DataRange.Standard)]
  1351. public static bool All3(ref float3 input)
  1352. {
  1353. return math.all(input);
  1354. }
  1355. [TestCompiler(DataRange.Standard)]
  1356. public static bool All2(ref float2 input)
  1357. {
  1358. return math.all(input);
  1359. }
  1360. [TestCompiler(DataRange.Standard)]
  1361. public static bool AllInt4(ref int4 input)
  1362. {
  1363. return math.all(input);
  1364. }
  1365. [TestCompiler(DataRange.Standard)]
  1366. public static bool AllInt3(ref int3 input)
  1367. {
  1368. return math.all(input);
  1369. }
  1370. [TestCompiler(DataRange.Standard)]
  1371. public static bool AllInt2(ref int2 input)
  1372. {
  1373. return math.all(input);
  1374. }
  1375. [TestCompiler(DataRange.Standard)]
  1376. public static bool AllBool4(ref bool4 input)
  1377. {
  1378. return math.all(input);
  1379. }
  1380. [TestCompiler(DataRange.Standard)]
  1381. public static bool AllBool3(ref bool3 input)
  1382. {
  1383. return math.all(input);
  1384. }
  1385. [TestCompiler(DataRange.Standard)]
  1386. public static bool AllBool2(ref bool2 input)
  1387. {
  1388. return math.all(input);
  1389. }
  1390. // ---------------------------------------------------------
  1391. // select
  1392. // ---------------------------------------------------------
  1393. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  1394. public static float Select4(ref bool4 c, ref float4 a, ref float4 b)
  1395. {
  1396. return Vectors.ConvertToFloat(math.select(a, b, c));
  1397. }
  1398. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  1399. public static float Select3(ref bool3 c, ref float3 a, ref float3 b)
  1400. {
  1401. return Vectors.ConvertToFloat(math.select(a, b, c));
  1402. }
  1403. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  1404. public static float Select(ref bool2 c, ref float2 a, ref float2 b)
  1405. {
  1406. return Vectors.ConvertToFloat(math.select(a, b, c));
  1407. }
  1408. // ---------------------------------------------------------
  1409. // step
  1410. // ---------------------------------------------------------
  1411. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1412. public static float Step4(ref float4 a, ref float4 b)
  1413. {
  1414. return Vectors.ConvertToFloat(math.step(a, b));
  1415. }
  1416. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1417. public static float Step3(ref float3 a, ref float3 b)
  1418. {
  1419. return Vectors.ConvertToFloat(math.step(a, b));
  1420. }
  1421. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1422. public static float Step2(ref float2 a, ref float2 b)
  1423. {
  1424. return Vectors.ConvertToFloat(math.step(a, b));
  1425. }
  1426. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1427. public static float Step(float a, float b)
  1428. {
  1429. return math.step(a, b);
  1430. }
  1431. // ---------------------------------------------------------
  1432. // reflect
  1433. // ---------------------------------------------------------
  1434. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1435. public static float Reflect4(ref float4 a, ref float4 b)
  1436. {
  1437. return Vectors.ConvertToFloat(math.reflect(a, b));
  1438. }
  1439. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1440. public static float Reflect3(ref float3 a, ref float3 b)
  1441. {
  1442. return Vectors.ConvertToFloat(math.reflect(a, b));
  1443. }
  1444. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1445. public static float Reflect2(ref float2 a, ref float2 b)
  1446. {
  1447. return Vectors.ConvertToFloat(math.reflect(a, b));
  1448. }
  1449. struct TestCompressInt4
  1450. {
  1451. #pragma warning disable 0649
  1452. public int Value0;
  1453. public int Value1;
  1454. public int Value2;
  1455. public int Value3;
  1456. #pragma warning restore 0649
  1457. }
  1458. struct TestCompressUInt4
  1459. {
  1460. #pragma warning disable 0649
  1461. public uint Value0;
  1462. public uint Value1;
  1463. public uint Value2;
  1464. public uint Value3;
  1465. #pragma warning restore 0649
  1466. }
  1467. struct TestCompressFloat4
  1468. {
  1469. #pragma warning disable 0649
  1470. public float Value0;
  1471. public float Value1;
  1472. public float Value2;
  1473. public float Value3;
  1474. #pragma warning restore 0649
  1475. }
  1476. }
  1477. }