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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Bug? Non injected barriers don't work when used more than once

Discussion in 'Entity Component System' started by tertle, Oct 19, 2018.

  1. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,624
    I had noticed that internal unity systems (e.g. CopyInitialTransformFromGameObjectSystem) had been using

    m_EndFrameBarrier = World.GetOrCreateManager<EndFrameBarrier>();


    Instead of

    [Inject] private EndFrameBarrier m_EndFrameBarrier;


    So I decided to do the same.

    Turns out this does not work if you create more than one buffer from the barrier because the handle is never added to the producer queue as the barrier is not added to the barrier list.

    For example this

    Code (CSharp):
    1.             var hideJob = new HideJob
    2.                               {
    3.                                   EntityCommandBuffer = this.barrier.CreateCommandBuffer().ToConcurrent(),
    4.                                   Frozen = this.GetComponentDataFromEntity<Frozen>()
    5.                               };
    6.             var hideHandle = hideJob.Schedule(this);
    7.  
    8.             var showJob = new ShowJob { EntityCommandBuffer = this.barrier.CreateCommandBuffer().ToConcurrent() };
    9.             var showHandle = showJob.Schedule(this, hideHandle);
    10.  
    11.             return showHandle;
    Only injected barriers are added to list
    ComponentSystem.cs Line 523
    m_BarrierList = ComponentSystemInjection.GetAllInjectedManagers<BarrierSystem>(this, world);


    Only barriers in this list are added to producer queue.
    ComponentSystem.cs Line 435
    Code (CSharp):
    1.             for (int i = 0; i < m_BarrierList.Length; ++i)
    2.             {
    3.                 m_BarrierList[i].AddJobHandleForProducer(outputJob);
    4.             }
    causes errors like if done without Inject

     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,653
    Hmm... which version ecs? In my case all works fine, I’m using more than one ECB from end frame barrier getted by GetOrCreateManager, I check it again today, but as I remember I didn’t see that error...
     
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,624
    p18 and p19

    I can replicate it with a very simple example which I can post tomorrow if needed.
     
  4. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,653
    Not need, yeah I understand what you mean. Barrier creates, but never playback?