3 Replies Latest reply on Jun 10, 2015 2:15 AM by dipak

    OpenGL interop




      I am currently trying to get the opengl/opencl interop running but can't get it to work. My current order of initialization is like this: init OpenGL context (debug context), Init OpenCL (with opengl sharing), create opengl ressources (texture and buffers), create opencl image from the opengl texture via clCreateFromGLTexture. Untill there everything works fine and no errors are reported. if i query the opencl image it has the same properties as the opengl texture, so this seems to work. but as soon as i try to aquire the opencl image via clEnqueueAcquireGLObjects, i get the error code -4 (CL_MEM_OBJECT_ALLOCATION_FAILURE). I have tried everything i could imagine but am stuck there. Any ideas what could create that error?

      the kernel is simply:

      __kernel void image_write(__write_only image2d_t image, float value) 
          int2 coords = (int2){ get_global_id(0), get_global_id(1) };
          write_imageui(image, coords, (uint4)value);

      the whole program can be seen at http://pastebin.com/jUw6f42a but only the functions initOpenCL (line 325) and setupOpenCLInteropBuffers (line 400) should be of interest (the error code is returned on line 411), the rest is opengl and working

      Btw. it only happens if i run it on the GPU, on the CPU no errors are returned. I am using a 5870.


        • Re: OpenGL interop


          From the first look, I've few suggestions:

          1. The issue may be due to lack of enough memory in the GPU. Please can you try with smaller problem size and observe.

          2. It also may be a memory aligned issue, so instead of malloc, you can use aligned_malloc (or something) and check.


          Please let us know findings of above experiments. If still problem exists, we'll try to look into details.



            • Re: OpenGL interop



              sorry for my late reply! I tried it with smaller problem sizes (128x128), but 512*512 shouldn't be too much under normal circumstances should it?!. For alignment, I am not sure where I use some buffer i would need to align. Iam not allocating a buffer that gets used by opencl. Iam only using the (opengl allocated) texture.