Search Unity

What should be the "jobIndex" for EntityCommandBuffer in IJobChunk?

Discussion in 'Data Oriented Technology Stack' started by TMPxyz, Jul 15, 2019.

  1. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    765
    Hi,

    I've a question on the jobIndex parameter for EntityCommandBuffer.

    The manual tells we should use "index" when use IJobParallelFor,

    The jobIndex must be a unique ID for each job. 
    For performance reasons, jobIndex should be the (increasing) index values passed to IJobParallelFor.Execute()


    But when in IJobChunk, should we use the chunkIndex for the whole chunk job, or use incremented entity index for each entity?
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    1,656
    Chunk index.

    It needs to be unique per thread which the index will be.
     
    TMPxyz likes this.
  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,423
    Or use thread index field with attribute [NativeSetThreadIndex] (on mobile, don’t remember exact syntax)