Forums - clCreateFromEGLImageKHR return -30

1 post / 0 new
clCreateFromEGLImageKHR return -30
yangcheng830117
Join Date: 11 Jun 21
Posts: 1
Posted: Tue, 2021-08-24 02:45

Device :Qualcomm® Snapdragon™ 855

OpenCL:VERSION:OpenCL 2.0 Adreno(TM) 640

ocl ext:cl_khr_egl_image   cl_khr_gl_sharing

egl ext:EGL_KHR_image EGL_KHR_image_base

In some reason,I want to use gl-cl interop func.

In my opinion,gl-cl interop will be faster than ssbo memcpy to cpu memory. But I can not create clImageBuffer from eglImage.

Step1:

Create a opengl image texture

  glGenTextures(1, &uInput); 
  glBindTexture(GL_TEXTURE_2D, uInput);
  glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, width, height);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  glTexSubImage2D(GL_TEXTURE_2D, 000, width,height, GL_RGBA, GL_UNSIGNED_BYTE,data);

Step2:

create a EGLImageKHR success

  EGLImageKHR image = eglCreateImageKHR(eglGetCurrentDisplay(), eglGetCurrentContext(), EGL_GL_TEXTURE_2D_KHR,reinterpret_cast<EGLClientBuffer>(uInput), 0);
  if (image == EGL_NO_IMAGE_KHR)
  {
    std::cout<<"create Image KHR fail"<<std::endl;
    return;
  };

Step3:

  cl_mem cl_image = clCreateFromEGLImageKHR(ins.context,
                               egl_dpy,
                               (CLeglImageKHR)image,
                               CL_MEM_READ_ONLY,
                               0,
                               &errNum);

I change cl_mem_flag to CL_MEM_READ_WRITE return the same error:

CL_INVALID_VALUE                            -30

I need your help.Thanks!

  • Up0
  • Down0

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.