Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Multi draw support when using RenderMeshIndirect

Discussion in 'General Graphics' started by TJHeuvel-net, Mar 29, 2023.

  1. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    784
  2. Rukhanka

    Rukhanka

    Joined:
    Dec 14, 2022
    Posts:
    89
    There is no SV_DrawID in D3D11/D3D12. I think this is some cross reference from gl_DrawId and its multi-draw rendering. Corresponding functionality exists in D3D12 by using indirect drawing. But approach taken by D3D API will get correct data in buffers based on resurce views used during ID3D12CommandSignature creation. So it is mystery how to correctly use InitIndirectDrawArgs(drawId) function in shader with non-zero drawId parameter.
     
  3. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    784
    I think i did figure it out. Im implementing this tutorial in Unity: https://vkguide.dev/docs/gpudriven

    In the case of doing gpu driven rendering, and culling in a compute shader. The compute shader passes data to the vertex shader, e.g. the visible indices. It also needs to know the drawID.

    We can therefore also pass along the drawid. If you get your vertex data by using the instanceId, you can make another structuredbuffer with drawids.
     
  4. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    784