Nessuna descrizione
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.

BurstCompatibleAttribute.cs 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. namespace Unity.Collections
  3. {
  4. /// <summary>
  5. /// Documents and enforces (via generated tests) that the tagged method or property has to stay burst compatible.
  6. /// </summary>
  7. /// <remarks>This attribute cannot be used with private methods or properties.</remarks>
  8. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, AllowMultiple = true)]
  9. public class BurstCompatibleAttribute : Attribute
  10. {
  11. /// <summary>
  12. /// Burst compatible compile target.
  13. /// </summary>
  14. public enum BurstCompatibleCompileTarget
  15. {
  16. /// <summary>
  17. /// Player.
  18. /// </summary>
  19. Player,
  20. /// <summary>
  21. /// Editor.
  22. /// </summary>
  23. Editor,
  24. /// <summary>
  25. /// Player and editor.
  26. /// </summary>
  27. PlayerAndEditor
  28. }
  29. /// <summary>
  30. /// Types to be used for the declared generic type or method.
  31. /// </summary>
  32. /// <remarks>
  33. /// The generic type arguments are tracked separately for types and methods. Say a generic type also contains
  34. /// a generic method, like in the case of Foo&lt;T&gt;.Bar&lt;U&gt;(T baz, U blah). You must specify
  35. /// GenericTypeArguments for Foo and also for Bar to establish the concrete types for T and U. When code
  36. /// generation occurs for the Burst compatibility tests, any time T appears (in the definition of Foo)
  37. /// it will be replaced with the generic type argument you specified for Foo and whenever U appears
  38. /// (in method Bar's body) it will be replaced by whatever generic type argument you specified for the method
  39. /// Bar.
  40. /// </remarks>
  41. public Type[] GenericTypeArguments { get; set; }
  42. /// <summary>
  43. /// Specifies the symbol that must be defined in order for the method to be tested for Burst compatibility.
  44. /// </summary>
  45. public string RequiredUnityDefine = null;
  46. /// <summary>
  47. /// Specifies whether code should be Burst compiled for the player, editor, or both.
  48. /// </summary>
  49. /// <remarks>
  50. /// When set to BurstCompatibleCompileTarget.Editor, the generated Burst compatibility code will be
  51. /// surrounded by #if UNITY_EDITOR to ensure that the Burst compatibility test will only be executed in the
  52. /// editor. The code will be compiled with Burst function pointers. If you have a non-null RequiredUnityDefine,
  53. /// an #if with the RequiredUnityDefine will also be emitted.<para/> <para/>
  54. ///
  55. /// When set to BurstCompatibilityCompileTarget.Player, the generated Burst compatibility code will
  56. /// only be surrounded by an #if containing the RequiredUnityDefine (or nothing if RequiredUnityDefine is null).
  57. /// Instead of compiling with Burst function pointers, a player build is started where the Burst AOT compiler
  58. /// will verify the Burst compatibility. This is done to speed up Burst compilation for the compatibility tests
  59. /// since Burst function pointer compilation is not done in parallel.<para/> <para/>
  60. ///
  61. /// When set to BurstCompatibilityCompileTarget.PlayerAndEditor, the generated Burst compatibility code will
  62. /// only be surrounded by an #if containing the RequiredUnityDefine (or nothing if RequiredUnityDefine is null).
  63. /// The code will be compiled both by the editor (using Burst function pointers) and with a player build (using
  64. /// Burst AOT).<para/> <para/>
  65. ///
  66. /// For best performance of the Burst compatibility tests, prefer to use BurstCompatibilityCompileTarget.Player
  67. /// as much as possible.
  68. /// </remarks>
  69. public BurstCompatibleCompileTarget CompileTarget = BurstCompatibleCompileTarget.Player;
  70. }
  71. /// <summary>
  72. /// Internal attribute to state that a method is not burst compatible even though the containing type is.
  73. /// </summary>
  74. [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor)]
  75. public class NotBurstCompatibleAttribute : Attribute
  76. {
  77. }
  78. }