#According to my profiler, the job isn't using burst when i have the attribute added

1 messages · Page 1 of 1 (latest)

gilded oar
#

So i have this simple job that updates some vertices in a native array but according to the profiler they are not using burst but i don't know why.

This is what my job looks like:

        [BurstCompile]
        struct DeformJob<T> : IJobParallelFor where T : struct, IMeshDeformPath
        {
            [ReadOnly]
            NativeArray<float3> _input;
            [WriteOnly]
            NativeArray<float3> _output;
            [ReadOnly]
            readonly T _path;
            [ReadOnly]
            readonly int _loop;
            public DeformJob(NativeArray<float3> input, NativeArray<float3> output, T path, int loop)
            {
                _input = input;
                _output = output;
                _path = path;
                _loop = loop;
            }
            public void Execute(int index)
            {
                var p = _path.Lerp(index*loop);
                var n = _path.Normal(index*loop);
                p += math.normalize(n) * _input[index].x;
                p.y = _input[index].y;
                _output[index] = p;
            }
        }

How do i get it to use burst?

true wind
#

how are you scheduling it

#

generics in burst have strict requirements on how they are used

#

you need to implicitly instantiate it

#

or you need to use the RegisterGenericJob attribute

gilded oar
#

i call it like this:

new DeformJob<T>(inputVerts, newVerts, path, i).Schedule(inputVerts.Length, 1024).Complete();```
true wind
#

yeah that won't work

#

you have to clearly define
new DeformJob<MyType> somewhere

#

either in code or via RegisterGenericJobAttribute

gilded oar
#

so generic jobs have to define the specific type i use

true wind
#

burst, but yes

gilded oar
#

thats a shame

true wind
#

burst requires concrete types

#

it doesn't know what variants your code wants

#

it's AOT

gilded oar
#

might be faster for me to use gpu at this point then

true wind
#

i have a few tricks around this

gilded oar
#

whats the easiest to try?

true wind
#

depends what you're doing but let me link an example

#

public JobHandle Build(NativeArray<T> positions, JobHandle dependency, ResizeNativeKeyedMapJob resizeStub = default, QuantizeJob quantizeStub = default)

#

for example i use default fields in a method that can be ignored, but is good enough to tell burst about the job

gilded oar
#

hm interesting