问题描述
我以前能够通过以下方式在CUDA中填充纹理以便在OpenGL中使用:
I've previously been able to populate textures in CUDA for use in OpenGL by:
- 创建并初始化GL纹理(
gl::GenTextures()
等) - 创建GL像素缓冲区对象
- 向CUDA注册PBO
- Create and initialize the GL texture (
gl::GenTextures()
, etc.) - Create a GL Pixel Buffer Object
- Register the PBO with CUDA
在更新/渲染循环中:
-
cudaGraphicsMapResource()
与PBO - 启动内核以更新PBO
-
cudaGraphicsUnmapResource()
来自CUDA的PBO - 加载GL程序,绑定纹理,正常渲染
- 洗净,重复冲洗.
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.
但是,我想知道PBO是否仍然是从内核写入纹理的最佳方法.我看过类似此人(已针对v5进行了更新),似乎根本没有使用PBO.
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.
我已经看到了对cudaTextureObject
和cudaSurfaceObject
的一些引用,但是我不清楚它们在OpenGL互操作中的作用.
I've seen some references to cudaTextureObject
and cudaSurfaceObject
, but their role in OpenGL interop is unclear to me.
PBO仍然是推荐的方法吗?如果没有,我应该研究哪些替代方案?
Are PBOs still the recommended approach? If not, what are the alternatives I should be investigating?
(我专门针对开普勒和较新的体系结构.)
(I'm specifically targeting Kepler and newer architectures.)
推荐答案
您可以在CUDA 6 SDK的官方示例中看到它,在"3_Imaging"目录中称为"simpleCUDA2GL".它有两种不同的方法来访问CUDA内核中的纹理.其中之一(我认为是旧的)使用PBO,在我的计算机上速度要慢3倍.
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.
这篇关于CUDA + OpenGL Interop,不建议使用的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!