Yesterday I was stumbled upon this for two hours straight. At first I thought that it was in my code after I changed my NativeArray mask to byte type, but after triple checking everything and digging around I discovered it is much worse. Basically Job works correctly if it is not [Burst] marked, or if Burst is in debug mode. It also works correctly if I manually inline my function, or change data type back to int, or do a straight cast from pointer:
[MethodImpl(MethodImplOptions.NoInlining)]
private static unsafe void ProcessColumnByte(
byte* solidMap,
float* uMap,
float* vMap,
in int2 simSize,
int idx,
int count)
{
var shiftLeft = -simSize.y;
var shiftRight = simSize.y;
const int shiftTop = 1;
const int shiftBottom = -1;
for (var j = 1; j < count; j++,
idx++)
{
var div = uMap[idx + shiftRight] + vMap[idx + shiftTop] - vMap[idx] - uMap[idx];
//it fixes this
//var solidsMap = new float4(*(solidMap + (idx + shiftLeft)), *(solidMap + idx + shiftRight), *(solidMap + idx + shiftBottom), *(solidMap + idx + shiftTop));
var solidsMap = new float4(solidMap[idx + shiftLeft], solidMap[idx + shiftRight], solidMap[idx + shiftBottom], solidMap[idx + shiftTop]);//basically I guess here it is
var s = csum(solidsMap);
var p = select(0, -div / s, s > 0);
var vectors = solidsMap * p;
uMap[idx] -= vectors.x;
}
}
9888072–1427010–VectorizerBug.zip (38.2 KB)