I have heard multiple times that a manual discard in the fragment shader, for example if(texture.a < 0.1) { discard; } was an expensive operation. My question is whether that's really true, or whether the 'expense' is just from hidden surface removal having to be disabled if a shader uses discard (and thus the 'expense' just comes from additional fragments that need to get processed which otherwise could be skipped)? I understand that tiled renderer architectures such as adreno have hidden surface removal features and that these features get deactivated by using blending or fragment discard, but let's say that all meshes are rendered with blending enabled anyway - would a discard in fragment shaders still incur a (significant) additional cost on adreno gpus?
Is fragment discard truly an expensive operation on Adreno?
Posted: Tue, 2021-08-31 08:24
That's about right. It's not that the single instruction itsef consumes lots of GPU cycles, but that using the instruction triggers side effects (like disablement of HSR features) which will cause less efficient exection of the workload in most use-cases.