Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

090-Vectors-Indexers.cs 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 VectorsIndexers
  8. {
  9. [TestCompiler(0)]
  10. [TestCompiler(1)]
  11. [TestCompiler(2)]
  12. [TestCompiler(3)]
  13. public static float Float4_get_IndexerLocal(int i)
  14. {
  15. var vector = new float4(5.0f, 6.0f, 7.0f, 8.0f);
  16. return vector[i];
  17. }
  18. [TestCompiler(DataRange.Standard)]
  19. public static float Float4_get_IndexerByRef(ref float4 vector)
  20. {
  21. return vector[0] + vector[2];
  22. }
  23. [TestCompiler(0)]
  24. [TestCompiler(1)]
  25. [TestCompiler(2)]
  26. [TestCompiler(3)]
  27. public static float Float4_set_IndexerLocal(int i)
  28. {
  29. var vector = new float4(0.0f);
  30. vector[i] = 2.0f * i;
  31. return vector[0] + vector[2];
  32. }
  33. [TestCompiler(DataRange.Standard)]
  34. public static float Float4_set_IndexerByRef(ref float4 vector)
  35. {
  36. vector[0] = 10.0f;
  37. vector[2] = 15.0f;
  38. return vector[0] + vector[2];
  39. }
  40. [TestCompiler(0)]
  41. [TestCompiler(1)]
  42. [TestCompiler(2)]
  43. public static float Float3_get_IndexerLocal(int i)
  44. {
  45. var vector = new float3(5.0f, 6.0f, 7.0f);
  46. return vector[i];
  47. }
  48. [TestCompiler(DataRange.Standard)]
  49. public static float Float3_get_IndexerByRef(ref float3 vector)
  50. {
  51. return vector[0] + vector[2];
  52. }
  53. [TestCompiler(0)]
  54. [TestCompiler(1)]
  55. [TestCompiler(2)]
  56. public static float Float3_set_IndexerLocal(int i)
  57. {
  58. var vector = new float3(0.0f);
  59. vector[i] = 2.0f * i;
  60. return vector[0] + vector[2];
  61. }
  62. [TestCompiler(DataRange.Standard)]
  63. public static float Float3_set_IndexerByRef(ref float3 vector)
  64. {
  65. vector[0] = 10.0f;
  66. vector[2] = 15.0f;
  67. return vector[0] + vector[2];
  68. }
  69. [TestCompiler(DataRange.Standard)]
  70. public static int Bool_set_Indexer_Indirect(ref float4 vec)
  71. {
  72. bool4 result = false;
  73. for (int i = 0; i < 4; i++)
  74. {
  75. result[i] = CheckVector(vec[i]);
  76. }
  77. return Vectors.ConvertToInt(result);
  78. }
  79. public static bool CheckVector(float value)
  80. {
  81. return value < 10.0f;
  82. }
  83. }
  84. }