cuGraphicsEGLRegisterImage returns 999

Hi,

I try to get QT in combination with EGL and cuda to work. However, currently I get stuck at the point where the program tries to register the eglimage. Unfornatelly the error code of cuGraphicsEGLRegisterImage is 999. Does anyone has an idea what could be wrong?

The code lookslike:


    EGLDisplay eglDisplay = eglGetCurrentDisplay();
    EGLContext eglContext = eglGetCurrentContext();
    GLuint texture;
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
    GLenum oglError = glGetError();
    if (oglError != GL_NO_ERROR) fprintf(stderr, "OGL Error %x\n", oglError);
    EGLAttrib eglImgAttrs[] = { EGL_IMAGE_PRESERVED, EGL_FALSE, EGL_NONE, EGL_NONE };
    EGLImageKHR eglImage = eglCreateImage(eglDisplay, eglContext, EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)(intptr_t)texture, eglImgAttrs);
    EGLint eglErrorCode = eglGetError();
    if (eglErrorCode != EGL_SUCCESS) fprintf(stderr, "EGL Error %x\n", eglErrorCode);
    CUgraphicsResource cudaResource;
    CUresult cudaError = cuGraphicsEGLRegisterImage(&cudaResource, eglImage, CU_GRAPHICS_REGISTER_FLAGS_NONE);
    /// Here cudaError is 999