I am doing some program, that can be written in two ways.
- render full screen quad and send some additional info to fragment shader. But in fragment shader I need to perform for-loop
- Move the loop to the CPU side of program and call draw-call on fullscreen quad repeatedly. Output will be rendered to texture. I will have two of them and swap active (write) and inactive (last output, read-only).
What can be faster ? I think, that number 1, but on the other side, loops are not very efficient in GLES shaders. And I need to calculate texture coordinates on the fly, which according to Apple doc is slower than if they goes directly from vertex shader and are not changed.
Point two can be improved by this:
- I can put all quads to single buffer and draw them with one draw call (each quad will have different depth, but will be still fulscreen), where depth will be "loop" variable. In shader I take this "depth" and use blending (which can be used on iOS 6 via gl_LastFragData)