Qt+CUDA+OpenGL, share CUDA context with QOpenGLContext

Viewed 63

I have a Qt program, which using QOpenGLContext for rendering.
Now I want to use CUDA to process image without extracting image to host.

If I use (QT += core gui opengl), without using QOpenGLContext, I will use cudaGraphicsGLRegisterImage and map OpenGL to CUDA and everything works fine.

But, when I use qputenv("QT_OPENGL", "angle"); (to setup QOpenGLContext) - even calling cudaGLGetDevices(&glDeviceCount, glDevices, glDeviceCount, cudaGLDeviceListAll); gives rubbish - meaning the CUDA context not the same as QOpenGLContext.

How can I setup CUDA context to be the same as QOpenGLContext?
I have read about CUDA context, e.g cuCtxCreate ( CUcontext* pctx, unsigned int flags, CUdevice dev
but it seems to me, that there no such option.
Maybe there are another solution, if I have to use QOpenGLContext?

0 Answers
Related