Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question GraphicsBuffer will break SRP Batch?

Discussion in 'Universal Render Pipeline' started by windsoulstar, Feb 29, 2024.

  1. windsoulstar

    windsoulstar

    Joined:
    May 13, 2018
    Posts:
    1
    Scene environment: The empty scene only have one mesh.
    I have a mesh with 10 submesh, and it have 10 materials with same shader variant, I want to send float array to shader,when i use material.SetFloatArray,it work normally with srp batch, as a result, the mesh use 1 setpass call.
    But the float array is exactly same for 10 materials, so I want to optimize the I/O from cpu to gpu. I try to use GraphicsBuffer to optimize the I/O and use material.SetBuffer api,from Frame Debugger, I see that the 10 materials break SRP Batch and the Batch Cause is "SRP:This material has custom buffer override". as a result, the mesh use 10 setpass call.
    the question: it is intended that custom buffer will break srp, or it is just a bug?
    my unity version is 2022.3.20f1. develop and test in windows
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,062
    Yes, it will break a batch.