Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Burst Job inside of generic class?

Discussion in 'Burst' started by fholm, Jan 18, 2019.

  1. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    I have a job that exists inside of a generic class, which I'm trying to burst compile:

    Code (csharp):
    1.  
    2.     // serializer concrete class which takes type arguments
    3.     public class Serializer<T0> : Serializer where T0 : struct, IComponentData {
    4.  
    5.       [BurstCompile]
    6.       struct Job : IJobChunk {
    7.         // type that signifies a networked entity
    8.         [ReadOnly] public ArchetypeChunkComponentType<NetworkedEntity> NetworkedComponentType;
    9.  
    10.         // the component this job serializes
    11.         [ReadOnly] public ArchetypeChunkComponentType<T0> TargetComponentType;
    12.  
    13.        // ... snip
    14.  
    The Serializer<T0> class instances are created using reflection and hosted in a system, but they are not systems themselves. Two things I've "Noticed":

    1) The unity editor or player will hard crash whenever I run this code (works fine without [BurstCompile])
    2) The job does not show up in the burst inspector so I'm assuming it's not even burst compiled
     
  2. NoDumbQuestion

    NoDumbQuestion

    Joined:
    Nov 10, 2017
    Posts:
    186
    The only think I found in doc is:

    upload_2019-1-18_17-27-34.png
    Maybe change it to
    public struct Serializer<T0> : Serializer where T0 : IComponentData
     
  3. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
  4. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    412
    I'm not sure it is your issue above... but Burst does not support today to have generic abstraction around job.schedule, so all jobs scheduled need to have an explicit usage of their type.
     
    not_a_valid_username likes this.
  5. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    Yes this was my issue - moved well past this :) thanks for the reply, but this thread is from January? :D