How to access GStreamer's OpenGL texture from CUDA without segfaults?

Andrey Sotnikov usaonmonday at gmail.com
Fri Sep 22 09:30:40 UTC 2023


Hello, dear GStreamer community,

I am trying to write a CUDA kernel that will process video frames 
received from glcolorconvert. This processing is supposed to happen 
inside a rendering step of GtkGLArea. The OpenGL context was 
successfully shared between GTK and GStreamer, and everything works 
until I try to use the texture in CUDA.

Here is what I am trying to do:

auto res = cudaGraphicsResource_t{};
CubDebugExit(cudaGraphicsGLRegisterImage(&res, image, target, 
cudaGraphicsRegisterFlagsReadOnly));
CubDebugExit(cudaGraphicsMapResources(1, &res));
auto texPtr  = (void *){};
auto texSize = size_t{};
CubDebugExit(cudaGraphicsResourceGetMappedPointer(&texPtr, &texSize, res));

The last line causes a segmentation fault, there are no errors before 
that. What secret sauce should I use?

Best.
Andrey.



More information about the gstreamer-devel mailing list