OpenGL/CL Interop

I’ve been trying to get the example code working for oclPostprocessGL with GL_INTEROP enabled, however the application just segfaults when I try. The application runs fine if I don’t uncomment the GL_INTEROP define.

Is interop supported yet? Has anyone got this to work?

Is GL_INTEROP likely to give me a significant performance increase?

Thanks.
Chris

OpenGL interoperability is not supported as of yet. I’m waiting for this one too.

I’m aware that OpenCL-OpenGL is not yet supported, but apparently some form of communication is possible since, for example, oclSimpleGL in the SDK can share a vertex buffer. What happens internally in this example? The comment read “copy data from the CL buffer via host”. Does this mean that the entire data set is copied twice through the PCIe buffer, once to the host and then once back again to a new location in device memory?

Good guess. If interop is not working, how else could you do it if not over the host?

It could make the copy internal on the device. Full interop would mean that no copies are performed at all.

So you mean the host pointer is virtual?Actully,data is just transfer between different device memory?

The OpenCL/OpenGL interoperability is supported with the driver beta version 195.39. You need to give the opengl context properties during the creation of your opencl context to enable it : http://oscarbg.blogspot.com/2009/11/explor…encl-19539.html

If you are under linux you can get the context properties this way :

cl_context_properties akProperties[] =

	{

	  CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),

	  CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(),

	  0

	};

Then you have to give akProperties as first argument to the function clCreateContext.

I still run into trouble with the oclPostProcessGL example in GL_INTEROP mode (XP32, GTX260, 195.39, toolkit/SDK 3.0 beta 1)

Before adding the properties I got CL_INVALID_CONTEXT, but after adding

[codebox]

//Create the context

cl_context_properties akProperties[] = {

	CL_GL_CONTEXT_KHR,

	(cl_context_properties)wglGetCurrentContext(),

	CL_WGL_HDC_KHR,

	(cl_context_properties)wglGetCurrentDC(), 0

};

//cxGPUContext = clCreateContext(0, uiNumDevices, cdDevices, NULL, NULL, &ciErrNum);

cxGPUContext = clCreateContext(akProperties, uiNumDevices, cdDevices, NULL, NULL, &ciErrNum);

[/codebox]

I get the error

!!! Error # -30 (CL_INVALID_VALUE) at line 659 , in file .\oclPostprocessGL.cpp !!!

from both of the statements

[codebox]

#ifdef GL_INTEROP

    cl_pbos[0] = clCreateFromGLBuffer(cxGPUContext, CL_MEM_READ_ONLY, pbo_source, &ciErrNum);

    cl_pbos[1]= clCreateFromGLBuffer(cxGPUContext, CL_MEM_WRITE_ONLY, pbo_dest, &ciErrNum);

[/codebox]

according to docs this error means that CL_MEM_READ_ONLY is an invalid argument to clCreateFromGLBuffer, but it is listed as a valid argument here

[post=“0”]http://www.khronos.org/opencl/sdk/1.0/docs/man/xhtml/clCreateFromGLBuffer.html[/post]

Anyone else got this working on this configuration or have an idea what the problem might be?

Hi guys,
I’m trying to get the SimpleGL example running and I’m having very similar issues with the CL/GL interop.
I’m using: Fedora.R11@64bit with NVIDIA Tesla C1060, NVIDIA UNIX x86_64 195.36.15.

It always crashes with a segfault when it comes to the context creation:

cl_context_properties props = {CL_GL_CONTEXT_KHR, (cl_context_properties) glXGetCurrentContext(),
CL_GLX_DISPLAY_KHR, (cl_context_properties) glXGetCurrentDisplay(),
CL_CONTEXT_PLATFORM,(cl_context_properties) platform, 0};

// create the OpenCL context - SEGFAULT here…
clContext = clCreateContextFromType(props, CL_DEVICE_TYPE_GPU, NULL, NULL, &status);

Any ideas how to debug this issue?

Is there a way to verify if glXGetCurrentDisplay() and glXGetCurrentContext() are returning the correct handlers to the GL-context?

Thx!