Search code examples
openglglsl

Check if glDrawElements doesn't produce any fragments


Is there any way to check if OpenGL draw command has produced any fragments? For example in the case of Depth Peeling for a transparent object I don't want to render consequent iterations if during the previous iteration no additional fragments were produced during the draw calls due to discards or depth test failures.


Solution

  • Even if there was a way (and there sort of is), you shouldn't do this. To do what you're talking about would require having the CPU wait until the GPU has finished rendering the particular iteration before issuing the rendering command for the next one. This is pretty bad for performance, both CPU and GPU.