Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

090-Vectors-Swizzles.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using NUnit.Framework;
  2. using Unity.Mathematics;
  3. namespace Burst.Compiler.IL.Tests
  4. {
  5. [TestFixture]
  6. internal partial class VectorsSwizzles
  7. {
  8. public struct StructWithFloat4
  9. {
  10. public float4 Vec4;
  11. }
  12. [TestCompiler]
  13. public static float SwizzleLoadLocalXyz()
  14. {
  15. var v4 = new float4(1.0f, 2.0f, 3.0f, 4.0f);
  16. var v3 = v4.xyz;
  17. return v3.x + v3.y * 10 + v3.z * 100;
  18. }
  19. [TestCompiler]
  20. public static float SwizzleLoadLoadlZyx()
  21. {
  22. var v4 = new float4(1.0f, 2.0f, 3.0f, 4.0f);
  23. var v3 = v4.zyx;
  24. return v3.x + v3.y * 10 + v3.z * 100;
  25. }
  26. [TestCompiler]
  27. public static float SwizzleStoreLocalZyx()
  28. {
  29. var v4 = new float4(1.0f, 2.0f, 3.0f, 4.0f);
  30. v4.zyx = new float3(10.0f, 20.0f, 30.0f);
  31. return v4.x + v4.y * 10.0f + v4.z * 100.0f + v4.w * 1000.0f;
  32. }
  33. [TestCompiler]
  34. public static float SwizzleLoadIndirectXyz()
  35. {
  36. var localStruct = new StructWithFloat4();
  37. localStruct.Vec4 = new float4(1.0f, 2.0f, 3.0f, 4.0f);
  38. var v3 = localStruct.Vec4.zyx;
  39. return v3.x + v3.y * 10 + v3.z * 100;
  40. }
  41. [TestCompiler]
  42. public static float SwizzleStoreIndirectXyz()
  43. {
  44. var localStruct = new StructWithFloat4();
  45. localStruct.Vec4 = new float4(4.0f, 5.0f, 6.0f, 7.0f);
  46. localStruct.Vec4.zyx = new float3(1.0f, 2.0f, 3.0f);
  47. var v3 = localStruct.Vec4;
  48. return v3.x + v3.y * 10 + v3.z * 100 + v3.w * 1000;
  49. }
  50. }
  51. }