Firstborn/Library/PackageCache/com.unity.burst@1.8.4/Documentation~/csharp-system-support.md
Schaken-Mods 9092858a58 updated to the latest editor
I updated everything to the latest Unity Editor. Also realized I had the wrong shaders on my hairs, those are fixed and the hairs look MUCH better!
2023-05-07 17:43:11 -05:00

1.6 KiB

C#/.NET System namespace support

Burst provides support for some of the System namespace, transforming these into Burst compatible variants in the Burst compiler.

System.Math

Burst supports all methods that System.Math declares except for the following methods that aren't supported:

  • double IEEERemainder(double x, double y)
  • Round(double value, int digits)

System.IntPtr

Burst supports all methods of System.IntPtr/System.UIntPtr, including the static fields IntPtr.Zero and IntPtr.Size

System.Threading.Interlocked

Burst supports atomic memory intrinsics for all methods provided by System.Threading.Interlocked (for example, Interlocked.Increment).

Make sure that the source location of the interlocked methods are naturally aligned. For example, the alignment of the pointer is a multiple of the pointed-to-type:

[StructLayout(LayoutKind.Explicit)]
struct Foo
{
    [FieldOffset(0)] public long a;
    [FieldOffset(5)] public long b;

    public long AtomicReadAndAdd()
    {
        return Interlocked.Read(ref a) + Interlocked.Read(ref b);
    }
}

If the pointer to the struct Foo has an alignment of 8, which is the natural alignment of a long value, the Interlocked.Read of a would be successful because it lies on a naturally aligned address. However, b would not be successful and undefined behavior happens at the load of b as a result.

System.Threading.Thread

Burst supports the MemoryBarrier method of System.Threading.Thread.

System.Threading.Volatile

Burst supports the non-generic variants of Read and Write provided by System.Threading.Volatile.