Reputation: 6529
I'm investigating GPGPU programming with OpenGL + GLSL. One problem is that if you have a shader that takes a long time to finish, it seems to be impossible to cancel it.
After setting up everything, I issue the final glReadPixels
call which blocks until all pixels have been rendered to a framebuffer. Depending on the shader, this could take a long time, even seconds. Is there a way to cancel the call (from another thread) or even query the progress? What happens if you set up an infinite loop in a shader?
Upvotes: 0
Views: 679
Reputation: 674
What happens if you set up an infinite loop in a shader?
I think you will get crash of video driver.
Upvotes: 0
Reputation: 10115
instead of glReadPixels you could use PixelBufferObjects which are not blocking. glReadPixels will wait (in your main thread) for the results, but PBO will continue... somewhere later in the code you can check if the data in PBO are available.
http://www.songho.ca/opengl/gl_pbo.html
http://www.opengl.org/wiki/Pixel_Buffer_Object
if you need some more advanced calculations then you may want to use OpenCL, that will give you more flexibility.
Upvotes: 3