Efficiency of branching in shaders

前端 未结 5 735
感动是毒
感动是毒 2020-12-07 22:58

I understand that this question may seem somewhat ungrounded, but if someone knows anything theoretical / has practical experience on this topic, it would be great

5条回答
  •  独厮守ぢ
    2020-12-07 23:33

    Here's a real world performance benchmark on a kindle Fire:

    In the fragment shader...

    This runs at 20fps:

    lowp vec4 a = vec4(0.0, 0.0, 0.0, 0.0);
    if (a.r == 0.0)
        gl_FragColor = texture2D ( texture1, TextureCoordOut );   
    

    This runs at 60fps:

    gl_FragColor = texture2D ( texture1, TextureCoordOut );   
    

提交回复
热议问题