Search Unity

Does Custom SRP help Increase Performance Compared to using OnRenderImage in Standard RP?

Discussion in 'General Graphics' started by AhSai, Apr 10, 2020.

  1. AhSai

    AhSai

    Joined:
    Jun 25, 2017
    Posts:
    129
    I am building for mobile platforms and I notice that whenever I use OnRenderImage() on any the camera, even if it only contains a single Blit(), it will introduce a huge frame rate drop. My question is will using Custom SRP increase performance for tasks like doing a Blit() from camera's targetTexture to another RT?
     
  2. Arycama

    Arycama

    Joined:
    May 25, 2014
    Posts:
    184
    Not really.

    You're essentially reading the entire framebuffer, and writing the same amount of data into another texture.

    Mobiles are very bandwidth-limited. A 32-bit framebuffer at 1080p is ~63 megabytes. (1920*1080*32/1024/1024 = 63.28125) At 30 fps, you're looking at nearly 2GB/s of bandwidth usage. (From memory, low-end mobile devices may have less than 10GB/s memory bandwidth).

    Usually after processing all the vertices, sampling all textures required to render the scene, generating/sampling shadow maps, etc, you're pretty close to hitting the bandwidth limit, after which things get -very- slow.

    Desktop and console GPUs generally have a few dozen GB/s of memory bandwidth at least, so it's not usually an issue.

    The only solution I can think of might be to render to a much smaller texture, and use a 16-bit format like RGB565. (Disabling 32-bit buffer in player settings might also help)

    However I'd consider whether you -really- need to use OnRenderImage for your game, or if it can just be saved for higher end devices that can handle it more easily.
     
  3. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    Creating the framebuffer copy needed to produce the source image necessary for the post-processing is the framerate killer for mid and low-end phones, as @Arycama posted. Unless you're dealing with mid-high and high-end Android phones, or modern iPhones, anything that requires a framebuffer copy is guaranteed to have a huge impact.

    If your post-processing uses only the current pixel color (no blurring, no distortion, no reading the depth buffer), it is possible to use framebuffer fetch to access the current pixel color on most phones, then use a command buffer instead of onRenderImage to draw your effect. You can read about it here: https://docs.unity3d.com/Manual/SL-PlatformDifferences.html