写了一个Android端OpenCL程序进行图片处理,涉及到OpenCL和OpenGL交互,所以定义了如下context_properties
cl_context_properties context_props[] = { CL_CONTEXT_PLATFORM, (cl_context_properties) cl_objs.platform, CL_GL_CONTEXT_KHR, (cl_context_properties) eglGetCurrentContext(), CL_EGL_DISPLAY_KHR, (cl_context_properties) eglGetCurrentDisplay(), 0};然后调用context = clCreateContext(context_props, 1, &device, NULL, NULL, &err)创建Context,但是返回CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR错误使用的手机为Samsung SM-N9200, Mali-T760GPU,且能查到cl_khr_gl_sharing extension。在Mali GPU的手机上似乎都存在这个问题,而高通手机则一切正常,想知道究竟是什么原因呢?
GraphicBuffer* graphicBuffer = new GraphicBuffer( width, height, (PixelFormat)pixel_format, GraphicBuffer::USAGE_HW_TEXTURE | GraphicBuffer::USAGE_HW_RENDER | GraphicBuffer::USAGE_SW_WRITE_RARELY | GraphicBuffer::USAGE_SW_READ_RARELY);
EGLImageKHR eglImage = eglCreateImageKHR( display, contenxt, EGL_NATIVE_BUFFER_ANDROID, graphicBuffer->getNativeBuffer(), NULL);
You can also refer to "Arm® Mali GPU OpenCL Developer Guide" for more detailed information.
infocenter.arm.com/.../index.jsp
感谢回复,现在我又发现一个新的问题……
使用clCreateFromEGLImageKHR创建cl_image时,如果分辨率超过960X540,那么只能使用CL_MEM_READ_ONLY,使用CL_MEM_READ_WRITE就会报错-CL_INVALID_VALUE,但是我现在需要创建一个1280X720分辨率的可读写的cl_image,要如何操作呢?
请帮忙看一下,谢谢!