Is it possible to save CUDA results in an open OpenGL texture?

Can CUDA be used to create OpenGL textures? I know it can be done by reading the CUDA results in system memory and then loading them into a texture ... But I would like to find a way to save this copy ... Can CUDA be used to generate textures?

+2


a source to share


2 answers


Yes, CUDA has API functions to interact with OpenGL

Use cudaGLRegisterBufferObject(GLuint bufObj)

to register with CUDA and then use cudaGLMapBufferObject( void ** devPtr, GLuint bufObj)

to get the device memory pointer for buffer management in your CUDA kernel.



Then undo cudaGLUnmapBufferObject(GLuint bufObj)

and then display.

For a complete description, see the CUDA Programming Guide that you download in the CUDA Toolkit.

+2


a source


Grade. You cannot write textures from the kernel directly, but you can make a copy of the results from your kernel to a cudaArray texture without copying it back to system memory. Look cudaGraphicsGLRegisterImage()

, cudaGraphicsMapResources()

and cudaGraphicsSubResourceGetMappedArray()

.



+3


a source







All Articles