开发者

Can CUDA results be stored in an OpenGL accessible texture?

Can CUDA be used 开发者_C百科to generate OpenGL textures? I know it can be done by reading the CUDA results back into system memory, and then loading that into a texture... But I'd like to find a way to save this copy... Can CUDA be used to generate textures?


Sort of. You can't write directly to textures from a kernel, but you can do a copy of the results from your kernel to the texture's mapped cudaArray without having to copy it back to system memory. Look into cudaGraphicsGLRegisterImage(), cudaGraphicsMapResources() and cudaGraphicsSubResourceGetMappedArray().


Yes, CUDA has API functions to allow for OpenGL Interoperability

Use cudaGLRegisterBufferObject(GLuint bufObj) to register to CUDA and then use cudaGLMapBufferObject( void ** devPtr, GLuint bufObj) to get the device memory pointer to manipulate the buffer in your CUDA kernal.

Once done, you unmap cudaGLUnmapBufferObject(GLuint bufObj) and then display.

Full explanation is in the CUDA Programming Guide that you download in the CUDA Toolkit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜