Drawing Partially Complete OpenCL Images

Hi,

I’m wondering if there is any way to display an OpenCL image as it is being written to? I’m creating an image using:

clCreateFromGLTexture

…then acquiring/releasing the image via:

clEnqueueAcquireGLObjects
clEnqueueReleaseGLObjects

I would like to be able to draw the partially-completed image; is something like this possible? Thanks for any suggestions.

Mark

No. While OpenCL has ownership the OpenGL side can’t use it. If you have a long running OpenCL computation you could have it write many image images instead of one big one, and display those as they finish.

Thanks for confirming this behavior; it was what I’d expected from the documentation. I’ll look into dividing into sub-regions and displaying those. Thanks again.

~M

[QUOTE=Engine Developer;42542]Thanks for confirming this behavior; it was what I’d expected from the documentation. I’ll look into dividing into sub-regions and displaying those. Thanks again.

~M[/QUOTE]

I’ve had a look at this approach and it is going to be impossible to create one texture per-region as this is for an image being rendered. Even small-ish images would take hundreds of thousands of GL textures to be created (the global range is the number of pixels in the image). Is there any other way to display GL textures without having to wait for the compute to finish? Thanks for any further suggestions.

What is the nature of computations you perform? Maybe you don’t even need OpenCL to begin with.

We ported the stackless traversal algorithm to run on OpenGL® 4.2 hardware, so that the kernel runs in a plain fragment or vertex shader without the need for Compute Shader or OpenCL™.

Coming at it from the other direction, is it possible to access buffers on the card as they are being filled? This way I wouldn’t need to use GL objects to fetch partial results. I’m just trying this approach now, however I only see zero-values after copying a buffer back to host. Is there anything specific to keep in mind when fetching results in this way? Thanks for any assistance.

The approach I would follow is to split the computation in multiple kernel dispatches that work on different regions of the same image. Between each dispatch you would release the gl object and then use GL to render the partial result before acquiring the object again in CL side, and then process the next region. It would involve overhead on synchronization, though.