I should preface with currently this question is mostly asking about Metal and iOS GPUs. That being said if this is GPU or OS specific and you can go into detail about other platforms that would be great to as this application will eventually be cross platform.
I am drawing some geometry in two draw calls.
- Opaque geometry is drawn. Discards happen. No particular triangle draw order. Fragments in this draw call occupy only 5% of the screens pixels.
- Transparent geometry is drawn. No discards happen. Triangles are drawn in depth order. Fragments in this call occupy a bulk of the screen pixels.
The question is essentially should I convert draw call 1 to ordered triangles with alpha=0 where I would generally discard. There will be a cost to ordering the triangles in draw 1 however it will not be two costly.
The reason I am unsure is that I know the second you call discard on a fragment you remove the possibility of Metal preforming early depth test which is allegedly quite an optimization. What I dont know is if discards disable early depth test on draw call 1 do they also disable the optimization for draw call 2's geometry?
Does the fragment stage happen after each draw calls vertex phase or after all of them?
Do you think I should explore sorting the triangles and using alpha blending on draw call 1? Again this would be a negligible CPU cost would it actually help the GPU?