Large overhead using OnRenderImage or Graphics.Blit

We use Graphics.Blit to simply copy the frame buffer to a texture. I noticed that adding OnRenderImage Graphics.Blit can reduce my framerate 20-30fps on high res iPad devices. On my iphone 5s it is having a 4-5ms cost and even higher on high res devices. I saw this issue

Not sure if it’s related because it says Android.

I did a bit of debugging and it looks like Hidden/BlitCopy takes up most of the GPU time. It also looks like it’s doing a copy of the depth and stencil possibly.

I’m doing a simple Blit to a lower res texture no post processing effects.

We are actually having the same issue. We are blitting a small texture to perform some work on it (128x128), we are blitting it 4 times and 2 of those are just blit copies. Just a simple blit copy takes 0.25ms.

When using OnRenderImage, you are forcing unity to render the camera into a RenderTexture instead of directly to the framebuffer, which can possibly double your fill rate (one draw into a rendertexture, a second draw to the framebuffer).

iPad’s have high resolution and typically have fill-rate issues. You would see less of a slowdown of lower resolution devices.

I’ve used this technique or rendering straight to a RT in both of these forums I still get a 20 fps drop in performance :0

I looked at the decompiled metal shader and I notice there is color Globals multiply. Can this be removed @Aras @Alexey ? It looks like it requires a cast and a multiply. Maybe that could shave off some millisecs? I actually tested it by recompiling the shader and the results look same.

struct Mtl_FragmentOut
{
    half4 SV_Target0 [[ color(0) ]];
};

fragment Mtl_FragmentOut xlatMtlMain(
    constant Globals_Type& Globals [[ buffer(0) ]],
    texture2d<half, access::sample > _MainTex [[ texture (0) ]] ,
    sampler sampler_MainTex [[ sampler (0) ]] ,
    Mtl_FragmentIn input [[ stage_in ]])
{
    Mtl_FragmentOut output;
    float4 u_xlat0;
    half4 u_xlat16_0;
    u_xlat16_0 = _MainTex.sample(sampler_MainTex, input.TEXCOORD0.xy);
    u_xlat0 = float4(u_xlat16_0) * Globals._Color; << What is Globals?
    output.SV_Target0 = u_xlat16_0;
    return output;
}