This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Hi, I created openCL context with openGLES config , and then use clCreateFromGLTexture2D function failed, do you know why ?

Hi

In android, I created cl context from gl like this :

cl_context_properties props[] = { CL_GL_CONTEXT_KHR, eglGetCurrentContext(), CL_EGL_DISPLAY_KHR, eglGetCurrentDisplay(), CL_CONTEXT_PLATFORM, clplatform,0);

clCreateContext(props,1,&device,NULL,NULL,NULL);

and then create opengl texture, this texture can be used .  After that , I want to use opencl to calculate this texture, so I do like this :

clCreateFromGLTexture2D(clContext, CL_MEM_READ_WRITE,GL_TEXTURE_2D, 0,texturename ,&errNum);

And this function failed, the errNum returned CL_INVALID_GL_OBJECT , and I do not know why , Can you help me  ?

Thanks

  • According to clCreateFromGLTexture2D man page:

    CL_INVALID_GL_OBJECT if texture is not a GL texture object whose type matches texture_target, if the specified miplevel of texture is not defined, or if the width or height of the specified miplevel is zero.

    Are any of these conditions true?

    Hth,

    Chris

  • Hi, thanks for your help .

    I think all of them are true , as first , the texture_target is same as opengles context , it's GL_TEXTURE_2D .

    And the miplevel is set as this :

    glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    Is there anything wrong ?

    Thanks

  • Not enough info atm, could you share the code that creates and initializes the texture in GL?

    Thanks.

    Chris

  • just like this :

      bitmap.lockPixels();
    const int w = bitmap.width();
    const int h = bitmap.height();
    const void* p = bitmap.getPixels();
    GLint crop[4] = { 0, h, w, -h };
    texture->w = w;
    texture->h = h;
    glGenTextures(1, &texture->name);
    glBindTexture(GL_TEXTURE_2D, texture->name);
    switch (bitmap.getConfig()) {
        case SkBitmap::kA8_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA,
                    GL_UNSIGNED_BYTE, p);
            break;
        case SkBitmap::kARGB_4444_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
                    GL_UNSIGNED_SHORT_4_4_4_4, p);
            break;
        case SkBitmap::kARGB_8888_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
                    GL_UNSIGNED_BYTE, p);
            break;
        case SkBitmap::kRGB_565_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB,
                    GL_UNSIGNED_SHORT_5_6_5, p);
            break;
        default:
            break;
    }
    glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  • Hi kongya,

    Nothing obvious from a cursory glance. Could you provide us with a minimal reproducer for this issue?

    Thanks,

    Chris

  • Hi, Chris

    How can send my code to you, via email ? Can you tell me your email address ?

    Thanks

  • If it is of a small size, you can attach it to your post.

    If however it is larger, then email wont help as there is a size limit on that too... any alternative method that you prefer should be fine with us.

    e.g. ftp, dropbox, github, etc

    Thanks in advance,

    Michael McGeagh

  • Hi, I upload the code to shared doc, can you see it  ?

    Thanks

  • Hi kongya0712,

    I have received the shared doc, thank you.

    I have created a ticket to investigate internally, and had a quick look with nothing obvious jumping out.

    Thanks for your time.

    Michael McGeagh

  • Hi kongya0712,

    After looking at the spec more closely, there are a few more things to highlight as possible causes to your problem.

    First thing to read is the extension "cl_khr_gl_sharing", you should realise that there is a limited number of supported texture formats compared to possible GLES texture formats, as in not every GLES texture can be used for CL-GLES interop.

    Secondly, there was an issue where Android itself altered the values for GL context and EGL display, which may be a problem here too. (we will need to investigate further for this one).

    I just wanted to update you on our progress, if you have made any progress yourself, please let others know.

    Kind Regards,

    Michael McGeagh

  • Hi,Michael

    I was not in internet for 2 weeks . And I just see your comment at now . Thank you for your help .

    I will check this issue with qualcomm , ask them this texture format can be used or not .

    If I have any progress, will tell you .

    Thanks

  • Hi,

    Has there been any progress on this issue?

    Thanks.

  • Hi aacosta,

    kongya never did get back to us regarding his particular device supporting the texture format or not, so I am unsure if he had solved this.

    Regardless since he was using a non-Mali GPU, there is not much we could do to help here so havent pursued the matter.

    If you have a Mali specific issue, please do let us know.

    Kind Regards,

    Michael McGeagh

  • Hi mcgeagh,

    I have the same issue with a Mali T760 GPU (Samsung S6).  The extension "cl_khr_gl_sharing" is enable. The opengl texture format used is GL_RGBA, GL_UNSIGNED_BYTE.

    Mali T760 supports opencl 1.1. So, GL_RGBA8 format should be supported. 

    Thanks.

  • Hi aacosta,

    Do you have a small reproducer for us to investigate?

    Any information, such as the device, OS version, Mali Driver version, etc... would help us.

    Kind Regards,

    Michael McGeagh