Best way to return a value from a Fragment Shader

I need to run couple of operations on the texture pixels and return true/false based on the result.
One example would be - if any pixel exceeded a specific value? (like 0.75) - Yes/No
If the texture contains true black pixel anywhere? - Yes/No


Just draw a specific value at the current pixel location to another render target (see MRT). Another option would be to use an SSBO.

Assuming OpenGL 4.3 support, compute shader reads the texture and writes the result to a buffer variable. You’ll need to test whether it’s faster to use a conditional assignment or atomicMax. If you can’t assume OpenGL 4.3, you can use a fragment shader with an atomic counter or image load/store. If you can’t assume OpenGL 4.2, you’ll need to get creative (without 4.2 or extensions, the only shader output mechanisms are the framebuffer and transform feedback).

Unfortunately GLSL 1.20.

What I have been doing now is sending vertices to vertex shader and calling glDrawArrays with GL_POINTS for all the pixels in the image. For each vertex I would read corresponding RGB from the texture and if the condition was passed I would return vertex position at (0,0), and if it didn’t pass I would return (1,1).

But I am looking for something faster than that.
For 4K image that’s pretty slow.

glGetTexImage2D then performing the test in the application would probably be faster than that.

I will probably try the OpenCL route…