Tested in…
Burst 1.7.0 and 1.6.4
Unity 2021.2.9f
*Refer to the code at the bottom or the attached ErrorTest.cs file
I’ve been constantly trying to fix this error thinking it was somehow my fault it would never compile.
However, I managed to reproduce the below error using the included ErrorTest.cs script by uncommenting a single element in either array2 or array3. Commenting out an element in array1 does not work. It only compiles if you comment out a total of 6 elements from array1.
Burst error BC1361: The static readonly array field `Unity.Mathematics.int3[ ] TestArrays::array1` of type `TestArrays` is not supported by Burst
The above error code is the same error code I get in my actual project. Though, the weird thing is I have an array that has a length of 512 of type ushort in the same containing static class, so I believe the error has something to do with structs only.
I tested it again and again, every time I removed the comment(s), I get the above error message in both the console and the Burst Inspector LLVM IR Optimization Diagnostics window. When I reverted the changes, it compiles without issues.
What I’ve done to try and correct this issue:
- Reset all packages
- Reimport all
- Update Burst, and roll back to older versions
- Creating new files, move files, etc thinking maybe it was somehow corrupted
- Run anti-viral scans
- Reinstall unity
- Update unity
- Cleaned system files, caches, purged old files, etc
Some of that might not even relate to the error, but I was trying anything I could think of.
I’m pretty confident that this is in fact, a bug. Hopefully someone with insight into the Burst Compiler can resolve this issue.
Thanks.
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine;
public class ErrorTest : MonoBehaviour {
private void Start () {
NativeArray<int3> arr1 = new NativeArray<int3>(8, Allocator.TempJob);
NativeArray<int3> arr2 = new NativeArray<int3>(8, Allocator.TempJob);
NativeArray<int3> arr3 = new NativeArray<int3>(8, Allocator.TempJob);
TestJob job = new TestJob(arr1, arr2, arr3);
job.Schedule().Complete();
LogResults(arr1);
LogResults(arr2);
LogResults(arr3);
arr1.Dispose();
arr2.Dispose();
arr3.Dispose();
}
private void LogResults (NativeArray<int3> array) {
string results = $"{array} Results:\n";
for (int i = 0; i < 8; i++) results += $"{array[i]}\n";
Debug.Log(results);
}
}
[BurstCompile]
public struct TestJob : IJob {
public NativeArray<int3> results1;
public NativeArray<int3> results2;
public NativeArray<int3> results3;
public TestJob (NativeArray<int3> results1, NativeArray<int3> results2, NativeArray<int3> results3) {
this.results1 = results1;
this.results2 = results2;
this.results3 = results3;
}
public void Execute () {
// Just abratrairly read some data from the arrays
for (int i = 0; i < 8; i++) {
results1[i] = TestArrays.array1[i] + TestArrays.array2[i].GetValue1() + TestArrays.array3[i].GetValue1();
results2[i] = TestArrays.array1[i] + TestArrays.array2[i].GetValue2() + TestArrays.array3[i].GetValue2();
results3[i] = TestArrays.array1[i] + TestArrays.array2[i].CalculateValue(i) + TestArrays.array3[i].CalculateValue(i);
}
}
}
public static class TestArrays {
[BurstCompatible]
public struct TestStruct1 {
private readonly int value1;
private readonly int value2;
public TestStruct1 (int value1, int value2) {
this.value1 = value1;
this.value2 = value2;
}
public int GetValue1 () => value1;
public int GetValue2 () => value2;
public int CalculateValue (int input) => value1 + value2 + input;
}
[BurstCompatible]
public struct TestStruct2 {
private readonly int value1;
private readonly int value2;
public TestStruct2 (int value1, int value2) {
this.value1 = value1;
this.value2 = value2;
}
public int GetValue1 () => value1;
public int GetValue2 () => value2;
public int CalculateValue (int input) => value1 + value2 + input;
}
// Total Length: 181
// This array is the one that "fails" when all elements are uncommented
// Comment out 6 elements from this array when no other element from array2
// and array3 are commented for burst to compile
// Length: 8
public static readonly int3[] array1 = new int3[] {
new int3(0, 1, 2),
new int3(3, 4, 5),
new int3(6, 7, 8),
new int3(9, 10, 11),
new int3(12, 13, 14),
new int3(15, 16, 17),
new int3(18, 19, 20),
new int3(21, 22, 23)
};
// Length: 8
public static readonly TestStruct1[] array2 = new TestStruct1[] {
new TestStruct1(1, 2),
new TestStruct1(3, 4),
new TestStruct1(5, 6),
new TestStruct1(7, 8),
new TestStruct1(9, 10),
new TestStruct1(11, 12),
new TestStruct1(13, 14),
new TestStruct1(15, 16)
};
// Length: 165
public static readonly TestStruct2[] array3 = new TestStruct2[] {
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
new TestStruct2(27, 28),
new TestStruct2(29, 30),
new TestStruct2(31, 32),
new TestStruct2(17, 18),
new TestStruct2(19, 20),
new TestStruct2(21, 22),
new TestStruct2(23, 24),
new TestStruct2(25, 26),
};
}
7945546–1016803–ErrorTest.cs (9.15 KB)