nou

OpenGL OpenCL interopearbility

Discussion created by nou on Jan 2, 2010
Latest reply on Jan 18, 2010 by nou

i try OGL OCL interoperability but i get some errors.

i create OGL context.

create CL context.

create VBO buffer and fill with some data

when i try get CL object from GL buffer i get error -34 from which mean CL_INVALID_CONTEXT when i use GPU.

when i try run code with CPU device i succesfully get CL object and get correct size. but it segafult when i set it as kernel argument and run it. well it segfault only if i try read or write into GL object.

gl_context = glXGetCurrentContext();//get gl context display = glXGetCurrentDisplay();//geting display handle cl_context_properties cl_properties[] = {CL_GL_CONTEXT_KHR, (cl_context_properties)gl_context, CL_GLX_DISPLAY_KHR, (cl_context_properties)display, CL_CONTEXT_PLATFORM, (cl_context_properties)platform, 0};//pass it to properties cl_c = clCreateContextFromType(cl_properties, CL_DEVICE_TYPE_GPU, NULL, NULL, &err_code);//create context glGenBuffers(1, &vbo);//create vbo buffer and fill it with some data glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(float)*grid_size*grid_size*4, grid, GL_STREAM_DRAW); //create CL buffer from GL buffer cl_m = clCreateFromGLBuffer(cl_c, CL_MEM_READ_WRITE, vbo, &err_code); size_t size; clGetMemObjectInfo(cl_m, CL_MEM_SIZE, sizeof(size_t), &size, NULL); printf("%p %p\n", cl_m, size);//when it is CPU it print out correnct size. with GPU both is (null) if(err_code) printf("Unable share GL object %d\n", err_code);//with GPU -34, with CPU CL_SUCCES

Outcomes