简体   繁体   中英

CUDA + OpenGL Interop without deprecated functionality

I've previously been able to populate textures in CUDA for use in OpenGL by:

  1. Create and initialize the GL texture ( gl::GenTextures() , etc.)
  2. Create a GL Pixel Buffer Object
  3. Register the PBO with CUDA

In the update/render loop:

  1. cudaGraphicsMapResource() with the PBO
  2. Launch the kernel to update the PBO
  3. cudaGraphicsUnmapResource() the PBO from CUDA
  4. Load the GL program, bind texture, render as normal
  5. 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.)

You can see on the official example in CUDA 6 SDK, it's called "simpleCUDA2GL" in "3_Imaging" directory. It has two different approaches to access texture inside CUDA kernel. One of them (I think the old one) uses the PBO, and it is 3 times slower on my machine.

You may want to look at this very recent CUDA GL Interop example from NVIDIA:

https://github.com/nvpro-samples/gl_cuda_interop_pingpong_st

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM