I’m fairly new to CUDA, but I’ve managed to display something generated by a kernel on the screen using OpenGL. I’ve tried serveval approach :
- Using a PBO and an OpenGL texture;
- Using a OpenGL texture as a CUDA surface and rendering on a quad;
- Using a renderbuffer as a CUDA surface and rendering using glBlitFramebuffer.
All of them worked, but, while implementing #2, I erroneously set the hint as cudaGraphicsRegisterFlagsWriteDiscard. Since all of the data will be generated by CUDA, I thought this was the correct option. However, later I realized that I needed a CUDA surface to write to an OpenGL texture, and when you use a surface, you need the LoadStore flag.
So basically my question is this : Since I cannot write to a CUDA texture in a kernel, and to write to an OpenGL texture you need a CUDA surface, what is the use case of cudaGraphicsRegisterFlagsWriteDiscard in cudaGraphicsGLRegisterImage?