Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  3. Want to see the most recent patch releases? Take a peek at the patch release page.
    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:
    1,505
    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

    Insert bacon, receive bugfix Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    3,884
    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:
    1,505
    cool thanks

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

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    1,505
    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

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

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    1,505
    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