Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Fine-grained control over world updating

Discussion in 'Entity Component System' started by sient, Jun 18, 2018.

  1. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I'd like to have a separate world for simulation that updates more slowly than the rendering world.

    Since this is a simulation world, it will be great to tick it fully off the main thread, but I suspect this is impossible due to limitations in the job system architecture (all jobs must run from the main thread).

    Since the main-thread tick for the simulation world may be >16ms which would break the frame-budget for the rendering world, it'd be great to time-slice the tick for the simulation world. I suspect the existing update groups can do this / are meant for this.

    However, at the moment I don't see much API surface around this. There is ScriptBehaviourUpdateOrder.CollectGroups, but looking at how it is used internally it seems like the actual logic to build the dependency graph is not exposed.
     
  2. capyvara

    capyvara

    Joined:
    Mar 11, 2010
    Posts:
    80
    jobs don't run on the main thread, they're just scheduled from it (this is what you meant?)
     
  3. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Yes, it still takes a decent chunk of time to actually coordinate and schedule the jobs, plus there are various interactions which are inheritenly single-threaded only (which the job system forces to be on the main thread, even though any thread would work).