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.
  2. Dismiss Notice

Bug SRP Batching Not Occuring on iOS Metal Frame Capture

Discussion in 'Universal Render Pipeline' started by steven_unity84, Jul 27, 2023.

  1. steven_unity84

    steven_unity84

    Joined:
    Jun 24, 2023
    Posts:
    4
    Unity: 2022.3.4f1
    URP: 14.0.8
    SRP: 1.21.5
    Shadergraph: 14.0.8

    Unity is reporting a totally reasonable number of draw calls in the frame capture during one of our most complex scenes (90-100) using the SRP Batcher. Stepping through it, it's about what I would expect it to do. The metal frame capture is reporting 2,200+ and eating up to 3ms of our CPU time because of it.

    Unity:
    Screenshot 2023-07-26 at 7.24.34 PM.png

    Metal: Screenshot 2023-07-26 at 10.55.16 PM.png

    The method of creation for the objects is to simply instantiate them through remote data received with a material on each object that has the same shader has nearly every other object. All object are simply mesh renderers rendering planes with our materials and textures attached.

    We are using shadergraph and don't seem to be doing anything too complex. All of our shaders show `SRP Batcher compatible`:
    Screenshot 2023-07-26 at 7.40.29 PM.png
    Screenshot 2023-07-26 at 7.27.11 PM.png
     
    Last edited: Jul 27, 2023
  2. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    625
    Hi, AFAIK the SRP Batcher doesn't reduce the number of Draw Calls. It reduces the CPU cost that Unity prepares a Draw Call.

    You can try disabling SRP Batcher in the build and compare the differences of CPU time cost.
     
  3. steven_unity84

    steven_unity84

    Joined:
    Jun 24, 2023
    Posts:
    4
    EDIT: I was incorrect, see recent post




    I do not believe that is correct. Considering Static and Dynamic Batching are methods of reducing draw calls, SRP Batcher would be a pretty misleading name if it didn't involve batching ;) Also, when I turn it off, the Editor ends up with about as many draw calls as the mobile device is reporting. Turning it off does not affect the mobile build at all.

    Regardless of the intent of the SRP Batcher, it significantly reduces draw calls from Unity when using the above simple shadergraph shaders, and it is not reflected on my metal devices. This includes an iPhone XS and a build on the exact mac machine I'm running the Unity Editor on. No batching seems to be occurring at all for both iOS and Mac builds, or if there is it's negligible.
     
    Last edited: Jul 27, 2023
  4. steven_unity84

    steven_unity84

    Joined:
    Jun 24, 2023
    Posts:
    4
    This could also be me not understanding what the SRP Batches are in the Frame Debugger in Unity. The window functions as if it's a single draw step in the frame, so it looks like it only has a hundred draws, but maybe that's incorrect.
    upload_2023-7-27_9-56-6.png


    EDIT: I've found when using `ProfilerRecorder.StartNew(ProfilerCategory.Render, "Draw Calls Count");` I get the same value of draw calls in editor vs my build.

    So I suppose my updated question would be, what's the disconnect here between the Frame Debugger and the actual Draw Calls? The SRP batcher very well and as I would expect in the frame debugger, but clearly we still have many more draw calls than is acceptable on mobile. Is there a reason there's no batching of drawcalls with the shaders provided? Marking the objects as static seems to have no effect
     

    Attached Files:

    wwWwwwW1 likes this.
  5. steven_unity84

    steven_unity84

    Joined:
    Jun 24, 2023
    Posts:
    4
    You were correct in that the SRP Batcher has it's own draw call count within, can't believe we missed that. It's different than working on the native frame debuggers so we must have over looked. Will create a new thread with a more correct question.
     
    wwWwwwW1 likes this.