Search Unity

  1. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice

Function pointer ref-of-class-fields safety

Discussion in 'Burst' started by Zuntatos, Jun 2, 2021.

  1. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    579
    If I call a burst method "void add (ref float3 a, ref float3 b)" like "add(ref someclass.varA, ref someother.varB)", is that potentially unsafe? What if a GC occurs (from another thread allocating or such) while the burst function is called? Does it pin the object, or does it use a temp copy, or some other way?
     
  2. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    324
    Yes, it should be safe as the .NET runtime is making sure that these refs are "fixed"
     
    Zuntatos and jasonboukheir like this.
unityunity