Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback Graphics.DrawMeshInstanced should accept NativeArray<float4x4>

Discussion in 'Graphics for ECS' started by OndraPaska, Jun 14, 2020.

  1. OndraPaska

    OndraPaska

    Joined:
    Jul 5, 2014
    Posts:
    12
    Using JobSystem with Graphics.DrawMeshInstanced is a pain now because (afaik) you have to copy data from nativearrays to managed memory.
    If there was an overload for Graphics.DrawMeshInstanced for NativeArray<float4x4> it would make it very natural to use.
     
    Krajca, Desoxi, zedarus and 2 others like this.
  2. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    This is still not a thing right (over 1 year later)..? Have the exact same issue at the moment and turning a massive NativeArray<float4x4> into a Matrix4x4[] is going to be very slow.
     
    Krajca likes this.
  3. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    same issue.. there was a thread about it in 2018. Said it was a top priority, still nothing.
    https://forum.unity.com/threads/nativearrays-and-drawmeshinstanced.522888/

    There's some ideas in that thread about using a pointer to a pinned array and using NativeArrays that way.

    Alternative would be GraphicsBuffers or ComputeBuffers but then you'd be basically writing your own version of Hybrid Renderer.
     
    Desoxi likes this.