Search Unity

Inter-Frame Jobs

Discussion in 'Entity Component System' started by btristan, Mar 26, 2019.

  1. btristan

    btristan

    Joined:
    Oct 15, 2018
    Posts:
    95
    Hello,

    I am just beginning to use ECS and Jobs and can do some basic things. However, I still don't know how to customize job execution. All my jobs are scheduled during OnUpdate and complete before the frame renders. This seems like the default setup for jobs and makes sense for a lot of use-cases.

    However, it seems like it would be advantageous to do some processing while the rendering is occurring.

    For example, if I have two systems: RenderSystem and PositionUpdaterSystem.

    The RenderSystem depends on position data and PositionUpdaterSystem makes changes to the position data.

    A conventional setup might be to schedule the PositionUpdaterSystem job then the RenderSystem job, so the positions all get updated before rendering.

    How would I set up my jobs to schedule the RenderSystem job in OnUpdate, then when that is done, schedule the PositionUpdaterSystem job but allow it to execute past the end of the frame and block the next RenderSystem job until it is complete? (the intent would be to allow the positions to be updated in the free time between frames)

    Job-Scheduling.png

    Thanks,
    -Tristan
     
  2. Singtaa

    Singtaa

    Joined:
    Dec 14, 2010
    Posts:
    492
    Sounds like you want to use
    AddJobHandleForProducer()
    on an earlier barrier (such as
    BeginSimulationEntityCommandBufferSystem)?