Search Unity

Auto layout is not supported by burst (1.1.1)

Discussion in 'Burst' started by GilCat, Jul 25, 2019.

  1. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    After updating to Burst 1.1.1 i started getting this error.
    My specific struct is ValueTuple<int, int>

    com.unity.collections@0.0.9-preview.20\Unity.Collections\NativeQueue.cs(406,4): error: Struct `System.ValueTuple`2` with auto layout is not supported by burst
    at Unity.Collections.NativeQueue`1.Concurrent<System.ValueTuple`2<System.Int32,System.Int32>>.Enqueue(Unity.Collections.NativeQueue`1.Concurrent<System.ValueTuple`2<int,int>>* this, System.ValueTuple`2<int,int> entry)
    at Stackray.Entities.ExtractChangedSlicesFromChunks.Execute(Stackray.Entities.ExtractChangedSlicesFromChunks* this, int index)
    at Unity.Jobs.IJobParallelForExtensions.ParallelForJobStruct`1<Stackray.Entities.ExtractChangedSlicesFromChunks>.Execute(ref Stackray.Entities.ExtractChangedSlicesFromChunks jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) (at C:\buildslave\unity\build\Runtime\Jobs\Managed\IJobParallelFor.cs:43)
     
  2. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    Anything on this?
    Thanks
     
  3. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    417
    Right, we currently don't support it. I don't think it will be a problem to support it (even we don't do anything special and it is not optimal)
     
    GilCat likes this.
  4. tim_jones

    tim_jones

    Unity Technologies

    Joined:
    May 2, 2019
    Posts:
    287
    We've looked into this. The reason we added validation in Burst 1.1 to prevent use of `Auto`-layout structs is that the Mono runtime is free to reorder or move fields in these structs, and we aren't able to generate native code that is guaranteed to match the Mono memory layout. For example, this ValueTuple:

    `ValueTuple<bool, int, bool>`

    might have its fields shifted at runtime to only take up 6 bytes, instead of the at-least-9 bytes that it would otherwise take up. If you are copying values between managed code and Burst-compiled code, it would fail at runtime in difficult-to-detect ways.

    For this reason we aren't able to add support for `Auto`-layout structs in Burst.
     
    Tony_Max and GilCat like this.
  5. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    Yeah that is what I thought regarding all the flexibility that comes with ValueTuple.
    Anyway this is an easy one to fix by implementing it myself.

    Again thanks for the wonderful job you guys been doing
     
    sheredom likes this.