Search Unity

Question About [BurstCompile] above a function

Discussion in 'Burst' started by MatanYamin, May 25, 2023.

  1. MatanYamin

    MatanYamin

    Joined:
    Feb 2, 2022
    Posts:
    110
    Hey everyone,

    So i'm using IJobParallelForTransform inside my game.

    Inside that Job, I have some functions to calculate things. I was wondering if I need to add the "[BurstCompile]" above each function in order to make it burst compile or having only 1 above the main Job is enough?
     
    Last edited: May 28, 2023
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    From what I know it's best to have a static class with all the helper functions. Then add the tag on the class, and on each static function.
    You can check if something is burst compiled in the burst inspector
     
    MatanYamin likes this.
  3. Per-Morten

    Per-Morten

    Joined:
    Aug 23, 2019
    Posts:
    119
    As far as I'm aware, functions you call from a bursted function is also bursted (excluding DLL stuff, etc), so if you have a job that has the [BurstCompile] attribute, then you don't need to add the [BurstCompile] attribute to the functions you call within that job.
     
    MatanYamin, tim_jones and DevDunk like this.
  4. MatanYamin

    MatanYamin

    Joined:
    Feb 2, 2022
    Posts:
    110