Search Unity

Accessing all ISharedComponentData in jobified parallel fashion?

Discussion in 'Entity Component System' started by Mr-Mechanical, Dec 19, 2019.

  1. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    Hello,

    I've made some forum posts on the post on this topic, but I'm worried things have changed with new APIs. How is this done now? I want to access look at/process ISharedComponentData in a parallel fashion.

    Thanks.
     
  2. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    Answer the same afaik. You can't operate on ISCD directly inside job. Only with ISCD index.
     
  4. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    The data is not on the chunk header. SCD sharing mechanism is by distributing only an integer index. The integer index together with SCD type index gets the real data. But EntityManager is not here to utilize those in the job, plus job touching managed data would be bad for Burst and bad for safety as SCD can be anything.

    I do hope there is a way to explicitly state that SCD is a value type and let those values be copied to each chunk (in some sense "shared" but not really) and use in-job. However all over the API ISharedComponentData isn't with `struct` type constraint.

    But then we get close to chunk component in concept with that. Maybe you can try using that instead. (together with blob inside that chunk component, so it get as close to SCD as possible. chunk component = not on each entity, blob = shared + readonly) Though I am not sure how chunk component works when entity move around to an another chunk. It could be more messy than SCD. Never use it before.
     
    Last edited: Dec 20, 2019
    Mr-Mechanical likes this.