Search Unity

Bug Accumulation of batches in scene view when using Graphics.DrawMeshInstancedIndirect

Discussion in 'High Definition Render Pipeline' started by Chris_Webb, Aug 11, 2022.

  1. Chris_Webb

    Chris_Webb

    Joined:
    Mar 18, 2014
    Posts:
    128
    Hello :)

    I have a pretty strange issue here.

    I am using Graphics.DrawMeshInstancedIndirect to render grass. This works fine.

    In the scene view, the frame times get longer and longer, until something in the editor is clicked. Moving or rotating the camera does not fix the issue.

    I have found that Unity is accumulating these instanced draw calls, and only seems to be clearing them at the same point where Time.frameCount changes. That is to say, in the scene view, Time.frameCount does not change when moving/rotating the camera, but doing other interactions with the editor increment this count, AND clear the buildup of drawcalls Unity is creating.

    This buildup of drawcalls does not happen in the game view.

    Unity 2022.1.11f1
    HDRP 13.1.8
     
  2. Chris_Webb

    Chris_Webb

    Joined:
    Mar 18, 2014
    Posts:
    128
    Hello,

    It seems the accumulation only happens when creating draws with Graphics.DrawMeshInstancedIndirect, inside RenderPipelineManager.beginCameraRendering.

    Doing the draws from LateUpdate is fine.

    This has other issues however, as because when flying around in the scene, the scene view does not call update until interactions are made, the rendered visuals are often out of sync until something is clicked on.

    So at the moment, I am kind of stuck between "the visuals are always correct, but the editor slows down" and "the visuals are often wrong, but the editor is fast".

    Is there perhaps some other correct way I am supposed to use Graphics.DrawMeshInstancedIndirect?

    Thanks :)