CUDA + OpenGL Interop,不建议使用的功能 [英] CUDA + OpenGL Interop without deprecated functionality

查看:104
本文介绍了CUDA + OpenGL Interop,不建议使用的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前能够通过以下方式在CUDA中填充纹理以便在OpenGL中使用:

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

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

在更新/渲染循环中:

  1. cudaGraphicsMapResource()与PBO
  2. 启动内核以更新PBO
  3. cudaGraphicsUnmapResource()来自CUDA的PBO
  4. 加载GL程序,绑定纹理,正常渲染
  5. 洗净,重复冲洗.
  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.

但是,我想知道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.

我已经看到了对cudaTextureObjectcudaSurfaceObject的一些引用,但是我不清楚它们在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,不建议使用的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆