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

Job Running after commandbuffer

Discussion in 'Entity Component System' started by dwatt-hollowworldgames, Jan 27, 2020.

  1. dwatt-hollowworldgames

    dwatt-hollowworldgames

    Joined:
    Apr 26, 2019
    Posts:
    104
    I have a situation where I want to have one job that creates entities using a command buffer and another which updates data on the entities just once. I don't want to constantly create and run the second job looking for entities with a tag. Is it possible to simply make the second job dependent on the first and know it will run on the entities the first creates? My assumption is that will not be the case as the job will run when the first finishes and not when the commandbuffer is executed and therefore will do nothing as the entities don't exist yet.
     
  2. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I think the temp entity given by ECB only make sense on the moment command is playing. The system with 2nd job can be positioned after the EntityCommandBufferSystem playback point, then work on a tag that was added as a part of entity creation.

    Why don't you want to look for entities with a tag? If it is about tag removal chunk movement (so they got worked on once) then you profile first if it is that expensive. Then if that is so you need to combine the 2nd job code in to the first where temp Entity is available to work on with the same ECB. The 2nd job with the tag remove could be more performant since it could work initializing values in parallel, with SIMD, etc.
     
    Last edited: Jan 27, 2020
  3. dwatt-hollowworldgames

    dwatt-hollowworldgames

    Joined:
    Apr 26, 2019
    Posts:
    104
    Thank you.

    yeah that makes sense. The old programmer in me wants to constantly do no more than is necessary to achieve the results. So I tend to remove any action that is not doing something. I believe I will just constantly launch the second job as I will need to constantly check for a tag which seems to be the same work either way.