Hi,

I am having some trouble using occlusion query to count fragments being drawn. I want to check that I am using occlusion query correctly by comparing the query result with an atomic counter that I increment manually in a fragment shader.

The occlusion query value starts at 0 and is incremented for each fragment that passes the depth test (I am using the query GL_SAMPLES_PASSED). My atomic counter starts at 0 and gets incremented each time a fragment program executes. With depth-testing and multisampling disabled I expect these values to be the same, but they are not. The query value is consistently greater than the atomic counter.

Before I start looking for errors in my code, I want to understand that OpenGL is doing what I think it should be doing so here is my question: do you know if the fragment shader executes once for each fragment that passes the depth test? (In other words, is there a one-to-one mapping between fragments that pass the depth test and fragment shader executions? I have depth testing disabled.)

Thanks.