I've previously been able to populate textures in CUDA for use in OpenGL by:
- Create and initialize the GL texture (
gl::GenTextures(), etc.) - Create a GL Pixel Buffer Object
- Register the PBO with CUDA
In the update/render loop:
cudaGraphicsMapResource()with the PBO- Launch the kernel to update the PBO
cudaGraphicsUnmapResource()the PBO from CUDA- Load the GL program, bind texture, render as normal
- Wash, rinse repeat.
However, I'm wondering if PBOs are still the best way to write a texture from a kernel. I've seen articles like this one (updated for v5 here) which don't appear to use PBOs at all.
I've seen some references to cudaTextureObject and cudaSurfaceObject, but their role in OpenGL interop is unclear to me.
Are PBOs still the recommended approach? If not, what are the alternatives I should be investigating?
(I'm specifically targeting Kepler and newer architectures.)