使用 opengl/CUDA 互操作性时是否需要重新创建纹理?
我想使用 CUDA 操作在 opengl 中使用的纹理。知道我需要为此使用 PBO,我想知道每次对 PBO 进行更改时是否都必须重新创建纹理,如下所示:
// Select the appropriate buffer
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, bufferID);
// Select the appropriate texture
glBindTexture( GL_TEXTURE_2D, textureID);
// Make a texture from the buffer
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, Width, Height,GL_BGRA, GL_UNSIGNED_BYTE, NULL);
Does glTexSubImage2D 等会从 PBO 复制数据吗?
I want to manipulate a texture which I use in opengl using CUDA. Knowing that I need to use a PBO for this I wonder if I have to recreate the texture every time I make changes to the PBO like this:
// Select the appropriate buffer
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, bufferID);
// Select the appropriate texture
glBindTexture( GL_TEXTURE_2D, textureID);
// Make a texture from the buffer
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, Width, Height,GL_BGRA, GL_UNSIGNED_BYTE, NULL);
Does glTexSubImage2D and the like copy the data from the PBO?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有像素传输操作都适用于缓冲区对象。由于glTexSubImage2D启动像素传输操作,因此它可以与缓冲区对象一起使用。
用于像素传输的缓冲区对象和纹理之间没有建立长期连接。缓冲区对象的使用方式与用于
glTexSubImage2D
调用的客户端内存指针非常相似。它用于在 OpenGL 格式化并将其拉入纹理时存储数据。完成后,您可以用它做任何您想做的事情。唯一的区别是,因为 OpenGL 管理缓冲区对象,所以从缓冲区的上传可以是异步的。那么,您就可以玩游戏,例如通过 GPU 操作(无论是来自 OpenGL、OpenCL 还是 CUDA)填充缓冲区对象。
All pixel transfer operations work with buffer objects. Since
glTexSubImage2D
initiates a pixel transfer operation, it can be used with buffer objects.There is no long-term connection made between buffer objects used for pixel transfers and textures. The buffer object is used much like a client memory pointer would be used for
glTexSubImage2D
calls. It's there to store the data while OpenGL formats and pulls it into the texture. Once it's done, you can do whatever you want with it.The only difference is that, because OpenGL manages the buffer object, the upload from the buffer can be asynchronous. Well that and you get to play games like filling the buffer object from GPU operations (whether from OpenGL, OpenCL, or CUDA).