How to read egl pixel data from a plain cuda kernel?

I have some cuda experience, but am very new to the tegra platform and the egl stream concept.

I am examining the syncSensor sample project from the jetson_multimedia_api package.


I can read pixel data if I use the cuSurfObjectCreate() boilerplate for the frames and do pixel lookups using surf2Dread() inside my kernel.

But I feel the surfaceobjects are cumbersome and they prevent me from using kernels I have written earlier without rewrite.

I want to run a regular kernel on the two images, so I am trying to pass the frames pPitch pointers directly as unsigned char*.

But I cant seem to get this to work. My kernel crashes immediately.

Can anyone elaborate on why this is the case? Do I need to map the egl frames pointer some way so it is accessible from a regular cuda core?

Kind regards


1 Like

Please refer to this sample:


You can have frame data in NvBuffer by calling:




And refer to the function calls for CUDA processing:

static bool
cuda_postprocess(context_t *ctx, int fd)
    if (ctx->enable_cuda)
        /* Create EGLImage from dmabuf fd */
        ctx->egl_image = NvEGLImageFromFd(ctx->egl_display, fd);
        if (ctx->egl_image == NULL)
            ERROR_RETURN("Failed to map dmabuf fd (0x%X) to EGLImage",

        /* Pass this buffer hooked on this egl_image to CUDA for
           CUDA processing - draw a rectangle on the frame */

        /* Destroy EGLImage */
        NvDestroyEGLImage(ctx->egl_display, ctx->egl_image);
        ctx->egl_image = NULL;

    return true;
1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.