OpenCL | OpenGL Interportability (OpenCL 1.2, OpenGL 3.1)

Texture-based Interportability utilizing OpenCL and OpenGL for both IG and Dedicated GPUs

Overview:
This article provides a basic demonstration of how to utilize texture-based interportability between OpenCL and OpenGL. The method presented here is based on “Method 1″ presented by [Shevtsov] and provides zero-copy interportability between OpenCL and OpenGL dedicated on dedicated device memory. This implementation also provides a simple example of utilizing buffer texture objects. Therefore, as a final result we have: RGBA32 data stored in a data buffer on the GPU, this data buffer is a portable object that can be transferred from OpenGL to OpenCL (assuming proper, machine dependent context), and then also utilized for OpenGL draw calls. The host-to-GPU data transfer only occurs once; the data will then be both modified and rendered from the same location in device (GPU) memory (upload once, modify with OpenCL, draw with OpenGL).

References

  • M. Shevtsov. “OpenCL and OpenGL Interportability Tutorial”, Intel Developer Zone. https://software.intel.com/en-us/articles/opencl-and-opengl-interoperability-tutorial
  • OpenGL Wiki. “Buffer Texture”. http://www.opengl.org/wiki/Buffer_Texture