简体   繁体   English

CUDA + OpenGL Interop,不建议使用功能

[英]CUDA + OpenGL Interop without deprecated functionality

I've previously been able to populate textures in CUDA for use in OpenGL by: 我以前可以通过以下方式在CUDA中填充纹理以供在OpenGL中使用:

  1. Create and initialize the GL texture ( gl::GenTextures() , etc.) 创建并初始化GL纹理( gl::GenTextures()等)
  2. Create a GL Pixel Buffer Object 创建GL像素缓冲区对象
  3. Register the PBO with CUDA 向CUDA注册PBO

In the update/render loop: 在更新/渲染循环中:

  1. cudaGraphicsMapResource() with the PBO 使用PBO的cudaGraphicsMapResource()
  2. Launch the kernel to update the PBO 启动内核以更新PBO
  3. cudaGraphicsUnmapResource() the PBO from CUDA cudaGraphicsUnmapResource()来自CUDA的PBO
  4. Load the GL program, bind texture, render as normal 加载GL程序,绑定纹理,正常渲染
  5. Wash, rinse repeat. 洗涤,重复冲洗。

However, I'm wondering if PBOs are still the best way to write a texture from a kernel. 但是,我想知道PBO是否仍然是从内核写入纹理的最佳方法。 I've seen articles like this one ( updated for v5 here ) which don't appear to use PBOs at all. 我看过类似这样的文章( 在此针对v5更新 ),这些文章似乎根本没有使用PBO。

I've seen some references to cudaTextureObject and cudaSurfaceObject , but their role in OpenGL interop is unclear to me. 我已经看到了一些对cudaTextureObjectcudaSurfaceObject引用,但是我不清楚它们在OpenGL互操作中的作用。

Are PBOs still the recommended approach? PBO仍然是推荐的方法吗? 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. 您可以在CUDA 6 SDK的官方示例中看到它,在“ 3_Imaging”目录中称为“ simpleCUDA2GL”。 It has two different approaches to access texture inside CUDA kernel. 它有两种不同的方法来访问CUDA内核中的纹理。 One of them (I think the old one) uses the PBO, and it is 3 times slower on my machine. 其中一个(我认为是旧的)使用PBO,在我的计算机上速度要慢3倍。

You may want to look at this very recent CUDA GL Interop example from NVIDIA: 您可能想看一下NVIDIA的最新CUDA GL Interop示例:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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