Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

how to pass data from one dependecy group to the next?

Discussion in '2018.1 Beta' started by laurentlavigne, Jan 14, 2018.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    Code (CSharp):
    1.  
    2. for (int i=0..30) // wouldn't that be nice to have that syntax in c#
    3. {
    4.    NativeArray<float> input = new NativeArray<float>(someArray, Allocator.Persistent);
    5.    NativeArray<float> output = new NativeArray<float>(some.Length, Allocator.Persistent);
    6.    new JobA()
    7.           {
    8.              input = input,
    9.              output = output
    10.           }.Schedule(30,5);
    11. }
    12. var dependency = JobHandle.CombineDependencies(handlesJobA);
    13. for (int i=0..10) // wanna
    14. {
    15.    NativeArray<float> output = new NativeArray<float>(some.Length, Allocator.Persistent);
    16.    new JobB()
    17.           {
    18.              input = somethingFromJobA,
    19.              output = output
    20.           }.Schedule(10,2,dependency);
    21. }
    How do I get some data from jobA to jobB?
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,660
    You pass the NativeArrays that you created on line 5 as inputs to the job on line 18.
     
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    cool thanks

    this jobs stuff is great, my code got much cleaner just by jobifying
     
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    so I see that you can't pass references to a job, and it seems that NativeArrays can't have class as type, how will operations on transforms or physics happen inside a job?
    And what about texture/compute shader read async operation, will they be accessible within a job?
     
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    Perhaps via the TransformAccess and TransformAccessArray APIs?
     
  6. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    thanks peter, it was lurking inside engine. do you know why jobs' scaffolding in unity assembly and accesses are in engine?
    I see that Access has no constructor that takes conveniently a transform while array does... I'm sure it'll come soon and it's cool to see the API's early days