Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. 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,875
    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

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,044
    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,875
    cool thanks

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

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    1,875
    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:
    2,358
    Perhaps via the TransformAccess and TransformAccessArray APIs?
     
  6. laurentlavigne

    laurentlavigne

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