- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi forum,
I have created an opencl context with the gl-cl interoperability. The context creation was fine and it did not give me any cl error string . But i am getting some trouble while making opencl image buffer from 2D gl texture object. I am getting the cl error string "CL_OUT_OF_RESOURCES"
I suspect that i have problem with context creation. Since i am not getting any cl error string other than CL_SUCCESS, i do not know how else to validate the successful opencl context creation with gl-cl interoperability.
To find the context info i am doing the following :
[cpp]
//now pull out the context infor from the recently created context
size_t contextPropertySize = 0; cl_context_properties *properties = NULL;
//now extract the context information that we have created
errNum = clGetContextInfo(_m_clContext,CL_CONTEXT_PROPERTIES,0,NULL,&contextPropertySize);
if(errNum != CL_SUCCESS) { osg::notify(osg::FATAL) << __FUNCTION__ << ": " << __LINE__ << ": " << "Error while clGetContextInfo(..)" << getErrorString(errNum) << std::endl; }
properties = new cl_context_properties[contextPropertySize];
errNum = clGetContextInfo(_m_clContext,CL_CONTEXT_PROPERTIES,contextPropertySize,properties,NULL);
if(errNum != CL_SUCCESS) { osg::notify(osg::FATAL) << __FUNCTION__ << ": " << __LINE__ << ": " << "Error while clGetContextInfo(..)" << getErrorString(errNum) << std::endl; }
[/cpp]
So i have all the information inside properties array . How do i confirm that content of the properties array contain the context properties for gl-cl interoperability ?
Regards
Sajjadul
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How are you creating the context? Your snippet shows code querrying the context but not the creation. You should create the context by setting the properties to enable CL/GL sharing. Also make sure to get the gl device associated with the gl context
[cpp]
cl_context_properties properties[] =
{
CL_CONTEXT_PLATFORM, (cl_context_properties) platform,
CL_GL_CONTEXT_KHR, (cl_context_properties) g_hRC,
CL_WGL_HDC_KHR, (cl_context_properties) g_hDC,
0
};
....
cl_int res = pclGetGLContextInfoKHR(properties, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR, 0, NULL, &devSize);
res = pclGetGLContextInfoKHR( properties, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR, sizeof(cl_device_id), &device, NULL);
.....
context = clCreateContext(properties,1,&device,0,0,&res);
[/cpp]
Of course, you should do the proper error checking at each step.
Raghu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the hint!
I saw many examples where they have not used the function "clGetGLContextInfoKHR(...)" and their context creation is successful. I am confused if it mandatory to use it or not. I am creating the context as follows:
[cpp]
cl_context_properties contextProperties[] = { #ifdef defined(_WIN32) CL_CONTEXT_PLATFORM, (cl_context_properties) _m_clPlatform, CL_GL_CONTEXT_KHR, (cl_context_properties) windowsContext->getWGLContext(), CL_WGL_HDC_KHR, (cl_context_properties) windowsContext->getHDC(), #elif defined(__GNUC__) CL_CONTEXT_PLATFORM, (cl_context_properties) _m_clPlatform, CL_GL_CONTEXT_KHR, (cl_context_properties) linuxContext->getContext(), CL_GLX_DISPLAY_KHR, (cl_context_properties) linuxContext->getDisplay(), #elif defined(__APPLE__) CGLContextObj glContext = CGLGetCurrentContext(); // get the current GL context CGLShareGroupObj shareGroup = CGLGetShareGroup(glContext); // share group
CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE, (cl_context_properties) shareGroup, #endif 0 };
_m_clContext = clCreateContext(contextProperties,1,&clDevices[clDevUsed],NULL,NULL,&errNum);
if(errNum != CL_SUCCESS) { osg::notify(osg::FATAL) << __FUNCTION__ << ": " << __LINE__ << ": " << " OpenCL Context Creation with GL-CL interoperability was not successful :" << getErrorString(errNum) << std::endl; return false; }
[/cpp]
I am getting CL_SUCCESS with the context creation. But later if i try to create 2D opencl image buffer from the valid opengl texture object i get the opencl error "CL_OUT_OF_RESOURCES". Any idea what might have caused it ?
It will be nice to know some scenarios that cause this type of error.
Thanks
Sajjadul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You get CL_OUT_OF_RESOURCES if for some reason the allocation failed (sorry dont have specifics). But I think the reason your call is failing is because you are creating a shared buffer without a shared context. You need to create the context using a device that is associated with both cl and gl.
Thanks,
Raghu

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page