Search Unity

Will C# Job System have a Texture2DAccess type.

Discussion in 'Data Oriented Technology Stack' started by Squ1ntP1g, Mar 1, 2018.

  1. Squ1ntP1g

    Squ1ntP1g

    Joined:
    Mar 1, 2018
    Posts:
    1
    Will C# Job System have a Texture2DAccess and SpriteAccess type that allows you to manipulate textures and sprites in Jobs?

    Will this be released with the main release of Unity 2018?
     
    Krajca likes this.
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    4,565
    If I have to guess: Soon™ :D
     
  3. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,130
    It would be a lot more flexible, if Unity offers a way for us to implement these kind of "Access" wrappers ourselves.
     
    Krajca likes this.
  4. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    4,565
    As far as I understand what they're doing, it's not feasible. And this is because they're basically bridging the native side to the job system without serious copying. Which means when the right methods like setVertices and setPixels, etc can accept Native* storage, they can map that or efficiently copy that if needed to the proper buffer.
    Otherwise you would copy your results multiple times and basically lose all the efficiency you're gaining with the use of the job system.

    This exactly the problem with the transforms. It will be super-cool when Unity itself handling the data. Until then you can move it yourself (I guess, I haven't tried yet) to reach the transforms, but it is horribly inefficient.

    But this is just an educated guess, since I have no access to Unity's source or any more info than you do.
     
  5. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    7,133
    So is that why the real power of the Job System is the Burst compiler that converts ILVM byte code to native assembly language code?
     
    Krajca likes this.
  6. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    4,565
    Basically.

    - potentially multi-threaded execution without race condition headache
    - optimized native code, which runs closer to Unity's C++ side
    - you don't marshaling data between the native side (Unity engine) and the managed side (your C# scripts)

    As far as I understand.
     
    Krajca likes this.
  7. OswaldHurlem

    OswaldHurlem

    Joined:
    Jan 6, 2017
    Posts:
    40
    You can have jobs modify the contents of managed arrays without copying.
    https://gist.github.com/OswaldHurlem/959a12005f049375f1eab98c06572ae8